Example usage for java.lang Throwable getLocalizedMessage

List of usage examples for java.lang Throwable getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang Throwable getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:io.getlime.push.service.PushMessageSenderService.java

private void sendMessageToAndroid(final FcmClient fcmClient, final PushMessageBody pushMessageBody,
        final PushMessageAttributes attributes, final String pushToken, final PushSendingCallback callback)
        throws PushServerException {

    FcmSendRequest request = new FcmSendRequest();
    request.setTo(pushToken);//from  ww  w  .ja v a2s .co  m
    request.setData(pushMessageBody.getExtras());
    request.setCollapseKey(pushMessageBody.getCollapseKey());
    if (attributes == null || !attributes.getSilent()) { // if there are no attributes, assume the message is not silent
        FcmNotification notification = new FcmNotification();
        notification.setTitle(pushMessageBody.getTitle());
        notification.setBody(pushMessageBody.getBody());
        notification.setIcon(pushMessageBody.getIcon());
        notification.setSound(pushMessageBody.getSound());
        notification.setTag(pushMessageBody.getCategory());
        request.setNotification(notification);
    }
    final ListenableFuture<ResponseEntity<FcmSendResponse>> future = fcmClient.exchange(request);

    future.addCallback(new ListenableFutureCallback<ResponseEntity<FcmSendResponse>>() {

        @Override
        public void onFailure(Throwable throwable) {
            Logger.getLogger(PushMessageSenderService.class.getName()).log(Level.SEVERE,
                    "Notification rejected by the FCM gateway: " + throwable.getLocalizedMessage());
            callback.didFinishSendingMessage(PushSendingCallback.Result.FAILED, null);
        }

        @Override
        public void onSuccess(ResponseEntity<FcmSendResponse> response) {
            for (FcmResult fcmResult : response.getBody().getFcmResults()) {
                if (fcmResult.getMessageId() != null) {
                    // no issues, straight sending
                    if (fcmResult.getRegistrationId() == null) {
                        Logger.getLogger(PushMessageSenderService.class.getName()).log(Level.INFO,
                                "Notification sent");
                        callback.didFinishSendingMessage(PushSendingCallback.Result.OK, null);
                    } else {
                        // no issues, straight sending + update token (pass it via context)
                        Logger.getLogger(PushMessageSenderService.class.getName()).log(Level.INFO,
                                "Notification sent and token has been updated");
                        Map<String, Object> contextData = new HashMap<>();
                        contextData.put(FcmResult.KEY_UPDATE_TOKEN, fcmResult.getRegistrationId());
                        callback.didFinishSendingMessage(PushSendingCallback.Result.OK, contextData);
                    }
                } else {
                    if (fcmResult.getFcmError() != null) {
                        switch (fcmResult.getFcmError().toLowerCase()) { // make sure to account for case issues
                        // token doesn't exist, remove device registration
                        case "notregistered":
                            Logger.getLogger(PushMessageSenderService.class.getName()).log(Level.SEVERE,
                                    "Notification rejected by the FCM gateway, invalid token, will be deleted: ");
                            callback.didFinishSendingMessage(PushSendingCallback.Result.FAILED_DELETE, null);
                            break;
                        // retry to send later
                        case "unavailable":
                            Logger.getLogger(PushMessageSenderService.class.getName()).log(Level.SEVERE,
                                    "Notification rejected by the FCM gateway, will retry to send: ");
                            callback.didFinishSendingMessage(PushSendingCallback.Result.PENDING, null);
                            break;
                        // non-recoverable error, remove device registration
                        default:
                            Logger.getLogger(PushMessageSenderService.class.getName()).log(Level.SEVERE,
                                    "Notification rejected by the FCM gateway, non-recoverable error, will be deleted: ");
                            callback.didFinishSendingMessage(PushSendingCallback.Result.FAILED_DELETE, null);
                            break;
                        }
                    }
                }
            }
        }
    });
}

From source file:org.trypticon.xmpp.bot.BaseBot.java

/**
 * Performs login using SASL./*from  ww  w  .j a v  a2s.c om*/
 *
 * @throws StreamException if a stream-level exception occurred.
 * @throws PacketException if a packet-level exception occurred.
 */
