Exemplo n.º 1
0
  private void manageAttachments(KpeopleAction action, DataHandler stream) throws IOException {

    InputStream is = null;
    String hashcode = null;
    try {
      is = stream.getInputStream();
      hashcode = Hashcode.getHashcode(is, Hashcode.SHA512);
    } catch (IOException e) {
      e.printStackTrace();
      throw e;
    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
    }

    String path = (String) currentProperties.get(KpeopleLabel.getEventXMLPath());
    try {
      path = ActionDataProcessorUtil.checkEventXMLPath(path);
    } catch (Exception e1) {
      e1.printStackTrace();
    }

    FileOutputStream outputStream = null;
    File tmpFilePath = null;
    try {
      path = path + action.getIdAction() + "-" + fileName;
      tmpFilePath = new File(path);
      outputStream = new FileOutputStream(tmpFilePath);
      stream.writeTo(outputStream);

      outputStream.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    // ActionDataProcessorUtil.deleteEventFile(tmpFilePath);

    String idAttachmentId = Long.toString(action.getIdAction()) + "-" + hashcode.substring(0, 6);

    KpeopleAttachment attachment = new KpeopleAttachment();
    attachment.setAttachmentName(fileName);
    attachment.setAttachmentHashcode(hashcode);
    attachment.setAttachmentData(path);
    attachment.setIdAttachment(idAttachmentId);
    attachment.setAttachmentType(eventResult.getContentType());

    eventResult.addAttachment(attachment);
  }
Exemplo n.º 2
0
  private void manageActionInfo(KpeopleAction action) {
    String idEvent = action.getSystemId() + action.getIdAction().toString() + action.getTimestamp();

    String actionType = action.getActionType();

    String systemType = null;
    try {
      systemType = ActionDataProcessorUtil.getSystemType(action.getSystemId());
    } catch (Exception e) {
      e.printStackTrace();
    }

    String systemId = action.getSystemId();

    String actionReference = action.getActionReference();

    long idAction = action.getIdAction();

    eventResult =
        new SharepointDocumentEvent(
            idEvent, actionType, systemType, idAction, systemId, actionReference);
  }
Exemplo n.º 3
0
  private void manageEventInfo(GetItemResponse response, String operation) {
    FieldInformationCollection fields = response.getFields();

    FieldInformation[] fieldsInformation = fields.getFieldInformation();

    String createdBy = null;
    String modifiedBy = null;
    String created = null;

    String modified = null;
    String contentType = null;
    String eventCreationDate = null;
    String eventAuthor = null;
    HashMap<String, String> hm = new HashMap<String, String>();

    for (int i = 0; i < fieldsInformation.length; i++) {
      FieldInformation field = fieldsInformation[i];
      String name = field.getInternalName();
      if (name.equalsIgnoreCase("BaseName")) {
        fileName = field.getValue();
        eventResult.setTitle(fileName);
      }
      if (name.equalsIgnoreCase("Created_x0020_By")) {
        createdBy = field.getValue();
      }
      if (name.equalsIgnoreCase("Modified_x0020_By")) {
        modifiedBy = field.getValue();
      }
      if (name.equalsIgnoreCase("Created_x0020_Date")) {
        created = field.getValue();
      }
      if (name.equalsIgnoreCase("Last_x0020_Modified")) {
        modified = field.getValue();
      }
      if (name.equalsIgnoreCase("File_x0020_Type")) {
        contentType = field.getValue();
      }
      if (name.equalsIgnoreCase("Process")) {
        String processValue[] = field.getValue().split("-");
        hm.put("kpeopletag", processValue[0]);
      }
    }

    if (operation.equalsIgnoreCase("modified")) {
      eventCreationDate = modified;
      eventAuthor = modifiedBy;
    }
    if (operation.equalsIgnoreCase("created")) {
      eventCreationDate = created;
      eventAuthor = createdBy;
    }

    eventResult.setContentType(contentType);

    eventResult.setCreationDate(ActionDataProcessorUtil.getDateString(eventCreationDate));
    Author author = new Author();
    author.setUsername(eventAuthor);
    eventResult.setAuthor(author);
    eventResult.setProperties(hm);
    // eventResult.setAuthor(eventAuthor);

  }