Example usage for java.lang ClassNotFoundException getMessage

List of usage examples for java.lang ClassNotFoundException getMessage

Introduction

In this page you can find the example usage for java.lang ClassNotFoundException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.evolveum.midpoint.web.page.admin.reports.component.RunReportPopupPanel.java

private <O extends ObjectType> List<LookupTableRowType> createLookupTableRows(JasperReportParameterDto param,
        String input) {//from  w  ww.  ja  va2  s.c  om
    ItemPath label = null;
    ItemPath key = null;
    List<LookupTableRowType> rows = new ArrayList<>();

    JasperReportParameterPropertiesDto properties = param.getProperties();

    if (properties == null) {
        return null;
    }

    String pLabel = properties.getLabel();
    if (pLabel != null) {
        label = new ItemPath(pLabel);
    }
    String pKey = properties.getKey();
    if (pKey != null) {
        key = new ItemPath(pKey);
    }

    String pTargetType = properties.getTargetType();
    Class<O> targetType = null;
    if (pTargetType != null) {
        try {
            targetType = (Class<O>) Class.forName(pTargetType);
        } catch (ClassNotFoundException e) {
            error("Error while creating lookup table for input parameter: " + param.getName() + ", "
                    + e.getClass().getSimpleName() + " (" + e.getMessage() + ")");

        }
    }

    if (label != null && targetType != null && input != null) {
        OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
        Task task = createSimpleTask(OPERATION_LOAD_RESOURCES);

        Collection<PrismObject<O>> objects;
        ObjectQuery query = QueryBuilder.queryFor(targetType, getPrismContext())
                .item(new QName(SchemaConstants.NS_C, pLabel)).startsWith(input)
                .matching(new QName(SchemaConstants.NS_MATCHING_RULE, "origIgnoreCase"))
                .maxSize(AUTO_COMPLETE_BOX_SIZE).build();
        try {
            objects = getPageBase().getModelService().searchObjects(targetType, query,
                    SelectorOptions.createCollection(GetOperationOptions.createNoFetch()), task, result);

            for (PrismObject<O> o : objects) {
                Object realKeyValue = null;
                PrismProperty<?> labelItem = o.findProperty(label);

                //TODO: e.g. support not only for property, but also ref, container..
                if (labelItem == null || labelItem.isEmpty()) {
                    continue;
                }
                PrismProperty<?> keyItem = o.findProperty(key);
                if ("oid".equals(pKey)) {
                    realKeyValue = o.getOid();
                }
                if (realKeyValue == null && (keyItem == null || keyItem.isEmpty())) {
                    continue;
                }

                //TODO: support for single/multivalue value
                if (!labelItem.isSingleValue()) {
                    continue;
                }

                Object realLabelValue = labelItem.getRealValue();
                realKeyValue = (realKeyValue == null) ? keyItem.getRealValue() : realKeyValue;

                // TODO: take definition into account
                //                    QName typeName = labelItem.getDefinition().getTypeName();

                LookupTableRowType row = new LookupTableRowType();

                if (realKeyValue != null) {
                    row.setKey(convertObjectToPolyStringType(realKeyValue).getOrig());
                } else {
                    throw new SchemaException(
                            "Cannot create lookup table with null key for label: " + realLabelValue);
                }

                row.setLabel(convertObjectToPolyStringType(realLabelValue));

                rows.add(row);
            }

            return rows;
        } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException
                | ConfigurationException | ExpressionEvaluationException e) {
            error("Error while creating lookup table for input parameter: " + param.getName() + ", "
                    + e.getClass().getSimpleName() + " (" + e.getMessage() + ")");
        }

    }
    return rows;
}

From source file:com.sec.ose.airs.service.protex.ProtexSDKAPIService.java

