Package org.apache.uima.resource

Examples of org.apache.uima.resource.ResourceConfigurationException


      // get value
      Object val = this.getConfigParameterValue(aContext + aParams[i].getName(), aGroupName);
      // is required value missing?
      if (val == null && aParams[i].isMandatory()) {
        if (aGroupName != null) {
          throw new ResourceConfigurationException(
                  ResourceConfigurationException.MANDATORY_VALUE_MISSING_IN_GROUP, new Object[] {
                      aParams[i].getName(), aGroupName, aContext });
        } else {
          throw new ResourceConfigurationException(
                  ResourceConfigurationException.MANDATORY_VALUE_MISSING, new Object[] {
                      aParams[i].getName(), aContext });
        }
      }
      // check datatype
View Full Code Here


  private void validateConfigurationParameterDataTypeMatch(ConfigurationParameter aParam,
          Object aValue, String aContextName) throws ResourceConfigurationException {
    if (aValue != null) {
      Class<?> valClass = aValue.getClass();
      if (aParam.isMultiValued() && !valClass.isArray()) {
        throw new ResourceConfigurationException(ResourceConfigurationException.ARRAY_REQUIRED,
                new Object[] { aParam.getName(), aContextName });
      }

      if (!valClass.equals(getParameterExpectedValueClass(aParam))) {
        throw new ResourceConfigurationException(
                ResourceConfigurationException.PARAMETER_TYPE_MISMATCH, new Object[] {
                    aContextName, valClass.getName(), aParam.getName(), aParam.getType() });
      }
    }
  }
View Full Code Here

        URL descriptorUrl = aCasProcessorConfiguration.getDescriptorUrl();
        String descriptorPath;
        try {
          descriptorPath = UriUtils.quote(descriptorUrl).getPath();
        } catch (URISyntaxException e) {
          throw new ResourceConfigurationException(e);
        }
        if (System.getProperty("os.name") != null
                && System.getProperty("os.name").toLowerCase().startsWith("linux")) {
          cmdArgs.add(descriptorPath);
        } else {
View Full Code Here

        URL descriptorUrl = aCasProcessorConfiguration.getDescriptorUrl();
        String descriptorPath;
        try {
          descriptorPath = UriUtils.quote(descriptorUrl).getPath();
        } catch (URISyntaxException e) {
          throw new ResourceConfigurationException(e);
        }
        cmdArgs.add("\"" + descriptorPath + "\"");
      } else {
        cmdArgs.add(arg);
      }
View Full Code Here

  public CasProcessorConfigurationJAXBImpl(CpeCasProcessor aCasProcessorConfig, ResourceManager aResourceManager)
          throws ResourceConfigurationException {
    this.resourceManager = aResourceManager;
   
    if (aCasProcessorConfig == null) {
      throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] {
          "<casProcessor>", "<casProcessors>" }, new Exception(CpmLocalizedMessage
              .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_EXP_bad_cpe_descriptor__WARNING", new Object[] { Thread
                              .currentThread().getName() })));
    }
