org.json.simple.JSONAware#org.alfresco.service.namespace.QName源码实例Demo

下面列出了org.json.simple.JSONAware#org.alfresco.service.namespace.QName 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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();
        }
    }
}
 
@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;
    }

}
 
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;
}
 
源代码4 项目: alfresco-repository   文件: FieldProcessorTest.java
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;
}
 
/**
 * 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)));
}
 
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;
}
 
源代码7 项目: alfresco-repository   文件: NodeDAOImpl.java
@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);
}
 
源代码8 项目: alfresco-repository   文件: ScriptNodeTest.java
/**
 * 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));
}
 
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;
}
 
源代码10 项目: alfresco-remote-api   文件: UserCSVUploadGet.java
@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;
}
 
@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);
}
 
源代码12 项目: alfresco-repository   文件: Version2ServiceImpl.java
/**
 * 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();
}
 
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;
        }
    });
}
 
源代码14 项目: alfresco-repository   文件: PermissionModelTest.java
public void testIncludePermissionGroups3()
{
    Set<PermissionReference> grantees = permissionModelDAO.getGranteePermissions(SimplePermissionReference.getPermissionReference(QName.createQName("cm", "cmobject",
            namespacePrefixResolver), "Editor"));

    assertEquals(19, grantees.size());
}
 
源代码15 项目: alfresco-repository   文件: QNameFieldProcessor.java
public Field generateField(QName fullName, ContentModelItemData<?> itemData, boolean isForcedField) 
{
    Type propDef = getTypeDefinition(fullName, itemData, isForcedField);
    Field field = null;
    if (propDef != null)
    {
        Object value = getValue(fullName, itemData);
        FieldGroup group = getGroup(propDef);
        field = makeField(propDef, value, group);
    }
    return field;
}
 
/**
 * 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;
}
 
源代码17 项目: alfresco-repository   文件: RhinoScriptProcessor.java
/**
 * @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);
    }
}
 
@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;
    }
 
源代码19 项目: alfresco-repository   文件: AuthenticationTest.java
/**
 * 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));
}
 
@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);
}
 
源代码21 项目: alfresco-repository   文件: RegistryServiceImpl.java
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;
}
 
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);
}
 
/**
 * 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;
}
 
源代码24 项目: alfresco-repository   文件: QNameTypeEditorTest.java
/** 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());
}
 
源代码25 项目: alfresco-repository   文件: PermissionModel.java
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;
}
 
/**
 * 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;
}
 
源代码27 项目: alfresco-remote-api   文件: HttpRangeProcessor.java
/**
 * 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);
   }
}
 
源代码28 项目: alfresco-repository   文件: SOLRDAOTest.java
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;
}
 
源代码29 项目: alfresco-repository   文件: AccessAuditor.java
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);
    }
}
 
源代码30 项目: alfresco-repository   文件: HiddenAspect.java
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);
    }
}