private void saslLogin(JID client, String password) throws StreamException, PacketException {
    FeaturesetConsumerManager manager = new FeaturesetConsumerManager();

    StartTLSSocketFeatureConsumer tls = new StartTLSSocketFeatureConsumer(streamSource);
    manager.registerFeatureConsumer(tls);

    SASLFeatureConsumer sasl = new SASLFeatureConsumer();
    sasl.getClientInfo().setServer(client.getDomain());
    sasl.getClientInfo().setCallbackHandler(new FixedCallbackHandler(client.getNode(), password));
    manager.registerFeatureConsumer(sasl);

    BindFeatureConsumer bind = new BindFeatureConsumer(client.getResource());
    manager.registerFeatureConsumer(bind);

    SessionFeatureConsumer session = new SessionFeatureConsumer(false);
    manager.registerFeatureConsumer(session);

    try {
        // Attach and run the consumers.
        manager.attach(stream);
        manager.run();

        // Check to see if an error occurred.
        Throwable failure = manager.getFailure();
        if (failure != null) {
            log.error("Authentication failed", failure);

            if (failure instanceof StreamException) {
                throw (StreamException) failure;
            } else if (failure instanceof PacketException) {
                throw (PacketException) failure;
            } else {
                throw new PacketException(failure.getLocalizedMessage(), PacketError.CANCEL,
                        PacketError.UNDEFINED_CONDITION);
            }
        }

        // If the SASL consumer didn't complete, try an older-style login.
        if (!manager.isFeatureConsumerCompleted(sasl)) {
            authLogin(client, password);
        } else {
            // Make sure the resource was bound.
            if (!manager.isFeatureConsumerCompleted(bind)) {
                throw new PacketException(PacketError.AUTH, PacketError.RESOURCE_CONSTRAINT_CONDITION);
            }

            // Make sure the session is active.
            if (!manager.isFeatureConsumerCompleted(session)) {
                throw new PacketException(PacketError.CANCEL, PacketError.SERVICE_UNAVAILABLE_CONDITION);
            }
        }
    } finally {
        manager.detach();
    }
}

From source file:org.craftercms.cstudio.alfresco.dm.script.DmContentServiceScript.java

/**
 * write content asset//from   w  w w  .  ja va 2 s  .  c  o  m
 *
 * @param site
 * @param path
 * @param assetName
 * @param in
 * @param isImage
 *          is this asset an image?
 * @param allowedWidth
 *          specifies the allowed image width in pixel if the asset is an image
 * @param allowedHeight
 *          specifies the allowed image height in pixel if the asset is an image
 * @param unlock
 *          unlock the content upon edit?
 * @return content asset info
 * @throws ServiceException
 */
