Package org.exoplatform.services.jcr.impl.core

Examples of org.exoplatform.services.jcr.impl.core.NodeImpl$PropertiesDataOrderComparator


    /**
     * {@inheritDoc}
     */
    public ScoreNode nextScoreNode() throws IOException {
        if (nodes.hasNext()) {
            NodeImpl n = (NodeImpl) nodes.next();
            return new ScoreNode(n.getData().getIdentifier(), 1.0f);
        } else {
            return null;
        }
    }
View Full Code Here


        /**
         * @inheritDoc
         */
        public Object next() {
            init();
            NodeImpl n = (NodeImpl) selfAndChildren.next();
            return n;
        }
View Full Code Here

         }
         String pathStr = excerptCall.substring(idx + EXCERPT_FUNC_LPAR.length(), end).trim();
         String decodedPath = ISO9075.decode(pathStr);
         try
         {
            NodeImpl n = (NodeImpl)getNodeImpl().getNode(decodedPath);
            return createExcerpt(n.getData().getIdentifier());
         }
         catch (PathNotFoundException e)
         {
            // does not exist or references a property
            try
View Full Code Here

   {

      checkInitialized();
      JCRPath path = session.getLocationFactory().parseAbsPath(absPath);
      QPath qpath = path.getInternalPath();
      NodeImpl parent = (NodeImpl)session.getTransientNodesManager().getItem(qpath.makeParentPath(), false);
      if (parent == null)
         throw new PathNotFoundException("Parent not found for " + path.getAsString(false));

      // validate as on parent child node
      parent.validateChildNode(qpath.getName(), Constants.NT_QUERY);

      NodeData queryData =
         TransientNodeData.createNodeData((NodeData)parent.getData(), qpath.getName(), Constants.NT_QUERY);
      NodeImpl queryNode =
         (NodeImpl)session.getTransientNodesManager().update(ItemState.createAddedState(queryData), false);

      NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();

      ItemAutocreator itemAutocreator =
         new ItemAutocreator(ntmanager, session.getValueFactory(), session.getTransientNodesManager(), false);

      PlainChangesLog changes =
         itemAutocreator.makeAutoCreatedItems((NodeData)queryNode.getData(), Constants.NT_QUERY, session
            .getTransientNodesManager(), session.getUserID());

      for (ItemState autoCreatedState : changes.getAllStates())
      {
         session.getTransientNodesManager().update(autoCreatedState, false);
View Full Code Here

   private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.ext.AddMetadataAction");

   public boolean execute(Context ctx) throws Exception
   {
      PropertyImpl property = (PropertyImpl)ctx.get("currentItem");
      NodeImpl parent = property.getParent();
      if (!parent.isNodeType("nt:resource"))
      {
         throw new Exception("incoming node is not nt:resource type");
      }

      InputStream data = null;
      String mimeType;

      try
      {
         if (property.getInternalName().equals(Constants.JCR_DATA))
         {
            data = ((PropertyData)property.getData()).getValues().get(0).getAsStream();
            try
            {
               mimeType = parent.getProperty("jcr:mimeType").getString();
            }
            catch (PathNotFoundException e)
            {
               return false;
            }
         }
         else if (property.getInternalName().equals(Constants.JCR_MIMETYPE))
         {
            int evt = (Integer)ctx.get(InvocationContext.EVENT);
            if (evt != ExtendedEvent.PROPERTY_ADDED)
            {
               // In case the mime type is modified we assume that the property jcr:data is modified too so to
               // prevent issue like JCR-1873 we do the data extraction only on jcr:data change
               return false;
            }

            mimeType = property.getString();
            try
            {
               PropertyImpl propertyImpl = (PropertyImpl)parent.getProperty("jcr:data");
               data = ((PropertyData)propertyImpl.getData()).getValues().get(0).getAsStream();
            }
            catch (PathNotFoundException e)
            {
               return false;
            }
         }
         else
         {
            return false;
         }

         if (data.available() == 0)
         {
            return false;
         }

         if (!parent.isNodeType("dc:elementSet"))
         {
            parent.addMixin("dc:elementSet");
         }

         DocumentReaderService readerService =
            (DocumentReaderService)((ExoContainer)ctx.get("exocontainer"))
               .getComponentInstanceOfType(DocumentReaderService.class);
         if (readerService == null)
         {
            throw new IllegalArgumentException("No DocumentReaderService configured for current container");
         }

         Properties props = new Properties();
         try
         {
            props = readerService.getDocumentReader(mimeType).getProperties(data);
         }
         catch (HandlerNotFoundException e)
         {
            LOG.debug("Binary value reader error, content by path " + property.getPath() + ", property id "
               + property.getData().getIdentifier() + " : " + e.getMessage());
         }
         catch (DocumentReadException e)
         {
            printWarning(property, e);
         }
         catch (IOException e)
         {
            printWarning(property, e);
         }

         Iterator entries = props.entrySet().iterator();
         while (entries.hasNext())
         {
            Entry entry = (Entry)entries.next();
            QName qname = (QName)entry.getKey();
            JCRName jcrName =
               property.getSession().getLocationFactory().createJCRName(
                  new InternalQName(qname.getNamespace(), qname.getName()));

            PropertyDefinitionDatas pds =
               parent.getSession().getWorkspace().getNodeTypesHolder().getPropertyDefinitions(
                  jcrName.getInternalName(), ((NodeData)parent.getData()).getPrimaryTypeName(),
                  ((NodeData)parent.getData()).getMixinTypeNames());
            if (pds.getDefinition(true) != null)
            {
               Value[] values = {createValue(entry.getValue(), property.getSession().getValueFactory())};
               parent.setProperty(jcrName.getAsString(), values);
            }
            else
            {
               parent.setProperty(jcrName.getAsString(), createValue(entry.getValue(), property.getSession()
                  .getValueFactory()));
            }
         }

         return false;
View Full Code Here

   public boolean execute(Context ctx) throws Exception
   {

      PropertyImpl property = (PropertyImpl)ctx.get("currentItem");
      NodeImpl parent = property.getParent();
      if (!parent.isNodeType("nt:resource"))
      {
         throw new Exception("incoming node is not nt:resource type");
      }

      InputStream data = null;
      String mimeType;

      try
      {
         if (property.getInternalName().equals(Constants.JCR_DATA))
         {
            data = ((PropertyData)property.getData()).getValues().get(0).getAsStream();
            try
            {
               mimeType = parent.getProperty("jcr:mimeType").getString();
            }
            catch (PathNotFoundException e)
            {
               return false;
            }
         }
         else if (property.getInternalName().equals(Constants.JCR_MIMETYPE))
         {
            mimeType = property.getString();
            try
            {
               PropertyImpl propertyImpl = (PropertyImpl)parent.getProperty("jcr:data");
               data = ((PropertyData)propertyImpl.getData()).getValues().get(0).getAsStream();
            }
            catch (PathNotFoundException e)
            {
               return false;
            }
         }
         else
         {
            return false;
         }

         if (!parent.isNodeType("dc:elementSet"))
         {
            parent.addMixin("dc:elementSet");
         }

         DocumentReaderService readerService =
            (DocumentReaderService)((ExoContainer)ctx.get("exocontainer"))
               .getComponentInstanceOfType(DocumentReaderService.class);
         if (readerService == null)
            throw new NullPointerException("No DocumentReaderService configured for current container");

         Properties props = new Properties();
         try
         {
            props = readerService.getDocumentReader(mimeType).getProperties(data);
         }
         catch (HandlerNotFoundException e)
         {
            log.debug(e.getMessage());
         }

         Iterator entries = props.entrySet().iterator();
         while (entries.hasNext())
         {
            Entry entry = (Entry)entries.next();
            QName qname = (QName)entry.getKey();
            JCRName jcrName =
               property.getSession().getLocationFactory().createJCRName(
                  new InternalQName(qname.getNamespace(), qname.getName()));

            PropertyDefinitionDatas pds =
               parent.getSession().getWorkspace().getNodeTypesHolder().getPropertyDefinitions(
                  jcrName.getInternalName(), ((NodeData)parent.getData()).getPrimaryTypeName(),
                  ((NodeData)parent.getData()).getMixinTypeNames());
            if (pds.getDefinition(true) != null)
            {
               Value[] values = {createValue(entry.getValue(), property.getSession().getValueFactory())};
               parent.setProperty(jcrName.getAsString(), values);
            }
            else
            {
               parent.setProperty(jcrName.getAsString(), createValue(entry.getValue(), property.getSession()
                  .getValueFactory()));
            }
         }

         return false;
View Full Code Here

         }
         String pathStr = excerptCall.substring(idx + EXCERPT_FUNC_LPAR.length(), end).trim();
         String decodedPath = ISO9075.decode(pathStr);
         try
         {
            NodeImpl n = (NodeImpl)getNodeImpl().getNode(decodedPath);
            return createExcerpt(n.getData().getIdentifier());
         }
         catch (PathNotFoundException e)
         {
            // does not exist or references a property
            try
View Full Code Here

   public boolean execute(Context ctx) throws Exception
   {

      PropertyImpl property = (PropertyImpl)ctx.get("currentItem");
      NodeImpl parent = (NodeImpl)property.getParent();
      if (!parent.isNodeType("nt:resource"))
      {
         throw new Exception("incoming node is not nt:resource type");
      }

      InputStream data = null;
      String mimeType;

      try
      {
         if (property.getInternalName().equals(Constants.JCR_DATA))
         {
            data = ((PropertyData)property.getData()).getValues().get(0).getAsStream();
            try
            {
               mimeType = parent.getProperty("jcr:mimeType").getString();
            }
            catch (PathNotFoundException e)
            {
               return false;
            }
         }
         else if (property.getInternalName().equals(Constants.JCR_MIMETYPE))
         {
            mimeType = property.getString();
            try
            {
               PropertyImpl propertyImpl = (PropertyImpl)parent.getProperty("jcr:data");
               data = ((PropertyData)propertyImpl.getData()).getValues().get(0).getAsStream();
            }
            catch (PathNotFoundException e)
            {
               return false;
            }
         }
         else
         {
            return false;
         }

         if (!parent.isNodeType("dc:elementSet"))
         {
            parent.addMixin("dc:elementSet");
         }

         DocumentReaderService readerService =
            (DocumentReaderService)((ExoContainer)ctx.get("exocontainer"))
               .getComponentInstanceOfType(DocumentReaderService.class);
         if (readerService == null)
            throw new NullPointerException("No DocumentReaderService configured for current container");

         Properties props = new Properties();
         try
         {
            props = readerService.getDocumentReader(mimeType).getProperties(data);
         }
         catch (HandlerNotFoundException e)
         {
            log.debug(e.getMessage());
         }

         Iterator entries = props.entrySet().iterator();
         while (entries.hasNext())
         {
            Entry entry = (Entry)entries.next();
            QName qname = (QName)entry.getKey();
            JCRName jcrName =
               property.getSession().getLocationFactory().createJCRName(
                  new InternalQName(qname.getNamespace(), qname.getName()));

            PropertyDefinitionDatas pds =
               parent.getSession().getWorkspace().getNodeTypesHolder().getPropertyDefinitions(
                  jcrName.getInternalName(), ((NodeData)parent.getData()).getPrimaryTypeName(),
                  ((NodeData)parent.getData()).getMixinTypeNames());
            if (pds.getDefinition(true) != null)
            {
               Value[] values = {createValue(entry.getValue(), property.getSession().getValueFactory())};
               parent.setProperty(jcrName.getAsString(), values);
            }
            else
            {
               parent.setProperty(jcrName.getAsString(), createValue(entry.getValue(), property.getSession()
                  .getValueFactory()));
            }
         }

         return false;
View Full Code Here

         if (lock.isSessionScoped() && !pendingLocks.contains(nodeId))
         {
            try
            {
               NodeImpl node =
                  ((NodeImpl)sessionImpl.getTransientNodesManager()
                     .getItemByIdentifier(lock.getNodeIdentifier(), false));

               if (node != null)
               {
                  node.unlock();
               }

            }
            catch (UnsupportedRepositoryOperationException e)
            {
View Full Code Here

            RepositoryException {

       checkInitialized();
       JCRPath path = session.getLocationFactory().parseAbsPath(absPath);
       QPath qpath = path.getInternalPath();
       NodeImpl parent = (NodeImpl)session.getTransientNodesManager().getItem(qpath.makeParentPath(), false);
       if (parent == null)
          throw new PathNotFoundException("Parent not found for " + path.getAsString(false));

       // validate as on parent child node
       parent.validateChildNode(qpath.getName(), Constants.NT_QUERY);

       NodeData queryData =
          TransientNodeData.createNodeData((NodeData)parent.getData(), qpath.getName(), Constants.NT_QUERY);
       NodeImpl queryNode =
          (NodeImpl)session.getTransientNodesManager().update(ItemState.createAddedState(queryData), false);

       NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();

       ItemAutocreator itemAutocreator = new ItemAutocreator(ntmanager, session.getValueFactory(),session.getTransientNodesManager());

       PlainChangesLog changes =
          itemAutocreator.makeAutoCreatedItems((NodeData)queryNode.getData(),  Constants.NT_QUERY, session
             .getTransientNodesManager(), session.getUserID());

       for (ItemState autoCreatedState : changes.getAllStates())
       {
          session.getTransientNodesManager().update(autoCreatedState, false);
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.core.NodeImpl$PropertiesDataOrderComparator

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.