public void init(String protexServerIP, String userID, String password) throws Exception {
    try {/*from w  w w . j ava2s  .  c om*/
        protexServerProxyClass = Class.forName(protexServerProxyClassName);
    } catch (ClassNotFoundException e) {
        log.error(e.getMessage());
        throw e;
    }

    Class<?>[] parameterTypes = { String.class, String.class, String.class, Long.class };
    Object[] args = { protexServerIP, userID, password, connectionTimeout };

    protexServerProxyObject = protexServerProxyClass.getConstructor(parameterTypes).newInstance(args);
    this.setAPIs();

    try {
        this.testConnection();
    } catch (Exception e) {
        log.error(e);
        throw e;
    }

    this.protexServerIP = protexServerIP;
    this.userID = userID;
    this.password = password;
}

From source file:com.aliyun.odps.graph.GraphJob.java

/**
 * ???? ODPS Graph ??.//from   w ww .  jav a  2s  . c  om
 *
 * <p>
 * ????{@link IOException}? {@link #run()} ?? {@link #run()}
 * 
 * </p>
 *
 * <p>
 * ?????
 *
 * <pre>
 * GraphJob job = new GraphJob();
 * ... //config job
 * job.submit();
 * while (!job.isComplete()) {
 *   Thread.sleep(4000); // do your work or sleep
 * }
 * if (job.isSuccessful()) {
 *   System.out.println(&quot;Job Success!&quot;);
 * } else {
 *   System.err.println(&quot;Job Failed!&quot;);
 * }
 * </pre>
 *
 * </p>
 *
 * @throws IOException
 *     ??
 */
public void submit() throws IOException {
    ensureState(JobState.DEFINE);

    try {
        parseArgs();
        String runner = "com.aliyun.odps.graph.job.NetworkJobRunner";
        if (SessionState.get().isLocalRun()) {
            runner = "com.aliyun.odps.graph.local.LocalGraphJobRunner";
        }
        JobRunner jobrunner = null;
        try {
            Class<? extends JobRunner> clz = (Class<? extends JobRunner>) Class.forName(runner);
            jobrunner = ReflectionUtils.newInstance(clz, this);
        } catch (ClassNotFoundException e) {
            LOG.fatal("Internal error: currupted installation.", e);
            throw new RuntimeException(e);
        }
        rJob = jobrunner.submit();

    } catch (OdpsException oe) {
        LOG.error(StringUtils.stringifyException(oe));
        throw new IOException(oe.getMessage());
    } catch (Exception e) {
        LOG.error(StringUtils.stringifyException(e));
        throw new IOException(e.getMessage());
    }

    state = JobState.RUNNING;
}

From source file:org.apache.dubbo.rpc.protocol.thrift.ThriftCodec.java

