Example usage for java.lang RuntimeException toString

List of usage examples for java.lang RuntimeException toString

Introduction

In this page you can find the example usage for java.lang RuntimeException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.mirth.connect.donkey.server.channel.DestinationChain.java

private List<ConnectorMessage> doCall() throws InterruptedException {
    List<ConnectorMessage> messages = new ArrayList<ConnectorMessage>();
    ConnectorMessage message = this.message;
    int startMetaDataId = enabledMetaDataIds.indexOf(message.getMetaDataId());
    boolean stopChain = false;

    /*/*from  w  ww  . j a va2  s . co  m*/
     * The message that we're starting with should be associated with one of the destinations in
     * this chain, if it's not, we can't proceed.
     */
    if (startMetaDataId == -1) {
        logger.error("The message's metadata ID for channel " + chainProvider.getChannelId()
                + " is not in the destination chain's list of enabled metadata IDs");
        return null;
    }

    // loop through each metaDataId in the chain, beginning with startMetaDataId
    for (int i = startMetaDataId; i < enabledMetaDataIds.size() && !stopChain; i++) {
        ThreadUtils.checkInterruptedStatus();
        Integer metaDataId = enabledMetaDataIds.get(i);
        Integer nextMetaDataId = (enabledMetaDataIds.size() > (i + 1)) ? enabledMetaDataIds.get(i + 1) : null;
        ConnectorMessage nextMessage = null;
        DestinationConnector destinationConnector = chainProvider.getDestinationConnectors().get(metaDataId);

        /*
         * TRANSACTION: Process Destination - Insert the custom metadata column data - store the
         * transformed content - store the encoded content - store the sent content (done prior
         * to sending since the sent content would be lost if the message gets queued) - store
         * the raw response content - update the message status to either PENDING or QUEUED - if
         * there is a next destination in the chain, create it's message (done in the next
         * transaction if a response transformer is used)
         */
        DonkeyDao dao = chainProvider.getDaoFactory().getDao();

        try {
            Status previousStatus = message.getStatus();

            try {
                switch (message.getStatus()) {
                case RECEIVED:
                    /*
                     * Only transform the message if we're going to be dispatching it in the
                     * main processing thread, or if the queue thread will not be handling
                     * transformation
                     */
                    if (destinationConnector.willAttemptSend()
                            || !destinationConnector.includeFilterTransformerInQueue()) {
                        destinationConnector.transform(dao, message, previousStatus, true);

                        // If the message status is QUEUED, send it to the destination connector
                        if (message.getStatus() == Status.QUEUED) {
                            String originalThreadName = Thread.currentThread().getName();
                            try {
                                Thread.currentThread()
                                        .setName(destinationConnector.getConnectorProperties().getName()
                                                + " Process Thread on "
                                                + destinationConnector.getChannel().getName() + " ("
                                                + chainProvider.getChannelId() + "), "
                                                + destinationConnector.getDestinationName() + " (" + metaDataId
                                                + ")");
                                destinationConnector.process(dao, message, previousStatus);
                            } finally {
                                Thread.currentThread().setName(originalThreadName);
                            }
                        } else if (message.getStatus() == Status.ERROR && message.getSent() == null) {
                            // If an error occurred in the filter/transformer, don't proceed with the rest of the chain
                            stopChain = true;
                        }
                    } else {
                        destinationConnector.updateQueuedStatus(dao, message, previousStatus);
                    }
                    break;

                case PENDING:
                    chainProvider.getDestinationConnectors().get(metaDataId).processPendingConnectorMessage(dao,
                            message);
                    break;

                case SENT:
                    break;

                default:
                    // the status should never be anything but one of the above statuses, but in case it's not, log an error
                    logger.error("Received a message with an invalid status in channel "
                            + chainProvider.getChannelId() + ".");
                    break;
                }
            } catch (RuntimeException e) { // TODO: remove this catch since we can't determine an error code
                // if an error occurred in processing the message through the current destination, then update the message status to ERROR and continue processing through the chain
                logger.error("Error processing destination "
                        + chainProvider.getDestinationConnectors().get(metaDataId).getDestinationName()
                        + " for channel " + chainProvider.getChannelId() + ".", e);
                stopChain = true;
                dao.rollback();
                message.setStatus(Status.ERROR);
                message.setProcessingError(e.toString());
                dao.updateStatus(message, previousStatus);
                // Insert errors if necessary
                if (StringUtils.isNotBlank(message.getProcessingError())) {
                    dao.updateErrors(message);
                }
            }

            // now that we're finished processing the current message, we can create the next message in the chain
            if (nextMetaDataId != null && !stopChain) {
                nextMessage = new ConnectorMessage(message.getChannelId(), message.getChannelName(),
                        message.getMessageId(), nextMetaDataId, message.getServerId(), Calendar.getInstance(),
                        Status.RECEIVED);

                DestinationConnector nextDestinationConnector = chainProvider.getDestinationConnectors()
                        .get(nextMetaDataId);
                nextMessage.setConnectorName(nextDestinationConnector.getDestinationName());
                nextMessage.setChainId(chainProvider.getChainId());
                nextMessage.setOrderId(nextDestinationConnector.getOrderId());

                // We don't create a new map here because the source map is read-only and thus won't ever be changed
                nextMessage.setSourceMap(message.getSourceMap());
                nextMessage.setChannelMap(new HashMap<String, Object>(message.getChannelMap()));
                nextMessage.setResponseMap(new HashMap<String, Object>(message.getResponseMap()));
                nextMessage.setRaw(new MessageContent(message.getChannelId(), message.getMessageId(),
                        nextMetaDataId, ContentType.RAW, message.getRaw().getContent(),
                        nextDestinationConnector.getInboundDataType().getType(),
                        message.getRaw().isEncrypted()));

                ThreadUtils.checkInterruptedStatus();
                dao.insertConnectorMessage(nextMessage, chainProvider.getStorageSettings().isStoreMaps(), true);
            }

            ThreadUtils.checkInterruptedStatus();

            if (message.getStatus() != Status.QUEUED) {
                dao.commit(chainProvider.getStorageSettings().isDurable());
            } else {
                // Block other threads from reading from or modifying the destination queue until both the current commit and queue addition finishes
                // Otherwise the same message could be sent multiple times.
                synchronized (destinationConnector.getQueue()) {
                    dao.commit(chainProvider.getStorageSettings().isDurable());

                    if (message.getStatus() == Status.QUEUED) {
                        destinationConnector.getQueue().add(message);
                    }
                }
            }

            messages.add(message);
        } catch (RuntimeException e) {
            // An exception caught at this point either occurred when attempting to handle an exception in the above try/catch, or when attempting to create the next destination's message, the thread cannot continue running
            logger.error("Error processing destination "
                    + chainProvider.getDestinationConnectors().get(metaDataId).getDestinationName()
                    + " for channel " + chainProvider.getChannelId() + ".", e);
            throw e;
        } finally {
            dao.close();
        }

        // Set the next message in the loop
        if (nextMetaDataId != null) {
            message = nextMessage;
        }
    }

    return messages;
}

