org.alfresco.service.namespace.QName Java Examples

The following examples show how to use org.alfresco.service.namespace.QName. 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: ScriptNodeTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * MNT-9369
 * <p>
 * Initially the ContentModel.PROP_AUTO_VERSION and ContentModel.PROP_AUTO_VERSION_PROPS are true by defaults.
 */
@Test
public void testVersioningPropsDefault()
{
    createTestContent(false);
    Map<QName, PropertyDefinition> versionableProps = DICTIONARY_SERVICE.getAspect(ContentModel.ASPECT_VERSIONABLE).getProperties();
    autoVersion = Boolean.parseBoolean(versionableProps.get(ContentModel.PROP_AUTO_VERSION).getDefaultValue());
    autoVersionProps = Boolean.parseBoolean(versionableProps.get(ContentModel.PROP_AUTO_VERSION_PROPS).getDefaultValue());

    TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            log.debug("Adding versionable aspect.");

            ScriptNode sn = new ScriptNode(testNode, SERVICE_REGISTRY);
            sn.addAspect("cm:versionable");
            return null;
        }
    });

    assertEquals("Incorrect Auto Version property.", autoVersion, NODE_SERVICE.getProperty(testNode, ContentModel.PROP_AUTO_VERSION));
    assertEquals("Incorrect Auto Version Props property.", autoVersionProps, NODE_SERVICE.getProperty(testNode, ContentModel.PROP_AUTO_VERSION_PROPS));
}
 
Example #2
Source File: MailMetadataExtracterTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * We have different things to normal, so
 *  do our own common tests.
 */
protected void testCommonMetadata(String mimetype, Map<QName, Serializable> properties)
{
    // Two equivalent ones
    assertEquals(
            "Property " + ContentModel.PROP_AUTHOR + " not found for mimetype " + mimetype,
            "Mark Rogers",
            DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_AUTHOR)));
    assertEquals(
          "Property " + ContentModel.PROP_ORIGINATOR + " not found for mimetype " + mimetype,
          "Mark Rogers",
          DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_ORIGINATOR)));
    // One other common bit
    assertEquals(
            "Property " + ContentModel.PROP_DESCRIPTION + " not found for mimetype " + mimetype,
            "This is a quick test",
            DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_DESCRIPTION)));
}
 
Example #3
Source File: ScriptRenditionService.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private RenditionDefinition loadRenditionDefinitionImpl(String shortOrLongFormQName)
{
    final QName renditionName = createQName(shortOrLongFormQName);
    
    // 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(renditionName);
            }
        }, AuthenticationUtil.getSystemUserName());
    return rendDefn;
}
 
Example #4
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testCanCheckInWhenOriginalHasUndeletableAspect()
{
    nodeService.addAspect(nodeRef, ContentModel.ASPECT_UNDELETABLE, null);
    // Pre-condition of test, original must have sys:undeletable
    assertTrue(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_UNDELETABLE));

    // Check-out nodeRef
    NodeRef workingCopy = this.cociService.checkout(
            this.nodeRef,
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("workingCopy"));
    assertNotNull(workingCopy);

    // Check that the working copy does not have the sys:undeletable aspect
    assertFalse(nodeService.hasAspect(workingCopy, ContentModel.ASPECT_UNDELETABLE));

    // Check-in: must work despite original having the sys:undeletable aspect (MNT-18546)
    Map<String, Serializable> versionProperties = new HashMap<String, Serializable>();
    versionProperties.put(Version.PROP_DESCRIPTION, "This is a test version");
    cociService.checkin(workingCopy, versionProperties);
}
 
