Java Code Examples for org.alfresco.service.cmr.repository.ChildAssociationRef#getQName()
The following examples show how to use
org.alfresco.service.cmr.repository.ChildAssociationRef#getQName() .
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: RepoTransferReceiverImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * move transfer node to new parent. * @param childNode * @param newParent */ private void moveNode(TransferManifestNormalNode childNode, TransferManifestNormalNode newParent) { List<ChildAssociationRef> currentParents = childNode.getParentAssocs(); List<ChildAssociationRef> newParents = new ArrayList<ChildAssociationRef>(); for (ChildAssociationRef parent : currentParents) { if (!parent.isPrimary()) { newParents.add(parent); } else { ChildAssociationRef newPrimaryAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, newParent .getNodeRef(), parent.getQName(), parent.getChildRef(), true, -1); newParents.add(newPrimaryAssoc); childNode.setPrimaryParentAssoc(newPrimaryAssoc); Path newParentPath = new Path(); newParentPath.append(newParent.getParentPath()); newParentPath.append(new Path.ChildAssocElement(newParent.getPrimaryParentAssoc())); childNode.setParentPath(newParentPath); } } childNode.setParentAssocs(newParents); }
Example 2
Source File: VirtualNodeServiceExtension.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private List<ChildAssociationRef> revertVirtualAssociation(ChildAssociationRef childAssocRef, NodeServiceTrait theTrait, NodeRef childRef) { childRef = smartStore.materialize(Reference.fromNodeRef(childRef)); ChildAssociationRef parent = theTrait.getPrimaryParent(childRef); final QName assocName = childAssocRef.getQName(); List<ChildAssociationRef> assocsToRemove = theTrait.getChildAssocs(parent.getParentRef(), childAssocRef.getTypeQName(), new QNamePattern() { @Override public boolean isMatch(QName qname) { return assocName .getLocalName() .equals(qname .getLocalName()); } }); return assocsToRemove; }
Example 3
Source File: MultiTServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public ChildAssociationRef getName(ChildAssociationRef childAssocRef) { if (childAssocRef == null) { return null; } return new ChildAssociationRef( childAssocRef.getTypeQName(), getName(childAssocRef.getParentRef()), childAssocRef.getQName(), getName(childAssocRef.getChildRef()), childAssocRef.isPrimary(), childAssocRef.getNthSibling()); }
Example 4
Source File: ScriptNode.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @return Helper to return the 'name' property for the node */ public String getName() { if (this.name == null) { // try and get the name from the properties first this.name = (String) getProperties().get("cm:name"); // if we didn't find it as a property get the name from the association name if (this.name == null) { ChildAssociationRef parentRef = this.nodeService.getPrimaryParent(this.nodeRef); if (parentRef != null && parentRef.getQName() != null) { this.name = parentRef.getQName().getLocalName(); } else { this.name = ""; } } } return this.name; }
Example 5
Source File: ThumbnailServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Map<String, FailedThumbnailInfo> getFailedThumbnails(NodeRef sourceNode) { Map<String, FailedThumbnailInfo> result = Collections.emptyMap(); if (nodeService.hasAspect(sourceNode, ContentModel.ASPECT_FAILED_THUMBNAIL_SOURCE)) { List<ChildAssociationRef> failedThumbnailChildren = nodeService.getChildAssocs(sourceNode, ContentModel.ASSOC_FAILED_THUMBNAIL, RegexQNamePattern.MATCH_ALL); result = new HashMap<String, FailedThumbnailInfo>(); for (ChildAssociationRef chAssRef : failedThumbnailChildren) { final QName failedThumbnailName = chAssRef.getQName(); NodeRef failedThumbnailNode = chAssRef.getChildRef(); Map<QName, Serializable> props = nodeService.getProperties(failedThumbnailNode); Date failureDateTime = (Date)props.get(ContentModel.PROP_FAILED_THUMBNAIL_TIME); int failureCount = (Integer)props.get(ContentModel.PROP_FAILURE_COUNT); final FailedThumbnailInfo failedThumbnailInfo = new FailedThumbnailInfo(failedThumbnailName.getLocalName(), failureDateTime, failureCount, failedThumbnailNode); result.put(failedThumbnailName.getLocalName(), failedThumbnailInfo); } } else { logger.debug(sourceNode + " does not have " + ContentModel.ASPECT_FAILED_THUMBNAIL_SOURCE + " aspect"); } return result; }
Example 6
Source File: DbNodeServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override @Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class) public boolean removeSecondaryChildAssociation(ChildAssociationRef childAssocRef) { // The node(s) involved may not be pending deletion checkPendingDelete(childAssocRef.getParentRef()); checkPendingDelete(childAssocRef.getChildRef()); Long parentNodeId = getNodePairNotNull(childAssocRef.getParentRef()).getFirst(); Long childNodeId = getNodePairNotNull(childAssocRef.getChildRef()).getFirst(); QName assocTypeQName = childAssocRef.getTypeQName(); QName assocQName = childAssocRef.getQName(); Pair<Long, ChildAssociationRef> assocPair = nodeDAO.getChildAssoc( parentNodeId, childNodeId, assocTypeQName, assocQName); if (assocPair == null) { // No association exists return false; } Long assocId = assocPair.getFirst(); ChildAssociationRef assocRef = assocPair.getSecond(); if (assocRef.isPrimary()) { throw new IllegalArgumentException( "removeSeconaryChildAssociation can not be applied to a primary association: \n" + " Child Assoc: " + assocRef); } // Delete the secondary association invokeBeforeDeleteChildAssociation(childAssocRef); nodeDAO.deleteChildAssoc(assocId); invokeOnDeleteChildAssociation(childAssocRef); // Done return true; }
Example 7
Source File: DbNodeServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class) public boolean removeChildAssociation(ChildAssociationRef childAssocRef) { // The node(s) involved may not be pending deletion checkPendingDelete(childAssocRef.getParentRef()); checkPendingDelete(childAssocRef.getChildRef()); Long parentNodeId = getNodePairNotNull(childAssocRef.getParentRef()).getFirst(); Long childNodeId = getNodePairNotNull(childAssocRef.getChildRef()).getFirst(); QName assocTypeQName = childAssocRef.getTypeQName(); QName assocQName = childAssocRef.getQName(); Pair<Long, ChildAssociationRef> assocPair = nodeDAO.getChildAssoc( parentNodeId, childNodeId, assocTypeQName, assocQName); if (assocPair == null) { // No association exists return false; } Long assocId = assocPair.getFirst(); ChildAssociationRef assocRef = assocPair.getSecond(); if (assocRef.isPrimary()) { NodeRef childNodeRef = assocRef.getChildRef(); // Delete the child node this.deleteNode(childNodeRef); // Done return true; } else { // Delete the association invokeBeforeDeleteChildAssociation(childAssocRef); nodeDAO.deleteChildAssoc(assocId); invokeOnDeleteChildAssociation(childAssocRef); // Done return true; } }
Example 8
Source File: NodeBrowserPost.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public ChildAssociation(ChildAssociationRef ref) { super(ref.getQName() != null ? ref.getQName() : null, ref.getTypeQName() != null ? ref.getTypeQName() : null); this.childRef = ref.getChildRef(); this.parentRef = ref.getParentRef(); // could be null if (childRef != null) this.childType = new QNameBean(getNodeType(childRef)); if (parentRef != null) this.parentType = new QNameBean(getNodeType(parentRef)); this.primary = ref.isPrimary(); }
Example 9
Source File: RenditionService2Impl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onContentUpdate(NodeRef sourceNodeRef, boolean newContent) { if (isEnabled()) { if (nodeService.exists(sourceNodeRef)) { logger.debug("onContentUpdate on " + sourceNodeRef); List<ChildAssociationRef> childAssocs = getRenditionChildAssociations(sourceNodeRef); for (ChildAssociationRef childAssoc : childAssocs) { NodeRef renditionNodeRef = childAssoc.getChildRef(); // TODO: This check will not be needed once the original RenditionService is removed. if (nodeService.hasAspect(renditionNodeRef, RenditionModel.ASPECT_RENDITION2)) { QName childAssocQName = childAssoc.getQName(); String renditionName = childAssocQName.getLocalName(); RenditionDefinition2 renditionDefinition = renditionDefinitionRegistry2.getRenditionDefinition(renditionName); if (renditionDefinition != null) { render(sourceNodeRef, renditionName); } else { logger.debug("onContentUpdate rendition " + renditionName + " only exists in the original rendition service."); } } } } else { logger.debug("onContentUpdate rendition " + sourceNodeRef + " does not exist."); } } }
Example 10
Source File: AbstractRenderingEngineTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Set up the rendition definition. * @param renditionAssoc ChildAssociationRef * @return RenditionDefinition */ private RenditionDefinition makeRenditionDefinition(ChildAssociationRef renditionAssoc) { String id = "definitionId"; RenditionDefinition definition = new RenditionDefinitionImpl(id, renditionAssoc.getQName(), TestRenderingEngine.NAME); definition.setRenditionAssociationType(renditionAssoc.getTypeQName()); definition.setRenditionParent(source); return definition; }
Example 11
Source File: GetChildAssocsMethod.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public List<ChildAssociationRef> execute(NodeProtocol protocol, Reference reference) throws ProtocolMethodException { NodeRef actualNodeRef = reference.execute(new GetActualNodeRefMethod(null)); NodeRef nodeRefReference = reference.toNodeRef(); List<ChildAssociationRef> referenceAssociations = new LinkedList<>(); if (!environment.isSubClass(environment.getType(nodeRefReference), ContentModel.TYPE_FOLDER)) { List<ChildAssociationRef> actualAssociations = environment.getChildAssocs(actualNodeRef, typeQNamePattern, qnamePattern, maxResults, preload); for (ChildAssociationRef actualAssoc : actualAssociations) { ChildAssociationRef referenceChildAssocRef = new ChildAssociationRef(actualAssoc.getTypeQName(), nodeRefReference, actualAssoc.getQName(), actualAssoc.getChildRef(), actualAssoc.isPrimary(), actualAssoc.getNthSibling()); referenceAssociations.add(referenceChildAssocRef); } } return referenceAssociations; }
Example 12
Source File: DocumentNavigator.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public boolean isDocument(Object o) { if (!(o instanceof ChildAssociationRef)) { return false; } ChildAssociationRef car = (ChildAssociationRef) o; return (car.getParentRef() == null) && (car.getQName() == null); }
Example 13
Source File: Node2ServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Assocs translation for version store * * @since 3.3 (Ent) */ @Override public List<AssociationRef> getTargetAssocs(NodeRef sourceRef, QNamePattern qnamePattern) { // Get the assoc references from the version store List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs( VersionUtil.convertNodeRef(sourceRef), Version2Model.CHILD_QNAME_VERSIONED_ASSOCS, qnamePattern); List<AssociationRef> result = new ArrayList<AssociationRef>(childAssocRefs.size()); for (ChildAssociationRef childAssocRef : childAssocRefs) { // Get the assoc reference NodeRef childRef = childAssocRef.getChildRef(); NodeRef referencedNode = (NodeRef)this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE); if (this.dbNodeService.exists(referencedNode)) { Long assocDbId = (Long)this.dbNodeService.getProperty(childRef, Version2Model.PROP_QNAME_ASSOC_DBID); // Build an assoc ref to add to the returned list AssociationRef newAssocRef = new AssociationRef( assocDbId, sourceRef, childAssocRef.getQName(), referencedNode); result.add(newAssocRef); } } return result; }
Example 14
Source File: Node2ServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Child Assocs translation for version store */ public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern) throws InvalidNodeRefException { // Get the child assoc references from the version store List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs( VersionUtil.convertNodeRef(nodeRef), typeQNamePattern, qnamePattern); List<ChildAssociationRef> result = new ArrayList<ChildAssociationRef>(childAssocRefs.size()); for (ChildAssociationRef childAssocRef : childAssocRefs) { if (! childAssocRef.getTypeQName().equals(Version2Model.CHILD_QNAME_VERSIONED_ASSOCS)) { // Get the child reference NodeRef childRef = childAssocRef.getChildRef(); NodeRef referencedNode = (NodeRef)this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE); if (this.dbNodeService.exists(referencedNode)) { // Build a child assoc ref to add to the returned list ChildAssociationRef newChildAssocRef = new ChildAssociationRef( childAssocRef.getTypeQName(), childAssocRef.getParentRef(), childAssocRef.getQName(), referencedNode, childAssocRef.isPrimary(), childAssocRef.getNthSibling()); result.add(newChildAssocRef); } } } // sort the results so that the order appears to be exactly as it was originally Collections.sort(result); return result; }
Example 15
Source File: VirtualNodeServiceExtensionTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private void setUpTestAssociations(NodeRef actualNodeRef) { rootChildrenQNames = new QName[13]; rootChildrenQNames[0] = QName.createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI, "Node2"); rootChildrenQNames[1] = QName.createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI, "Node1"); NodeRef node2 = nodeService.getChildByName(virtualFolder1NodeRef, ContentModel.ASSOC_CONTAINS, "Node2"); String node2ChildNameString = "test1_2.txt"; ChildAssociationRef node2ChildAssoc = createContent(node2, node2ChildNameString); node2Test1_2_TXTNodeRef = node2ChildAssoc.getChildRef(); rootChildrenQNames[2] = QName.createQNameWithValidLocalName(NamespaceService.CONTENT_MODEL_1_0_URI, node2ChildNameString); nodeService.setProperty(node2ChildAssoc.getChildRef(), ContentModel.PROP_TITLE, NODE2TEST1_2_TXT); node2ChildrenQNames = new QName[2]; node2ChildrenQNames[0] = QName.createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI, "Node2_1"); node2ChildrenQNames[1] = node2ChildAssoc.getQName(); NodeRef node2_1 = nodeService.getChildByName(node2, ContentModel.ASSOC_CONTAINS, "Node2_1"); node2_1ChildrenQNames = new QName[10]; for (int i = 1; i <= 10; i++) { ChildAssociationRef childAssoc = createContent(node2_1, "test" + i + "_2_1.txt"); rootChildrenQNames[2 + i] = QName.createQNameWithValidLocalName(NamespaceService.CONTENT_MODEL_1_0_URI, childAssoc.getQName().getLocalName()); node2_1ChildrenQNames[i - 1] = childAssoc.getQName(); } }
Example 16
Source File: RenditionedAspect.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map) */ public void onUpdateProperties( NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after) { if (this.nodeService.exists(nodeRef)) { // Find the changed properties List<QName> changedProperties = getChangedProperties(before, after); // There may be a different policy for different rendition kinds. List<ChildAssociationRef> renditions = getRenditionChildAssociations(nodeRef); for (ChildAssociationRef chAssRef : renditions) { final QName renditionAssocName = chAssRef.getQName(); // Rendition Definitions are persisted underneath the Data Dictionary for which Group ALL // has Consumer access by default. However, we cannot assume that that access level applies for all deployments. See ALF-7334. RenditionDefinition rendDefn = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<RenditionDefinition>() { @Override public RenditionDefinition doWork() throws Exception { return renditionService.loadRenditionDefinition(renditionAssocName); } }, AuthenticationUtil.getSystemUserName()); if (rendDefn == null) { if (logger.isDebugEnabled()) { // We will see this debug if a new RenditionService2 definition exists. StringBuilder msg = new StringBuilder(); msg.append("Cannot update rendition ") .append(renditionAssocName) .append(" on node ").append(nodeRef) .append(" as the renditionDefinition could not be loaded."); logger.debug(msg.toString()); } continue; } Serializable updateRenditionsPolicy = rendDefn.getParameterValue(AbstractRenderingEngine.PARAM_UPDATE_RENDITIONS_ON_ANY_PROPERTY_CHANGE); boolean updateRenditionsAlways = updateRenditionsPolicy == null ? false : (Boolean)updateRenditionsPolicy; boolean renditionUpdateRequired = false; for (QName qname : changedProperties) { try { PropertyDefinition propertyDef = dictionaryService.getProperty(qname); if (propertyDef == null) { // the property is not recognised continue; } else if (!propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT)) { // not a content type if (updateRenditionsAlways) { renditionUpdateRequired = true; } continue; } else { // it is a content property. We always update renditions for changes to content. renditionUpdateRequired = true; } } catch (ClassCastException ccx) { // the property does not confirm to the model continue; } } if (renditionUpdateRequired) { this.queueUpdate(nodeRef, rendDefn, chAssRef); } } } }
Example 17
Source File: IntegrityChecker.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * This handles the creation of secondary child associations. * * @see AssocSourceTypeIntegrityEvent * @see AssocTargetTypeIntegrityEvent * @see AssocSourceMultiplicityIntegrityEvent * @see AssocTargetMultiplicityIntegrityEvent * @see AssocTargetRoleIntegrityEvent */ public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNew) { if (isNew) { return; } if (! storesToIgnore.contains(tenantService.getBaseName(childAssocRef.getChildRef().getStoreRef()).toString())) { IntegrityEvent event = null; // check source type event = new AssocSourceTypeIntegrityEvent( nodeService, dictionaryService, childAssocRef.getParentRef(), childAssocRef.getTypeQName()); save(event); // check target type event = new AssocTargetTypeIntegrityEvent( nodeService, dictionaryService, childAssocRef.getChildRef(), childAssocRef.getTypeQName()); save(event); // check source multiplicity event = new AssocSourceMultiplicityIntegrityEvent( nodeService, dictionaryService, childAssocRef.getChildRef(), childAssocRef.getTypeQName(), false); save(event); // check target multiplicity event = new AssocTargetMultiplicityIntegrityEvent( nodeService, dictionaryService, childAssocRef.getParentRef(), childAssocRef.getTypeQName(), false); save(event); // check target role event = new AssocTargetRoleIntegrityEvent( nodeService, dictionaryService, childAssocRef.getParentRef(), childAssocRef.getTypeQName(), childAssocRef.getQName()); save(event); } }
Example 18
Source File: Node2ServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * {@inheritDoc} * <p> * * Implementation for version store v2 */ @Override public List<AssociationRef> getTargetAssocsByPropertyValue(NodeRef sourceRef, QNamePattern qnamePattern, QName propertyQName, Serializable propertyValue) { // If lightWeightVersionStore call default version store implementation. if (sourceRef.getStoreRef().getIdentifier().equals(VersionModel.STORE_ID)) { return super.getTargetAssocsByPropertyValue(sourceRef, qnamePattern, propertyQName, propertyValue); } // Get the assoc references from the version store. List<ChildAssociationRef> childAssocRefs = this.dbNodeService.getChildAssocs(VersionUtil.convertNodeRef(sourceRef), Version2Model.CHILD_QNAME_VERSIONED_ASSOCS, qnamePattern); List<AssociationRef> result = new ArrayList<AssociationRef>(childAssocRefs.size()); for (ChildAssociationRef childAssocRef : childAssocRefs) { // Get the assoc reference. NodeRef childRef = childAssocRef.getChildRef(); NodeRef referencedNode = (NodeRef) this.dbNodeService.getProperty(childRef, ContentModel.PROP_REFERENCE); if (this.dbNodeService.exists(referencedNode)) { Long assocDbId = (Long) this.dbNodeService.getProperty(childRef, Version2Model.PROP_QNAME_ASSOC_DBID); // Check if property type validation has to be done. if (propertyQName != null) { Serializable propertyValueRetrieved = this.dbNodeService.getProperty(referencedNode, propertyQName); // Check if property value has been retrieved (property // exists) and is equal to the requested value. if (propertyValueRetrieved == null || !propertyValueRetrieved.equals(propertyValue)) { continue; } } // Build an assoc ref to add to the returned list. AssociationRef newAssocRef = new AssociationRef(assocDbId, sourceRef, childAssocRef.getQName(), referencedNode); result.add(newAssocRef); } } return result; }
Example 19
Source File: ThumbnailServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * @see org.alfresco.service.cmr.thumbnail.ThumbnailService#updateThumbnail(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.TransformationOptions) */ public void updateThumbnail(final NodeRef thumbnail, final TransformationOptions transformationOptions) { if (logger.isDebugEnabled() == true) { logger.debug("Updating thumbnail (thumbnail=" + thumbnail.toString() + ")"); } // First check that we are dealing with a rendition object if (renditionService.isRendition(thumbnail)) { // Get the node that is the source of the thumbnail ChildAssociationRef parentAssoc = renditionService.getSourceNode(thumbnail); if (parentAssoc == null) { if (logger.isDebugEnabled() == true) { logger.debug("Updating thumbnail: The thumbnails parent cannot be found (thumbnail=" + thumbnail.toString() + ")"); } throw new ThumbnailException(ERR_NO_PARENT); } final QName renditionAssociationName = parentAssoc.getQName(); NodeRef sourceNode = parentAssoc.getParentRef(); // Get the content property QName contentProperty = (QName)nodeService.getProperty(thumbnail, ContentModel.PROP_CONTENT_PROPERTY_NAME); // Set the basic detail of the transformation options transformationOptions.setSourceNodeRef(sourceNode); transformationOptions.setSourceContentProperty(contentProperty); transformationOptions.setTargetContentProperty(ContentModel.PROP_CONTENT); // Do the thumbnail transformation. Rendition Definitions are persisted underneath the Data Dictionary for which Group ALL // has Consumer access by default. However, we cannot assume that that access level applies for all deployments. See ALF-7334. RenditionDefinition rendDefn = AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<RenditionDefinition>() { @Override public RenditionDefinition doWork() throws Exception { return renditionService.loadRenditionDefinition(renditionAssociationName); } }, AuthenticationUtil.getSystemUserName()); if (rendDefn == null) { String renderingEngineName = getRenderingEngineNameFor(transformationOptions); rendDefn = renditionService.createRenditionDefinition(parentAssoc.getQName(), renderingEngineName); } Map<String, Serializable> params = thumbnailRegistry.getThumbnailRenditionConvertor().convert(transformationOptions, null); for (String key : params.keySet()) { rendDefn.setParameterValue(key, params.get(key)); } renditionService.render(sourceNode, rendDefn); } else { if (logger.isDebugEnabled() == true) { logger.debug("Updating thumbnail: cannot update a thumbnail node that isn't the correct thumbnail type (thumbnail=" + thumbnail.toString() + ")"); } } }
Example 20
Source File: DbNodeServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private NodeRef restoreNodeImpl(NodeRef archivedNodeRef, NodeRef destinationParentNodeRef, QName assocTypeQName, QName assocQName) { Pair<Long, NodeRef> archivedNodePair = getNodePairNotNull(archivedNodeRef); Long archivedNodeId = archivedNodePair.getFirst(); Set<QName> existingAspects = nodeDAO.getNodeAspects(archivedNodeId); Set<QName> newAspects = new HashSet<QName>(5); Map<QName, Serializable> existingProperties = nodeDAO.getNodeProperties(archivedNodeId); Map<QName, Serializable> newProperties = new HashMap<QName, Serializable>(11); // the node must be a top-level archive node if (!existingAspects.contains(ContentModel.ASPECT_ARCHIVED)) { throw new AlfrescoRuntimeException("The node to restore is not an archive node"); } // Remove the secondary link to the user that deleted the node List<ChildAssociationRef> parentAssocsToRemove = getParentAssocs( archivedNodeRef, ContentModel.ASSOC_ARCHIVED_LINK, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef parentAssocToRemove : parentAssocsToRemove) { this.removeSecondaryChildAssociation(parentAssocToRemove); } ChildAssociationRef originalPrimaryParentAssocRef = (ChildAssociationRef) existingProperties.get( ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC); Serializable originalOwner = existingProperties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_OWNER); // remove the archived aspect Set<QName> removePropertyQNames = new HashSet<QName>(11); Set<QName> removeAspectQNames = new HashSet<QName>(3); removePropertyQNames.add(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC); removePropertyQNames.add(ContentModel.PROP_ARCHIVED_BY); removePropertyQNames.add(ContentModel.PROP_ARCHIVED_DATE); removePropertyQNames.add(ContentModel.PROP_ARCHIVED_ORIGINAL_OWNER); removeAspectQNames.add(ContentModel.ASPECT_ARCHIVED); // restore the original ownership if (originalOwner == null || originalOwner.equals(OwnableService.NO_OWNER)) { // The ownable aspect was not present before removeAspectQNames.add(ContentModel.ASPECT_OWNABLE); removePropertyQNames.add(ContentModel.PROP_OWNER); } else { newAspects.add(ContentModel.ASPECT_OWNABLE); newProperties.put(ContentModel.PROP_OWNER, originalOwner); } // Prepare the node for restoration: remove old aspects and properties; add new aspects and properties nodeDAO.removeNodeProperties(archivedNodeId, removePropertyQNames); nodeDAO.removeNodeAspects(archivedNodeId, removeAspectQNames); nodeDAO.addNodeProperties(archivedNodeId, newProperties); nodeDAO.addNodeAspects(archivedNodeId, newAspects); if (destinationParentNodeRef == null) { // we must restore to the original location destinationParentNodeRef = originalPrimaryParentAssocRef.getParentRef(); } // check the associations if (assocTypeQName == null) { assocTypeQName = originalPrimaryParentAssocRef.getTypeQName(); } if (assocQName == null) { assocQName = originalPrimaryParentAssocRef.getQName(); } // move the node to the target parent, which may or may not be the original parent ChildAssociationRef newChildAssocRef = moveNode( archivedNodeRef, destinationParentNodeRef, assocTypeQName, assocQName); // the node reference has changed due to the store move NodeRef restoredNodeRef = newChildAssocRef.getChildRef(); invokeOnRestoreNode(newChildAssocRef); // done if (logger.isDebugEnabled()) { logger.debug("Restored node: \n" + " original noderef: " + archivedNodeRef + "\n" + " restored noderef: " + restoredNodeRef + "\n" + " new parent: " + destinationParentNodeRef); } return restoredNodeRef; }