当前位置: 首页>>代码示例>>Java>>正文


Java GUID.generate方法代码示例

本文整理汇总了Java中org.alfresco.util.GUID.generate方法的典型用法代码示例。如果您正苦于以下问题:Java GUID.generate方法的具体用法?Java GUID.generate怎么用?Java GUID.generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.util.GUID的用法示例。


在下文中一共展示了GUID.generate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testExportSiteWithMutipleUsers

import org.alfresco.util.GUID; //导入方法依赖的package包/类
public void testExportSiteWithMutipleUsers() throws Exception
{
    // Create a site
    String shortName = GUID.generate();
    createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);

    // add a user and a person as members
    addSiteMember(USER_FROM_LDAP, shortName);
    addSiteMember(USER_ONE, shortName);

    // Export site
    Response response = sendRequest(new GetRequest(getExportUrl(shortName)), 200);

    // check exported files
    List<String> entries = getEntries(new ZipInputStream(new ByteArrayInputStream(
            response.getContentAsByteArray())));
    assertFalse(entries.contains("No_Users_In_Site.txt"));
    assertFalse(entries.contains("No_Persons_In_Site.txt"));
    assertTrue(entries.contains("People.acp"));
    assertTrue(entries.contains(shortName + "-people.xml"));
    assertTrue(entries.contains("Users.acp"));
    assertTrue(entries.contains(shortName + "-users.xml"));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:SiteExportServiceTest.java

示例2: canVisitOldestDirsFirst

import org.alfresco.util.GUID; //导入方法依赖的package包/类
@Test
public void canVisitOldestDirsFirst()
{
    File cacheRoot = new File(TempFileProvider.getTempDir(), GUID.generate());
    cacheRoot.deleteOnExit();
    contentCache.setCacheRoot(cacheRoot);
    
    File f1 = tempfile(createDirs("2000/3/30/17/45/31"), "files-are-unsorted.bin");
    File f2 = tempfile(createDirs("2000/3/4/17/45/31"), "another-file.bin");
    File f3 = tempfile(createDirs("2010/12/24/23/59/58"), "a-second-before.bin");
    File f4 = tempfile(createDirs("2010/12/24/23/59/59"), "last-one.bin");
    File f5 = tempfile(createDirs("2000/1/7/2/7/12"), "first-one.bin");
    
    // Check that directories and files are visited in correct order
    FileHandler handler = Mockito.mock(FileHandler.class);
    contentCache.processFiles(handler);
    
    InOrder inOrder = Mockito.inOrder(handler);
    inOrder.verify(handler).handle(f5);
    inOrder.verify(handler).handle(f2);
    inOrder.verify(handler).handle(f1);
    inOrder.verify(handler).handle(f3);
    inOrder.verify(handler).handle(f4);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:ContentCacheImplTest.java

示例3: testExportSiteWithNoUsers

import org.alfresco.util.GUID; //导入方法依赖的package包/类
public void testExportSiteWithNoUsers() throws Exception
{
    // Create a site
    String shortName = GUID.generate();
    createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);

    // Export site
    Response response = sendRequest(new GetRequest(getExportUrl(shortName)), 200);

    // check No_Users_In_Site.txt and No_Persons_In_Site.txt present
    List<String> entries = getEntries(new ZipInputStream(new ByteArrayInputStream(
            response.getContentAsByteArray())));
    assertTrue(entries.contains("No_Users_In_Site.txt"));
    assertTrue(entries.contains("No_Persons_In_Site.txt"));
    assertFalse(entries.contains("Users.acp"));
    assertFalse(entries.contains("People.acp"));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:18,代码来源:SiteExportServiceTest.java

示例4: testGetMembership

import org.alfresco.util.GUID; //导入方法依赖的package包/类
public void testGetMembership() throws Exception
{
    // Create a site
    String shortName  = GUID.generate();
    createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
    
    // Test error conditions
    sendRequest(new GetRequest(URL_SITES + "/badsite" + URL_MEMBERSHIPS + "/" + USER_ONE), 404);
    sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/baduser"), 404);
    sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 404);
    
    Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_ONE), 200);
    JSONObject result = new JSONObject(response.getContentAsString());
    
    // Check the result
    assertEquals(SiteModel.SITE_MANAGER, result.get("role"));
    assertEquals(USER_ONE, result.getJSONObject("authority").get("userName")); 
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:19,代码来源:SiteServiceTest.java