private void encodeRequest(Channel channel, ChannelBuffer buffer, Request request) throws IOException {

    RpcInvocation inv = (RpcInvocation) request.getData();

    int seqId = nextSeqId();

    String serviceName = inv.getAttachment(Constants.INTERFACE_KEY);

    if (StringUtils.isEmpty(serviceName)) {
        throw new IllegalArgumentException(
                "Could not find service name in attachment with key " + Constants.INTERFACE_KEY);
    }/*from  w  ww .j a v a2 s. co m*/

    TMessage message = new TMessage(inv.getMethodName(), TMessageType.CALL, seqId);

    String methodArgs = ExtensionLoader
            .getExtensionLoader(ClassNameGenerator.class).getExtension(channel.getUrl()
                    .getParameter(ThriftConstants.CLASS_NAME_GENERATOR_KEY, ThriftClassNameGenerator.NAME))
            .generateArgsClassName(serviceName, inv.getMethodName());

    if (StringUtils.isEmpty(methodArgs)) {
        throw new RpcException(RpcException.SERIALIZATION_EXCEPTION,
                "Could not encode request, the specified interface may be incorrect.");
    }

    Class<?> clazz = cachedClass.get(methodArgs);

    if (clazz == null) {

        try {

            clazz = ClassHelper.forNameWithThreadContextClassLoader(methodArgs);

            cachedClass.putIfAbsent(methodArgs, clazz);

        } catch (ClassNotFoundException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        }

    }

    TBase args;

    try {
        args = (TBase) clazz.newInstance();
    } catch (InstantiationException e) {
        throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
    } catch (IllegalAccessException e) {
        throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
    }

    for (int i = 0; i < inv.getArguments().length; i++) {

        Object obj = inv.getArguments()[i];

        if (obj == null) {
            continue;
        }

        TFieldIdEnum field = args.fieldForId(i + 1);

        String setMethodName = ThriftUtils.generateSetMethodName(field.getFieldName());

        Method method;

        try {
            method = clazz.getMethod(setMethodName, inv.getParameterTypes()[i]);
        } catch (NoSuchMethodException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        }

        try {
            method.invoke(args, obj);
        } catch (IllegalAccessException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        } catch (InvocationTargetException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        }

    }

    RandomAccessByteArrayOutputStream bos = new RandomAccessByteArrayOutputStream(1024);

    TIOStreamTransport transport = new TIOStreamTransport(bos);

    TBinaryProtocol protocol = new TBinaryProtocol(transport);

    int headerLength, messageLength;

    byte[] bytes = new byte[4];
    try {
        // magic
        protocol.writeI16(MAGIC);
        // message length placeholder
        protocol.writeI32(Integer.MAX_VALUE);
        // message header length placeholder
        protocol.writeI16(Short.MAX_VALUE);
        // version
        protocol.writeByte(VERSION);
        // service name
        protocol.writeString(serviceName);
        // dubbo request id
        protocol.writeI64(request.getId());
        protocol.getTransport().flush();
        // header size
        headerLength = bos.size();

        // message body
        protocol.writeMessageBegin(message);
        args.write(protocol);
        protocol.writeMessageEnd();
        protocol.getTransport().flush();
        int oldIndex = messageLength = bos.size();

        // fill in message length and header length
        try {
            TFramedTransport.encodeFrameSize(messageLength, bytes);
            bos.setWriteIndex(MESSAGE_LENGTH_INDEX);
            protocol.writeI32(messageLength);
            bos.setWriteIndex(MESSAGE_HEADER_LENGTH_INDEX);
            protocol.writeI16((short) (0xffff & headerLength));
        } finally {
            bos.setWriteIndex(oldIndex);
        }

    } catch (TException e) {
        throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
    }

    buffer.writeBytes(bytes);
    buffer.writeBytes(bos.toByteArray());

}

From source file:com.alibaba.dubbo.rpc.protocol.thrift.ThriftCodec.java