Example #5
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private NodeRef createFolderWithPermission(NodeRef parent, String username, String permission)
{
    // Authenticate as system user because the current user should not be node owner
    AuthenticationComponent authenticationComponent = (AuthenticationComponent) this.applicationContext.getBean("authenticationComponent");
    authenticationComponent.setSystemUserAsCurrentUser();

    // Create the folder
    NodeRef folder = nodeService.createNode(
            parent, 
            ContentModel.ASSOC_CHILDREN, 
            QName.createQName("TestFolder" + GUID.generate()), 
            ContentModel.TYPE_CONTENT).getChildRef();

    // Apply permissions to folder
    permissionService.deletePermissions(folder);
    permissionService.setInheritParentPermissions(folder, false);
    permissionService.setPermission(folder, userName, permission, true);

    // Authenticate test user
    TestWithUserUtils.authenticateUser(this.userName, PWD, this.rootNodeRef, this.authenticationService);

    return folder;
}
 
Example #6
Source File: Version2ServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new version history node, applying the root version aspect is required
 *
 * @param nodeRef   the node ref
 * @return          the version history node reference
 */
protected NodeRef createVersionHistory(NodeRef nodeRef)
{
    long start = System.currentTimeMillis();
    
    HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(ContentModel.PROP_NAME, nodeRef.getId());
    props.put(Version2Model.PROP_QNAME_VERSIONED_NODE_ID, nodeRef.getId());

    // Create a new version history node
    ChildAssociationRef childAssocRef = this.dbNodeService.createNode(
            getRootNode(),
            Version2Model.CHILD_QNAME_VERSION_HISTORIES,
            QName.createQName(Version2Model.NAMESPACE_URI, nodeRef.getId()),
            Version2Model.TYPE_QNAME_VERSION_HISTORY,
            props);
    
    if (logger.isTraceEnabled())
    {
        logger.trace("created version history nodeRef: " + childAssocRef.getChildRef() + " for " + nodeRef + " in "+(System.currentTimeMillis()-start)+" ms");
    }
    
    return childAssocRef.getChildRef();
}
 
Example #7
Source File: QuickShareRestApiTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private NodeRef createTestFile(final NodeRef parent, final String name, final File quickFile)
{
	return transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
    {
        public NodeRef execute() throws Throwable
        {
            Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
            props.put(ContentModel.PROP_NAME, name);
            ChildAssociationRef result = nodeService.createNode(parent,
                                                    ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS,
                                                    ContentModel.TYPE_CONTENT, props);
            
            NodeRef nodeRef = result.getChildRef();
            ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
            writer.setMimetype(TEST_MIMETYPE_JPEG);
            writer.putContent(quickFile);
            
            return nodeRef;
        }
    });
}
 
Example #8
Source File: NodeDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected int updateChildAssocIndex(
        Long parentNodeId,
        Long childNodeId,
        QName assocTypeQName,
        QName assocQName,
        int index)
{
    ChildAssocEntity assoc = new ChildAssocEntity();
    // Parent
    NodeEntity parentNode = new NodeEntity();
    parentNode.setId(parentNodeId);
    assoc.setParentNode(parentNode);
    // Child
    NodeEntity childNode = new NodeEntity();
    childNode.setId(childNodeId);
    assoc.setChildNode(childNode);
    // Type QName
    assoc.setTypeQNameAll(qnameDAO, assocTypeQName, true);
    // QName
    assoc.setQNameAll(qnameDAO, assocQName, true);
    // Index
    assoc.setAssocIndex(index);
    
    return template.update(UPDATE_CHILD_ASSOCS_INDEX, assoc);
}
 
Example #9
Source File: VirtualCheckOutCheckInServiceExtension.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public NodeRef checkout(NodeRef nodeRef, NodeRef destinationParentNodeRef, QName destinationAssocTypeQName,
            QName destinationAssocQName)
{
    CheckOutCheckInServiceTrait theTrait = getTrait();
    NodeRef materialNodeRef = smartStore.materializeIfPossible(nodeRef);
    NodeRef materialDestination = smartStore.materializeIfPossible(destinationParentNodeRef);
    NodeRef workingCopy = theTrait.checkout(materialNodeRef,
                                            materialDestination,
                                            destinationAssocTypeQName,
                                            destinationAssocQName);

    Reference parentReference = Reference.fromNodeRef(destinationParentNodeRef);
    if (parentReference != null)
    {
        Reference workingCopyReference = NodeProtocol.newReference(workingCopy,
                                                                   parentReference);
        return workingCopyReference.toNodeRef(workingCopy.getStoreRef());
    }
    else
    {
        return workingCopy;
    }

}
 