示例5: initStaticData

import org.alfresco.util.GUID; //导入方法依赖的package包/类
@BeforeClass public static void initStaticData() throws Exception
{
    OWNABLE_SERVICE    = APP_CONTEXT_INIT.getApplicationContext().getBean("OwnableService", OwnableService.class);
    TRANSACTION_HELPER = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
    
    // One user creates a site.
    final String siteShortName = GUID.generate();
    SITE_INFO = TEMP_SITES.createTestSiteWithUserPerRole(siteShortName,
                                                         "sitePreset",
                                                         SiteVisibility.PUBLIC,
                                                         TEST_USER1.getUsername());
    // A site contributor creates a document in it.
    TEST_DOC  = TEMP_NODES.createNode(SITE_INFO.doclib, "userOnesDoc", ContentModel.TYPE_CONTENT, SITE_INFO.siteContributor);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:15,代码来源:TakeOwnershipActionExecuterTest.java

示例6: testExecution

import org.alfresco.util.GUID; //导入方法依赖的package包/类
/**
 * Test execution
 */
public void testExecution()
{
    // Execute the action
    ActionImpl action = new ActionImpl(null, GUID.generate(), StartWorkflowActionExecuter.NAME, null);
    action.setParameterValue(StartWorkflowActionExecuter.PARAM_WORKFLOW_NAME, "activiti$activitiReview");
    action.setParameterValue(WorkflowModel.PROP_WORKFLOW_DUE_DATE.toPrefixString(namespaceService), new Date());
    NodeRef reviewer = personService.getPerson(AuthenticationUtil.getAdminUserName());
    action.setParameterValue(WorkflowModel.ASSOC_ASSIGNEE.toPrefixString(namespaceService), reviewer);
    executer.execute(action, this.nodeRef);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:14,代码来源:StartWorkflowActionExecuterTest.java

示例7: getNewTicket

import org.alfresco.util.GUID; //导入方法依赖的package包/类
public String getNewTicket()
{
    String currentUser = getCurrentUserName();
    String ticket = userToTicket.get(currentUser);
    if (ticket == null)
    {
        ticket = GUID.generate();
        userToTicket.put(currentUser, ticket);
    }
    return ticket;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:TestAuthenticationServiceImpl.java

示例8: createXmlFile

import org.alfresco.util.GUID; //导入方法依赖的package包/类
/**
 * 
 */
private FileInfo createXmlFile(NodeRef folder)
{
    String name = GUID.generate();
    FileInfo testXmlFile = fileFolderService.create(folder, name + ".xml", ContentModel.TYPE_CONTENT);
    ContentWriter writer = contentService.getWriter(testXmlFile.getNodeRef(), ContentModel.PROP_CONTENT, true);
    writer.setMimetype("text/xml");
    writer.setEncoding("UTF-8");
    writer.putContent(sampleXML);
    return testXmlFile;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:14,代码来源:XSLTFunctionsTest.java

示例9: testGetPeopleSorting

import org.alfresco.util.GUID; //导入方法依赖的package包/类
public void testGetPeopleSorting() throws Exception
{
    String filter = GUID.generate();
    String usernameA = filter + "-aaa-";
    String usernameB = filter + "-BBB-";
    String usernameC = filter + "-ccc-";
    String usernameD = filter + "-ddd-";
    String randomUserName = "userFilterTest-" + GUID.generate();
    createPerson(randomUserName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
            "myJobTitle", "myEmailAddress", "myBio", "images/avatar.jpg", 0, Status.STATUS_OK);
    checkSorting(randomUserName, "userName", randomUserName);

    createPerson(usernameA, "myTitle", filter, "aaa", "myOrganisation", "jobaaa", usernameA + "@alfresco.com", "myBio", "images/avatar.jpg", 2048, Status.STATUS_OK);
    createPerson(usernameB, "myTitle", filter, "bbb", "myOrganisation", "bbjobb", usernameB + "@alfresco.com", "myBio", "images/avatar.jpg", 256, Status.STATUS_OK);
    createPerson(usernameC, "myTitle", filter, "ccc", "myOrganisation", "cccjob", usernameC + "@alfresco.com", "myBio", "images/avatar.jpg", 512, Status.STATUS_OK);
    createPerson(usernameD, "myTitle", filter, "DDD", "myOrganisation", "aJobd", usernameD + "@alfresco.com", "myBio", "images/avatar.jpg", 1024, Status.STATUS_OK);

    addUserUsageContent(usernameA, 22);
    addUserUsageContent(usernameB, 10);
    addUserUsageContent(usernameC, 37);
    addUserUsageContent(usernameD, 50);
    userUsageTrackingComponent.execute();

    checkSorting(filter, SORT_BY_USERNAME, usernameA, usernameB, usernameC, usernameD);
    checkSorting(filter, SORT_BY_FULLNAME, usernameA, usernameB, usernameC, usernameD);
    checkSorting(filter, SORT_BY_JOBTITLE, usernameA, usernameB, usernameC, usernameD);
    checkSorting(filter, SORT_BY_EMAIL, usernameA, usernameB, usernameC, usernameD);
    checkSorting(filter, SORT_BY_QUOTA, usernameA, usernameB, usernameC, usernameD);
    checkSorting(filter, SORT_BY_USAGE, usernameA, usernameB, usernameC, usernameD);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:31,代码来源:PersonServiceTest.java

示例10: createNode

import org.alfresco.util.GUID; //导入方法依赖的package包/类
/**
 * Create a new Node of the specified type as a child of this node.
 * 
 * Beware: Any unsaved property changes will be lost when this is called.  To preserve property changes call {@link #save()} first.
 *    
 * @param name Name of the node to create (can be null for a node without a 'cm:name' property)
 * @param type QName type (fully qualified or short form such as 'cm:content')
 * @param properties Associative array of the default properties for the node.
 * @param assocType QName of the child association type (fully qualified or short form e.g. 'cm:contains')
 * @param assocName QName of the child association name (fully qualified or short form e.g. 'fm:discussion')
 * 
 * @return Newly created Node or null if failed to create.
 */
public ScriptNode createNode(String name, String type, Object properties, String assocType, String assocName)
{
    ParameterCheck.mandatoryString("Node Type", type);
    ParameterCheck.mandatoryString("Association Type", assocType);
    
    Map<QName, Serializable> props = null;
    
    if (properties instanceof ScriptableObject)
    {
        props = new HashMap<QName, Serializable>(4, 1.0f);
        extractScriptableProperties((ScriptableObject)properties, props);
    }
    
    if (name != null)
    {
        if (props == null) props = new HashMap<QName, Serializable>(1, 1.0f);
        props.put(ContentModel.PROP_NAME, name);
    }
    else
    {
        // set name for the assoc local name
        name = GUID.generate();
    }
    
    ChildAssociationRef childAssocRef = this.nodeService.createNode(
            this.nodeRef,
            createQName(assocType),
            assocName == null ?
                 QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name)) :
                 createQName(assocName),
            createQName(type),
            props);
    
    reset();
    
    return newInstance(childAssocRef.getChildRef(), this.services, this.scope);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:51,代码来源:ScriptNode.java

示例11: getLock

import org.alfresco.util.GUID; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String getLock(QName lockQName, long timeToLive, long retryWait, int retryCount)
{
    String lockToken = GUID.generate();
    getLockImpl(lockToken, lockQName, timeToLive, retryWait, retryCount);
    // Done
    return lockToken;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:JobLockServiceImpl.java

示例12: testALF5027

import org.alfresco.util.GUID; //导入方法依赖的package包/类
/**
 * http://issues.alfresco.com/jira/browse/ALF-5027
 */
public void testALF5027() throws Exception
{
    String userName = "bob" + GUID.generate();
    createUser(userName);
    PermissionService permissionService = (PermissionService)applicationContext.getBean("PermissionService");
    permissionService.setPermission(rootNodeRef, userName, PermissionService.COORDINATOR, true);
    
    AuthenticationUtil.setRunAsUser(userName);
    
    NodeRef myNodeRef = nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("{test}myTestNode" + GUID.generate()),
            ContentModel.TYPE_CONTENT).getChildRef();
    
    CheckOutCheckInService coci = (CheckOutCheckInService)applicationContext.getBean("CheckoutCheckinService");
    NodeRef workingcopy = coci.checkout(myNodeRef);
    assertNotNull(workingcopy);
    
    assertFalse(nodeService.hasAspect(myNodeRef, ContentModel.ASPECT_DUBLINCORE));
    
    Action action1 = this.actionService.createAction(AddFeaturesActionExecuter.NAME);
    action1.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_DUBLINCORE);        
    actionService.executeAction(action1, myNodeRef);
    
    // The action should have been ignored since the node is locked
    assertFalse(nodeService.hasAspect(myNodeRef, ContentModel.ASPECT_DUBLINCORE));
    
    coci.checkin(workingcopy, null);
    actionService.executeAction(action1, myNodeRef);
    
    assertTrue(nodeService.hasAspect(myNodeRef, ContentModel.ASPECT_DUBLINCORE));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:ActionServiceImplTest.java

示例13: createNode

import org.alfresco.util.GUID; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected NodeRef createNode(TypeDefinition typeDef, FormData data)
{
    NodeRef nodeRef = null;

    if (data != null)
    {
        // firstly, ensure we have a destination to create the node in
        NodeRef parentRef = null;
        FieldData destination = data.getFieldData(DESTINATION);
        if (destination == null)
        {
            throw new FormException("Failed to persist form for '"
                        + typeDef.getName().toPrefixString(this.namespaceService) + "' as '" + DESTINATION
                        + "' data was not provided.");
        }

        // create the parent NodeRef
        String destinationValue = (String) destination.getValue();
        parentRef = getParentNodeRef(destinationValue);
        if (parentRef == null)
        {
            throw new FormException("Failed to persist form for '"
                        + typeDef.getName().toPrefixString(this.namespaceService) + "' as '" + destinationValue
                        + "' does not exist as path or NodeRef in the system.");
        }

        data.removeFieldData(DESTINATION);

        // if a name property is present in the form data use it as the node
        // name,
        // otherwise generate a guid
        String nodeName = null;
        FieldData nameData = data.getFieldData(NAME_PROP_DATA);
        if (nameData != null)
        {
            nodeName = (String) nameData.getValue();

            // remove the name data otherwise 'rename' gets called in
            // persistNode
            data.removeFieldData(NAME_PROP_DATA);
        }
        if (nodeName == null || nodeName.length() == 0)
        {
            nodeName = GUID.generate();
        }

        // create the node
        Map<QName, Serializable> nodeProps = new HashMap<QName, Serializable>(1);
        nodeProps.put(ContentModel.PROP_NAME,
                      nodeName);
        nodeRef = this.nodeService.createNode(parentRef,
                                              ContentModel.ASSOC_CONTAINS,
                                              QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
                                                                QName.createValidLocalName(nodeName)),
                                              typeDef.getName(),
                                              nodeProps).getChildRef();
        // adding additional aspects for now with empty properties...this
        // will not be needed anymore when we'll use form processor for
        // generating the form
        for (QName qname : getRequestedAspects())
        {
            this.nodeService.addAspect(nodeRef,
                                       qname,
                                       new HashMap<QName, Serializable>());
        }
        // if the physical structure is configured we'll create for now
        // simple folders
        FieldData physicalStructure = data.getFieldData(PHYSICAL_STRUCTURE);
        if (physicalStructure != null)
        {
            List<String> folderPhysicalStructure = (List<String>) physicalStructure.getValue();
            createPhysicalStructure(nodeRef,
                                    folderPhysicalStructure);
            data.removeFieldData(PHYSICAL_STRUCTURE);
        }
    }

    return nodeRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:82,代码来源:TypeAndAspectsFormProcessor.java

示例14: testMNT_10873

import org.alfresco.util.GUID; //导入方法依赖的package包/类
@Test
public void testMNT_10873() throws Exception
{
    String fileName = TEST_FILE_NAME + GUID.generate();
    final MockHttpServletRequest lockRequest = new MockHttpServletRequest();
    MockHttpServletResponse lockResponse = new MockHttpServletResponse();
    lockRequest.addHeader(WebDAV.HEADER_TIMEOUT, WebDAV.SECOND + 5);
    // set request uri to point to non-existent file
    lockRequest.setRequestURI("/" + fileName);
    
    String content = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><D:lockinfo xmlns:D=\"DAV:\"><D:lockscope xmlns:D=\"DAV:\">" +
            "<D:exclusive xmlns:D=\"DAV:\"/></D:lockscope><D:locktype xmlns:D=\"DAV:\"><D:write xmlns:D=\"DAV:\"/></D:locktype>" +
            "<D:owner xmlns:D=\"DAV:\">" + userName + "</D:owner></D:lockinfo>";

    lockRequest.setContent(content.getBytes("UTF-8"));

    lockMethod.setDetails(lockRequest, lockResponse, davHelper, folderNodeRef);
    lockMethod.parseRequestHeaders();
    lockMethod.parseRequestBody();
    
    RetryingTransactionCallback<Void> lockExecuteImplCallBack = new RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            lockMethod.executeImpl();
            return null;
        }
    };
    
    // lock node for 5 seconds
    this.transactionService.getRetryingTransactionHelper().doInTransaction(lockExecuteImplCallBack);
    
    assertEquals("Unexpected response status code.", HttpServletResponse.SC_CREATED, lockResponse.getStatus());
    
    RetryingTransactionCallback<NodeRef> getNodeRefCallback = new RetryingTransactionCallback<NodeRef>()
    {
        @Override
        public NodeRef execute() throws Throwable
        {
            return lockMethod.getNodeForPath(folderNodeRef, lockRequest.getRequestURI()).getNodeRef();
        }
    };
    
    NodeRef nodeRef = this.transactionService.getRetryingTransactionHelper().doInTransaction(getNodeRefCallback);
    
    assertTrue("NodeRef should exists.", nodeService.exists(nodeRef));        
    assertTrue("sys:webdavNoContent aspect should be applied on node.", nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WEBDAV_NO_CONTENT));
    
    // sleep for 6 seconds to ensure that timer was triggered
    Thread.sleep(6000);
    
    assertFalse("File should note exist in repo any more.", nodeService.exists(nodeRef));
    assertFalse("File should note exist in trashcan.", nodeService.exists(new NodeRef(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, nodeRef.getId())));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:56,代码来源:LockMethodTest.java

示例15: tearDown

import org.alfresco.util.GUID; //导入方法依赖的package包/类
@After
public void tearDown() throws Exception
{
    method = null;
    request = null;
    response = null;

    if (txn.getStatus() == Status.STATUS_MARKED_ROLLBACK)
    {
        txn.rollback();
    }
    else
    {
        txn.commit();
    }
    
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
 
    nodeService.deleteNode(versionableDoc);

    // As per MNT-10037 try to create a node and delete it in the next txn
    txn = transactionService.getUserTransaction();
    txn.begin();

    Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
    String nodeName = "leak-session-doc-" + GUID.generate();
    properties.put(ContentModel.PROP_NAME, nodeName);

    NodeRef nodeRef = nodeService.createNode(companyHomeNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(ContentModel.USER_MODEL_URI, nodeName),
            ContentModel.TYPE_CONTENT, properties).getChildRef();
    contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true).putContent("WebDAVTestContent");

    txn.commit();

    txn = transactionService.getUserTransaction();
    txn.begin();

    nodeService.deleteNode(nodeRef);

    txn.commit();

    AuthenticationUtil.clearCurrentSecurityContext();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:44,代码来源:DeleteMethodTest.java


注:本文中的org.alfresco.util.GUID.generate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。