From source file:terse.vm.Terp.java

public void tick() {
    --tickCounter;//from w  w w. j  a  va 2s .  c o m
    if (tickCounter < 1) {
        try {
            throw new RuntimeException("Going To Throw TooManyTicks");
        } catch (RuntimeException ex) {
            ex.printStackTrace();

            StringBuffer sb = new StringBuffer(ex.toString());
            StackTraceElement[] elems = ex.getStackTrace();
            for (StackTraceElement e : elems) {
                sb.append("\n  * ");
                sb.append(e.toString());
            }

            say(sb.toString());
        }
        throw new TooManyTicks();
    }

}

From source file:android.support.v7.widget.SuggestionsAdapter.java

/**
 * This method is overridden purely to provide a bit of protection against
 * flaky content providers.//w w w  .j av  a  2  s .com
 *
 * @see android.widget.ListAdapter#getView(int, View, ViewGroup)
 */
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    try {
        return super.getView(position, convertView, parent);
    } catch (RuntimeException e) {
        Log.w(LOG_TAG, "Search suggestions cursor threw exception.", e);
        // Put exception string in item title
        View v = newView(mContext, mCursor, parent);
        if (v != null) {
            ChildViewCache views = (ChildViewCache) v.getTag();
            TextView tv = views.mText1;
            tv.setText(e.toString());
        }
        return v;
    }
}