Example #10
Source File: FieldProcessorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Map<QName, PropertyDefinition> makePropertyDefs()
{
    QName dataTypeName = QName.createQName(URI, "Type");
    PropertyDefinition propDef1 = MockClassAttributeDefinition.mockPropertyDefinition(
            qName1, dataTypeName,
            null,// Defalt title, so sets label to be same as name.
            DESCRIPTION1, false,
            "Default1", false, false);
    PropertyDefinition propDef2 = MockClassAttributeDefinition.mockPropertyDefinition(
            qName2, dataTypeName,
            TITLE,
            DESCRIPTION2, true,
            "Default2", true, true);
    Map<QName, PropertyDefinition> propDefs = new HashMap<QName, PropertyDefinition>();
    propDefs.put(qName1, propDef1);
    propDefs.put(qName2, propDef2);
    return propDefs;
}
 
Example #11
Source File: LuceneCategoryServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName qname)
{
    ResultSet resultSet = null;
    try
    {
        resultSet = indexerAndSearcher.getSearcher(storeRef, false).query(storeRef, "lucene",
                "PATH:\"/" + getPrefix(qname.getNamespaceURI()) + ISO9075.encode(qname.getLocalName()) + "\"", null);
        
        Set<NodeRef> nodeRefs = new HashSet<NodeRef>(resultSet.length());
        for (ResultSetRow row : resultSet)
        {
            nodeRefs.add(row.getNodeRef());
        }
        
        return nodeRefs;
    }
    finally
    {
        if (resultSet != null)
        {
            resultSet.close();
        }
    }
}
 
Example #12
Source File: UserCSVUploadGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected List<Pair<QName, Boolean>> buildPropertiesForHeader(
		Object resource, String format, WebScriptRequest req) {
	List<Pair<QName,Boolean>> properties = 
		new ArrayList<Pair<QName,Boolean>>(UserCSVUploadPost.COLUMNS.length);
	boolean required = true;
	for(QName qname : UserCSVUploadPost.COLUMNS) 
	{
		Pair<QName,Boolean> p = null;
		if(qname != null)
		{
			p = new Pair<QName, Boolean>(qname, required);
		}
		else
		{
			required = false;
		}
		properties.add(p);
	}
	return properties;
}
 
Example #13
Source File: UpgradePasswordHashTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private NodeRef createUser(String caseSensitiveUserName, char[] password, String encoding)
{
    try
    {
        repositoryAuthenticationDao.createUser(caseSensitiveUserName,password);
    } catch (AuthenticationException e)
    {
       if (!e.getMessage().contains("User already exists")) { throw e; }
    }

    NodeRef userNodeRef = repositoryAuthenticationDao.getUserOrNull(caseSensitiveUserName);
    if (userNodeRef == null)
    {
        throw new AuthenticationException("User name does not exist: " + caseSensitiveUserName);
    }
    Map<QName, Serializable> properties = nodeService.getProperties(userNodeRef);
    properties.remove(ContentModel.PROP_PASSWORD_HASH);
    properties.remove(ContentModel.PROP_HASH_INDICATOR);
    properties.remove(ContentModel.PROP_PASSWORD);
    properties.remove(ContentModel.PROP_PASSWORD_SHA256);
    String encoded =  compositePasswordEncoder.encode(encoding,new String(password), null);
    properties.put("sha256".equals(encoding)?ContentModel.PROP_PASSWORD_SHA256:ContentModel.PROP_PASSWORD, encoded);

    nodeService.setProperties(userNodeRef, properties);
    return userNodeRef;
}
 
Example #14
Source File: NodeContext.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Construct
 * 
 * @param elementName QName
 * @param parentContext ParentContext
 * @param typeDef TypeDefinition
 */
public NodeContext(QName elementName, ParentContext parentContext, TypeDefinition typeDef)
{
    super(elementName, parentContext.getDictionaryService(), parentContext.getImporter());
    this.parentContext = parentContext;
    this.typeDef = typeDef;
    this.uuid = null;
}
 