public ResultTO writeContentAsset(String site, String path, String assetName, InputStreamContent in,
        String isImage, String allowedWidth, String allowedHeight, String allowLessSize, String draft,
        String unlock, String systemAsset) {
    if (assetName != null) {
        assetName = assetName.replace(" ", "_");
    }
    /* Disable DRAFT repo Dejan 29.03.2012 */
    boolean isDraft = Boolean.valueOf(draft);
    /*
    if(isDraft) {
       //path = DmUtils.buildDraftFolder(path);
       path = DmUtils.getDraftFolder(path);
    }
    */
    boolean isSystemAsset = Boolean.valueOf(systemAsset);
    /***************************************/

    Map<String, String> params = new FastMap<String, String>();
    params.put(DmConstants.KEY_SITE, site);
    params.put(DmConstants.KEY_PATH, path);
    params.put(DmConstants.KEY_FILE_NAME, assetName);
    params.put(DmConstants.KEY_IS_IMAGE, isImage);
    params.put(DmConstants.KEY_ALLOW_LESS_SIZE, allowLessSize);
    params.put(DmConstants.KEY_ALLOWED_WIDTH, allowedWidth);
    params.put(DmConstants.KEY_ALLOWED_HEIGHT, allowedHeight);
    params.put(DmConstants.KEY_CONTENT_TYPE, "");
    params.put(DmConstants.KEY_CREATE_FOLDERS, "true");

    params.put(DmConstants.KEY_IS_PREVIEW, String.valueOf(isDraft));
    params.put(DmConstants.KEY_UNLOCK, unlock);
    params.put(DmConstants.KEY_SYSTEM_ASSET, String.valueOf(isSystemAsset));

    String id = site + ":" + path + ":" + assetName + ":" + "";
    // processContent will close the input stream
    String fullPath = null;
    PersistenceManagerService persistenceManagerService = getServicesManager()
            .getService(PersistenceManagerService.class);
    ServicesConfig servicesConfig = getServicesManager().getService(ServicesConfig.class);
    NodeRef nodeRef = null;
    try {
        fullPath = servicesConfig.getRepositoryRootPath(site) + path + "/" + assetName;
        //fullPath = fullPath.replaceAll(" ", "");
        nodeRef = persistenceManagerService.getNodeRef(fullPath);

        if (nodeRef != null) {
            if (persistenceManagerService.getObjectState(nodeRef) == State.SYSTEM_PROCESSING) {
                logger.error(String.format("Error Content %s is being processed (Object State is %s);",
                        assetName, State.SYSTEM_PROCESSING.toString()));
                throw new RuntimeException(String.format("Content \"%s\" is being processed", assetName));
            }
            persistenceManagerService.setSystemProcessing(fullPath, true);
        }
        DmContentService dmContentService = getServicesManager().getService(DmContentService.class);
        ResultTO result = dmContentService.processContent(id, in.getInputStream(), false, params,
                DmConstants.CONTENT_CHAIN_ASSET);
        if (isSystemAsset) {
            ContentAssetInfoTO assetInfoTO = (ContentAssetInfoTO) result.getItem();
            fullPath = fullPath.replace(assetName, assetInfoTO.getFileName());
        }
        nodeRef = persistenceManagerService.getNodeRef(fullPath);
        if (nodeRef != null) {
            persistenceManagerService.transition(fullPath, ObjectStateService.TransitionEvent.SAVE);
        }
        ResultTO resultTO = ScriptUtils.createSuccessResult(result.getItem());
        return resultTO;
    } catch (ContentNotAllowedException e) {
        return ScriptUtils.createFailureResult(CStudioConstants.HTTP_STATUS_IMAGE_SIZE_ERROR,
                e.getLocalizedMessage());
    } catch (AlfrescoRuntimeException e) {
        logger.error("Error processing content", e);
        Throwable cause = e.getCause();
        if (cause != null) {
            return ScriptUtils.createFailureResult(CStudioConstants.HTTP_STATUS_INTERNAL_SERVER_ERROR,
                    cause.getLocalizedMessage());
        }
        return ScriptUtils.createFailureResult(CStudioConstants.HTTP_STATUS_INTERNAL_SERVER_ERROR,
                e.getLocalizedMessage());
    } catch (Exception e) {
        logger.error("Error processing content", e);
        return ScriptUtils.createFailureResult(CStudioConstants.HTTP_STATUS_INTERNAL_SERVER_ERROR,
                e.getLocalizedMessage());
    } finally {
        if (nodeRef != null) {
            persistenceManagerService.setSystemProcessing(fullPath, false);
        }
    }
}

From source file:org.pentaho.reporting.libraries.resourceloader.ResourceManager.java

public void registerFactoryCache() {
    try {/* w  w  w. j a va 2s .com*/
        final ObjectFactory objectFactory = LibLoaderBoot.getInstance().getObjectFactory();
        final ResourceFactoryCacheProvider maybeDataCacheProvider = objectFactory
                .get(ResourceFactoryCacheProvider.class);
        final ResourceFactoryCache cache = maybeDataCacheProvider.createFactoryCache();
        if (cache != null) {
            setFactoryCache(cache);
        }
    } catch (Throwable e) {
        synchronized (failedModules) {
            if (failedModules.contains(ResourceFactoryCacheProvider.class) == false) {
                logger.warn("Failed to create factory cache: " + e.getLocalizedMessage());
                failedModules.add(ResourceFactoryCacheProvider.class);
            }
        }
    }
}

From source file:com.mbientlab.metawear.app.HomeFragment.java