private void encodeRequest(Channel channel, ChannelBuffer buffer, Request request) throws IOException {

    RpcInvocation inv = (RpcInvocation) request.getData();

    int seqId = nextSeqId();

    String serviceName = inv.getAttachment(Constants.INTERFACE_KEY);

    if (StringUtils.isEmpty(serviceName)) {
        throw new IllegalArgumentException(
                new StringBuilder(32).append("Could not find service name in attachment with key ")
                        .append(Constants.INTERFACE_KEY).toString());
    }/*  w w  w .  j  a v  a2 s  .  co m*/

    TMessage message = new TMessage(inv.getMethodName(), TMessageType.CALL, seqId);

    String methodArgs = ExtensionLoader
            .getExtensionLoader(ClassNameGenerator.class).getExtension(channel.getUrl()
                    .getParameter(ThriftConstants.CLASS_NAME_GENERATOR_KEY, ThriftClassNameGenerator.NAME))
            .generateArgsClassName(serviceName, inv.getMethodName());

    if (StringUtils.isEmpty(methodArgs)) {
        throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, new StringBuilder(32)
                .append("Could not encode request, the specified interface may be incorrect.").toString());
    }

    Class<?> clazz = cachedClass.get(methodArgs);

    if (clazz == null) {

        try {

            clazz = ClassHelper.forNameWithThreadContextClassLoader(methodArgs);

            cachedClass.putIfAbsent(methodArgs, clazz);

        } catch (ClassNotFoundException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        }

    }

    TBase args;

    try {
        args = (TBase) clazz.newInstance();
    } catch (InstantiationException e) {
        throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
    } catch (IllegalAccessException e) {
        throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
    }

    for (int i = 0; i < inv.getArguments().length; i++) {

        Object obj = inv.getArguments()[i];

        if (obj == null) {
            continue;
        }

        TFieldIdEnum field = args.fieldForId(i + 1);

        String setMethodName = ThriftUtils.generateSetMethodName(field.getFieldName());

        Method method;

        try {
            method = clazz.getMethod(setMethodName, inv.getParameterTypes()[i]);
        } catch (NoSuchMethodException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        }

        try {
            method.invoke(args, obj);
        } catch (IllegalAccessException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        } catch (InvocationTargetException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        }

    }

    RandomAccessByteArrayOutputStream bos = new RandomAccessByteArrayOutputStream(1024);

    TIOStreamTransport transport = new TIOStreamTransport(bos);

    TBinaryProtocol protocol = new TBinaryProtocol(transport);

    int headerLength, messageLength;

    byte[] bytes = new byte[4];
    try {
        // magic
        protocol.writeI16(MAGIC);
        // message length placeholder
        protocol.writeI32(Integer.MAX_VALUE);
        // message header length placeholder
        protocol.writeI16(Short.MAX_VALUE);
        // version
        protocol.writeByte(VERSION);
        // service name
        protocol.writeString(serviceName);
        // dubbo request id
        protocol.writeI64(request.getId());
        protocol.getTransport().flush();
        // header size
        headerLength = bos.size();

        // message body
        protocol.writeMessageBegin(message);
        args.write(protocol);
        protocol.writeMessageEnd();
        protocol.getTransport().flush();
        int oldIndex = messageLength = bos.size();

        // fill in message length and header length
        try {
            TFramedTransport.encodeFrameSize(messageLength, bytes);
            bos.setWriteIndex(MESSAGE_LENGTH_INDEX);
            protocol.writeI32(messageLength);
            bos.setWriteIndex(MESSAGE_HEADER_LENGTH_INDEX);
            protocol.writeI16((short) (0xffff & headerLength));
        } finally {
            bos.setWriteIndex(oldIndex);
        }

    } catch (TException e) {
        throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
    }

    buffer.writeBytes(bytes);
    buffer.writeBytes(bos.toByteArray());

}

From source file:com.google.gsa.valve.rootAuth.RootAuthorizationProcess.java

/**
 * Gets the authorization process instance needed to process the request
 * /*ww w  . ja v a2s  .c om*/
 * @param repository the repository configuration information
 * 
 * @return the authorization class 
 */
private AuthorizationProcessImpl getAuthorizationProcess(ValveRepositoryConfiguration repository) {

    AuthorizationProcessImpl authProcess = null;

    //protection
    if (repository != null) {

        try {

            String authZComponent = repository.getAuthZ();
            logger.debug("Authorization module is: " + authZComponent);

            if (authZComponent != null) {
                authProcess = (AuthorizationProcessImpl) Class.forName(authZComponent).newInstance();
                authProcess.setValveConfiguration(valveConf);
            } else {
                logger.debug("This repository[" + repository.getId()
                        + "] does not cointain any Authorization class");
            }

        } catch (LinkageError le) {
            logger.error(repository.getId() + " - Can't instantiate class [AuthorizationProcess-LinkageError]: "
                    + le.getMessage(), le);
            authProcess = null;
        } catch (InstantiationException ie) {
            logger.error(repository.getId()
                    + " - Can't instantiate class [AuthorizationProcess-InstantiationException]: "
                    + ie.getMessage(), ie);
            authProcess = null;
        } catch (IllegalAccessException iae) {
            logger.error(repository.getId()
                    + " - Can't instantiate class [AuthorizationProcess-IllegalAccessException]: "
                    + iae.getMessage(), iae);
            authProcess = null;
        } catch (ClassNotFoundException cnfe) {
            logger.error(repository.getId()
                    + " - Can't instantiate class [AuthorizationProcess-ClassNotFoundException]: "
                    + cnfe.getMessage(), cnfe);
            authProcess = null;
        } catch (Exception e) {
            logger.error(repository.getId() + " - Can't instantiate class [AuthorizationProcess-Exception]: "
                    + e.getMessage(), e);
            authProcess = null;
        }
    }

    return authProcess;
}

