Package org.foafrealm.bean

Examples of org.foafrealm.bean.TomcatPerson


      {
        if(request.getUserPrincipal()!=null)
        {
          try
          {
            TomcatPerson person = ((FOAFPrincipal)request.getUserPrincipal()).getPerson();
            viewerLogged = person.getURI().toString();
          }
          catch (Exception e)
          {
            //ignore viewerLogged will stay null
          }
        }
       
        if(viewerLogged!=null && viewerLogged.startsWith("mailto:"))
          viewerLogged = viewerLogged.substring(7);
           
        if(viewerCheck!=null&&!"".equals(viewerCheck))
        {
          if(viewerCheck.startsWith("mailto:"))
            viewerCheck = viewerCheck.substring(7);
       
          if(!viewerCheck.equals(viewerLogged))
          {
            try
            {
              sendJSONResponse(response,ERROR);
              return;
            }
            catch (IOException e)
            {
              //ignore
            }
          }
        }
      }
     
     
      if(type.equals("getAllBookmarks"))
      {
              //level 1 means all bookmarks of this user.       
        String bookmarks = getBookmarks(request);
              try {
                if(bookmarks == null||"".equals(bookmarks.trim()))
                  sendJSONResponse(response,EMPTY);
                else
                  sendJSONResponse(response,bookmarks);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      //to be developed if needed.
      //else if(type.equals("getOneLevel"))
      //{
       
      //}
      else if(type.equals("pasteNode"))
      {             
              String bookmarks = pasteResource(request);
              try {
                if(bookmarks == null||"".equals(bookmarks.trim()))
                  sendJSONResponse(response,EMPTY);
                else
                  sendJSONResponse(response,bookmarks);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      else if(type.equals("removeNode"))
      {
             
              String item;
              String parent;
              String permanently;
              String resourceType;
             
              item = request.getParameter("item");
              parent = request.getParameter("parent");
              permanently = request.getParameter("permanently");
              resourceType = request.getParameter("resType");
             
              XfoafSscfResource res = XfoafSscfResource.getXfoafSscfResource(item);
              XfoafSscfResource parentRes = XfoafSscfResource.getXfoafSscfResource(parent);
             
              //check the rights to remove the resource
              //String resIssuer = null;
              //boolean userOwnsRes = false;
             // if(res.getIssuedBy()!=null) {
             //   resIssuer = res.getIssuedBy().getUri().toString();
              //  resIssuer = (resIssuer.startsWith("mailto:"))?resIssuer.substring(7):resIssuer;
              //  userOwnsRes = resIssuer.equals(viewerLogged);
              //}
             
              //TODO possible null here
              String parentResIssuer = parentRes.getIssuedBy().getURI().toString();
              parentResIssuer = (parentResIssuer.startsWith("mailto:"))?parentResIssuer.substring(7):parentResIssuer;
              boolean userOwnsParentRes = parentResIssuer.equals(viewerLogged);
             
              try {
               
                 if(!userOwnsParentRes) sendJSONResponse(response,ERROR);
               
          if(res != null &&!"".equals(parentRes))
          {
            //if permanently was set it means that the suggested directory should be removed
            // permanently
            if(permanently!=null&&!"".equals(permanently)&&permanently.equals("1"))
            {
              res.addRemovedSuggested(parentRes)
            }
            else
            {
              res.deleteIsIn(parentRes);
              if(!res.listIsIn().hasNext()) //&&userOwnsRes
              {
                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();
              }
             
View Full Code Here


      if(type.equals("get"))
      {
        if(person==null||"".equals(person)) {
          try
          {
            TomcatPerson tPerson = ((FOAFPrincipal)req.getUserPrincipal()).getPerson();
            person = tPerson.getURI().toString();
          }
          catch (Exception e)
          {
            //ignore
          }
View Full Code Here

TOP

Related Classes of org.foafrealm.bean.TomcatPerson

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.