예제 #1
0
  private String addDocumentType(Map<String, String> parameters) throws Exception {
    DocumentType docType = new DocumentType();
    docType.setUid(Long.parseLong(parameters.get("uid")));
    docType.setName(parameters.get("name"));
    if (parameters.get("heritedfrom").isEmpty()) {
      docType.setDocumentTypeUid(-1);
    } else {
      docType.setDocumentTypeUid(Long.parseLong(parameters.get("heritedfrom")));
    }

    ArrayList<Map<String, String>> l =
        (ArrayList<Map<String, String>>)
            new JSONDeserializer().deserialize(parameters.get("jsonParameters"));
    List<Meta> metas = new ArrayList<Meta>();
    for (Map metaDatas : l) {
      Meta meta = new Meta();
      meta.setUid(-1);
      meta.setName(String.valueOf(metaDatas.get("name")));
      meta.setMetaType((Integer) metaDatas.get("metaType"));
      if (String.valueOf(metaDatas.get("metaFeedUid")).isEmpty()) {
        meta.setMetaFeedUid(-1L);
      } else {
        meta.setMetaFeedUid(((Integer) metaDatas.get("metaFeedUid")).longValue());
      }
      meta.setDocumentTypeUid(docType.getUid());
      metas.add(meta);
    }
    String xmlStream = XMLGenerators.getDocumentTypeXMLDescriptor(docType, metas);
    studioController.addDocumentType(sessionUid, xmlStream);
    return "";
  }
예제 #2
0
 /** @deprecated */
 private String removeWorkflowStatusManager(Map<String, String> parameters) throws Exception {
   long workflowStatusUid = Long.parseLong(parameters.get("workflowStatusUid"));
   String securityEntityName = parameters.get("securityEntityName");
   String securityEntitySource = parameters.get("securityEntitySource");
   int securityEntityType = Integer.parseInt(parameters.get("securityEntityType"));
   studioController.deleteWorkflowStatusManager(
       sessionUid,
       workflowStatusUid,
       securityEntityName,
       securityEntitySource,
       securityEntityType);
   return "";
 }
예제 #3
0
 private String searchMetaFeedValues(Map<String, String> parameters) throws Exception {
   String[] st =
       studioController.searchMetaFeedValues(
           sessionUid, Long.parseLong(parameters.get("uid")), parameters.get("criteria"));
   String jsonResp = "[";
   for (int u = 0; u < st.length; u++) {
     jsonResp += "{\"value\":\"" + st[u] + "\"}";
     if (u < st.length - 1) {
       jsonResp += ",";
     }
   }
   jsonResp += "]";
   return jsonResp;
 }
예제 #4
0
  private String updateEnumerationValues(Map<String, String> parameters) throws Exception {
    long enumerationUid = Long.parseLong(parameters.get("uid"));
    ArrayList<HashMap<String, String>> l =
        (ArrayList<HashMap<String, String>>)
            new JSONDeserializer().deserialize(parameters.get("json"));
    Vector<String> values = new Vector<String>();

    for (HashMap<String, String> map : l) {
      for (String key : map.keySet()) {
        values.add(map.get(key));
      }
    }
    String stream = XMLGenerators.getEnumerationValuesXMLDescriptor(enumerationUid, values);
    studioController.updateEnumerationValues(sessionUid, stream);
    return "";
  }
예제 #5
0
  private String statusList(Map<String, String> parameters) throws Exception {
    WorkflowStatus[] list =
        studioController.getWorkflowStatuses(sessionUid, Long.parseLong(parameters.get("uid")));
    WorkflowStatusDefinition[] results = new WorkflowStatusDefinition[list.length];
    int ind = 0;
    for (WorkflowStatus it : list) {
      WorkflowStatusDefinition n = new WorkflowStatusDefinition();
      n.setPosition(ind);
      n.setWorkflowStatus(it);
      WorkflowStatusManager[] mn =
          studioController.getWorkflowStatusManagers(sessionUid, it.getUid());
      n.setWorkflowStatusManagers(mn);
      results[ind] = n;
      ind++;
    }
    XStream xml = new XStream(new DomDriver());
    XStream xstream =
        new XStream(
            new JettisonMappedXmlDriver() {

              public HierarchicalStreamWriter createWriter(Writer writer) {
                return new JsonWriter(writer, "".toCharArray(), "", JsonWriter.DROP_ROOT_MODE);
              }
            });
    xstream.aliasField(
        "securityEntityName", WorkflowStatusManager.class, "localSecurityEntityName");
    xstream.aliasField(
        "securityEntitySource", WorkflowStatusManager.class, "localSecurityEntitySource");
    xstream.aliasField(
        "securityEntityType", WorkflowStatusManager.class, "localSecurityEntityType");
    xstream.aliasField("workflowStatusUid", WorkflowStatusManager.class, "localWorkflowStatusUid");
    xstream.setMode(XStream.NO_REFERENCES);
    String jsonResp = xstream.toXML(results);
    return jsonResp;
  }
