Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1281

StoreProperties - storing properties into a separate file ( FileSystemSource and mode:extraPropertiesBehavior="store" )f

    XMLWordPrintable

Details

    Description

      When

      versionManager.checkin(contentNode.getPath());
      
      org.modeshape.graph.property.ValueFormatException: Error converting String to a Name: jcr:predecessorsjcr:lastModified
              at org.modeshape.graph.property.basic.NameValueFactory.create(NameValueFactory.java:135)                                                             
              at org.modeshape.graph.property.basic.NameValueFactory.create(NameValueFactory.java:83)                                                              
              at org.modeshape.graph.property.basic.NameValueFactory.create(NameValueFactory.java:55)                                                              
              at org.modeshape.connector.filesystem.StoreProperties.parse(StoreProperties.java:374)                                                                
              at org.modeshape.connector.filesystem.StoreProperties.load(StoreProperties.java:258)                                                                 
              at org.modeshape.connector.filesystem.StoreProperties.getResourceProperties(StoreProperties.java:192)                                                
              at org.modeshape.connector.filesystem.FileSystemWorkspace.getNode(FileSystemWorkspace.java:464)                                                      
              at org.modeshape.connector.filesystem.FileSystemWorkspace.putNode(FileSystemWorkspace.java:385)                                                      
              at org.modeshape.graph.connector.base.PathWorkspace$PutCommand.apply(PathWorkspace.java:292)                                                         
              at org.modeshape.graph.connector.base.PathWorkspace.commit(PathWorkspace.java:225)                                                                   
              at org.modeshape.graph.connector.base.PathTransaction$WorkspaceChanges.commit(PathTransaction.java:926)                                              
              at org.modeshape.graph.connector.base.PathTransaction.commit(PathTransaction.java:817)                                                               
              at org.modeshape.graph.connector.base.Connection.execute(Connection.java:130)                                                                        
              at org.modeshape.graph.connector.RepositoryConnectionPool$ConnectionWrapper.execute(RepositoryConnectionPool.java:1129)                              
              at org.modeshape.graph.request.CompositeRequestChannel$2.call(CompositeRequestChannel.java:193)                                                      
              at org.modeshape.graph.request.CompositeRequestChannel$2.call(CompositeRequestChannel.java:183)                                                      
              at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)                                                                                
              at java.util.concurrent.FutureTask.run(FutureTask.java:138)                                                                                          
              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)                                                               
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)                                                                   
              at java.lang.Thread.run(Thread.java:662)         
      

      When debugging, I found that it happens when storing a property

      {http://www.jcp.org/jcr/1.0}

      predecessors = null

      it is the only property with null value

      Bar.java
      session = JCRFactoryUtil.createSession();
      
      Workspace workspace = session.getWorkspace();
      
      VersionManager versionManager = workspace.getVersionManager();
      
      Node rootNode = getRootNode(session, companyId);
      
      Node repositoryNode = getFolderNode(rootNode, repositoryId);
      
      if (repositoryNode.hasNode(fileName)) {
      	throw new DuplicateFileException(fileName);
      }
      else {
      	Node fileNode = repositoryNode.addNode(
      		fileName, JCRConstants.NT_FILE);
      
      	Node contentNode = fileNode.addNode(
      		JCRConstants.JCR_CONTENT, JCRConstants.NT_RESOURCE);
      
      	contentNode.addMixin(JCRConstants.MIX_VERSIONABLE);
      	contentNode.setProperty(
      		JCRConstants.JCR_MIME_TYPE, "text/plain");
      
      	ValueFactory valueFactory = session.getValueFactory();
      
      	Binary binary = valueFactory.createBinary(is);
      
      	contentNode.setProperty(JCRConstants.JCR_DATA, binary);
      
      	contentNode.setProperty(
      		JCRConstants.JCR_LAST_MODIFIED, Calendar.getInstance());
      
      	session.save();
      
      	Version version = versionManager.checkin(contentNode.getPath());
      
      	VersionHistory versionHistory =
      		versionManager.getVersionHistory(contentNode.getPath());
      
      	versionHistory.addVersionLabel(
      		version.getName(), VERSION_DEFAULT, false);
      
      <configuration xmlns:mode="http://www.modeshape.org/1.0"
      	xmlns:jcr="http://www.jcp.org/jcr/1.0">
      
      	<mode:sources jcr:primaryType="nt:unstructured">
      		<mode:source jcr:name="fileSystemSource"
      			mode:classname="org.modeshape.connector.filesystem.FileSystemSource"
      			mode:workspaceRootPath="/opt/liferay/bundles/data/modeshape/home"
      			mode:creatingWorkspacesAllowed="true" mode:updatesAllowed="true"
      			mode:extraPropertiesBehavior="store">
      			<defaultWorkspaceName>liferay</defaultWorkspaceName>
      			<predefinedWorkspaceNames>system</predefinedWorkspaceNames>
      			<predefinedWorkspaceNames>liferay</predefinedWorkspaceNames>
      		</mode:source>
      	</mode:sources>
      
      	<!-- Define the JCR repositories -->
      	<mode:repositories>
      		<mode:repository jcr:name="fileSystemRepo">
      			<mode:source>fileSystemSource</mode:source>
      			<!-- Define any custom node types. Importing CND files via JcrConfiguration 
      				is equivalent to specifying here. -->
      			<mode:option jcr:name="systemSourceName" mode:value="system@fileSystemSource" />
      		</mode:repository>
      	</mode:repositories>
      </configuration>
      

      Attachments

        Activity

          People

            rhauch Randall Hauch (Inactive)
            lisak_jira Jakub Liska (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: