예제 #1
0
 private Object getAnnotationValue(final Object object, final String methodName)
     throws SiminovException {
   try {
     return object.getClass().getMethod(methodName, null).invoke(object, null);
   } catch (Exception e) {
     Log.loge(
         getClass().getName(),
         "getAnnotationValue",
         "Exception caught while getting annotation value, CLASS-NAME: "
             + object.getClass().getName()
             + ", METHOD NAME: "
             + methodName
             + ", "
             + e.getMessage());
     throw new SiminovException(
         getClass().getName(),
         "getAnnotationValue",
         "Exception caught while getting annotation value, CLASS-NAME: "
             + object.getClass().getName()
             + ", METHOD NAME: "
             + methodName
             + ", "
             + e.getMessage());
   }
 }
  private void doValidation() throws DeploymentException {

    /*
     * Validation for name field.
     */
    String name = libraryDescriptor.getName();
    if (name == null || name.length() <= 0) {
      Log.loge(
          getClass().getName(),
          "doValidation",
          "LIBRARY-NAME IS MANDATORY FIELD - LIBRARY-DESCRIPTOR: " + this.libraryName);
      throw new DeploymentException(
          getClass().getName(),
          "doValidation",
          "LIBRARY-NAME IS MANDATORY FIELD - LIBRARY-DESCRIPTOR: " + this.libraryName);
    }

    Iterator<String> databaseMappingPaths = libraryDescriptor.getDatabaseMappingPaths();
    while (databaseMappingPaths.hasNext()) {
      String databaseMappingPath = databaseMappingPaths.next();

      if (databaseMappingPath.endsWith(XML_FILE_EXTENSION)) {
        if (!databaseMappingPath.contains(SIMINOV_DESCRIPTOR_EXTENSION)) {
          Log.loge(
              getClass().getName(),
              "doValidation",
              "INVALID LIBRARY DATABASE MAPPING PATH FOUND, it should contain .core extension in path, PATH-DEFINED: "
                  + databaseMappingPath);
          throw new DeploymentException(
              getClass().getName(),
              "doValidation",
              "INVALID LIBRARY DATABASE MAPPING PATH FOUND, it should contain .core extension in path, PATH-DEFINED: "
                  + databaseMappingPath);
        }
      }
    }
  }
  public LibraryDescriptorParser(final String libraryName) {

    if (libraryName == null || libraryName.length() <= 0) {
      Log.loge(getClass().getName(), "Constructor", "Invalid Library Name Found.");
      throw new DeploymentException(
          getClass().getName(), "Constructor", "Invalid Library Name Found.");
    }

    this.libraryName = libraryName;

    Context context = resources.getApplicationContext();
    if (context == null) {
      Log.loge(getClass().getName(), "Constructor", "Invalid Application Context Found.");
      throw new DeploymentException(
          getClass().getName(), "Constructor", "Invalid Application Context Found.");
    }

    InputStream libraryDescriptorStream = null;
    libraryDescriptorStream =
        getClass()
            .getClassLoader()
            .getResourceAsStream(
                libraryName.replace(".", "/") + "/" + Constants.LIBRARY_DESCRIPTOR_FILE_NAME);

    if (libraryDescriptorStream == null) {
      Log.loge(
          getClass().getName(),
          "Constructor",
          "Invalid Library Descriptor Stream Found, LIBRARY-NAME: "
              + this.libraryName
              + ", PATH: "
              + libraryName.replace(".", "/")
              + "/"
              + Constants.LIBRARY_DESCRIPTOR_FILE_NAME);
      throw new DeploymentException(
          getClass().getName(),
          "Constructor",
          "Invalid Library Descriptor Stream Found, LIBRARY-NAME: "
              + this.libraryName
              + ", PATH: "
              + libraryName.replace(".", "/")
              + "/"
              + Constants.LIBRARY_DESCRIPTOR_FILE_NAME);
    }

    try {
      parseMessage(libraryDescriptorStream);
    } catch (Exception exception) {
      Log.loge(
          getClass().getName(),
          "Constructor",
          "Exception caught while parsing LIBRARY-DESCRIPTOR: "
              + this.libraryName
              + ", "
              + exception.getMessage());
      throw new DeploymentException(
          getClass().getName(),
          "Constructor",
          "Exception caught while parsing LIBRARY-DESCRIPTOR: "
              + this.libraryName
              + ", "
              + exception.getMessage());
    }

    doValidation();
  }