Пример #1
1
  @Test
  public void addMultipleFiles() throws Exception {

    Map<String, Map<String, Object>> parameters = new HashMap<String, Map<String, Object>>();
    parameters.put("input", new HashMap<String, Object>());
    parameters.get("input").put("content", multiFileCollectionInput);

    ArrayList<HashMap<String, byte[]>> files = new ArrayList<HashMap<String, byte[]>>();

    String[] binaryfiles = {
      "/home/bala/Pictures/zbcdefghijklm.jpg", "/home/bala/Pictures/bsnlbill.png"
    };

    for (String fileName : binaryfiles) {
      File uploadfile = new File(fileName);
      byte[] b = new byte[(int) uploadfile.length()];
      try {

        FileInputStream fileInputStream = new FileInputStream(uploadfile);
        b = IOUtils.toByteArray(fileInputStream);

      } catch (FileNotFoundException e) {
        throw e;
      } catch (IOException e1) {
        throw e1;
      }
      HashMap<String, byte[]> f = new HashMap<String, byte[]>();
      f.put(DMSUTILS.splitFileName(fileName), b);
      files.add(f);
    }
    parameters.get("input").put("files", files);
    parameters = dmsService.add(domainName, entity, parameters);

    HashMap<String, Object> expectedOutputContent;
    expectedOutputContent =
        (HashMap<String, Object>)
            FormatXml.getInstanceof(domainName)
                .in(parameters.get("output").get("content").toString());

    log.debug("addMultipleFiles: " + expectedOutputContent.toString());

    List<HashMap<String, String>> fileList = getFileList(expectedOutputContent);
    for (HashMap<String, String> file : fileList) {
      if (file.get("status") != null) {
        assertTrue(file.get("status").equals("true"));
      }
    }
    System.out.println(expectedOutputContent.toString());
  }
Пример #2
0
 @Override
 public Map<String, Map<String, Object>> findManage(
     final String domain,
     final String service,
     final String entity,
     final Map<String, Map<String, Object>> parameters) {
   log.debug("ENTITY:" + entity);
   PropertyManagement Management = PropertyManagement.getInstance();
   Map<String, String> propList = Management.getProperties(domain, service, entity);
   parameters.put("output", new HashMap<String, Object>());
   HashMap<String, Object> output = (HashMap<String, Object>) parameters.get("output");
   output.put("statusCode", "200");
   HashMap<String, Object> content = new HashMap<String, Object>();
   content.put("Collections", propList);
   output.put("content", FormatXml.getInstanceof(domain).out(content));
   log.debug("findManage parameters:" + parameters);
   return parameters;
 }
Пример #3
0
  @Override
  public Map<String, Map<String, Object>> deleteManage(
      final String domain,
      final String service,
      final String entity,
      final Map<String, Map<String, Object>> parameters) {
    log.debug("ENTITY:" + entity);
    PropertyManagement Management = PropertyManagement.getInstance();
    Integer result = Management.deleteProperties(domain, service, entity);
    parameters.put("output", new HashMap<String, Object>());
    HashMap<String, Object> output = (HashMap<String, Object>) parameters.get("output");
    output.put("statusCode", "200");
    HashMap<String, Object> content = new HashMap<String, Object>();
    HashMap<String, Object> out = new HashMap<String, Object>();

    out.put("Success", result + " rows deleted");
    content.put("Collections", out);
    output.put("content", FormatXml.getInstanceof(domain).out(content));
    log.debug("deleteManage parameters:" + parameters);
    return parameters;
  }
Пример #4
0
  @Test
  public void addSingleXMLFile() throws Exception {

    Map<String, Map<String, Object>> parameters = new HashMap<String, Map<String, Object>>();
    parameters.put("input", new HashMap<String, Object>());
    parameters.get("input").put("content", singleFileCollectionInput);

    parameters = dmsService.add(domainName, entity, parameters);

    HashMap<String, Object> expectedOutputContent;
    expectedOutputContent =
        (HashMap<String, Object>)
            FormatXml.getInstanceof(domainName)
                .in(parameters.get("output").get("content").toString());

    log.debug("addSingleFile: " + expectedOutputContent.toString());

    List<HashMap<String, String>> fileList = getFileList(expectedOutputContent);
    for (HashMap<String, String> file : fileList) {
      if (file.get("status") != null) {
        assertTrue(file.get("status").equals("true"));
      }
    }
  }
Пример #5
0
  private Map<String, String> getConfigXMLAsMap(
      final String domain, final Map<String, Map<String, Object>> parameters) {
    log.methodEntry("getConfigXMLAsMap entry");
    String content = (String) parameters.get("input").get("content");
    log.debug("input.content:" + content);
    if (content.trim().isEmpty()) {
      throw new GenericException(domain, "ERR-CONFIG-0002");
    }
    Map<String, Object> formatXml = FormatXml.getInstanceof(domain).in(content);
    Map<String, Object> collection = (HashMap<String, Object>) formatXml.get("Collections");
    if (collection == null) {
      throw new GenericException(domain, "ERR-CONFIG-0002");
    }
    log.debug("input.content.Collection:" + collection);
    Map<String, String> output = new HashMap<String, String>();
    List<String> KEY = new ArrayList<String>();
    List<String> VALUE = new ArrayList<String>();

    for (Entry<String, Object> entry : collection.entrySet()) {
      if (entry.getKey().equalsIgnoreCase("ConfigurationKeys")
          && entry.getValue() instanceof HashMap) {
        HashMap<String, Object> confighash = (HashMap<String, Object>) entry.getValue();
        for (String key : confighash.keySet()) {
          if (key.equalsIgnoreCase("ConfigurationKey")
              && confighash.get(key) instanceof ArrayList<?>) {

            ArrayList<HashMap<String, Object>> list =
                (ArrayList<HashMap<String, Object>>) confighash.get(key);
            Iterator it = list.iterator();
            for (; it.hasNext(); ) {
              HashMap<String, Object> hash = (HashMap<String, Object>) it.next();
              for (Entry<String, Object> key1 : hash.entrySet()) {
                if (key1.getKey().equalsIgnoreCase("key")) {
                  KEY.add((String) key1.getValue());
                } else if (key1.getKey().equalsIgnoreCase("value")) {
                  VALUE.add((String) key1.getValue());
                }
              }
            }
          } else if (key.equalsIgnoreCase("ConfigurationKey")
              && confighash.get(key) instanceof HashMap<?, ?>) {

            HashMap<String, Object> list = (HashMap<String, Object>) confighash.get(key);

            for (Entry<String, Object> key1 : list.entrySet()) {
              if (key1.getKey().equalsIgnoreCase("key")) {
                KEY.add((String) key1.getValue());
              } else if (key1.getKey().equalsIgnoreCase("value")) {
                VALUE.add((String) key1.getValue());
              }
            }
          }
        }
      }
    }
    for (int i = 0; i < KEY.size(); i++) {
      output.put(KEY.get(i), VALUE.get(i));
    }
    log.methodExit("getConfigXMLAsMap exit");
    return output;
  }