From source file:org.alfresco.repo.transfer.HttpClientTransmitterImpl.java

public Transfer begin(TransferTarget target, String fromRepositoryId, TransferVersion fromVersion)
        throws TransferException {
    PostMethod beginRequest = getPostMethod();
    try {/* ww w .  j  ava  2 s .  co m*/
        HostConfiguration hostConfig = getHostConfig(target);
        HttpState httpState = getHttpState(target);

        beginRequest.setPath(target.getEndpointPath() + "/begin");
        try {
            NameValuePair[] nameValuePair = new NameValuePair[] {
                    new NameValuePair(TransferCommons.PARAM_FROM_REPOSITORYID, fromRepositoryId),
                    new NameValuePair(TransferCommons.PARAM_ALLOW_TRANSFER_TO_SELF, "false"),
                    new NameValuePair(TransferCommons.PARAM_VERSION_EDITION, fromVersion.getEdition()),
                    new NameValuePair(TransferCommons.PARAM_VERSION_MAJOR, fromVersion.getVersionMajor()),
                    new NameValuePair(TransferCommons.PARAM_VERSION_MINOR, fromVersion.getVersionMinor()),
                    new NameValuePair(TransferCommons.PARAM_VERSION_REVISION,
                            fromVersion.getVersionRevision()) };

            //add the parameter defining the root of the transfer on the file system if exist
            NodeRef transferRootNode = this.getFileTransferRootNodeRef(target.getNodeRef());
            if (transferRootNode != null) {
                //add the parameter
                ArrayList<NameValuePair> nameValuePairArrayList = new ArrayList<NameValuePair>(
                        nameValuePair.length + 1);
                Collections.addAll(nameValuePairArrayList, nameValuePair);
                nameValuePairArrayList.add(new NameValuePair(TransferCommons.PARAM_ROOT_FILE_TRANSFER,
                        transferRootNode.toString()));
                nameValuePair = nameValuePairArrayList.toArray(new NameValuePair[0]);
            }

            beginRequest.setRequestBody(nameValuePair);

            int responseStatus = httpClient.executeMethod(hostConfig, beginRequest, httpState);

            checkResponseStatus("begin", responseStatus, beginRequest);
            //If we get here then we've received a 200 response
            //We're expecting the transfer id encoded in a JSON object...
            JSONObject response = new JSONObject(beginRequest.getResponseBodyAsString());

            Transfer transfer = new Transfer();
            transfer.setTransferTarget(target);

            String transferId = response.getString(TransferCommons.PARAM_TRANSFER_ID);
            transfer.setTransferId(transferId);

            if (response.has(TransferCommons.PARAM_VERSION_MAJOR)) {
                String versionMajor = response.getString(TransferCommons.PARAM_VERSION_MAJOR);
                String versionMinor = response.getString(TransferCommons.PARAM_VERSION_MINOR);
                String versionRevision = response.getString(TransferCommons.PARAM_VERSION_REVISION);
                String edition = response.getString(TransferCommons.PARAM_VERSION_EDITION);
                TransferVersion version = new TransferVersionImpl(versionMajor, versionMinor, versionRevision,
                        edition);
                transfer.setToVersion(version);
            } else {
                TransferVersion version = new TransferVersionImpl("0", "0", "0", "Unknown");
                transfer.setToVersion(version);
            }

            if (log.isDebugEnabled()) {
                log.debug("begin transfer transferId:" + transferId + ", target:" + target);
            }

            return transfer;
        } catch (RuntimeException e) {
            log.debug("unexpected exception", e);
            throw e;
        } catch (Exception e) {
            String error = "Failed to execute HTTP request to target";
            log.debug(error, e);
            throw new TransferException(MSG_HTTP_REQUEST_FAILED,
                    new Object[] { "begin", target.toString(), e.toString() }, e);
        }
    } finally {
        log.debug("releasing connection");
        beginRequest.releaseConnection();
    }
}