private void initiateDfu() {
    final String DFU_PROGRESS_FRAGMENT_TAG = "dfu_progress_popup";
    DfuProgressFragment dfuProgressDialog = new DfuProgressFragment();
    dfuProgressDialog.show(getFragmentManager(), DFU_PROGRESS_FRAGMENT_TAG);

    getActivity().runOnUiThread(new Runnable() {
        final NotificationManager manager = (NotificationManager) getActivity()
                .getSystemService(Context.NOTIFICATION_SERVICE);
        final Notification.Builder checkpointNotifyBuilder = new Notification.Builder(getActivity())
                .setSmallIcon(android.R.drawable.stat_sys_upload).setOnlyAlertOnce(true).setOngoing(true)
                .setProgress(0, 0, true);
        final Notification.Builder progressNotifyBuilder = new Notification.Builder(getActivity())
                .setSmallIcon(android.R.drawable.stat_sys_upload).setOnlyAlertOnce(true).setOngoing(true)
                .setContentTitle(getString(R.string.notify_dfu_uploading));
        final int NOTIFICATION_ID = 1024;

        @Override//from   w w  w. j  a  v a 2s. c  om
        public void run() {
            mwBoard.updateFirmware(new MetaWearBoard.DfuProgressHandler() {
                @Override
                public void reachedCheckpoint(State dfuState) {
                    switch (dfuState) {
                    case INITIALIZING:
                        checkpointNotifyBuilder.setContentTitle(getString(R.string.notify_dfu_bootloader));
                        break;
                    case STARTING:
                        checkpointNotifyBuilder.setContentTitle(getString(R.string.notify_dfu_starting));
                        break;
                    case VALIDATING:
                        checkpointNotifyBuilder.setContentTitle(getString(R.string.notify_dfu_validating));
                        break;
                    case DISCONNECTING:
                        checkpointNotifyBuilder.setContentTitle(getString(R.string.notify_dfu_disconnecting));
                        break;
                    }

                    manager.notify(NOTIFICATION_ID, checkpointNotifyBuilder.build());
                }

                @Override
                public void receivedUploadProgress(int progress) {
                    progressNotifyBuilder.setContentText(String.format("%d%%", progress)).setProgress(100,
                            progress, false);
                    manager.notify(NOTIFICATION_ID, progressNotifyBuilder.build());
                    ((DfuProgressFragment) getFragmentManager().findFragmentByTag(DFU_PROGRESS_FRAGMENT_TAG))
                            .updateProgress(progress);
                }
            }).onComplete(new AsyncOperation.CompletionHandler<Void>() {
                final Notification.Builder builder = new Notification.Builder(getActivity())
                        .setOnlyAlertOnce(true).setOngoing(false).setAutoCancel(true);

                @Override
                public void success(Void result) {
                    ((DialogFragment) getFragmentManager().findFragmentByTag(DFU_PROGRESS_FRAGMENT_TAG))
                            .dismiss();
                    builder.setContentTitle(getString(R.string.notify_dfu_success))
                            .setSmallIcon(android.R.drawable.stat_sys_upload_done);
                    manager.notify(NOTIFICATION_ID, builder.build());

                    Toast.makeText(getActivity(), R.string.message_dfu_success, Toast.LENGTH_SHORT).show();

                    fragBus.resetConnectionStateHandler(5000L);
                }

                @Override
                public void failure(Throwable error) {
                    Log.e("MetaWearApp", "Firmware update failed", error);

                    Throwable cause = error.getCause() == null ? error : error.getCause();
                    ((DialogFragment) getFragmentManager().findFragmentByTag(DFU_PROGRESS_FRAGMENT_TAG))
                            .dismiss();
                    builder.setContentTitle(getString(R.string.notify_dfu_fail))
                            .setSmallIcon(android.R.drawable.ic_dialog_alert)
                            .setContentText(cause.getLocalizedMessage());
                    manager.notify(NOTIFICATION_ID, builder.build());

                    Toast.makeText(getActivity(), error.getLocalizedMessage(), Toast.LENGTH_SHORT).show();

                    fragBus.resetConnectionStateHandler(5000L);
                }
            });
        }
    });
}

