Package org.corrib.s3b.sscf.manage

Examples of org.corrib.s3b.sscf.manage.WebBookmarkResource


    String sha1sum = Sha1sum.getInstance().calc(user);
    for(String uri : uris){
      String shaURI = (uri + "__"
          + sha1sum);

      WebBookmarkResource wbr = WebBookmarkResource.getWebBookmarkResource(shaURI);
      if(wbr != null){
        wbr.setSynchronizationState(synchronizationState);
      }
    }
  }
View Full Code Here


 
  public String getWebBookmarkDescription(String uri)
  {
    if(uri!=null&&!"".equals(uri.trim()))
    {
      WebBookmarkResource wbr = WebBookmarkResource.getWebBookmarkResource(uri);
      if(wbr!=null)
      {
        WebResourceDescription wrd = new WebResourceDescription();
       
        wrd.setName(wbr.getLabel());
        if(wbr.getComment()!=null)
          wrd.setDescription(wbr.getComment());
        wrd.setLink(wbr.getSeeAlso().toString());
        wrd.setTags(wbr.getTags());
        return wrd.toJSON();
      }
    }
   
    return null;
View Full Code Here

          SiocPostResource post = SiocPostResource.getInstance(resource.getStringURI());
          bookmarksTreeSiocData(post, viewer, buffer, depth, session, null, initialLevel, true,standalone,true,selectedUri,null);
       
        if(type.equals(S3B_SSCF.WebResource))
        {
          WebBookmarkResource wbr = WebBookmarkResource.getWebBookmarkResource(resource.getStringURI());
          bookmarksTreeWebResource(wbr, viewer, buffer, initialLevel, true, standalone, true, selectedUri);
        }
        if(type.equals(S3B_SSCF.HexResource))
        {
          WebBookmarkResource wbr = WebBookmarkResource.getWebBookmarkResource(resource.getStringURI());
          bookmarksTreeHexResource(wbr, viewer, buffer, initialLevel, true, standalone, true,selectedUri);
        }
      }
      else
      {
View Full Code Here

      if (resource instanceof SiocDataResource) {
        bookmarksTreeSiocData(resource, viewer, buffer, depth, session, it, level, parentIsOwner, standalone, inOwn,selectedUri,pathsToUri);
      }
      if (resource instanceof WebBookmarkResource)
      {
        WebBookmarkResource wbr = (WebBookmarkResource)resource;
        Object type = wbr.getGraphPropertyValue(RDF.type);
       
        if(type.toString().equals(S3B_SSCF.WebResource))
          bookmarksTreeWebResource((WebBookmarkResource) resource, viewer,buffer, level,parentIsOwner,standalone,inOwn,selectedUri);
        else if(type.toString().equals(S3B_SSCF.HexResource))
          bookmarksTreeHexResource((WebBookmarkResource) resource, viewer,buffer, level,parentIsOwner,standalone,inOwn,selectedUri);
View Full Code Here

      //recursive call to fetch bookmarks stored in subDirectory
      if(xres != null && xres.isDirectory()){
        result.addAll(loadPosts(xres));
      }else if(xres != null){
        if(!urisIn.contains(xres.getURI().toString())){
          WebBookmarkResource childWbr = WebBookmarkResource.getWebBookmarkResource(xres.getURI().toString());
          urisIn.add(childWbr.getURI().toString());
          String[] tags = extractWebBookmarkResourceTags(childWbr);
          String wbrURI = childWbr.getSeeAlso().toString();
          //don't add resources marked as IGNORED
          if(!SynchronizationState.IGNORED.equals(childWbr.getSynchronizationState())){
            //we use label here as it is mapped from Post.Description in post when it is imported and stored in repo
            SynchronizationPost post = new SynchronizationPost(wbrURI,childWbr.getLabel(),wbrURI,childWbr.getIssueDate(),true,childWbr.getSynchronizationState(),tags);
            result.add(post);
          }
        }
      }
    }
View Full Code Here

    //check if resources were loaded for the given user
    //if any changes were made to them and ,if any, if the changes were made later than
    //the last time resources were loaded from the database
    if(getLoadedPosts(user) == null || getLastLoadDate(user) == null ||
        (getLastChangeDate(user) != null && getLastChangeDateInMillis(user) > getLastLoadDateInMillis(user))){
      WebBookmarkResource wbr = WebBookmarkResource.getWebBookmarkResource(user);
      result = loadPosts(wbr);
      result = removeDuplicates(result);
      logger.info("STORED BOOKMARKS READ SIZE: " + result.size());
      setLoadedPosts(user, result);
    }else{
View Full Code Here

        //first element is the import directory for bookmarking source, second element is the first directory in the tree
        String dirUri = path.get(1);
        NodeContainer nc = new NodeContainer();


        WebBookmarkResource wbr = WebBookmarkResource.getWebBookmarkResource(dirUri);
        //set dynamic load
        nc.setDyn(true);

        //Web bookmark
        nc.setType("directory");
        DirectoryNode dn = new DirectoryNode();

        dn.setId(wbr.getResource().toString());

        dn.setLabel((wbr.getLabel()!=null&&!"".equals(wbr.getLabel())) ? escapeForJs(wbr.getLabel()) : wbr.getStringURI().toString() );

        int level = 3;
        dn.setLevel(level);
        dn.setOwn(true)
        dn.setStandalone(false);
View Full Code Here

     
      String resType = req.getParameter("type");
        
        if(resType!=null&&!"".equals(resType)&&resType.equals("web"))
        {
          WebBookmarkResource wbr = WebBookmarkResource.getWebBookmarkResourceIfExists(resUri);
          
          if(wbr != null)
            wbr.increaseResourceHits();
     
          if(wbr!=null&&wbr.getSeeAlso()!=null)
            resp.sendRedirect(wbr.getSeeAlso().toString());
          else if(resUri.contains("__"))
            resp.sendRedirect(resUri.substring(0,resUri.lastIndexOf("__")));
          else resp.sendRedirect(resUri);
        }
        else
View Full Code Here

              {
                if(resourceType!=null&&!"".equals(resourceType))
                {
                  if(resourceType.equals("webBookmark"))
                  {
                    WebBookmarkResource web = WebBookmarkResource.getWebBookmarkResource(item);
                    web.remove();
                  }
                  //TODO: other types ...
                  //TODO: use &&userOwnsRes
                }
                else
                  res.remove();
              }
            }
            sendJSONResponse(response,OK);
          }
          else
            sendJSONResponse(response,ERROR);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      else if(type.equals("removeAll"))
      {
              String item;
              String parent;
             
              item = request.getParameter("item");
              parent = request.getParameter("parent");
             
              XfoafSscfResource res = XfoafSscfResource.getXfoafSscfResource(item);
              XfoafSscfResource parentRes = XfoafSscfResource.getXfoafSscfResource(parent);
             
              String loggedPerson = null;
             
              if(request.getUserPrincipal()!=null) {
          try {
            TomcatPerson person = ((FOAFPrincipal)request.getUserPrincipal()).getPerson();
            loggedPerson = person.getURI().toString();
          }
          catch (Exception e){/*ignore viewerLogged will stay null*/}
        }
           
              String parentIssuer = null;
             
              //we want to delete all the resources of somebody and we know his mbox
              if(parent.startsWith("mailto:")) {
                Person person = PersonFactory.findPerson(parent);
                if(person!=null) parentIssuer = person.getURI().toString();
              }
              else if(parentRes.getIssuedBy()!=null) {
                parentIssuer = parentRes.getIssuedBy().getStringURI();
              }
             
              String resIssuer = res.getIssuedBy()!=null?res.getIssuedBy().getStringURI():loggedPerson;
             
              if(loggedPerson!=null&&loggedPerson.equals(parentIssuer)&&
                  resIssuer.equals(parentIssuer))
              {
                try {
            if(parentRes!= null)
            {
             
              ResourceRemover rm = new ResourceRemover();
              rm.removeAll(res, parentRes);
             
              sendJSONResponse(response,OK);
            }
            else
              sendJSONResponse(response,ERROR);
          } catch (IOException e) {
            e.printStackTrace();
          }
              }
      }
      else if(type.equals("addBookmark"))
      {
              String result = insertResource(request);
             
              try {
          if(result!=null)
            sendJSONResponse(response,result);
          else sendJSONResponse(response,ERROR);
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      else if(type.equals("directoryDescription"))
      {
              String uri = request.getParameter("uri");
              String sioc = request.getParameter("sioc");
              String webBookmark = request.getParameter("webBookmark");
             
              if(uri!=null&&!"".equals(uri))
              {
                String result;
                if(sioc!=null)
                  result = SscfHelper2.getInstance().getSiocResourceDescription(uri, sioc);
                else if(webBookmark!=null) {
                  result = SscfHelper2.getInstance().getWebBookmarkDescription(uri);
                }
                else result = SscfHelper2.getInstance().getDirectoryDescription(uri);
                try {
            if(result!=null)
            {
              //System.out.println(result);
              sendJSONResponse(response,result);
            }
            else sendJSONResponse(response,ERROR);
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
              }
      }
      else if(type.equals("importNode"))
      {
              String result = importSuggestedResource(request);
             
              try {
          if(result!=null)
            sendJSONResponse(response,result);
          else sendJSONResponse(response,ERROR);
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      else if(type.equals("directoryPolicy"))
      {
              String uri = request.getParameter("uri");
             
              //add new policy if parameter set.
              String policy = request.getParameter("policy");
              String remove = request.getParameter("remove");
             
              if(policy!=null&&!"".equals(policy))
              {
                XfoafSscfResource resource = XfoafSscfResource.getXfoafSscfResource(uri);
                if(resource!=null)
                {
                  if(remove!=null&&!"".equals(remove)&&"1".equals(remove))
                  { 
                    resource.deleteAccessibleTo(policy);
                  }
                  else
                    resource.addAccessibleTo(policy);
                }
              }
             
              if(uri!=null&&!"".equals(uri))
              {
                String result = SscfHelper2.getInstance().getDirectoryPolicies(uri);
                try {
            if(result!=null)
              sendJSONResponse(response,result);
            else sendJSONResponse(response,ERROR);
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
              }
      }
      else if(type.equals("generateWordnet"))
      {  
              String name = request.getParameter("name");
              String desc = request.getParameter("desc");
              String thesUri = request.getParameter("thesUri");
                   
              if(name!=null&&!"".equals(name.trim()) )
              {
                String result = SscfHelper2.getInstance().getWordNetValues(name,desc,thesUri);
                try {
            if(result!=null)
              sendJSONResponse(response,result);
            else sendJSONResponse(response,EMPTY);
          } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
              }
      }
      else if(type.equals("createDirectory"))
      {
              String bookmarks = createDirectory(request);
              try {
                if(bookmarks == null||"".equals(bookmarks.trim()))
                  sendJSONResponse(response,EMPTY);
                else
                  sendJSONResponse(response,bookmarks);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      else if(type.equals("sendClick"))
      {
              String uri = request.getParameter("item");
              String resType = request.getParameter("resourceType");
              try {
                if(uri == null||"".equals(uri.trim()))
                  response.getWriter().write(EMPTY);
                else
                {               
                  System.out.println("I received a click to: "+uri);
                 
                  if(resType!=null&&!"".equals(resType)&&resType.equals("web"))
                  {
                    WebBookmarkResource wbr = WebBookmarkResource.getWebBookmarkResource(uri);
                    if(wbr != null)
                      wbr.increaseResourceHits();
                  }
                  else
                  {
                    XfoafSscfResource xfsr = XfoafSscfResource.getXfoafSscfResource(uri);
                    if(xfsr != null)
View Full Code Here

   */
  public String insertWebResource(String destinations,String item,String view,HttpSession session,String serviceAddr,String label,String desc,String type,String ikhUri, String tags)
  {
    String[] destTable = destinations.split(";;");
    Person viewer = PersonFactory.findPerson(view);
    WebBookmarkResource wbr=null;
    String resourceType= null;
   
    //harvest the bookmark
    if(ikhUri!=null&&!"".equals(ikhUri.trim())) {
      IKHConnector ikhc = new IKHConnector(ikhUri+"$"+item+"$",tags,view);
      ikhc.start();
    }
   
    BookmarksHelper bh = new BookmarksHelper("http://foo.bar");
   
    if(type.equals("web"))
      resourceType = S3B_SSCF.WebResource;
    else if(type.equals("hex"))
      resourceType = S3B_SSCF.HexResource;
   
    if(viewer!=null)
    {
      if(viewer.getMbox_sha1sum()!=null)
        wbr = WebBookmarkResource.getWebBookmarkResource(item,null,viewer.getMbox_sha1sum(),resourceType);
      else
        wbr = WebBookmarkResource.getWebBookmarkResource(item,view,null,resourceType);
     
      if(wbr!=null)
      {
        wbr.setLabel(label);
        if(desc!=null&&!"".equals(desc.trim()))
          wbr.setComment(desc);
       
        //ArrayList<String> ltags = new ArrayList<String>();
        bh.placeResources(wbr, destTable, viewer);
        /*
         * Add tags for newly created resource
         */
        try {
          if (tags != null) {
         
            Tagging tagging = new Tagging(wbr.getURI(),viewer.getURI());
            List<Term> terms = tagging.addTerms(tags);
           
            TaggingDbLogic tdbl = new TaggingDbLogic();
            tdbl.addTagging(tagging, serviceAddr);
           
            List<String> atags = new ArrayList<String>();
            for(Term term:terms)
              atags.add(term.getTag());
            wbr.setTags(atags);
           
          }
        } catch (Exception e) {
          //logger.severe("URI of logged in user is incorrect " + e);
          e.printStackTrace();
        }
       
        //notify synchronization resource loader that resources of user were changed
          ResourcesLoader.setLastChangeDate(view, new Date());
        //it will be useful to have type here.
        return getBookmarks(wbr.getStringURI(), viewer.getURI().toString(), session, 2, true,false,serviceAddr,resourceType);
      }
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.corrib.s3b.sscf.manage.WebBookmarkResource

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.