Package org.exoplatform.services.jcr.core

Examples of org.exoplatform.services.jcr.core.ExtendedSession


      if (workspaceName == null)
      {
         throw new IllegalArgumentException("Workspace Name is null");
      }

      ExtendedSession session = cache.get(key(repository, workspaceName));
      // create and cache new session

      if (session == null)
      {
         if (conversationState != null)
         {
            session =
                     (ExtendedSession) repository.getDynamicSession(workspaceName, conversationState.getIdentity()
                              .getMemberships());
         }
         else if (!isSystem)
         {
            session = (ExtendedSession)repository.login(workspaceName);
         }
         else
         {
            session = (ExtendedSession)repository.getSystemSession(workspaceName);
         }

         session.registerLifecycleListener(this);

         cache.put(key(repository, workspaceName), session);
      }

      return session;
View Full Code Here


      if (workspaceName == null)
      {
         throw new NullPointerException("Workspace Name is null");
      }

      ExtendedSession session = cache.get(key(repository, workspaceName));
      // create and cache new session

      if (session == null)
      {

         if (!isSystem)
            session = (ExtendedSession)repository.login(workspaceName);
         else
            session = (ExtendedSession)repository.getSystemSession(workspaceName);

         session.registerLifecycleListener(this);

         cache.put(key(repository, workspaceName), session);
      }

      return session;