From source file:org.geotools.gce.imagemosaic.catalog.GTDataStoreGranuleCatalog.java

public GTDataStoreGranuleCatalog(final Properties params, final boolean create, final DataStoreFactorySpi spi,
        final Hints hints) {
    super(hints);
    Utilities.ensureNonNull("params", params);
    Utilities.ensureNonNull("spi", spi);

    try {/*from  w  w w.  ja v  a2  s . c om*/
        this.pathType = (PathType) params.get(Utils.Prop.PATH_TYPE);
        this.locationAttribute = (String) params.get(Utils.Prop.LOCATION_ATTRIBUTE);
        final String temp = (String) params.get(Utils.Prop.SUGGESTED_SPI);
        this.suggestedRasterSPI = temp != null ? (ImageReaderSpi) Class.forName(temp).newInstance() : null;
        this.parentLocation = (String) params.get(Utils.Prop.PARENT_LOCATION);
        if (params.containsKey(Utils.Prop.HETEROGENEOUS)) {
            this.heterogeneous = (Boolean) params.get(Utils.Prop.HETEROGENEOUS);
        }

        // creating a store, this might imply creating it for an existing underlying store or
        // creating a brand new one
        Map<String, Serializable> dastastoreParams = Utils.filterDataStoreParams(params, spi);

        // H2 workadound
        if (Utils.isH2Store(spi)) {
            Utils.fixH2DatabaseLocation(dastastoreParams, parentLocation);
            Utils.fixH2MVCCParam(dastastoreParams);
        }

        if (!create) {
            tileIndexStore = spi.createDataStore(dastastoreParams);
        } else {
            // this works only with the shapefile datastore, not with the others
            // therefore I try to catch the error to try and use themethdo without *New*
            try {
                tileIndexStore = spi.createNewDataStore(dastastoreParams);
            } catch (UnsupportedOperationException e) {
                tileIndexStore = spi.createDataStore(dastastoreParams);
            }
        }

        if (Utils.isOracleStore(spi)) {
            tileIndexStore = new OracleDatastoreWrapper(tileIndexStore,
                    FilenameUtils.getFullPath(parentLocation));
        }

        // is this a new store? If so we do not set any properties
        if (create) {
            return;
        }

        String typeName = null;
        boolean scanForTypeNames = false;

        if (params.containsKey(Utils.Prop.TYPENAME)) {
            typeName = (String) params.get(Utils.Prop.TYPENAME);
        }

        if (params.containsKey(Utils.SCAN_FOR_TYPENAMES)) {
            scanForTypeNames = Boolean.valueOf(params.get(Utils.SCAN_FOR_TYPENAMES).toString());
        }

        // if this is not a new store let's extract basic properties from it
        if (scanForTypeNames) {
            String[] typeNames = tileIndexStore.getTypeNames();
            if (typeNames != null) {
                for (String tn : typeNames) {
                    this.typeNames.add(tn);
                }
            }
        } else if (typeName != null) {
            addTypeName(typeName, false);
        }
        if (this.typeNames.size() > 0) {
            extractBasicProperties(typeNames.iterator().next());
        } else {
            extractBasicProperties(typeName);
        }
    } catch (Throwable e) {
        try {
            if (tileIndexStore != null)
                tileIndexStore.dispose();
        } catch (Throwable e1) {
            if (LOGGER.isLoggable(Level.FINE))
                LOGGER.log(Level.FINE, e1.getLocalizedMessage(), e1);
        } finally {
            tileIndexStore = null;
        }

        throw new IllegalArgumentException(e);
    }

}

From source file:com.christophergs.mbientbasic.HomeFragment.java

