Package org.davinci.server.review

Examples of org.davinci.server.review.Comment


    synchronized(project){
      Hashtable<String, Comment> reviewHash = reviewFilePool.get(project);
      if (null == reviewHash)
        return true;

      Comment lastAccessTime = new Comment();
      lastAccessTime.setCreated(new Date(System.currentTimeMillis()));
      reviewHash.put(LAST_ACCESS_TIME, lastAccessTime);
    }
    return true;
  }
View Full Code Here


      doc = new CommentsDocument(project);
      project.setCommentsDocument(doc);
    }

//    reviewHash = (Hashtable<String, Comment>) Utils.deepClone(reviewHash);
    Comment lastAccessTime = reviewHash.get(LAST_ACCESS_TIME);
    reviewHash.remove(LAST_ACCESS_TIME);
    // clearUnconsistentComments(reviewHash);
    doc.setCommentList(new ArrayList<Comment>(reviewHash.values()));

    Marshaller marshaller = new Marshaller(project);
View Full Code Here

  public boolean clearReviewByProject(IDavinciProject project) {
    Hashtable<String, Comment> reviewHash = reviewFilePool.get(project);
    if (null == reviewHash)
      return true;
    synchronized(project){
      Comment lastAccessTime = reviewHash.get(LAST_ACCESS_TIME);
      lastAccessTime.setCreated(new Date(0));
      reviewHash.clear();
      reviewHash.put(LAST_ACCESS_TIME, lastAccessTime);
    }
    return true;
  }