Example #15
Source File: AuthenticationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Test for ACE-4909
 */
public void testCheckUserDisabledTenant()
{
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    String domainName = "ace4909.domain";
    String userName = "ace4909" + TenantService.SEPARATOR + domainName;
    Map<QName, Serializable> props = createPersonProperties(userName);
    NodeRef userNodeRef = personService.createPerson(props);
    assertNotNull(userNodeRef);
    authenticationService.createAuthentication(userName, "passwd".toCharArray());
    tenantAdminService.createTenant(domainName, TENANT_ADMIN_PW.toCharArray(), null);
    tenantAdminService.disableTenant(domainName);
    assertTrue("The user should exist", dao.userExists(userName));
}
 
Example #16
Source File: WorkflowQNameConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Map QName to workflow variable name
 * 
 * @param name  QName
 * @return  workflow variable name
 */
public QName mapNameToQName(String name)
{
    QName qName = cache.getQName(name);
    if (qName == null)
    {
        qName = convertNameToQName(name);
        cache.putNameToQName(name, qName);
        cache.putQNameToName(qName, name);
    }
    return qName;
}
 
Example #17
Source File: RhinoScriptProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @see org.alfresco.service.cmr.repository.ScriptProcessor#execute(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.util.Map)
 */
public Object execute(NodeRef nodeRef, QName contentProp, Map<String, Object> model)
{
    try
    {
        if (this.services.getNodeService().exists(nodeRef) == false)
        {
            throw new AlfrescoRuntimeException("Script Node does not exist: " + nodeRef);
        }
        
        if (contentProp == null)
        {
            contentProp = ContentModel.PROP_CONTENT;
        }
        ContentReader cr = this.services.getContentService().getReader(nodeRef, contentProp);
        if (cr == null || cr.exists() == false)
        {
            throw new AlfrescoRuntimeException("Script Node content not found: " + nodeRef);
        }
        
        // compile the script based on the node content
        Script script;
        Context cx = Context.enter();
        try
        {
            script = cx.compileString(resolveScriptImports(cr.getContentString()), nodeRef.toString(), 1, null);
        }
        finally
        {
            Context.exit();
        }
        
        return executeScriptImpl(script, model, false, nodeRef.toString());
    }
    catch (Throwable err)
    {
        throw new ScriptException("Failed to execute script '" + nodeRef.toString() + "': " + err.getMessage(), err);
    }
}
 
Example #18
Source File: FileFolderServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public PagingResults<FileInfo> list(final NodeRef contextNodeRef, final boolean files, final boolean folders,
            final String pattern, final Set<QName> ignoreQNames, final List<Pair<QName, Boolean>> sortProps,
            final PagingRequest pagingRequest)
{
    return thisService.list(contextNodeRef,
                            files,
                            folders,
                            pattern,
                            ignoreQNames,
                            sortProps,
                            pagingRequest);
}
 
Example #19
Source File: ChainingUserRegistrySynchronizerTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * <p>Test that an attribute is also removed on the Alfresco side, when it's removed at the AD level.</p> 
 * <p>MNT-14026: LDAP sync fails to update attribute's value deletion.</p>
 */
public void testSyncDeletedProperty() throws Exception
{
    try
    {
        logger.info("testSyncDeletedProperty executing..");
        // Execute an LDAP sync where the AD server returns the attributes of a person, including the 'mail' property.
        executeMockedLDAPSyncWithActiveDirectoryEmailProp();

        Map<QName, Serializable> userProperties = this.nodeService.getProperties(this.personService.getPerson("U1"));
        assertTrue("User's email must be not null.", userProperties.get(ContentModel.PROP_EMAIL).equals("[email protected]"));

        // Execute an LDAP sync where the AD server returns the attributes
        // of a person without the 'mail' property, because it was deleted.
        executeMockedLDAPSyncWithoutActiveDirectoryEmailProp();

        userProperties = this.nodeService.getProperties(this.personService.getPerson("U1"));
        assertTrue("User must have the email property even though it's null", userProperties.containsKey(ContentModel.PROP_EMAIL));
        assertTrue("User's email must be null on a 2rd sync, since the email property was removed at the AD level.", userProperties.get(ContentModel.PROP_EMAIL) == null);
    }
    finally
    {
        logger.info("testSyncDeletedProperty executing finally");

        tearDownTestUsersAndGroups();
        logger.info("testSyncDeletedProperty finished finally");
    }
}
 