From source file:org.pentaho.platform.scheduler.SchedulerAdminUIComponent.java

/**
 * @return//  www  .  j a v  a2 s .co  m
 */
private Document doGetJobNames() {
    Document document = DocumentHelper.createDocument();
    document.setName(SCHEDULER_ACTION_STR);
    Element root = document.addElement(GET_JOB_NAMES_ACTION_STR);
    try {
        String[] triggerGroups = sched.getTriggerGroupNames();
        for (int i = 0; i < triggerGroups.length; i++) {
            String[] triggerNames = sched.getTriggerNames(triggerGroups[i]);
            for (int j = 0; j < triggerNames.length; j++) {
                Element job = root.addElement(JOB);
                try {
                    job.addAttribute("triggerState", //$NON-NLS-1$
                            Integer.toString(sched.getTriggerState(triggerNames[j], triggerGroups[i])));

                    Trigger trigger = sched.getTrigger(triggerNames[j], triggerGroups[i]);

                    job.addAttribute("triggerName", trigger.getName()); //$NON-NLS-1$
                    job.addAttribute("triggerGroup", trigger.getGroup()); //$NON-NLS-1$
                    Date date = trigger.getNextFireTime();
                    job.addAttribute("nextFireTime", //$NON-NLS-1$
                            (date == null) ? Messages.getString("SchedulerAdminUIComponent.USER_NEVER") //$NON-NLS-1$
                                    : date.toString());
                    date = trigger.getPreviousFireTime();
                    job.addAttribute("prevFireTime", //$NON-NLS-1$
                            (date == null) ? Messages.getString("SchedulerAdminUIComponent.USER_NEVER") //$NON-NLS-1$
                                    : date.toString());

                    // get the job info
                    job.addAttribute(JOB_NAME, trigger.getJobName());
                    job.addAttribute(JOB_GROUP, trigger.getJobGroup());
                    JobDetail jobDetail = sched.getJobDetail(trigger.getJobName(), trigger.getJobGroup());

                    job.addElement("description").addCDATA(jobDetail.getDescription()); //$NON-NLS-1$

                    Date d = trigger.getStartTime();
                    if (null != d) {
                        job.addAttribute(StandardSettings.START_DATE_TIME, Long.toString(d.getTime()));
                    }
                    d = trigger.getEndTime();
                    if (null != d) {
                        job.addAttribute(StandardSettings.END_DATE_TIME, Long.toString(d.getTime()));
                    }

                    if (trigger instanceof CronTrigger) {
                        job.addAttribute(StandardSettings.CRON_STRING,
                                ((CronTrigger) trigger).getCronExpression());
                    } else if (trigger instanceof SimpleTrigger) {
                        long repeatInSecs = ((SimpleTrigger) trigger).getRepeatInterval();
                        job.addAttribute(StandardSettings.REPEAT_TIME_MILLISECS, Long.toString(repeatInSecs));
                    } else {
                        throw new RuntimeException(Messages.getErrorString(
                                "SchedulerAdminUIComponent.ERROR_0423_UNRECOGNIZED_TRIGGER", //$NON-NLS-1$
                                trigger.getClass().getName()));
                    }

                    JobDataMap m = jobDetail.getJobDataMap();
                    if (null != m.getString(StandardSettings.ACTION)) {
                        ActionInfo actionInfo = new ActionInfo(m.getString(StandardSettings.SOLUTION),
                                m.getString(StandardSettings.PATH), m.getString(StandardSettings.ACTION));
                        job.addAttribute(StandardSettings.ACTIONS_REFS, actionInfo.toString());
                    }

                    // job.addAttribute("class",
                    // jobDetail.getClass().getName()); //$NON-NLS-1$
                } catch (RuntimeException e) {
                    throw e;
                } catch (Exception e) {
                    job.addElement("description").addCDATA(e.getMessage()); //$NON-NLS-1$
                    job.addAttribute("triggerState", "3"); // ERROR //$NON-NLS-1$ //$NON-NLS-2$
                }
            }
        }
    } catch (SchedulerException e) {
        String msg = Messages.getErrorString("SchedulerAdminUIComponent.ERROR_0001_ErrorInScheduler")
                + e.toString();
        error(msg);
        root.addAttribute(RESULT, msg);
        addErrorElementToDocument(document, msg);
    }

    return document;
}