From source file:de.tudarmstadt.ukp.clarin.webanno.brat.annotation.BratAnnotator.java

public BratAnnotator(String id, IModel<BratAnnotatorModel> aModel,
        final AnnotationDetailEditorPanel aAnnotationDetailEditorPanel) {
    super(id, aModel);

    // Allow AJAX updates.
    setOutputMarkupId(true);//  w  w w . j  a v  a2s . com

    // The annotator is invisible when no document has been selected. Make sure that we can
    // make it visible via AJAX once the document has been selected.
    setOutputMarkupPlaceholderTag(true);

    if (getModelObject().getDocument() != null) {
        collection = "#" + getModelObject().getProject().getName() + "/";
    }

    vis = new WebMarkupContainer("vis");
    vis.setOutputMarkupId(true);

    controller = new AbstractDefaultAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void respond(AjaxRequestTarget aTarget) {
            final IRequestParameters request = getRequest().getPostParameters();

            // Parse annotation ID if present in request
            VID paramId;
            if (!request.getParameterValue(PARAM_ID).isEmpty()
                    && !request.getParameterValue(PARAM_ARC_ID).isEmpty()) {
                throw new IllegalStateException("[id] and [arcId] cannot be both set at the same time!");
            } else if (!request.getParameterValue(PARAM_ID).isEmpty()) {
                paramId = VID.parseOptional(request.getParameterValue(PARAM_ID).toString());
            } else {
                paramId = VID.parseOptional(request.getParameterValue(PARAM_ARC_ID).toString());
            }

            // Ignore ghosts
            if (paramId.isGhost()) {
                error("This is a ghost annotation, select layer and feature to annotate.");
                aTarget.addChildren(getPage(), FeedbackPanel.class);
                return;
            }

            // Get action
            String action = request.getParameterValue(PARAM_ACTION).toString();

            // Load the CAS if necessary
            boolean requiresCasLoading = action.equals(SpanAnnotationResponse.COMMAND)
                    || action.equals(ArcAnnotationResponse.COMMAND)
                    || action.equals(GetDocumentResponse.COMMAND);
            JCas jCas = null;
            if (requiresCasLoading) {
                // Make sure we load the CAS only once here in case of an annotation action.
                try {
                    jCas = getCas(getModelObject());
                } catch (ClassNotFoundException e) {
                    error("Invalid reader: " + e.getMessage());
                } catch (IOException e) {
                    error(e.getMessage());
                } catch (UIMAException e) {
                    error(ExceptionUtils.getRootCauseMessage(e));
                }
            }

            // HACK: If an arc was clicked that represents a link feature, then open the
            // associated span annotation instead.
            if (paramId.isSlotSet() && action.equals(ArcAnnotationResponse.COMMAND)) {
                action = SpanAnnotationResponse.COMMAND;
                paramId = new VID(paramId.getId());
            }

            BratAjaxCasController controller = new BratAjaxCasController(repository, annotationService);

            // Doing anything but a span annotation when a slot is armed will unarm it
            if (getModelObject().isSlotArmed() && !action.equals(SpanAnnotationResponse.COMMAND)) {
                getModelObject().clearArmedSlot();
            }

            Object result = null;
            try {
                LOG.info("AJAX-RPC CALLED: [" + action + "]");

                if (action.equals(WhoamiResponse.COMMAND)) {
                    result = controller.whoami();
                } else if (action.equals(SpanAnnotationResponse.COMMAND)) {
                    assert jCas != null;

                    if (getModelObject().isSlotArmed()) {
                        if (paramId.isSet()) {
                            // Fill slot with existing annotation
                            aAnnotationDetailEditorPanel.setSlot(aTarget, jCas, getModelObject(),
                                    paramId.getId());
                        } else if (!CAS.TYPE_NAME_ANNOTATION
                                .equals(getModelObject().getArmedFeature().getType())) {
                            // Fill slot with new annotation (only works if a concret type is
                            // set for the link feature!
                            SpanAdapter adapter = (SpanAdapter) getAdapter(annotationService,
                                    annotationService.getLayer(getModelObject().getArmedFeature().getType(),
                                            getModelObject().getProject()));

                            Offsets offsets = getSpanOffsets(request, jCas, paramId);

                            try {
                                int id = adapter.add(jCas, offsets.getBegin(), offsets.getEnd(), null, null);
                                aAnnotationDetailEditorPanel.setSlot(aTarget, jCas, getModelObject(), id);
                            } catch (BratAnnotationException e) {
                                error(e.getMessage());
                                LOG.error(ExceptionUtils.getRootCauseMessage(e), e);
                            }
                        } else {
                            error("Cannot auto-create targets for generic links.");
                        }
                    } else {
                        if (paramId.isSet()) {
                            getModelObject().setForwardAnnotation(false);
                        }
                        // Doing anything but filling an armed slot will unarm it
                        getModelObject().clearArmedSlot();

                        Selection selection = getModelObject().getSelection();

                        selection.setRelationAnno(false);

                        Offsets offsets = getSpanOffsets(request, jCas, paramId);
                        selection.setAnnotation(paramId);
                        selection.set(jCas, offsets.getBegin(), offsets.getEnd());

                        aAnnotationDetailEditorPanel.setLayerAndFeatureModels(jCas, getModelObject());

                        if (BratAnnotatorUtility.isDocumentFinished(repository, getModelObject())) {
                            error("This document is already closed. Please ask your project "
                                    + "manager to re-open it via the Montoring page");
                        }

                        bratRenderHighlight(aTarget, selection.getAnnotation());

                        if (selection.getAnnotation().isNotSet()) {
                            bratRenderGhostSpan(aTarget, jCas, selection.getBegin(), selection.getEnd());
                        } else {
                            bratRender(aTarget, jCas);
                            result = new SpanAnnotationResponse();
                        }
                    }
                } else if (action.equals(ArcAnnotationResponse.COMMAND)) {
                    assert jCas != null;

                    Selection selection = getModelObject().getSelection();

                    selection.setRelationAnno(true);
                    selection.setAnnotation(paramId);
                    selection.setOriginType(request.getParameterValue(PARAM_ORIGIN_TYPE).toString());
                    selection.setOrigin(request.getParameterValue(PARAM_ORIGIN_SPAN_ID).toInteger());
                    selection.setTargetType(request.getParameterValue(PARAM_TARGET_TYPE).toString());
                    selection.setTarget(request.getParameterValue(PARAM_TARGET_SPAN_ID).toInteger());

                    aAnnotationDetailEditorPanel.setLayerAndFeatureModels(jCas, getModelObject());

                    if (BratAnnotatorUtility.isDocumentFinished(repository, getModelObject())) {
                        error("This document is already closed. Please ask admin to re-open");
                    }

                    bratRenderHighlight(aTarget, getModelObject().getSelection().getAnnotation());

                    if (getModelObject().getSelection().getAnnotation().isNotSet()) {
                        bratRenderGhostArc(aTarget, jCas);
                    } else {
                        bratRender(aTarget, jCas);
                        result = new ArcAnnotationResponse();
                    }
                } else if (action.equals(LoadConfResponse.COMMAND)) {
                    result = controller.loadConf();
                } else if (action.equals(GetCollectionInformationResponse.COMMAND)) {
                    if (getModelObject().getProject() != null) {
                        result = controller.getCollectionInformation(getModelObject().getAnnotationLayers());
                    } else {
                        result = new GetCollectionInformationResponse();
                    }
                } else if (action.equals(GetDocumentResponse.COMMAND)) {
                    if (getModelObject().getProject() != null) {
                        result = controller.getDocumentResponse(getModelObject(), 0, jCas, true);
                    } else {
                        result = new GetDocumentResponse();
                    }
                }

                LOG.info("AJAX-RPC DONE: [" + action + "]");
            } catch (ClassNotFoundException e) {
                error("Invalid reader: " + e.getMessage());
            } catch (UIMAException e) {
                error(ExceptionUtils.getRootCauseMessage(e));
            } catch (IOException e) {
                error(e.getMessage());
            }

            // Serialize updated document to JSON
            if (result == null) {
                LOG.warn("AJAX-RPC: Action [" + action + "] produced no result!");
            } else {
                String json = toJson(result);
                // Since we cannot pass the JSON directly to Brat, we attach it to the HTML
                // element into which BRAT renders the SVG. In our modified ajax.js, we pick it
                // up from there and then pass it on to BRAT to do the rendering.
                aTarget.prependJavaScript("Wicket.$('" + vis.getMarkupId() + "').temp = " + json + ";");
            }
            aTarget.addChildren(getPage(), FeedbackPanel.class);
            if (getModelObject().getSelection().getAnnotation().isNotSet()) {
                aAnnotationDetailEditorPanel.setAnnotationLayers(getModelObject());
            }
            aTarget.add(aAnnotationDetailEditorPanel);
        }
    };

    add(vis);
    add(controller);
}