private void initiateDfu() {
    final String DFU_PROGRESS_FRAGMENT_TAG = "dfu_progress_popup";
    DfuProgressFragment dfuProgressDialog = new DfuProgressFragment();
    dfuProgressDialog.show(getFragmentManager(), DFU_PROGRESS_FRAGMENT_TAG);

    getActivity().runOnUiThread(new Runnable() {
        final NotificationManager manager = (NotificationManager) getActivity()
                .getSystemService(Context.NOTIFICATION_SERVICE);
        final Notification.Builder checkpointNotifyBuilder = new Notification.Builder(getActivity())
                .setSmallIcon(android.R.drawable.stat_sys_upload).setOnlyAlertOnce(true).setOngoing(true)
                .setProgress(0, 0, true);
        final Notification.Builder progressNotifyBuilder = new Notification.Builder(getActivity())
                .setSmallIcon(android.R.drawable.stat_sys_upload).setOnlyAlertOnce(true).setOngoing(true)
                .setContentTitle(getString(R.string.notify_dfu_uploading));
        final int NOTIFICATION_ID = 1024;

        @Override// w ww. ja v a2  s  . c  o m
        public void run() {
            mwBoard.updateFirmware(new MetaWearBoard.DfuProgressHandler() {
                @Override
                public void reachedCheckpoint(State dfuState) {
                    switch (dfuState) {
                    case INITIALIZING:
                        checkpointNotifyBuilder.setContentTitle(getString(R.string.notify_dfu_bootloader));
                        break;
                    case STARTING:
                        checkpointNotifyBuilder.setContentTitle(getString(R.string.notify_dfu_starting));
                        break;
                    case VALIDATING:
                        checkpointNotifyBuilder.setContentTitle(getString(R.string.notify_dfu_validating));
                        break;
                    case DISCONNECTING:
                        checkpointNotifyBuilder.setContentTitle(getString(R.string.notify_dfu_disconnecting));
                        break;
                    }

                    manager.notify(NOTIFICATION_ID, checkpointNotifyBuilder.build());
                }

                @Override
                public void receivedUploadProgress(int progress) {
                    progressNotifyBuilder.setContentText(String.format("%d%%", progress)).setProgress(100,
                            progress, false);
                    manager.notify(NOTIFICATION_ID, progressNotifyBuilder.build());
                    ((DfuProgressFragment) getFragmentManager().findFragmentByTag(DFU_PROGRESS_FRAGMENT_TAG))
                            .updateProgress(progress);
                }
            }).onComplete(new AsyncOperation.CompletionHandler<Void>() {
                final Notification.Builder builder = new Notification.Builder(getActivity())
                        .setOnlyAlertOnce(true).setOngoing(false).setAutoCancel(true);

                @Override
                public void success(Void result) {
                    ((DialogFragment) getFragmentManager().findFragmentByTag(DFU_PROGRESS_FRAGMENT_TAG))
                            .dismiss();
                    builder.setContentTitle(getString(R.string.notify_dfu_success))
                            .setSmallIcon(android.R.drawable.stat_sys_upload_done);
                    manager.notify(NOTIFICATION_ID, builder.build());

                    Snackbar.make(getActivity().findViewById(R.id.drawer_layout), R.string.message_dfu_success,
                            Snackbar.LENGTH_LONG).show();
                    fragBus.resetConnectionStateHandler(5000L);
                }

                @Override
                public void failure(Throwable error) {
                    Log.e("MetaWearApp", "Firmware update failed", error);

                    Throwable cause = error.getCause() == null ? error : error.getCause();
                    ((DialogFragment) getFragmentManager().findFragmentByTag(DFU_PROGRESS_FRAGMENT_TAG))
                            .dismiss();
                    builder.setContentTitle(getString(R.string.notify_dfu_fail))
                            .setSmallIcon(android.R.drawable.ic_dialog_alert)
                            .setContentText(cause.getLocalizedMessage());
                    manager.notify(NOTIFICATION_ID, builder.build());

                    Snackbar.make(getActivity().findViewById(R.id.drawer_layout), error.getLocalizedMessage(),
                            Snackbar.LENGTH_LONG).show();
                    fragBus.resetConnectionStateHandler(5000L);
                }
            });
        }
    });
}

From source file:org.geoserver.taskmanager.web.ConfigurationPage.java