View Full Code Here

  private void addErrorHandling(CpeCasProcessor aCasProcessorConfig)
          throws ResourceConfigurationException {
    CasProcessorErrorHandling casProcessorErrorHandling = aCasProcessorConfig.getErrorHandling();

    if (casProcessorErrorHandling == null) {
      throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] {
          "errorHandling", "casProcessor" }, new Exception(CpmLocalizedMessage.getLocalizedMessage(
              CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_missing_xml_element__WARNING",
              new Object[] { Thread.currentThread().getName(), name, "<errorHandling>" })));
    }
    CasProcessorMaxRestarts maxRestarts = casProcessorErrorHandling.getMaxConsecutiveRestarts();
    if (maxRestarts == null) {
      throw new ResourceConfigurationException(
              ResourceConfigurationException.MANDATORY_VALUE_MISSING, new Object[] {
                  "maxConsecutiveRestarts", "CPE" }, new Exception(CpmLocalizedMessage
                      .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                              "UIMA_CPM_EXP_missing_xml_element__WARNING", new Object[] {
                                  Thread.currentThread().getName(), name,
                                  "<maxConsecutiveRestarts>" })));
    }
    maxRetryThreshold = maxRestarts.getRestartCount();
    waitTimeBetweenRestarts = maxRestarts.getWaitTimeBetweenRetries();

    maxRestartThreshold = maxRestarts.getRestartCount();

    if (!validActionOnError(maxRestarts.getAction())) {
      throw new ResourceConfigurationException(
              ResourceConfigurationException.MANDATORY_VALUE_MISSING, new Object[] { "action",
                  "CPE" }, new Exception(CpmLocalizedMessage.getLocalizedMessage(
                      CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_bad_action_string__WARNING",
                      new Object[] { Thread.currentThread().getName(), name,
                          "<maxConsecutiveRestarts>", maxRestarts.getAction() })));
    }
    actionOnMaxRestarts = maxRestarts.getAction();

    // Setup Error rate Threshold in terms of (count)/(sample size) eg. 3/1000
    CasProcessorErrorRateThreshold errorRateThresholdType = casProcessorErrorHandling
            .getErrorRateThreshold();
    if (errorRateThresholdType == null) {
      throw new ResourceConfigurationException(
              ResourceConfigurationException.MANDATORY_VALUE_MISSING, new Object[] {
                  "errorRateThreshold", "CPE" },
              new Exception(CpmLocalizedMessage.getLocalizedMessage(
                      CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_EXP_missing_xml_element__WARNING", new Object[] {
                          Thread.currentThread().getName(), name, "<errorRateThreshold>" })));
    }

    errorRate = errorRateThresholdType.getMaxErrorCount();
    errorSampleSize = errorRateThresholdType.getMaxErrorSampleSize();

    if (!validActionOnError(errorRateThresholdType.getAction())) {
      throw new ResourceConfigurationException(
              ResourceConfigurationException.MANDATORY_VALUE_MISSING, new Object[] { "action",
                  "CPE" }, new Exception(CpmLocalizedMessage.getLocalizedMessage(
                      CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_bad_action_string__WARNING",
                      new Object[] { Thread.currentThread().getName(), name,
                          "<errorRateThreshold>", maxRestarts.getAction() })));
View Full Code Here

   *          configuration object containing Cas Processor configuration
   */
  private void addDeploymentParameters(CpeCasProcessor aCasProcessorConfig)
          throws ResourceConfigurationException {
    if (aCasProcessorConfig == null) {
      throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] {
          "<casProcessor>", "<casProcessors>" }, new Exception(CpmLocalizedMessage
              .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_EXP_bad_cpe_descriptor_no_cp__WARNING", new Object[] { Thread
                              .currentThread().getName() })));
    }
    CasProcessorDeploymentParams deployParams = aCasProcessorConfig.getDeploymentParams();

    if (deployParams != null) {
      CasProcessorDeploymentParam[] parameters = deployParams.getAll();
      for (int i = 0; parameters != null && i < parameters.length; i++) {
        try {
          if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
            UIMAFramework.getLogger(this.getClass()).logrb(
                    Level.FINEST,
                    this.getClass().getName(),
                    "initialize",
                    CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                    "UIMA_CPM_show_cp_deploy_params__FINEST",
                    new Object[] { Thread.currentThread().getName(), name,
                        parameters[i].getParameterName(), parameters[i].getParameterValue() });
          }
          NameValuePair nvp = new NameValuePair_impl();
          nvp.setName(parameters[i].getParameterName());

          // If a value is a path to a file and IS a relative path convert to absolute path using
          // CPE_HOME variable
          String value = CPMUtils.convertToAbsolutePath(System.getProperty("CPM_HOME"),
                  CPEFactory.CPM_HOME, parameters[i].getParameterValue());
          nvp.setValue(value);
          if (deploymentParameters == null) {
            deploymentParameters = new ArrayList();
          }
          deploymentParameters.add(nvp);

        } catch (Exception e) {
          throw new ResourceConfigurationException(e);
        }
      }
    }
    CasProcessorRunInSeperateProcess rsp = null;
    if ((rsp = aCasProcessorConfig.getRunInSeparateProcess()) != null
View Full Code Here

   * @throws ResourceConfigurationException
   */
  private void addDeploymentType(CpeCasProcessor aCasProcessorConfig)
          throws ResourceConfigurationException {
    if (aCasProcessorConfig == null) {
      throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] {
          "<casProcessor>", "<casProcessors>" }, new Exception(CpmLocalizedMessage
              .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_EXP_bad_cpe_descriptor_no_cp__WARNING", new Object[] { Thread
                              .currentThread().getName() })));
    }
    String deployType = aCasProcessorConfig.getDeployment();
    if (deployType == null || deployType.trim().length() == 0) {
      throw new ResourceConfigurationException(InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING,
              new Object[] { "deployment", "casProcessor" }, new Exception(CpmLocalizedMessage
                      .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                              "UIMA_CPM_EXP_missing_attribute_from_xml_element__WARNING",
                              new Object[] { Thread.currentThread().getName(),
                                  aCasProcessorConfig.getName(), "deployment", "<casProcessor>" })));
View Full Code Here

   *          configuration object containing Cas Processor configuration
   */
  private void addFiltering(CpeCasProcessor aCasProcessorConfig)
          throws ResourceConfigurationException {
    if (aCasProcessorConfig == null) {
      throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] {
          "<casProcessor>", "<casProcessors>" }, new Exception(CpmLocalizedMessage
              .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_EXP_bad_cpe_descriptor_no_cp__WARNING", new Object[] { Thread
                              .currentThread().getName() })));
    }
View Full Code Here

   *          configuration object containing Cas Processor configuration
   */
  private void addBatchSize(CpeCasProcessor aCasProcessorConfig)
          throws ResourceConfigurationException {
    if (aCasProcessorConfig == null) {
      throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] {
          "<casProcessor>", "<casProcessors>" }, new Exception(CpmLocalizedMessage
              .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_EXP_bad_cpe_descriptor_no_cp__WARNING", new Object[] { Thread
                              .currentThread().getName() })));
    }
    CpeCheckpoint checkpoint = aCasProcessorConfig.getCheckpoint();
    if (checkpoint == null) {
      throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] {
          "<checkpoint>", "<casProcessor>" }, new Exception(CpmLocalizedMessage
              .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_EXP_missing_xml_element__WARNING", new Object[] {
                          Thread.currentThread().getName(), aCasProcessorConfig.getName(),
                          "<checkpoint>" })));
    }

    try {
      if (checkpoint.getBatchSize() > 0) {
        batchSize = checkpoint.getBatchSize();
      }
    } catch (NumberFormatException e) {
      throw new ResourceConfigurationException(InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING,
              new Object[] { "batch", "<checkpoint>" }, new Exception(CpmLocalizedMessage
                      .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                              "UIMA_CPM_EXP_missing_attribute_from_xml_element__WARNING",
                              new Object[] { Thread.currentThread().getName(),
                                  aCasProcessorConfig.getName(), "batch", "<checkpoint>" })));
View Full Code Here

TOP

Related Classes of org.apache.uima.resource.ResourceConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.