Example #20
Source File: OpenDocumentMetadataExtracter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
    @Override
    protected Map<String, Serializable> extractSpecific(Metadata metadata,
         Map<String, Serializable> properties, Map<String, String> headers) 
    {
       putRawValue(KEY_CREATION_DATE, getDateOrNull(metadata.get(Metadata.CREATION_DATE)), properties);
       putRawValue(KEY_CREATOR, metadata.get(Metadata.CREATOR), properties);
       putRawValue(KEY_DATE, getDateOrNull(metadata.get(Metadata.DATE)), properties);
       putRawValue(KEY_DESCRIPTION, metadata.get(Metadata.DESCRIPTION), properties);
       putRawValue(KEY_GENERATOR, metadata.get("generator"), properties);
       putRawValue(KEY_INITIAL_CREATOR, metadata.get("initial-creator"), properties);
       putRawValue(KEY_KEYWORD, metadata.get(Metadata.KEYWORDS), properties);
       putRawValue(KEY_LANGUAGE, metadata.get(Metadata.LANGUAGE), properties);
//     putRawValue(KEY_PRINT_DATE, getDateOrNull(metadata.get(Metadata.)), rawProperties);
//     putRawValue(KEY_PRINTED_BY, metadata.get(Metadata.), rawProperties);
           
       // Handle user-defined properties dynamically
       Map<String, Set<QName>> mapping = super.getMapping();
       for (String key : mapping.keySet())
       {
           if (metadata.get(CUSTOM_PREFIX + key) != null)
           {
                putRawValue(key, metadata.get(CUSTOM_PREFIX + key), properties);
           }
       }
       
       return properties;
    }
 
Example #21
Source File: RegistryServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Collection<String> getChildElements(RegistryKey key)
{
    // Get the path without creating it
    Pair<NodeRef, QName> keyPair = getPath(key, false);
    if (keyPair == null)
    {
        // Nothing at that path
        return Collections.<String>emptyList();
    }
    // Use a query to find the children
    RegexQNamePattern qnamePattern = new RegexQNamePattern(key.getNamespaceUri(), ".*");
    List<ChildAssociationRef> childAssocRefs = nodeService.getChildAssocs(
            keyPair.getFirst(),
            ContentModel.ASSOC_CHILDREN,
            qnamePattern);
    // The localname of each one of the child associations represents a path element
    Collection<String> results = new ArrayList<String>(childAssocRefs.size());
    for (ChildAssociationRef assocRef : childAssocRefs)
    {
        results.add(assocRef.getQName().getLocalName());
    }
    // Done
    if (logger.isDebugEnabled())
    {
        logger.debug("Retrieved child elements from registry: \n" +
                "   Key:      " + key + "\n" +
                "   Elements: " + results);
    }
    return results;
}
 
Example #22
Source File: HiddenAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addHiddenAspect(NodeRef nodeRef, int visibilityMask, boolean explicit)
{
    Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
    props.put(ContentModel.PROP_VISIBILITY_MASK, visibilityMask);
    props.put(ContentModel.PROP_HIDDEN_FLAG, explicit);
    nodeService.addAspect(nodeRef, ContentModel.ASPECT_HIDDEN, props);

    if (logger.isDebugEnabled())
    {
        logger.debug("Applied hidden marker: " + nodeRef);
    }
}
 
Example #23
Source File: AccessAuditor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void onCopyComplete(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef,
        boolean copyToNewNode, Map<NodeRef, NodeRef> copyMap)
{
    if (auditEnabled())
    {
        getNodeChange(targetNodeRef).onCopyComplete(classRef, sourceNodeRef, targetNodeRef,
                copyToNewNode, copyMap);
    }
}
 
