private void loaduserInterfaces() {
    DOMUtil util = null;
    File userInterfacesFile = null;
    File dir = null;
    Document interfacesDoc = null;
    LinkedList children = null;
    TreeItem item = null;

    util = new DOMUtil();

    dir = new File(System.getProperty("user.home"), FILE_TOOLBOXUSER_CONFIGURATIONS_DIRECTORY);
    userInterfacesFile = new File(dir, PATH_INTERFACES_DEFINITION_XML);
    try {
      interfacesDoc = util.readerToDocument(new FileReader(userInterfacesFile));

      children = DOMUtil.getChildrenByTagName(interfacesDoc.getDocumentElement(), "interface");

      for (int i = 0; i < children.size(); i++) {
        final String itemtext = this.createItemName((Element) children.get(i));

        item = new TreeItem(this.interfaceTree, SWT.NULL);

        item.setText(itemtext);
      }

    } catch (final Exception e) {

    }
  }
  public void generateEngineOutputManager(
      File servicePath, Document describeDocument, String processingName) throws Exception {
    File stylesheet = new File(servicePath, SHELL_OUTPUT_MANAGER_XLST_PATH);
    Document xslDocument;
    File shellScriptFolder = new File(servicePath, SHELL_SCRIPT_PATH);
    shellScriptFolder.mkdirs();

    if (stylesheet.exists()) {
      xslDocument = domUtil.fileToDocument(stylesheet);
      transformer =
          TransformerFactory.newInstance()
              .newTemplates(new DOMSource(xslDocument))
              .newTransformer();
      transformer.setParameter("processingName", processingName);
      transformer.setParameter(
          "complexDataFolderPath", new File(servicePath, COMPLEX_DATA_PATH).getAbsolutePath());
      transformer.transform(
          new StreamSource(DOMUtil.getDocumentAsInputStream(describeDocument)),
          new StreamResult(
              new FileOutputStream(
                  new File(
                      shellScriptFolder,
                      SHELL_SCRIPT_FILE_PREFIX + processingName + "_outputManager.tmp"))));
    }
  }
  private Document extractMetadataFromItem(String itemId, StoreItem storeItem, File webappDir)
      throws Exception {
    Document extractedDoc = null;

    Properties props;
    props = new Properties();
    props.load(
        new FileInputStream(
            new File(webappDir, "WEB-INF/classes/metadataExtractionProcessings.properties")));

    // trying shell script
    String command = props.getProperty("shell." + storeItem.type);
    if (command != null && command.equals("") == false) {
      File commandFile;
      commandFile = new File(webappDir, "WEB-INF/metadataExtractors/" + command);
      commandFile.setExecutable(true, false);

      Properties prefs = Prefs.load(webappDir);

      File dataFile;
      dataFile = new File(prefs.getProperty("download.dir"), itemId);

      File outFile;
      outFile = new File(prefs.getProperty("download.dir"), itemId + "_metadata.xml");

      ProcessBuilder pb;
      Process p;

      pb =
          new ProcessBuilder("./" + command, dataFile.getAbsolutePath(), outFile.getAbsolutePath());
      pb.directory(commandFile.getParentFile());
      p = pb.start();
      p.waitFor();

      DOMUtil util;
      util = new DOMUtil();

      extractedDoc = util.fileToDocument(outFile);
    }

    return extractedDoc;
  }
 public TBXScript[] getExecuteScriptDescriptorSync(File servicePath, String operationName)
     throws IOException, SAXException {
   TBXScript[] scripts = new TBXScript[2];
   scripts[0] = new TBXScript();
   scripts[0].setScriptDoc(
       domUtil.inputStreamToDocument(
           new FileInputStream(
               new File(
                   servicePath,
                   EXECUTE_TOOLBOX_SCRIPT_FOLDER_PATH + EXECUTE_SHELL_ENGINE_SCRIPT_FILE_NAME))));
   scripts[0].setPath(PATH_OPERATION + "/" + operationName + "/" + FIRST_SCRIPT_FILE_NAME);
   scripts[0].setType(Script.SCRIPT_TYPE_FIRST_SCRIPT);
   scripts[1] = new TBXScript();
   scripts[1].setScriptDoc(
       domUtil.inputStreamToDocument(
           new FileInputStream(
               new File(
                   servicePath,
                   EXECUTE_TOOLBOX_SCRIPT_FOLDER_PATH + EXECUTE_SHELL_ERROR_SCRIPT_FILE_NAME))));
   scripts[1].setPath(PATH_OPERATION + "/" + operationName + "/" + GLOBAL_ERROR_SCRIPT_FILE_NAME);
   scripts[1].setType(Script.SCRIPT_TYPE_GLOBAL_ERROR);
   return scripts;
 }
 public String generateEngineTemplate(
     File newServicePath, Document describeDocument, String processingName) throws Exception {
   Document xslDocument;
   String shellTemplate = null;
   File stylesheet = new File(newServicePath, SHELL_TEMPLATE_XSLT_PATH);
   File shellScriptFolder = new File(newServicePath, SHELL_SCRIPT_PATH);
   shellScriptFolder.mkdirs();
   if (stylesheet.exists()) {
     xslDocument = domUtil.fileToDocument(stylesheet);
     transformer = TransformerFactory.newInstance().newTransformer(new DOMSource(xslDocument));
     transformer.transform(
         new StreamSource(DOMUtil.getDocumentAsInputStream(describeDocument)),
         new StreamResult(
             new FileOutputStream(
                 new File(
                     shellScriptFolder,
                     SHELL_SCRIPT_FILE_PREFIX + processingName + "_template.sh"))));
     shellTemplate =
         IOUtil.loadString(
             new File(
                 shellScriptFolder, SHELL_SCRIPT_FILE_PREFIX + processingName + "_template.sh"));
   }
   return shellTemplate;
 }
 public TBXScript[] getExecuteScriptDescriptorAsync(File servicePath, String operationName)
     throws IOException, SAXException {
   TBXScript[] scripts = new TBXScript[6];
   scripts[0] = new TBXScript();
   scripts[0].setScriptDoc(
       domUtil.inputStreamToDocument(
           new FileInputStream(
               new File(
                   servicePath,
                   EXECUTE_ASYNC_SHELL_ENGINE_SCRIPT_FOLDER_PATH + FIRST_SCRIPT_FILE_NAME))));
   scripts[0].setPath(PATH_OPERATION + "/" + operationName + "/" + FIRST_SCRIPT_FILE_NAME);
   scripts[0].setType(Script.SCRIPT_TYPE_FIRST_SCRIPT);
   scripts[1] = new TBXScript();
   scripts[1].setScriptDoc(
       domUtil.inputStreamToDocument(
           new FileInputStream(
               new File(
                   servicePath,
                   EXECUTE_ASYNC_SHELL_ENGINE_SCRIPT_FOLDER_PATH + SECOND_SCRIPT_FILE_NAME))));
   scripts[1].setPath(PATH_OPERATION + "/" + operationName + "/" + SECOND_SCRIPT_FILE_NAME);
   scripts[1].setType(Script.SCRIPT_TYPE_SECOND_SCRIPT);
   scripts[2] = new TBXScript();
   scripts[2].setScriptDoc(
       domUtil.inputStreamToDocument(
           new FileInputStream(
               new File(
                   servicePath,
                   EXECUTE_ASYNC_SHELL_ENGINE_SCRIPT_FOLDER_PATH + THIRD_SCRIPT_FILE_NAME))));
   scripts[2].setPath(PATH_OPERATION + "/" + operationName + "/" + THIRD_SCRIPT_FILE_NAME);
   scripts[2].setType(Script.SCRIPT_TYPE_THIRD_SCRIPT);
   scripts[3] = new TBXScript();
   scripts[3].setScriptDoc(
       domUtil.inputStreamToDocument(
           new FileInputStream(
               new File(
                   servicePath,
                   EXECUTE_ASYNC_SHELL_ENGINE_SCRIPT_FOLDER_PATH
                       + RESPONSE_BUILDER_SCRIPT_FILE_NAME))));
   scripts[3].setPath(
       PATH_OPERATION + "/" + operationName + "/" + RESPONSE_BUILDER_SCRIPT_FILE_NAME);
   scripts[3].setType(Script.SCRIPT_TYPE_RESPONSE_BUILDER);
   scripts[4] = new TBXScript();
   scripts[4].setScriptDoc(
       domUtil.inputStreamToDocument(
           new FileInputStream(
               new File(
                   servicePath,
                   EXECUTE_ASYNC_SHELL_ENGINE_SCRIPT_FOLDER_PATH
                       + RESPONSE_BUILDER_ERROR_SCRIPT_FILE_NAME))));
   scripts[4].setPath(
       PATH_OPERATION + "/" + operationName + "/" + RESPONSE_BUILDER_ERROR_SCRIPT_FILE_NAME);
   scripts[4].setType(Script.SCRIPT_TYPE_ERROR_ON_RESP_BUILDER);
   scripts[5] = new TBXScript();
   scripts[5].setScriptDoc(
       domUtil.inputStreamToDocument(
           new FileInputStream(
               new File(
                   servicePath,
                   EXECUTE_ASYNC_SHELL_ENGINE_SCRIPT_FOLDER_PATH
                       + GLOBAL_ERROR_SCRIPT_FILE_NAME))));
   scripts[5].setPath(PATH_OPERATION + "/" + operationName + "/" + GLOBAL_ERROR_SCRIPT_FILE_NAME);
   scripts[5].setType(Script.SCRIPT_TYPE_GLOBAL_ERROR);
   return scripts;
 }
  @Override
  public Object executeTag(org.w3c.dom.Element itoa) throws Exception {
    String result = String.valueOf(getInt(DOMUtil.getFirstChild(itoa)));

    return result;
  }
  @Override
  public Object executeTag(org.w3c.dom.Element connEl) throws Exception {
    CswClient client;
    Object opType = null;
    try {
      String operationType =
          this.engine.evaluateString(
              connEl.getAttribute("type"), IEngine.EngineStringType.ATTRIBUTE);

      LinkedList<Element> children = DOMUtil.getChildren(connEl);
      client = (CswClient) this.executeChildTag(children.get(0));

      Document xmlSnippet;
      xmlSnippet = (Document) this.executeChildTag(children.get(1));

      TransactionType t = new TransactionType();

      if (operationType.equals("DELETE")) {
        DeleteType delete = new DeleteType();
        delete.setTypeName(evaluateAttribute(connEl, "typeName"));

        QueryConstraintType con = new QueryConstraintType();
        con.setVersion("");
        delete.setConstraint(con);

        JAXBElement<FilterType> filter =
            (JAXBElement<FilterType>)
                JAXBUtil.getInstance().unmarshall(DOMUtil.getDocumentAsInputStream(xmlSnippet));
        con.setFilter(filter.getValue());

        opType = delete;
      } else if (operationType.equals("INSERT")) {
        InsertType insert = new InsertType();
        insert
            .getAny()
            .add(JAXBUtil.getInstance().unmarshall(DOMUtil.getDocumentAsInputStream(xmlSnippet)));
        opType = insert;
      } /*else
        {
            UpdateType update=new UpdateType();
            update.getAny().add(JAXBUtil.getInstance().unmarshall(DOMUtil.getDocumentAsInputStream(xmlSnippet)));
            opType=update;
        }*/

      t.getInsertOrUpdateOrDelete().add(opType);
      TransactionResponseType response = client.transact(t);

      File tempFile = IOUtil.getTemporaryFile();

      JAXBUtil.getInstance()
          .marshall(
              OFactory.csw.createTransactionResponse(response), new FileOutputStream(tempFile));

      DOMUtil util;
      util = new DOMUtil();
      Document xmlDoc = util.fileToDocument(tempFile);
      tempFile.delete();

      return xmlDoc;
    } catch (Exception e) {
      e.printStackTrace();
      throw e;
    }

    // JAXBUtil.getInstance().marshall(response, new
    // FileOutputStream("/home/massi/TEMP/GetRecordsResponse.xml"));

  }