From source file:edu.lternet.pasta.auditmanager.AuditManagerResource.java

/**
 * <strong>Get Recent Uploads</strong> operation, gets a list of zero or more audit 
 * records of either recently inserted or recently updated data packages, as specified
 * in the request./*from  w  ww.  j av  a2s.c o m*/
 *
 * <h4>Query Parameters:</h4>
 * <table border="1" cellspacing="0" celpadding="3">
 *   <tr>
 *     <td><b>Parameter</b></td>
 *     <td><b>Value Constraints</b></td>
 *   </tr>
 *   <tr>
 *     <td>serviceMethod</td>
 *     <td>Either of &quot;createDataPackage&quot; or &quot;updateDataPackage&quot;
 *     </td>
 *   </tr>
 *   <tr>
 *     <td>fromTime</td>
 *     <td>An ISO8601 timestamp</td>
 *   </tr>
 *   <tr>
 *     <td>limit</td>
 *     <td>A positive whole number</td>
 *   </tr>
 * </table>
 * <br/>
 * The query parameter <code>serviceMethod</code> should have the value
 * &quot;createDataPackage&quot; (to retrieve recent inserts) or &quot;updateDataPackage&quot;
 * (to retrieve recent updates)
 * <br/>
 * The query parameter <code>fromTime</code> is used to specify the
 * date/time in the past that represents the oldest audit records that should be
 * returned. Data packages uploaded prior to that time are not considered
 * recent uploads and are thus filtered from the query results.
 * <br/>
 * The query parameter <code>limit</code> sets an upper limit on the number
 * of audit records returned. For example, "limit=3".
 *
 * <h4>Responses:</h4>
 *
 * <p>If the request is successful, the response will contain XML text.</p>
 *
 * <table border="1" cellspacing="0" cellpadding="3">
 *   <tr>
 *     <td><b>Status</b></td>
 *     <td><b>Reason</b></td>
 *     <td><b>Entity</b></td>
 *     <td><b>MIME type</b></td>
 *   </tr>
 *   <tr>
 *     <td>200 OK</td>
 *     <td>If the request was successful.</td>
 *     <td>The specified subscription's attributes.</td>
 *     <td><code>application/xml</code></td>
 *   </tr>
 *   <tr>
 *     <td>400 Bad Request</td>
 *     <td>If the specified identification number cannot be parsed as an integer.</td>
 *     <td>An error message.</td>
 *     <td><code>text/plain</code></td>
 *   </tr>
 *   <tr>
 *     <td>401 Unauthorized</td>
 *     <td>If the requesting user is not authorized to read the specified subscription.</td>
 *     <td>An error message.</td>
 *     <td><code>text/plain</code></td>
 *   </tr>
 * </table>
 *
 * @param headers  the HTTP request headers containing the authorization token.
 * @param uriInfo  the POST request's body, of XML representing a log entry.
 * @return an appropriate HTTP response.
 */