Example #24
Source File: WorkflowObjectFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private NodeRef getNodeVariable(Map<String, Object> variables, QName qName)
{
    Object obj = getVariable(variables, qName);
    if (obj==null)
    {
        return null;
    }
    if(obj instanceof ScriptNode)
    {
        ScriptNode scriptNode  = (ScriptNode) obj;
        return scriptNode.getNodeRef();
    }
    String message = "Variable "+qName+" should be of type ScriptNode but was "+obj.getClass();
    throw new WorkflowException(message);
}
 
Example #25
Source File: SOLRDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private NodeRef createTestNode(NodeRef parent)
{
    NodeRef nodeRef = nodeService.createNode(parent,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, this.getClass().getName()),
            ContentModel.TYPE_CONTAINER).getChildRef();
    return nodeRef;
}
 
Example #26
Source File: ParameterDefinitionImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructor
 * 
 * @param name          the name of the parameter
 * @param type          the type of the parameter
 * @param displayLabel  the display label
 */
public ParameterDefinitionImpl(
        String name, 
        QName type,
        boolean isMandatory,
        String displayLabel)
{
    this.name = name;
    this.type = type;
    this.displayLabel = displayLabel;
    this.isMandatory = isMandatory;
    this.isMultiValued = false;
}
 
Example #27
Source File: QNameTypeEditorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Check that loading a bean with a QName containing a reference to a namespace works. */
@Test
public void testPopulateBeanWithNamespace() throws Exception
{
    QNameContainer qNameContainer = (QNameContainer) applicationContext.getBean("qNameContainerWithNamespace");

    QName expectedQName = QName.createQName("http://www.alfresco.org/model/content/1.0", "namespacedName");
    assertEquals("Loading String as QName failed.", expectedQName, qNameContainer.getQName());
}
 
Example #28
Source File: PermissionModel.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Set<PermissionReference> getAllPermissionsImpl(QName typeName, Set<QName> aspects, boolean exposedOnly)
{
    Set<PermissionReference> permissions = new LinkedHashSet<PermissionReference>(128, 1.0f);

    ClassDefinition cd = dictionaryService.getClass(typeName);
    mutableState.lock.readLock().lock();
    try
    {
        permissions.addAll(mutableState.getAllPermissionsImpl(typeName, exposedOnly));

        if (cd != null && aspects != null)
        {
            Set<QName> defaultAspects = cd.getDefaultAspectNames();
            for (QName aspect : aspects)
            {
                if (!defaultAspects.contains(aspect))
                {
                    mutableState.addAspectPermissions(aspect, permissions, exposedOnly);
                }
            }
        }
    }
    finally
    {
        mutableState.lock.readLock().unlock();
    }
    return permissions;
}
 
Example #29
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Helper method that creates a bag of properties for the test type
 * 
 * @return  bag of properties
 */
private Map<QName, Serializable> createTypePropertyBag()
{
    Map<QName, Serializable> result = new HashMap<QName, Serializable>();
    result.put(PROP_NAME_QNAME, TEST_VALUE_NAME);
    return result;
}
 
Example #30
Source File: HttpRangeProcessor.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Process a range header for a HttpServletResponse - handles single and multiple range requests.
 * 
 * @param res the HTTP servlet response
 * @param reader the content reader
 * @param range the byte range
 * @param ref the content NodeRef
 * @param property the content property
 * @param mimetype the content mimetype
 * @param userAgent the user agent string
 * @return whether or not the range could be processed
 * @throws IOException
 */
public boolean processRange(HttpServletResponse res, ContentReader reader, String range,
      NodeRef ref, QName property, String mimetype, String userAgent)
   throws IOException
{
   // test for multiple byte ranges present in header
   if (range.indexOf(',') == -1)
   {
      return processSingleRange(res, reader, range, mimetype);
   }
   else
   {
      return processMultiRange(res, range, ref, property, mimetype, userAgent);
   }
}