Java Code Examples for org.alfresco.service.cmr.version.Version#getVersionProperty()
The following examples show how to use
org.alfresco.service.cmr.version.Version#getVersionProperty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseVersionStoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Helper method to check the validity of the list of newly created versions. * * @param beforeVersionTime the time before the versions where created * @param versions the collection of version objects */ private void checkVersionCollection(String expectedVersionLabel, long beforeVersionTime, Collection<Version> versions) { for (Version version : versions) { // Get the frozen id from the version String frozenNodeId = null; // Switch VersionStore depending on configured impl if (versionService.getVersionStoreReference().getIdentifier().equals(Version2Model.STORE_ID)) { // V2 version store (eg. workspace://version2Store) frozenNodeId = ((NodeRef)version.getVersionProperty(Version2Model.PROP_FROZEN_NODE_REF)).getId(); } else if (versionService.getVersionStoreReference().getIdentifier().equals(VersionModel.STORE_ID)) { // Deprecated V1 version store (eg. workspace://lightWeightVersionStore) frozenNodeId = (String)version.getVersionProperty(VersionModel.PROP_FROZEN_NODE_ID); } assertNotNull("Unable to retrieve the frozen node id from the created version.", frozenNodeId); // Get the original node ref (based on the forzen node) NodeRef origionaNodeRef = this.versionableNodes.get(frozenNodeId); assertNotNull("The versionable node ref that relates to the frozen node id can not be found.", origionaNodeRef); // Check the new version checkNewVersion(beforeVersionTime, expectedVersionLabel, version, origionaNodeRef); } }
Example 2
Source File: VersionServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Helper method to check the validity of the list of newly created versions. * * @param beforeVersionTime the time before the versions where created * @param versions the collection of version objects */ private void CheckVersionCollection(String expectedVersionLabel, long beforeVersionTime, Collection<Version> versions) { for (Version version : versions) { // Get the frozen id from the version String frozenNodeId = null; // Switch VersionStore depending on configured impl if (versionService.getVersionStoreReference().getIdentifier().equals(Version2Model.STORE_ID)) { // V2 version store (eg. workspace://version2Store) frozenNodeId = ((NodeRef)version.getVersionProperty(Version2Model.PROP_FROZEN_NODE_REF)).getId(); } else if (versionService.getVersionStoreReference().getIdentifier().equals(VersionModel.STORE_ID)) { // Deprecated V1 version store (eg. workspace://lightWeightVersionStore) frozenNodeId = (String)version.getVersionProperty(VersionModel.PROP_FROZEN_NODE_ID); } assertNotNull("Unable to retrieve the frozen node id from the created version.", frozenNodeId); // Get the origional node ref (based on the forzen node) NodeRef originalNodeRef = this.versionableNodes.get(frozenNodeId); assertNotNull("The versionable node ref that relates to the frozen node id can not be found.", originalNodeRef); // Check the new version checkNewVersion(beforeVersionTime, expectedVersionLabel, version, originalNodeRef); } }
Example 3
Source File: VersionServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * @see org.alfresco.service.cmr.version.VersionService#restore(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName, boolean) */ public NodeRef restore( NodeRef nodeRef, NodeRef parentNodeRef, QName assocTypeQName, QName assocQName, boolean deep) { if (logger.isDebugEnabled()) { logger.debug("Run as user " + AuthenticationUtil.getRunAsUser()); logger.debug("Fully authenticated " + AuthenticationUtil.getFullyAuthenticatedUser()); } NodeRef restoredNodeRef = null; // Check that the node does not exist if (this.nodeService.exists(nodeRef) == true) { // Error since you can not restore a node that already exists throw new VersionServiceException(MSGID_ERR_RESTORE_EXISTS, new Object[]{nodeRef.toString()}); } // Try and get the version details that we want to restore to Version version = getHeadVersion(nodeRef); if (version == null) { // Error since there is no version information available to restore the node from throw new VersionServiceException(MSGID_ERR_RESTORE_NO_VERSION, new Object[]{nodeRef.toString()}); } // Set the uuid of the new node Map<QName, Serializable> props = new HashMap<QName, Serializable>(1); props.put(ContentModel.PROP_NODE_UUID, version.getVersionProperty(VersionModel.PROP_FROZEN_NODE_ID)); // Get the type of the node node QName type = (QName)version.getVersionProperty(VersionModel.PROP_FROZEN_NODE_TYPE); // Disable auto-version behaviour this.policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE); try { // Create the restored node restoredNodeRef = this.nodeService.createNode( parentNodeRef, assocTypeQName, assocQName, type, props).getChildRef(); } finally { // Enable auto-version behaviour this.policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE); } // Now we need to revert the newly restored node revert(restoredNodeRef, version, deep); return restoredNodeRef; }