@GET
@Path("recent-uploads")
public Response getRecentUploads(@Context HttpHeaders headers, @Context UriInfo uriInfo) {
    try {
        Properties properties = ConfigurationListener.getProperties();
        assertAuthorizedToRead(headers, MethodNameUtility.methodName());
        AuditManager auditManager = new AuditManager(properties);
        QueryString queryString = new QueryString(uriInfo);
        queryString.checkForIllegalKeys(VALID_RECENT_UPLOADS_KEYS);
        Map<String, List<String>> queryParams = queryString.getParams();
        String xmlString = auditManager.getRecentUploads(queryParams);
        return Response.ok(xmlString).build();
    } catch (ClassNotFoundException e) {
        return WebExceptionFactory.make(Status.INTERNAL_SERVER_ERROR, e, e.getMessage()).getResponse();
    } catch (ResourceNotFoundException e) {
        return WebExceptionFactory.makeNotFound(e).getResponse();
    } catch (SQLException e) {
        return WebExceptionFactory.make(Status.INTERNAL_SERVER_ERROR, e, e.getMessage()).getResponse();
    } catch (UnauthorizedException e) {
        return WebExceptionFactory.makeUnauthorized(e).getResponse();
    } catch (WebApplicationException e) {
        return e.getResponse();
    } catch (IllegalStateException e) {
        return WebExceptionFactory.makeBadRequest(e).getResponse();
    }
}

