public NodeRef getNodeRef(int n) { return cars.get(n).getChildRef(); }
private List<NodeRef> getCurrentItems(NodeRef packageRef) { List<ChildAssociationRef> children = nodeService.getChildAssocs( packageRef, PCKG_CONTAINS, RegexQNamePattern.MATCH_ALL); ArrayList<NodeRef> results = new ArrayList<NodeRef>(children.size()); for (ChildAssociationRef child : children) { results.add(child.getChildRef()); } return results; }
private List<CategoryTemplateNode> buildCategoryNodeList(Collection<ChildAssociationRef> childRefs) { List<CategoryTemplateNode> answer = new ArrayList<CategoryTemplateNode>(childRefs.size()); for (ChildAssociationRef ref : childRefs) { // create our Node representation from the NodeRef CategoryTemplateNode child = new CategoryTemplateNode(ref.getChildRef(), this.services, this.imageResolver); answer.add(child); } return answer; }
private CredentialsPagingResults(List<ChildAssociationRef> refs, int size, boolean hasMore, String remoteSystem) { this.size = size; this.hasMore = hasMore; this.results = new ArrayList<BaseCredentialsInfo>(refs.size()); for (ChildAssociationRef ref : refs) { this.results.add( loadCredentials(remoteSystem, ref.getParentRef(), ref.getChildRef()) ); } }
/** * Returns the System Container for the current tenant */ public static NodeRef getSystemContainer(final NodeService nodeService, final Repository repositoryHelper) { // Grab the root of the repository, for the current tennant final NodeRef root = repositoryHelper.getRootHome(); // Locate the system folder, in the root List<ChildAssociationRef> sysRefs = nodeService.getChildAssocs( root, ContentModel.ASSOC_CHILDREN, SYSTEM_FOLDER_QNAME); if (sysRefs.size() != 1) { throw new IllegalStateException("System folder missing / duplicated! Found " + sysRefs); } final NodeRef system = sysRefs.get(0).getChildRef(); return system; }
private NodeRef createTransferRecord(String transferId) { log.debug("TransferSummaryReport createTransferRecord"); NodeRef reportParentFolder = getParentFolder(); String name = getReportFileName(reportParentFolder); QName recordName = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, name); Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_NAME, name); props.put(TransferModel.PROP_PROGRESS_POSITION, 0); props.put(TransferModel.PROP_PROGRESS_ENDPOINT, 1); props.put(TransferModel.PROP_TRANSFER_STATUS, TransferProgress.Status.PRE_COMMIT.toString()); log.debug("Creating transfer summary report with name: " + name); ChildAssociationRef assoc = nodeService.createNode(reportParentFolder, ContentModel.ASSOC_CONTAINS, recordName, TransferModel.TYPE_TRANSFER_RECORD, props); log.debug("<-createTransferSummartReportRecord: " + assoc.getChildRef()); return assoc.getChildRef(); }
/** * @return The child associations for this Node. As a Map of assoc name to a List of TemplateNodes. */ public Map<String, List<TemplateNode>> getChildAssocs() { if (this.childAssocs == null) { List<ChildAssociationRef> refs = this.services.getNodeService().getChildAssocs(this.nodeRef); this.childAssocs = new QNameMap<String, List<TemplateNode>>(this); for (ChildAssociationRef ref : refs) { String qname = ref.getTypeQName().toString(); List<TemplateNode> nodes = this.childAssocs.get(qname); if (nodes == null) { // first access for the list for this qname nodes = new ArrayList<TemplateNode>(4); this.childAssocs.put(ref.getTypeQName().toString(), nodes); } nodes.add( new TemplateNode(ref.getChildRef(), this.services, this.imageResolver) ); } } return this.childAssocs; }
protected void createEncryptedProperties(List<NodeRef> nodes) { for(int i = 0; i < NUM_PROPERTIES; i++) { NodeRef nodeRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("assoc1"), NODE_TYPE).getChildRef(); nodes.add(nodeRef); Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(PROP, nodeRef.toString()); props = metadataEncryptor.encrypt(props); nodeService.setProperties(nodeRef, props); } }
protected Map<String, Serializable> getVersionMetaData(NodeRef versionNodeRef) { // Get the meta data List<ChildAssociationRef> metaData = this.dbNodeService.getChildAssocs( versionNodeRef, RegexQNamePattern.MATCH_ALL, CHILD_QNAME_VERSION_META_DATA); Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(metaData.size()); for (ChildAssociationRef ref : metaData) { NodeRef metaDataValue = (NodeRef)ref.getChildRef(); String name = (String)this.dbNodeService.getProperty(metaDataValue, PROP_QNAME_META_DATA_NAME); Serializable value = this.dbNodeService.getProperty(metaDataValue, PROP_QNAME_META_DATA_VALUE); versionProperties.put(name, value); } return versionProperties; }
private Rating removeRating(NodeRef targetNode, String ratingSchemeName, final String user) { List<ChildAssociationRef> ratingChildren = getRatingNodeChildren(targetNode, ratingSchemeName, user); if (ratingChildren.isEmpty()) { return null; } ChildAssociationRef child = ratingChildren.get(0); Map<QName, Serializable> properties = nodeService.getProperties(child.getChildRef()); Rating result = null; // If the rating is for the specified scheme delete it. // Get the scheme name and check it. if (ratingSchemeName.equals(properties.get(ContentModel.PROP_RATING_SCHEME))) { Float score = (Float) properties.get(ContentModel.PROP_RATING_SCORE); Date date = (Date)properties.get(ContentModel.PROP_RATED_AT); nodeService.deleteNode(child.getChildRef()); recalculateRatingRollups(targetNode, getRatingScheme(ratingSchemeName)); result = new Rating(getRatingScheme(ratingSchemeName), score, user, date); } return result; }
public Iterator getAttributeAxisIterator(Object o) throws UnsupportedAxisException { ArrayList<Property> properties = new ArrayList<Property>(); NodeRef nodeRef = ((ChildAssociationRef) o).getChildRef(); Map<QName, Serializable> map = nodeService.getProperties(nodeRef); for (QName qName : map.keySet()) { if(map.get(qName) instanceof Collection) { for(Serializable ob : (Collection<Serializable>) map.get(qName)) { Property property = new Property(qName, ob, nodeRef); properties.add(property); } } else { Property property = new Property(qName, map.get(qName), nodeRef); properties.add(property); } } return properties.iterator(); }
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); result.put(failedThumbnailName.getLocalName(), failedThumbnailInfo);
@Commit @Test public void testDuplicateChildAssocCleanup() throws Exception { Map<QName, ChildAssociationRef> assocRefs = buildNodeGraph(); NodeRef n1Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"root_p_n1")).getChildRef(); ChildAssociationRef n1pn3Ref = assocRefs.get(QName.createQName(BaseNodeServiceTest.NAMESPACE,"n1_p_n3")); // Recreate the association from n1 to n3 i.e. duplicate it QName assocQName = QName.createQName(BaseNodeServiceTest.NAMESPACE, "dup"); ChildAssociationRef dup1 = nodeService.addChild( n1pn3Ref.getParentRef(), n1pn3Ref.getChildRef(), n1pn3Ref.getTypeQName(), assocQName); ChildAssociationRef dup2 = nodeService.addChild( n1pn3Ref.getParentRef(), n1pn3Ref.getChildRef(), n1pn3Ref.getTypeQName(), assocQName); assertEquals("Duplicate not created", dup1, dup2); List<ChildAssociationRef> dupAssocs = nodeService.getChildAssocs(n1pn3Ref.getParentRef(), n1pn3Ref.getTypeQName(), assocQName); assertEquals("Expected duplicates", 2, dupAssocs.size()); // Now delete the specific association nodeService.removeChildAssociation(dup1); }
private CredentialsPagingResults(List<ChildAssociationRef> refs, int size, boolean hasMore, String remoteSystem) { this.size = size; this.hasMore = hasMore; this.results = new ArrayList<BaseCredentialsInfo>(refs.size()); for (ChildAssociationRef ref : refs) { this.results.add( loadCredentials(remoteSystem, ref.getParentRef(), ref.getChildRef()) ); } }
/** * Returns the NodeRef of a given Child Container within the current Tenant's * System Container, if found */ public static NodeRef getSystemChildContainer(final QName childName, final NodeService nodeService, final Repository repositoryHelper) { NodeRef system = getSystemContainer(nodeService, repositoryHelper); // Find the container, under system List<ChildAssociationRef> containerRefs = nodeService.getChildAssocs( system, ContentModel.ASSOC_CHILDREN, childName); NodeRef container = null; if (containerRefs.size() > 0) { container = containerRefs.get(0).getChildRef(); if (containerRefs.size() > 1) logger.warn("Duplicate Shared Credentials Containers found: " + containerRefs); } return container; }
private NodeRef saveActionCondition(NodeRef actionNodeRef, ActionCondition actionCondition, QName AssociationQName, QName typeName) { Map<QName, Serializable> props = new HashMap<QName, Serializable>(2); props.put(ActionModel.PROP_DEFINITION_NAME, actionCondition.getActionConditionDefinitionName()); props.put(ContentModel.PROP_NODE_UUID, actionCondition.getId()); NodeRef conditionNodeRef = this.nodeService.createNode(actionNodeRef, AssociationQName, AssociationQName, typeName, props).getChildRef(); saveConditionProperties(conditionNodeRef, actionCondition); saveParameters(conditionNodeRef, actionCondition); return conditionNodeRef; }
/** * @return The child associations for this Node. As a Map of assoc name to a List of TemplateNodes. */ public Map<String, List<TemplateNode>> getChildAssocs() { if (this.childAssocs == null) { List<ChildAssociationRef> refs = this.services.getNodeService().getChildAssocs(this.nodeRef); this.childAssocs = new QNameMap<String, List<TemplateNode>>(this); for (ChildAssociationRef ref : refs) { String qname = ref.getTypeQName().toString(); List<TemplateNode> nodes = this.childAssocs.get(qname); if (nodes == null) { // first access for the list for this qname nodes = new ArrayList<TemplateNode>(4); this.childAssocs.put(ref.getTypeQName().toString(), nodes); } nodes.add( new TemplateNode(ref.getChildRef(), this.services, this.imageResolver) ); } } return this.childAssocs; }
@Before public void createTestFolder() { initContextAndCreateUser(); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); final NodeRef companyHome = repositoryHelper.getCompanyHome(); Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_NAME, this.getClass() + "_testFolder"); testFolder = nodeService.createNode(companyHome, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS, ContentModel.TYPE_FOLDER, props).getChildRef(); // Let anyone (meaning non-admin) do anything (meaning create new content) permissionService.setPermission(testFolder, PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS, true); this.nodesToBeTidiedUp.add(testFolder); }
protected Map<String, Serializable> getVersionMetaData(NodeRef versionNodeRef) { // Get the meta data List<ChildAssociationRef> metaData = this.dbNodeService.getChildAssocs( versionNodeRef, RegexQNamePattern.MATCH_ALL, CHILD_QNAME_VERSION_META_DATA); Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(metaData.size()); for (ChildAssociationRef ref : metaData) { NodeRef metaDataValue = (NodeRef)ref.getChildRef(); String name = (String)this.dbNodeService.getProperty(metaDataValue, PROP_QNAME_META_DATA_NAME); Serializable value = this.dbNodeService.getProperty(metaDataValue, PROP_QNAME_META_DATA_VALUE); versionProperties.put(name, value); } return versionProperties; }
private List<CategoryTemplateNode> buildCategoryNodeList(Collection<ChildAssociationRef> childRefs) { List<CategoryTemplateNode> answer = new ArrayList<CategoryTemplateNode>(childRefs.size()); for (ChildAssociationRef ref : childRefs) { // create our Node representation from the NodeRef CategoryTemplateNode child = new CategoryTemplateNode(ref.getChildRef(), this.services, this.imageResolver); answer.add(child); } return answer; }