Package org.corrib.s3b.sscf.manage.sioc

Examples of org.corrib.s3b.sscf.manage.sioc.PostedResource


   * @param resourceUri
   * @return
   */
  public static List<SiocPostBean> getRootPosts(String resourceUri) {
    XfoafSscfResource resource = XfoafSscfResource.getXfoafSscfResource(resourceUri);
    PostedResource postedResource = PostedResource.create(resource.getStringURI());
   
    return postedResource.getRootPosts();
   
  }
View Full Code Here


   * @param resourceUri
   * @return
   */
  public static int getAllPostsNo(String resourceUri) {
    XfoafSscfResource resource = XfoafSscfResource.getXfoafSscfResource(resourceUri);
    PostedResource postedResource = PostedResource.create(resource.getStringURI());
    List<SiocPostBean> posts = postedResource.getRootPosts();
   
    int postNo = 0;
    for (SiocPostBean post : posts) {
      postNo += post.getRepliesNo();
    }
View Full Code Here

    }

    //create the XfoafSscfResource object for current resource
    XfoafSscfResource resource = XfoafSscfResource.getXfoafSscfResource(resourceUri);
   
    PostedResource postedResource = PostedResource.create(resource.getStringURI());
   
    // export all the posts on given resource to the 2RDF
    if (request.getParameter("export2RDF") != null && "true".equals(request.getParameter("export2RDF"))) {
     
      response.setContentType("text/xml");
      response.getWriter().write(postedResource.exportPosts2RDF());
     
      return;
    }
   
   
    //get the user mbox from request
    String authorMbox = request.getParameter("authorMbox");   
    if (authorMbox == null || "".equals(authorMbox)) {
      response.sendError(HttpServletResponse.SC_BAD_REQUEST, String.format(MISSING_AUTHOR_MBOX));
      return;
    }
   
   
    //create a Person object for current user
    Person person = PersonFactory.findPerson(authorMbox);
    if (person == null) {
      person = PersonFactory.createPerson(authorMbox, null, false);
    }
   
   
    // show root posts of given resource
    if (request.getParameter("getRootPosts") != null && "true".equals(request.getParameter("getRootPosts"))) {
     
      //get the evaluation of the resource
      float currentRating = Float.isNaN(resource.getEvaluation()) ? 0 : resource.getEvaluation();
      float currentUserRating = Float.isNaN(resource.getEvaluation(person)) ? 0 : resource.getEvaluation(person);
     
      //System.out.println("__eval " + resource.getEvaluation(person) + " .. " + resource.getEvaluationsNo());
     
      //sets the attributes used after redirection
      request.setAttribute("resourceUri", resourceUri);
      request.setAttribute("authorMbox", authorMbox);
      request.setAttribute("currentRating", Float.valueOf(currentRating));
      request.setAttribute("currentUserRating", Float.valueOf(currentUserRating));
      request.setAttribute("isUserAllowedToRate", Float.isNaN(resource.getEvaluation(person)) ? true : false );
      request.setAttribute("currentRatingsNo", resource.getEvaluationsNo());
     
      /*System.out.println(request.getAttribute("currentRating") + " " + request.getAttribute("currentUserRating") + " "
          + request.getAttribute("currentRatingsNo"));*/
     
      request.getRequestDispatcher(JSP_PAGE_PATH).forward(request,response);
      return;
    }
   
    // add the post
    if (request.getParameter("addPost") != null && "true".equals(request.getParameter("addPost"))) {
      // get the post information from the request
      String postTitle = request.getParameter("postTitle");
      String parentPostUri = request.getParameter("parentPostUri");
      String postBody = request.getParameter("postBody");
      String postKeywords = request.getParameter("postKeywords");
      //String isRootPost = request.getParameter("isRootPost");

      if (postBody == null || "".equals(postBody)) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, String.format(MISSING_PARAM_ADDED_POST));
        return;
      }

      Set<String> hasKeywords = new TreeSet<String>();
      if (postKeywords != null && !"".equals(postKeywords)) {
        processKeywords(postKeywords, hasKeywords)
      }
     
     
      String strMilis = Long.toString(System.currentTimeMillis());
      //create a post with attributes set to given values
      SiocPostBean post = new SiocPostBean();
      post.setUri(request.getRequestURL()+"/"+Sha1sum.getInstance().calc(person.getMbox().toString()+strMilis));
      post.setPostedBy(person);
      post.setPostedResource(resourceUri);
      post.setPostBody(postBody);
      post.setPostedWhen(strMilis);
      post.setPostTitle(postTitle);
      post.setKeywords(hasKeywords);

    //  try {
        // add new post on current resource to the reposistory and get its uri
        if (parentPostUri != null && !"0".equals(parentPostUri)) {
          //System.out.println("if");
          postedResource.addPost(post, parentPostUri);
        } else {
          //System.out.println("else");
          postedResource.addPost(post, null);
        }
       
        List<SiocPostBean> posts = postedResource.getRootPosts();
        int postsNo = 0;
        for (SiocPostBean p : posts) {
          postsNo += p.getRepliesNo();
        }

View Full Code Here

TOP

Related Classes of org.corrib.s3b.sscf.manage.sioc.PostedResource

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.