View Full Code Here

    */
   protected void deserialize(Node importRoot, XmlSaveType saveType, boolean isImportedByStream, int uuidBehavior,
      InputStream is) throws RepositoryException, SAXException, IOException
   {

      ExtendedSession extendedSession = (ExtendedSession)importRoot.getSession();
      ExtendedWorkspace extendedWorkspace = (ExtendedWorkspace)extendedSession.getWorkspace();
      if (isImportedByStream)
      {
         if (saveType == XmlSaveType.SESSION)
         {
            extendedSession.importXML(importRoot.getPath(), is, uuidBehavior);
         }
         else if (saveType == XmlSaveType.WORKSPACE)
         {
            extendedWorkspace.importXML(importRoot.getPath(), is, uuidBehavior);
         }

      }
      else
      {
         XMLReader reader = XMLReaderFactory.createXMLReader();
         if (saveType == XmlSaveType.SESSION)
         {
            reader.setContentHandler(extendedSession.getImportContentHandler(importRoot.getPath(), uuidBehavior));

         }
         else if (saveType == XmlSaveType.WORKSPACE)
         {
            reader.setContentHandler(extendedWorkspace.getImportContentHandler(importRoot.getPath(), uuidBehavior));
View Full Code Here

    */
   protected byte[] serialize(Node exportRootNode, boolean isSystemView, boolean isStream) throws IOException,
      RepositoryException, SAXException, TransformerConfigurationException
   {

      ExtendedSession extendedSession = (ExtendedSession)exportRootNode.getSession();

      ByteArrayOutputStream outStream = new ByteArrayOutputStream();

      if (isSystemView)
      {

         if (isStream)
         {
            extendedSession.exportSystemView(exportRootNode.getPath(), outStream, false, false);
         }
         else
         {
            SAXTransformerFactory saxFact = (SAXTransformerFactory)TransformerFactory.newInstance();
            TransformerHandler handler = saxFact.newTransformerHandler();
            handler.setResult(new StreamResult(outStream));
            extendedSession.exportSystemView(exportRootNode.getPath(), handler, false, false);
         }
      }
      else
      {
         if (isStream)
         {
            extendedSession.exportDocumentView(exportRootNode.getPath(), outStream, false, false);
         }
         else
         {
            SAXTransformerFactory saxFact = (SAXTransformerFactory)TransformerFactory.newInstance();
            TransformerHandler handler = saxFact.newTransformerHandler();
            handler.setResult(new StreamResult(outStream));
            extendedSession.exportDocumentView(exportRootNode.getPath(), handler, false, false);
         }
      }
      outStream.close();
      return outStream.toByteArray();
   }
View Full Code Here

   protected File serializeToFile(Node exportRootNode, boolean isSystemView, boolean isStream) throws IOException,
                                                                                          RepositoryException,
                                                                                          SAXException,
                                                                                          TransformerConfigurationException {

     ExtendedSession extendedSession = (ExtendedSession) exportRootNode.getSession();

     File file = File.createTempFile("export", ".xml");
    
     FileOutputStream outStream = new FileOutputStream(file);

     if (isSystemView) {

       if (isStream) {
         extendedSession.exportSystemView(exportRootNode.getPath(), outStream, false, false);
       } else {
         SAXTransformerFactory saxFact = (SAXTransformerFactory) TransformerFactory.newInstance();
         TransformerHandler handler = saxFact.newTransformerHandler();
         handler.setResult(new StreamResult(outStream));
         extendedSession.exportSystemView(exportRootNode.getPath(), handler, false, false);
       }
     } else {
       if (isStream) {
         extendedSession.exportDocumentView(exportRootNode.getPath(), outStream, false, false);
       } else {
         SAXTransformerFactory saxFact = (SAXTransformerFactory) TransformerFactory.newInstance();
         TransformerHandler handler = saxFact.newTransformerHandler();
         handler.setResult(new StreamResult(outStream));
         extendedSession.exportDocumentView(exportRootNode.getPath(), handler, false, false);
       }
     }
     outStream.close();
     return file;
   }
View Full Code Here

   }

   protected void serialize(Node rootNode, boolean isSystemView, boolean isStream, File content) throws IOException,
      RepositoryException, SAXException, TransformerConfigurationException
   {
      ExtendedSession extendedSession = (ExtendedSession)rootNode.getSession();

      OutputStream outStream = new FileOutputStream(content);
      if (isSystemView)
      {

         if (isStream)
         {
            extendedSession.exportSystemView(rootNode.getPath(), outStream, false, false);
         }
         else
         {
            SAXTransformerFactory saxFact = (SAXTransformerFactory)TransformerFactory.newInstance();
            TransformerHandler handler = saxFact.newTransformerHandler();
            handler.setResult(new StreamResult(outStream));
            extendedSession.exportSystemView(rootNode.getPath(), handler, false, false);
         }
      }
      else
      {
         if (isStream)
         {
            extendedSession.exportDocumentView(rootNode.getPath(), outStream, false, false);
         }
         else
         {
            SAXTransformerFactory saxFact = (SAXTransformerFactory)TransformerFactory.newInstance();
            TransformerHandler handler = saxFact.newTransformerHandler();
            handler.setResult(new StreamResult(outStream));
            extendedSession.exportDocumentView(rootNode.getPath(), handler, false, false);
         }
      }
      outStream.close();

   }
View Full Code Here

         {

            PlainChangesLog subLog = logIterator.nextLog();
            String sessionId = subLog.getSessionId();

            ExtendedSession userSession;

            if (subLog.getSession() != null)
            {
               userSession = subLog.getSession();
            }
            else
            {
               userSession = sessionRegistry.getSession(sessionId);
            }

            if (userSession != null)
            {
               for (ItemState itemState : subLog.getAllStates())
               {
                  if (itemState.isEventFire())
                  {

                     ItemData item = itemState.getData();
                     try
                     {
                        int eventType = eventType(itemState);
                        if (eventType != SKIP_EVENT && isTypeMatch(criteria, eventType)
                           && isPathMatch(criteria, item, userSession) && isIdentifierMatch(criteria, item)
                           && isNodeTypeMatch(criteria, item, userSession, subLog)
                           && isSessionMatch(criteria, sessionId))
                        {

                           String path =
                              userSession.getLocationFactory().createJCRPath(item.getQPath()).getAsString(false);
                           if (eventType== ExtendedEvent.NODE_MOVED)
                           {
                               String oldPath =
                                       userSession.getLocationFactory().createJCRPath(itemState.getOldPath()).getAsString(false);
                               Map<String, String> info = new HashMap<String, String>();
                               if(itemState.isMoved())
                               {
                                   info.put(ExtendedEvent.SRC_ABS_PATH, oldPath);
                                   info.put(ExtendedEvent.DEST_ABS_PATH, path);
                               }
                               else if (itemState.isOrdered())
                               {
                                   info.put(ExtendedEvent.SRC_CHILD_REL_PATH, oldPath);
                                   info.put(ExtendedEvent.DEST_CHILD_REL_PATH, path);
                               }

                               events.add(new EventImpl(eventType, path, userSession.getUserID(), info));
                           }
                            else
                           {
                               events.add(new EventImpl(eventType, path, userSession.getUserID()));

                           }

                        }
                     }
View Full Code Here

      if (workspaceName == null)
      {
         throw new NullPointerException("Workspace Name is null");
      }

      ExtendedSession session = cache.get(key(repository, workspaceName));
      // create and cache new session

      if (session == null)
      {
         ConversationState conversationState = ConversationState.getCurrent();
         if (conversationState != null && conversationState.getIdentity().getUserId().equals(DynamicIdentity.DYNAMIC))
         {
            session = (ExtendedSession) repository.getDynamicSession(workspaceName, conversationState.getIdentity().getMemberships());
         }
         else if (!isSystem)
         {
            session = (ExtendedSession)repository.login(workspaceName);
         }
         else
         {
            session = (ExtendedSession)repository.getSystemSession(workspaceName);
         }

         session.registerLifecycleListener(this);

         cache.put(key(repository, workspaceName), session);
      }

      return session;
View Full Code Here

    * Method for moving old storage into temporary location.
    * @throws Exception
    */
   private void moveOldStructure() throws Exception
   {
      ExtendedSession session = (ExtendedSession)service.getStorageSession();
      try
      {
         if (session.itemExists(storagePathOld))
         {
            return;
         }
         else
         {
            session.move(service.getStoragePath(), storagePathOld, false);
            session.save();
         }
      }
      finally
      {
         session.logout();
      }
   }
View Full Code Here

    * Method for removing old storage from temporary location.
    * @throws RepositoryException
    */
   private void removeOldStructure() throws RepositoryException
   {
      ExtendedSession session = (ExtendedSession)service.getStorageSession();
      try
      {
         if (session.itemExists(storagePathOld))
         {
            NodeIterator usersIter = ((ExtendedNode)session.getItem(usersStorageOld)).getNodesLazily();
            while (usersIter.hasNext())
            {
               Node currentUser = usersIter.nextNode();
               currentUser.remove();
               session.save();
            }

            NodeIterator groupsIter = ((ExtendedNode)session.getItem(groupsStorageOld)).getNodesLazily();
            while (groupsIter.hasNext())
            {
               Node currentGroup = groupsIter.nextNode();
               currentGroup.remove();
               session.save();
            }

            NodeIterator membershipTypesIter =
               ((ExtendedNode)session.getItem(membershipTypesStorageOld)).getNodesLazily();
            while (membershipTypesIter.hasNext())
            {
               Node currentMembershipType = membershipTypesIter.nextNode();
               currentMembershipType.remove();
               session.save();
            }

            session.getItem(storagePathOld).remove();
            session.save();
         }
      }
      finally
      {
         session.logout();
      }
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.core.ExtendedSession

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.