From source file:org.alfresco.web.app.servlet.ajax.AjaxServlet.java

/**
 * Handles any error that occurs during the execution of the servlet
 * /* ww  w . j a va  2  s.com*/
 * @param response The response
 * @param cause The cause of the error
 */
protected void handleError(HttpServletResponse response, RuntimeException cause)
        throws ServletException, IOException {
    // if we can send back the 500 error with the error from the top of the 
    // stack as the error status message.

    // NOTE: if we use the built in support for generating error pages for
    //       500 errors we can tailor the output for AJAX calls so that the
    //       body of the response can be used to show the error details.

    if (!response.isCommitted()) {
        // dump the error if debugging is enabled
        if (logger.isDebugEnabled()) {
            logger.error(cause);
            Throwable theCause = cause.getCause();
            if (theCause != null) {
                logger.error("caused by: ", theCause);
            }
        }

        // extract a message from the exception
        String msg = cause.getMessage();
        if (msg == null) {
            msg = cause.toString();
        }
        // ALF-9036. We need to trap incomplete sessions
        if (cause instanceof IllegalStateException) {
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED, cause.getMessage());
        } else {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
        }
    } else {
        // the response has already been comitted, not much we can do but
        // let the error through and let the container deal with it
        throw cause;
    }
}

From source file:za.co.eon.econtentsolutions.component.abstractlticomponent.AbstractLTIComponentServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  w  ww  .  ja  va2  s . co  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try (PrintWriter out = response.getWriter()) {
        Launch launch = tsugi.getLaunch(request, response);
        if (launch.isComplete()) {
            launch.getOutput().flashSuccess("LTI Launch validated and redirected");
            log.info("LTI Launch validated and redirected...");
            return;
        }
        if (!launch.isValid()) {
            out.println("<pre>");
            out.println("Launch is not valid but nowhere to redirect");
            out.println(launch.getErrorMessage());
            out.println("Base String:");
            out.println(launch.getBaseString());
            out.println("</pre>");
            out.close();

            throw new RuntimeException(launch.getErrorMessage());
        }

        HttpSession session = request.getSession();
        Output o = launch.getOutput();

        Properties versions = o.header(out);
        o.bodyStart(out);
        o.flashMessages(out);

        //
        out.println("<pre>");

        // Dump out some stuff from the Request Object
        out.println("");
        out.println(
                "<a href=\"http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html\" target=\"_blank\">HttpServletRequest</a> data:");
        out.println("req.getRequestURL()=" + request.getRequestURL());
        out.println("req.getMethod()=" + request.getMethod());
        out.println("req.getServletPath()=" + request.getServletPath());
        out.println("req.getPathInfo()=" + request.getPathInfo());
        out.println("req.getQueryString()=" + request.getQueryString());

        out.println("");
        out.print("<a href=\"");
        out.print(launch.getGetUrl(null) + "/zap");
        out.println("\">Click here to see if we stay logged in with a GET</a>");

        out.println("");
        out.println(
                "Using the <a href=\"http://csev.github.io/tsugi-java/apidocs/index.html\" target=\"_blank\">Tsugi API</a>:");
        out.println("Content Title: " + launch.getContext().getTitle());
        out.println("Context Settings: " + launch.getContext().getSettings().getSettingsJson());
        out.println("User Email: " + launch.getUser().getEmail());
        out.println("isInstructor()=" + launch.getUser().isInstructor());
        out.println("isTenantAdmin()=" + launch.getUser().isTenantAdmin());
        out.println("Link Title: " + launch.getLink().getTitle());
        out.println("Link Settings: " + launch.getLink().getSettings().getSettingsJson());
        out.println("Sourcedid: " + launch.getResult().getSourceDID());
        out.println("Service URL: " + launch.getService().getURL());
        out.println("");
        out.println("JavaScript library versions:");
        out.println(TsugiUtils.dumpProperties(versions));

        out.println("");
        out.println("Using the provided JDBC connection:");
        Connection c = null;
        try {
            c = launch.getConnection();
            out.println("Connection: " + c);
            DatabaseMetaData meta = c.getMetaData();
            String productName = meta.getDatabaseProductName();
            String productVersion = meta.getDatabaseProductVersion();
            String URL = meta.getURL();
            out.println("Connection product=" + productName + " version=" + productVersion);
            out.println("Connection URL=" + URL);
        } catch (Exception ex) {
            log.error("Unable to get connection metadata", ex);
            out.println("Unable to get connection metadata:" + ex.getMessage());
        }

        // Do a simple query just to see how it is done
        if (c != null) {
            Statement stmt = null;
            String query = "SELECT plugin_id, plugin_path FROM lms_plugins;";

            try {
                stmt = c.createStatement();
                ResultSet rs = stmt.executeQuery(query);
                int num = 0;
                while (rs.next()) {
                    String plugin_path = rs.getString("plugin_path");
                    out.println("plugin_path=" + plugin_path);
                    num++;
                }
                out.println("Successfully read " + num + " rows from the database");
            } catch (SQLException e) {
                out.println("Problems reading database");
                out.println("INSERT INTO mjjs (name) VALUES ('tsugi');");
                e.printStackTrace();
            }
        }

        // Cheat and look at the internal data Tsugi maintains - this depends on
        // the JDBC implementation
        Properties sess_row = (Properties) session.getAttribute("lti_row");
        if (sess_row != null) {
            out.println("");
            out.println("Tsugi-managed internal session data (Warning: org.tsugi.impl.jdbc.Tsugi_JDBC only)");
            String x = TsugiUtils.dumpProperties(sess_row);
            out.println(x);
        }

        out.println("</pre>");

        // Do the Footer
        o.footerStart(out);
        out.println("<!-- App footer stuff goes here -->");
        o.footerEnd(out);

        out.close();
    } catch (RuntimeException re) {
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>AbstractLTIComponentServlet Error</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>AbstractLTIComponentServlet</h1>");
            out.println("<h3 style=\"color: red;\">Error</h3>");
            out.println("<p>Servlet AbstractLTIComponentServlet at " + request.getContextPath()
                    + " threw an exception.</p>");
            out.println("<p>Exception: " + re.toString() + "<br />");
            out.println("Message: " + re.getMessage() + "<br />");
            out.println("Stacktrace:</p>");
            out.println("<p>" + re.getStackTrace().toString() + "</p>");
            out.println("</body>");
            out.println("</html>");
        }
    }
}