protected AjaxSubmitLink saveOrApplyButton(final String id, final boolean doReturn) {
    return new AjaxSubmitLink(id) {
        private static final long serialVersionUID = 3735176778941168701L;

        @Override//from   ww w . ja  v a 2 s  .  co m
        public void onSubmit(AjaxRequestTarget target, Form<?> form) {
            attributesModel.save(true);
            List<ValidationError> errors = TaskManagerBeans.get().getTaskUtil()
                    .validate(configurationModel.getObject());
            if (!errors.isEmpty()) {
                for (ValidationError error : errors) {
                    //TODO: use localized resource based on error type instead of toString
                    form.error(error.toString());
                }
                addFeedbackPanels(target);
                return;
            } else if (!configurationModel.getObject().isTemplate() && !initMode) {
                configurationModel.getObject().setValidated(true);
            }

            try {
                originalConfigurationModel.setObject(TaskManagerBeans.get().getDataUtil().saveScheduleAndRemove(
                        InitConfigUtil.unwrap(configurationModel.getObject()), removedTasks,
                        batchesPanel.getRemovedBatches()));
                configurationModel
                        .setObject(initMode ? InitConfigUtil.wrap(originalConfigurationModel.getObject())
                                : originalConfigurationModel.getObject());
                removedTasks.clear();
                batchesPanel.getRemovedBatches().clear();
                if (doReturn) {
                    doReturn();
                } else {
                    oldTasks = new HashMap<>(configurationModel.getObject().getTasks());
                    oldBatches = new HashMap<>(configurationModel.getObject().getBatches());
                    form.success(new ParamResourceModel("success", getPage()).getString());
                    target.add(batchesPanel);
                    ((MarkupContainer) batchesPanel.get("form:batchesPanel:listContainer:items")).removeAll();
                    addFeedbackPanels(target);
                    if (initMode) {
                        setResponsePage(new InitConfigurationPage(configurationModel));
                    }
                }
            } catch (ConstraintViolationException e) {
                form.error(new ParamResourceModel("duplicate", getPage()).getString());
                addFeedbackPanels(target);
            } catch (Exception e) {
                LOGGER.log(Level.WARNING, e.getMessage(), e);
                Throwable rootCause = ExceptionUtils.getRootCause(e);
                form.error(rootCause == null ? e.getLocalizedMessage() : rootCause.getLocalizedMessage());
                addFeedbackPanels(target);
            }
        }

        protected void onError(AjaxRequestTarget target, Form<?> form) {
            addFeedbackPanels(target);
        }
    };
}

From source file:com.ntsync.android.sync.syncadapter.SyncAdapter.java

private void setPrgErrorMsg(AccountSyncResult appSyncResult, final Throwable e) {
    appSyncResult.setErrorMsg(String.format(mContext.getText(R.string.errormsg_programmingerror).toString(),
            e.getLocalizedMessage()));
}

From source file:org.apache.synapse.message.store.impl.jms.JmsStore.java

private Destination getDestination(Session session) {
    Destination dest = queue;/*from w w w .j  a v a  2s.  co m*/
    if (dest != null) {
        return dest;
    }
    InitialContext newContext = null;
    try {
        dest = lookup(context, javax.jms.Destination.class, destination);
    } catch (NamingException e) {
        if (logger.isDebugEnabled()) {
            logger.debug(nameString() + ". Could not lookup destination [" + destination + "]. Message: "
                    + e.getLocalizedMessage());
        }
        newContext = newContext();
    }
    try {
        if (newContext != null) {
            dest = lookup(newContext, javax.jms.Destination.class, destination);
        }
    } catch (Throwable t) {
        logger.info(nameString() + ". Destination [" + destination + "] not defined in JNDI context. Message:"
                + t.getLocalizedMessage());
    }
    if (dest == null && session != null) {
        try {
            dest = session.createQueue(destination);
            if (logger.isDebugEnabled()) {
                logger.debug(nameString() + " created destination [" + destination + "] from session object.");
            }
        } catch (JMSException e) {
            logger.error(nameString() + " could not create destination [" + destination + "]. Error:"
                    + e.getLocalizedMessage(), e);
            dest = null;
        }
    }
    if (dest == null && session == null) {
        if (logger.isDebugEnabled()) {
            logger.debug(nameString() + ". Both destination and session is null."
                    + " Could not create destination.");
        }
    }
    synchronized (queueLock) {
        queue = dest;
    }
    return dest;
}