예제 #6
0
 private String getUnheritedMetas(Map<String, String> parameters) throws Exception {
   Meta[] list =
       documentVersionController.getUnheritedMetas(
           sessionUid, Long.parseLong(parameters.get("documentTypeUid")));
   String jsonResp = new JSONSerializer().exclude("class").serialize(list);
   return jsonResp;
 }
예제 #7
0
  /** @deprecated */
  private String createWorkflowStatus(Map<String, String> parameters) throws Exception {
    long workflowUid = Long.parseLong(parameters.get("workflowUid"));
    String workflowName = parameters.get("workflowName");
    String workflowDescription = parameters.get("workflowDescription");
    String statusName = parameters.get("statusName");

    //        Vector<WorkflowStatusDefinition> workflowStatus = new
    // Vector<WorkflowStatusDefinition>();
    //        XMLGenerators.getWorkflowXMLDescriptor(workflowUid, workflowStatus);

    String xmlStream = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
    xmlStream += "<workflow uid=\"" + workflowUid + "\">\n";
    for (WorkflowStatus ws : studioController.getWorkflowStatuses(sessionUid, workflowUid)) {
      xmlStream +=
          "<status uid=\"" + ws.getUid() + "\" successor-uid=\"" + ws.getSuccessorUid() + "\">";
      xmlStream += "<name>" + ws.getName() + "</name>\n";
      for (WorkflowStatusManager wsm :
          studioController.getWorkflowStatusManagers(sessionUid, ws.getUid())) {
        xmlStream +=
            "<manager type=\""
                + 1
                + "\" uid=\""
                + wsm.getSecurityEntityName()
                + "\" source=\""
                + wsm.getSecurityEntitySource()
                + "\" />";
      }
      xmlStream += "</status>\n";
    }
    xmlStream += "<status uid=\"-1\" successor-uid=\"-1\">";
    xmlStream += "<name>" + statusName + "</name>";
    xmlStream += "</status>\n";
    xmlStream += "</workflow>\n";

    studioController.updateWorkflow(
        sessionUid, workflowUid, workflowName, workflowDescription, xmlStream);
    return "";
  }
예제 #8
0
  private String createWorflow(Map<String, String> parameters) throws Exception {
    ArrayList<Map<String, String>> statusList =
        (ArrayList<Map<String, String>>)
            new JSONDeserializer().deserialize(parameters.get("jsonParameters"));
    Vector<WorkflowStatusDefinition> statusDefinitionList = new Vector<WorkflowStatusDefinition>();

    for (Map statusMap : statusList) {
      //            long statusUid = statusMap.get("uid") != null ?
      // Long.parseLong(String.valueOf(statusMap.get("uid"))) : -1;
      long successorUid =
          statusMap.get("successorUid") != null
              ? Long.parseLong(String.valueOf(statusMap.get("successorUid")))
              : -1;

      // WorkflowStatus

      WorkflowStatus status = new WorkflowStatus();
      //            status.setUid(statusUid);
      status.setName(String.valueOf(statusMap.get("name")));
      status.setSuccessorUid(successorUid);

      // WorkflowStatusManagers

      ArrayList<Map<String, String>> managersList =
          (ArrayList<Map<String, String>>) statusMap.get("managers");
      WorkflowStatusManager[] wsmTab = new WorkflowStatusManager[managersList.size()];
      for (int i = 0; i < managersList.size(); ++i) {
        Map managersMap = managersList.get(i);
        WorkflowStatusManager wsm = new WorkflowStatusManager();
        wsm.setSecurityEntityName(String.valueOf(managersMap.get("uid")));
        wsm.setSecurityEntitySource(String.valueOf(managersMap.get("source")));
        wsm.setSecurityEntityType(Integer.parseInt(String.valueOf(managersMap.get("type"))));
        wsmTab[i] = wsm;
      }

      WorkflowStatusDefinition statusDefinition = new WorkflowStatusDefinition();
      statusDefinition.setWorkflowStatus(status);
      statusDefinition.setWorkflowStatusManagers(wsmTab);

      statusDefinitionList.add(statusDefinition);
    }

    studioController.createWorkflow(
        sessionUid,
        parameters.get("name"),
        parameters.get("description"),
        XMLGenerators.getWorkflowXMLDescriptor(-1, statusDefinitionList));
    return "";
  }
예제 #9
0
 private String removeMetaFeed(Map<String, String> parameters) throws Exception {
   studioController.removeMetaFeed(sessionUid, Long.parseLong(parameters.get("uid")));
   return "";
 }
예제 #10
0
 private String addMetaFeed(Map<String, String> parameters) throws Exception {
   studioController.addMetaFeed(sessionUid, parameters.get("name"), parameters.get("className"));
   return "";
 }
예제 #11
0
 private String deleteDocumentType(Map<String, String> parameters) throws Exception {
   studioController.deleteDocumentType(sessionUid, Long.parseLong(parameters.get("uid")));
   return "";
 }