View Full Code Here

    Hashtable<String, Comment> reviewHash = reviewFilePool.get(project);
    if (null == reviewHash)
      return true;

    Comment lastAccessTime = reviewHash.get(LAST_ACCESS_TIME);
    if (System.currentTimeMillis() - lastAccessTime.getCreated().getTime() > DESTROY_TIME || forced) {
      synchronized(project){
        persistReviewFile(project);
        reviewHash.clear();
        /*
         * This is usually called by an iterator so modifying the underlying
View Full Code Here

      Hashtable<String, Comment> reviewHash = loadReviewFile(project);
      if (null == reviewHash)
        return false;

      Set<Entry<String, Comment>> entries = reviewHash.entrySet();
      Comment newOne, oldOne;
      String str;
      String[] parts;
      Map<String, Comment> tmpReview = new HashMap<String, Comment>();
      for (Entry<String, Comment> entry : entries) {
        if (LAST_ACCESS_TIME.equals(entry.getKey()))
          continue;

        oldOne = entry.getValue();
        if (parentVersion.equals(oldOne.getPageVersion())) {
          newOne = (Comment) Utils.deepClone(oldOne);

          // Re-calculate the comment id
          str = newOne.getId();
          String drawingJson = newOne.getDrawingJson();
          if (str.contains("_")) {
            parts = str.split("_");
            str = parts[0] + '_' + (Integer.parseInt(parts[1]) + 1);
          } else {
            str += ("_" + 1);
          }
          drawingJson = drawingJson.replace(newOne.getId(), str);
          newOne.setDrawingJson(drawingJson);
          newOne.setId(str);


          // Re-calculate the comment replyTo id
          str = newOne.getReplyTo();
          if (!"0".equals(str)) {
            if (str.contains("_")) {
              parts = str.split("_");
              str = parts[0] + '_' + (Integer.parseInt(parts[1]) + 1);
            } else {
              str += ("_" + 1);
            }
          }
          newOne.setReplyTo(str);

          // Re-calculate the comment page name
          str = newOne.getPageName();
          if (null != str) {
            parts = str.split("/");
            newOne.setPageName(parts[0] + '/' + parts[1] + '/' + version.getTime() + '/'
                + parts[3] + '/' + parts[4]);
          }
          tmpReview.put(newOne.getId(), newOne);
        }
      }
      reviewHash.putAll(tmpReview);
    }
    return true;
View Full Code Here

      IStorage file = project.getCommentsFileStorage();

      Document document = initCommentsFile(file);
      Node node = document.getFirstChild();
      NodeList children = node.getChildNodes();
      Comment comm;
      for (int i = 0; i < children.getLength(); i++) {
        node = children.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE
            && CommentsDocument.COMMENT.equalsIgnoreCase(node
                .getNodeName())) {
          comm = unmarshallComment(node);
          if (null != comm) {
            comm.setProject(project);
            commentsDoc.getCommentList().add(comm);
          }
        }
      }
    } catch (SAXException e) {
View Full Code Here

      return null;

    SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATE_PATTERN);
    sdf.setCalendar(Calendar.getInstance(new SimpleTimeZone(0, "GMT")));

    Comment comment = new Comment();
    Node node;

    NodeList children = commentNode.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
      node = children.item(i);
      if (node.getNodeType() == Node.ELEMENT_NODE) {
        if (Comment.PAGE_STATE.equalsIgnoreCase(node.getNodeName()))
          comment.setPageState(getValue(node));
        else if (Comment.PAGE_STATE_LIST.equalsIgnoreCase(node.getNodeName()))
          comment.setPageStateList(getValue(node));
        else if (Comment.VIEW_SCENE.equalsIgnoreCase(node.getNodeName()))
          comment.setViewScene(getValue(node));
        else if (Comment.VIEW_SCENE_LIST.equalsIgnoreCase(node.getNodeName()))
          comment.setViewSceneList(getValue(node));
        else if (Comment.PAGE_NAME.equalsIgnoreCase(node.getNodeName()))
          comment.setPageName(getValue(node));
        else if (Comment.SUBJECT.equalsIgnoreCase(node.getNodeName()))
          comment.setSubject(getValue(node));
        else if (Comment.CONTENT.equalsIgnoreCase(node.getNodeName()))
          comment.setContent(getValue(node));
        else if (Comment.DRAWING_JSON.equalsIgnoreCase(node
            .getNodeName())) {
          comment.setDrawingJson(getValue(node));
        } else if (Comment.CREATED.equalsIgnoreCase(node.getNodeName()))
          comment.setCreated(sdf.parse(getValue(node)));
        else if (Comment.ID.equalsIgnoreCase(node.getNodeName()))
          comment.setId(getValue(node));
        else if (Comment.OWNER_ID.equalsIgnoreCase(node.getNodeName()))
          comment.setOwnerId(getValue(node));
        else if (Comment.DESIGNER_ID.equalsIgnoreCase(node.getNodeName()))
          comment.setDesignerId(getValue(node));
//        else if (Comment.DEPTH.equalsIgnoreCase(node.getNodeName()))
//          comment.setDepth(Short.parseShort(getValue(node)));
//        else if (Comment.ORDER.equalsIgnoreCase(node.getNodeName()))
//          comment.setOrder(Float.parseFloat(getValue(node)));
        else if (Comment.REPLY_TO.equalsIgnoreCase(node.getNodeName()))
          comment.setReplyTo(getValue(node));
        else if (Comment.EMAIL.equalsIgnoreCase(node.getNodeName()))
          comment.setEmail(getValue(node));
        else if (Comment.REOPEN_VERSION.equalsIgnoreCase(node
            .getNodeName()))
          comment.setReopenVersion(getValue(node));
      }
    }
    return comment;
  }
View Full Code Here

  static final private Logger theLogger = Logger.getLogger(AddComment.class.getName());

  @Override
  public void handleCommand(HttpServletRequest req, HttpServletResponse resp, IUser user)
      throws IOException {
    Comment comment = extractComment(req);
   
    IUserManager userManager = ServerManager.getServerManager().getUserManager();
    String designerName = comment.getDesignerId();
    IUser designer = null;
    try {
      if(ServerManager.LOCAL_INSTALL && IDavinciServerConstants.LOCAL_INSTALL_USER.equalsIgnoreCase(designerName)) {
        designer = userManager.getUser(IDavinciServerConstants.LOCAL_INSTALL_USER);
      } else {
        designer = userManager.getUser(designerName);
      }
    } catch (UserException e) {
      errorString = "Failure getting user for 'designer'. Reason: " + e.getMessage();
      theLogger.severe((String) errorString);
      return;
    }
   
    //Set up project based on designer
    DavinciProject project = new DavinciProject();
    project.setOwnerId(designer.getUserID());
    comment.setProject(project);

    comment.setEmail(user.getPerson().getEmail());

    IDesignerUser du = ReviewManager.getReviewManager()
        .getDesignerUser(designerName);
    Version version = du.getVersion(comment.getPageVersion());

    if (version != null && version.isClosed()){
      errorString = "The version was closed by another user while editing. Please reload the review data.";
      return;
    }
    List<Comment> commentList = new ArrayList<Comment>(1);
    commentList.add(comment);
    ReviewCacheManager.$.updateComments(commentList);

    String emailResult = null;
    if (version != null && version.isReceiveEmail()) { // Send the notification only the designer want receive it.
      Boolean zazl = req.getParameter("zazl") != null;
      emailResult = notifyRelatedPersons(user, designer, comment, req, zazl);
    }

    SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATE_PATTERN);
    sdf.setCalendar(Calendar.getInstance(new SimpleTimeZone(0, "GMT")));
    try {
      JSONObject json = new JSONObject()
          .put("id", comment.getId())
          .put("created", sdf.format(comment.getCreated()))
//            .put("order", comment.getOrder())
          .put("email", user.getPerson().getEmail())
          .put("reviewer", user.getUserID());
      if (emailResult != null) {
        json.put("emailResult", emailResult);
View Full Code Here

   
    return Utils.substitute(Utils.getTemplates().getProperty(Constants.TEMPLATE_COMMENT), props);
  }

  protected Comment extractComment(HttpServletRequest req) {
    Comment comment = new Comment();
    String paramValue;

    paramValue = req.getParameter(Comment.ID);
    comment.setId(paramValue);

    paramValue = req.getParameter(Comment.CONTENT);
    comment.setContent(paramValue);

//    paramValue = req.getParameter(Comment.DEPTH);
//    comment.setDepth(Short.parseShort(paramValue));

    paramValue = req.getParameter(Comment.OWNER_ID);
    comment.setOwnerId(paramValue);

    paramValue = req.getParameter(Comment.DESIGNER_ID);
    comment.setDesignerId(paramValue);
   
    paramValue = req.getParameter(Comment.PAGE_NAME);
    comment.setPageName(paramValue);

    paramValue = req.getParameter(Comment.PAGE_STATE);
    comment.setPageState(paramValue);

    paramValue = req.getParameter(Comment.PAGE_STATE_LIST);
    comment.setPageStateList(paramValue);

    paramValue = req.getParameter(Comment.VIEW_SCENE);
    comment.setViewScene(paramValue);

    paramValue = req.getParameter(Comment.VIEW_SCENE_LIST);
    comment.setViewSceneList(paramValue);

    paramValue = req.getParameter(Comment.SUBJECT);
    comment.setSubject(paramValue);

//    paramValue = req.getParameter(Comment.PREVIOUS_ORDER);
//    comment.setOrder(Float.parseFloat(paramValue));
//
//    paramValue = req.getParameter(Comment.NEXT_ORDER);
//    comment.setOrder((comment.getOrder() + Float.parseFloat(paramValue)) / 2);

    paramValue = req.getParameter(Comment.REPLY_TO);
    comment.setReplyTo(paramValue);

    paramValue = req.getParameter(Comment.REOPEN_VERSION);
    comment.setReopenVersion(paramValue);

    paramValue = req.getParameter(Comment.DRAWING_JSON);
    comment.setDrawingJson(paramValue);

    comment.setCreated(new Date());

    return comment;
  }
View Full Code Here

public class UpdateComment extends Command {
  @Override
  public void handleCommand(HttpServletRequest req, HttpServletResponse resp, IUser user)
      throws IOException {

    Comment comment = extractComment(req);
   
    String designerName = comment.getDesignerId();
    IDesignerUser du = ReviewManager.getReviewManager().getDesignerUser(designerName);
    DavinciProject project = new DavinciProject();
    project.setOwnerId(du.getName());
   
    comment.setProject(project);
    Comment existingComm = ReviewCacheManager.$.getComment(project, comment.getId());
    Version version = du.getVersion(existingComm.getPageVersion());
    try {
      if (version != null && version.isClosed()){
        throw new Exception("The version is closed by others during your editting. Please reload the review data.");
      }
View Full Code Here

TOP

Related Classes of org.davinci.server.review.Comment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.