From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java

private boolean initClassesAndMethodsByReflection() {
    if (notificationBuilderClass != null) {
        return true;
    }/*from   w  w  w  . j a va  2  s .  com*/
    try {
        notificationBuilderClass = Class.forName("android.app.Notification$Builder"); //API Level 11
        notificationBigTextStyleClass = Class.forName("android.app.Notification$BigTextStyle"); //API Level 16
        notificationStyleClass = Class.forName("android.app.Notification$Style"); //API Level 16
        notificationBigPictureStyleClass = Class.forName("android.app.Notification$BigPictureStyle"); //API Level 16
        if (android.os.Build.VERSION.SDK_INT >= ANDROID_MARSHMALLOW) {
            iconClass = Class.forName("android.graphics.drawable.Icon"); //API Level 23
        }
        if (!buildMethodsByReflection()) {
            // fall back to creating the legacy notification.
            return false;
        }
        return true;
    } catch (final ClassNotFoundException ex) {
        log.debug("Failed to get notification builder classes by reflection : " + ex.getMessage(), ex);
        return false;
    }
}

From source file:com.aurel.track.dbase.MigrateTo37.java

private Connection getConnection() {
    try {/* ww  w .  j a  v  a2s .  co  m*/
        PropertiesConfiguration tcfg = new PropertiesConfiguration();
        tcfg = HandleHome.getTorqueProperties(servletContext, false);
        String jdbcURL = (String) tcfg.getProperty("torque.dsfactory.track.connection.url");
        String jdbcUser = (String) tcfg.getProperty("torque.dsfactory.track.connection.user");
        String jdbcPassword = (String) tcfg.getProperty("torque.dsfactory.track.connection.password");
        String jdbcDriver = (String) tcfg.getProperty("torque.dsfactory.track.connection.driver");
        System.err.println("Using this username: " + jdbcUser);
        System.err.println("Using this password: " + jdbcPassword != null);
        System.err.println("Using this JDBC URL: " + jdbcURL);
        try {
            Class.forName(jdbcDriver);
        } catch (ClassNotFoundException e) {
            System.err.println("Loading the jdbcDriver " + jdbcDriver + "  failed with " + e.getMessage());
            System.err.println(ExceptionUtils.getStackTrace(e));
        }
        // establish a connection
        return DriverManager.getConnection(jdbcURL, jdbcUser, jdbcPassword);
    } catch (Exception e) {
        System.err.println("Getting the JDBC connection failed with " + e.getMessage());
        System.err.println(ExceptionUtils.getStackTrace(e));
    }
    return null;
}