From source file:org.openspaces.rest.space.SpaceAPIController.java

@ExceptionHandler(RuntimeException.class)
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public @ResponseBody ErrorResponse resolveRuntimeException(RuntimeException e) throws IOException {
    if (logger.isLoggable(Level.SEVERE))
        logger.log(Level.SEVERE, "received RuntimeException (unhandled) exception", e.getMessage());

    return new ErrorResponse(new ErrorMessage("Unhandled exception [" + e.getClass() + "]: " + e.toString()));
}

From source file:org.lsc.AbstractSynchronize.java

public boolean run(IBean entry) {

    LscModifications lm = null;/*from ww  w.  j a  va2s  .  c  om*/
    IBean dstBean = null;
    /** Hash table to pass objects into JavaScript condition */
    Map<String, Object> conditionObjects = null;

    try {
        /*
         * Log an error if the source object could not be retrieved! This
         * shouldn't happen.
         */
        if (entry == null) {
            counter.incrementCountError();
            AbstractSynchronize.LOGGER
                    .error("Synchronization aborted because no source object has been found !");
            return false;
        }

        // Search destination for matching object
        if (id != null) {
            dstBean = abstractSynchronize.getBean(task, task.getDestinationService(), id.getKey(),
                    id.getValue(), !fromSource, fromSource);
        } else {
            LscDatasets entryDatasets = new LscDatasets();
            for (String datasetName : entry.datasets().getAttributesNames()) {
                entryDatasets.getDatasets().put(datasetName, entry.getDatasetById(datasetName));
            }
            dstBean = abstractSynchronize.getBean(task, task.getDestinationService(), entry.getMainIdentifier(),
                    entryDatasets, !fromSource, fromSource);
        }

        // Calculate operation that would be performed
        LscModificationType modificationType = BeanComparator.calculateModificationType(task, entry, dstBean);

        // Retrieve condition to evaluate before creating/updating
        Boolean applyCondition = null;
        String conditionString = task.getSyncOptions().getCondition(modificationType);

        // Don't use JavaScript evaluator for primitive cases
        if (conditionString.matches("true")) {
            applyCondition = true;
        } else if (conditionString.matches("false")) {
            applyCondition = false;
        } else {
            conditionObjects = new HashMap<String, Object>();
            conditionObjects.put("dstBean", dstBean);
            conditionObjects.put("srcBean", entry);
            conditionObjects.putAll(task.getScriptingVars());

            // Evaluate if we have to do something
            applyCondition = ScriptingEvaluator.evalToBoolean(task, conditionString, conditionObjects);
        }

        if (applyCondition) {
            lm = BeanComparator.calculateModifications(task, entry, dstBean);

            // if there's nothing to do, skip to the next object
            if (lm == null) {
                return true;
            }

            counter.incrementCountModifiable();

            // no modification: log action for debugging purposes and forget
            if ((modificationType == LscModificationType.CREATE_OBJECT && abstractSynchronize.nocreate)
                    || (modificationType == LscModificationType.UPDATE_OBJECT && abstractSynchronize.noupdate)
                    || (modificationType == LscModificationType.CHANGE_ID
                            && (abstractSynchronize.nomodrdn || abstractSynchronize.noupdate))) {
                abstractSynchronize.logShouldAction(lm, syncName);
                return true;
            }

        } else {
            return true;
        }

        // if we got here, we have a modification to apply - let's do it!
        if (task.getDestinationService().apply(lm)) {
            counter.incrementCountCompleted();
            abstractSynchronize.logAction(lm, id, syncName);
            return true;
        } else {
            counter.incrementCountError();
            abstractSynchronize.logActionError(lm, (id != null ? id.getValue() : entry.getMainIdentifier()),
                    new Exception("Technical problem while applying modifications to the destination"));
            return false;
        }
    } catch (RuntimeException e) {
        counter.incrementCountError();
        abstractSynchronize.logActionError(lm,
                (id != null ? id.getValue() : (entry != null ? entry.getMainIdentifier() : e.toString())), e);

        if (e.getCause() instanceof LscServiceCommunicationException) {
            AbstractSynchronize.LOGGER.error("Connection lost! Aborting.");
        }
        return false;
    } catch (Exception e) {
        counter.incrementCountError();
        abstractSynchronize.logActionError(lm, (id != null ? id.getValue() : entry.getMainIdentifier()), e);
        return false;
    }
}

From source file:com.kjsaw.alcosys.ibacapp.IBAC.java

public void surfaceCreated(SurfaceHolder holder) {
    // TODO Auto-generated method stub
    int cameraCount = 0;
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    cameraCount = Camera.getNumberOfCameras();

    for (int camIdx = 0; camIdx < cameraCount; camIdx++) {
        Camera.getCameraInfo(camIdx, cameraInfo);
        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            try {
                camera = Camera.open(camIdx);
                camera.setDisplayOrientation(90);
                Session.isFacingCamera = true;
                return;
            } catch (RuntimeException re) {
                Logging.d(re.toString());
            }// w  w w.ja v  a2s. c om
        }
    }

    camera = Camera.open();
    camera.setDisplayOrientation(90);
}