本文整理汇总了Java中org.alfresco.util.GUID类的典型用法代码示例。如果您正苦于以下问题:Java GUID类的具体用法?Java GUID怎么用?Java GUID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GUID类属于org.alfresco.util包,在下文中一共展示了GUID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initStaticData
import org.alfresco.util.GUID; //导入依赖的package包/类
@BeforeClass public static void initStaticData() throws Exception
{
CONTENT_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("ContentService", ContentService.class);
NODE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("NodeService", NodeService.class);
SERVICE_REGISTRY = APP_CONTEXT_INIT.getApplicationContext().getBean("ServiceRegistry", ServiceRegistry.class);
TRANSACTION_HELPER = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
PERMISSION_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("permissionService", PermissionServiceSPI.class);
SEARCH_SCRIPT = APP_CONTEXT_INIT.getApplicationContext().getBean("searchScript", Search.class);
VERSIONABLE_ASPECT = APP_CONTEXT_INIT.getApplicationContext().getBean("versionableAspect", VersionableAspect.class);
VERSION_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("VersionService", VersionService.class);
DICTIONARY_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("DictionaryService", DictionaryService.class);
NAMESPACE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("namespaceService", NamespaceService.class);
DICTIONARY_DAO = APP_CONTEXT_INIT.getApplicationContext().getBean("dictionaryDAO", DictionaryDAO.class);
TENANT_ADMIN_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("tenantAdminService", TenantAdminService.class);
MESSAGE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("messageService", MessageService.class);
TRANSACTION_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("transactionComponent", TransactionService.class);
POLICY_COMPONENT = APP_CONTEXT_INIT.getApplicationContext().getBean("policyComponent", PolicyComponent.class);
USER_ONES_TEST_SITE = STATIC_TEST_SITES.createTestSiteWithUserPerRole(GUID.generate(), "sitePreset", SiteVisibility.PRIVATE, USER_ONE_NAME);
USER_ONES_TEST_FILE = STATIC_TEST_NODES.createQuickFile(MimetypeMap.MIMETYPE_TEXT_PLAIN, USER_ONES_TEST_SITE.doclib, "test.txt", USER_ONE_NAME);
}
示例2: updateUser
import org.alfresco.util.GUID; //导入依赖的package包/类
@Override
public void updateUser(String userName, char[] rawPassword) throws AuthenticationException
{
NodeRef userRef = getUserOrNull(userName);
if (userRef == null)
{
throw new AuthenticationException("User name does not exist: " + userName);
}
Map<QName, Serializable> properties = nodeService.getProperties(userRef);
String salt = GUID.generate();
properties.remove(ContentModel.PROP_SALT);
properties.put(ContentModel.PROP_SALT, salt);
properties.put(ContentModel.PROP_PASSWORD_HASH, compositePasswordEncoder.encodePreferred(new String(rawPassword), salt));
properties.put(ContentModel.PROP_HASH_INDICATOR, compositePasswordEncoder.getPreferredEncoding());
properties.remove(ContentModel.PROP_PASSWORD);
properties.remove(ContentModel.PROP_PASSWORD_SHA256);
nodeService.setProperties(userRef, properties);
}
示例3: testGetPotentialMemberships
import org.alfresco.util.GUID; //导入依赖的package包/类
/**
* @since 4.0
*/
public void testGetPotentialMemberships() throws Exception
{
// Create a site
String shortName = GUID.generate();
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
// Check the memberships
String filter = "";
String authorityType = "GROUP";
String url = "/api/sites/" + shortName + "/potentialmembers?filter=" + filter + "&maxResults=10&authorityType=" + authorityType;
Response response = sendRequest(new GetRequest(url), 200);
final String contentAsString = response.getContentAsString();
JSONObject result = new JSONObject(contentAsString);
assertNotNull(result);
JSONArray people = result.getJSONArray("people");
assertNotNull("people array was null", people);
JSONArray data = result.getJSONArray("data");
assertNotNull("data array was null", data);
// Delete the site
sendRequest(new DeleteRequest(URL_SITES + "/" + shortName), 200);
}
示例4: 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"));
}
示例5: createTestDocuments
import org.alfresco.util.GUID; //导入依赖的package包/类
protected NodeRef[] createTestDocuments(final RequestContext requestContext) {
NodeRef[] docNodeRefs = TenantUtil.runAsUserTenant(new TenantRunAsWork<NodeRef[]>()
{
@Override
public NodeRef[] doWork() throws Exception
{
String siteName = "site" + GUID.generate();
SiteInformation siteInfo = new SiteInformation(siteName, siteName, siteName, SiteVisibility.PUBLIC);
TestSite site = currentNetwork.createSite(siteInfo);
NodeRef nodeRefDoc1 = getTestFixture().getRepoService().createDocument(site.getContainerNodeRef("documentLibrary"), "Test Doc1", "Test Doc1 Title", "Test Doc1 Description", "Test Content");
NodeRef nodeRefDoc2 = getTestFixture().getRepoService().createDocument(site.getContainerNodeRef("documentLibrary"), "Test Doc2", "Test Doc2 Title", "Test Doc2 Description", "Test Content");
NodeRef[] result = new NodeRef[2];
result[0] = nodeRefDoc1;
result[1] = nodeRefDoc2;
return result;
}
}, requestContext.getRunAsUser(), requestContext.getNetworkId());
return docNodeRefs;
}
示例6: testPutContentToFolder
import org.alfresco.util.GUID; //导入依赖的package包/类
/**
* Creating a folder and trying to update it with a file
*/
@Test
public void testPutContentToFolder() throws Exception
{
FileInfo testFileInfo = fileFolderService.create(companyHomeNodeRef, "folder-" + GUID.generate(), ContentModel.TYPE_FOLDER);
try
{
executeMethod(WebDAV.METHOD_PUT, testFileInfo.getName(), testDataFile, null);
fail("The PUT execution should fail with a 400 error");
}
catch (WebDAVServerException wse)
{
// The execution failed and it is expected
assertTrue(wse.getHttpStatusCode() == HttpServletResponse.SC_BAD_REQUEST);
}
catch (Exception e)
{
fail("Failed to upload a file: " + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
}
finally
{
nodeService.deleteNode(testFileInfo.getNodeRef());
}
}
示例7: makePackageContainer
import org.alfresco.util.GUID; //导入依赖的package包/类
private NodeRef makePackageContainer()
{
NodeRef packages = findOrCreatePackagesFolder();
String packageId = "pkg_" + GUID.generate();
QName packageName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, packageId);
try {
policyBehaviourFilter.disableBehaviour(packages, ContentModel.ASPECT_AUDITABLE);
ChildAssociationRef packageAssoc = nodeService.createNode(packages, ContentModel.ASSOC_CONTAINS, packageName,
WorkflowModel.TYPE_PACKAGE);
NodeRef packageContainer = packageAssoc.getChildRef();
// TODO: For now, grant full access to everyone
permissionService.setPermission(packageContainer, PermissionService.ALL_AUTHORITIES,
PermissionService.ALL_PERMISSIONS, true);
return packageContainer;
}
finally
{
policyBehaviourFilter.enableBehaviour(packages, ContentModel.ASPECT_AUDITABLE);
}
}
示例8: addPackageItems
import org.alfresco.util.GUID; //导入依赖的package包/类
private void addPackageItems(final NodeRef packageRef)
{
for (NodeRef item : addItems)
{
String name = (String) nodeService.getProperty(item, ContentModel.PROP_NAME);
if (name == null)
{
name = GUID.generate();
}
String localName = QName.createValidLocalName(name);
QName qName = QName.createQName(CM_URL, localName);
behaviourFilter.disableBehaviour(item, ContentModel.ASPECT_AUDITABLE);
try
{
nodeService.addChild(packageRef, item, PCKG_CONTAINS, qName);
}
finally
{
behaviourFilter.enableBehaviour(item, ContentModel.ASPECT_AUDITABLE);
}
}
}
示例9: testCreateNodeWithId
import org.alfresco.util.GUID; //导入依赖的package包/类
/**
* Tests node creation with a pre-determined {@link ContentModel#PROP_NODE_UUID uuid}.
*/
public void testCreateNodeWithId() throws Exception
{
String uuid = GUID.generate();
// create a node with an explicit UUID
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
properties.put(ContentModel.PROP_NODE_UUID, uuid);
ChildAssociationRef assocRef = nodeService.createNode(
rootNodeRef,
ASSOC_TYPE_QNAME_TEST_CHILDREN,
QName.createQName("pathA"),
ContentModel.TYPE_CONTAINER,
properties);
// check it
NodeRef expectedNodeRef = new NodeRef(rootNodeRef.getStoreRef(), uuid);
NodeRef checkNodeRef = assocRef.getChildRef();
assertEquals("Failed to create node with a chosen ID", expectedNodeRef, checkNodeRef);
}
示例10: testUpdate
import org.alfresco.util.GUID; //导入依赖的package包/类
public void testUpdate() throws Exception
{
final String oldMimetype = GUID.generate();
final String newMimetype = GUID.generate();
Pair<Long, String> oldMimetypePair = get(oldMimetype, true, true);
// Update it
RetryingTransactionCallback<Pair<Long, String>> callback = new RetryingTransactionCallback<Pair<Long, String>>()
{
public Pair<Long, String> execute() throws Throwable
{
int count = mimetypeDAO.updateMimetype(oldMimetype, newMimetype);
assertEquals("Incorrect number updated", 1, count);
return mimetypeDAO.getMimetype(newMimetype);
}
};
Pair<Long, String> newMimetypePair = txnHelper.doInTransaction(callback, false, false);
// Check
assertEquals("ID should remain the same if the old mimetype existed",
oldMimetypePair.getFirst(), newMimetypePair.getFirst());
get(oldMimetype, false, false);
get(newMimetype, false, true);
}
示例11: createAuthorityContext
import org.alfresco.util.GUID; //导入依赖的package包/类
/**
* Creates authority context
*
* @param user
* @return
*/
private void createAuthorityContext(String user)
{
String groupName = "Group_ROOT" + GUID.generate();
AuthenticationUtil.setRunAsUser(user);
if (rootGroupName == null)
{
rootGroupName = authorityService.getName(AuthorityType.GROUP, groupName);
}
if (!authorityService.authorityExists(rootGroupName))
{
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
rootGroupName = authorityService.createAuthority(AuthorityType.GROUP, groupName);
groupA = authorityService.createAuthority(AuthorityType.GROUP, "Test_GroupA");
authorityService.addAuthority(rootGroupName, groupA);
groupB = authorityService.createAuthority(AuthorityType.GROUP, "Test_GroupB");
authorityService.addAuthority(rootGroupName, groupB);
authorityService.addAuthority(groupA, user1);
authorityService.addAuthority(groupB, user2);
}
}
示例12: testExportSiteWithOneLDAPUser
import org.alfresco.util.GUID; //导入依赖的package包/类
public void testExportSiteWithOneLDAPUser() throws Exception
{
// Create a site
String shortName = GUID.generate();
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
// add a user synced from LDAP(authenticator node not present)
addSiteMember(USER_FROM_LDAP, shortName);
// Export site
Response response = sendRequest(new GetRequest(getExportUrl(shortName)), 200);
// check No_Users_In_Site.txt present
// because there is no user associated with the single member of the
// site
List<String> entries = getEntries(new ZipInputStream(new ByteArrayInputStream(
response.getContentAsByteArray())));
assertFalse(entries.contains("Users.acp"));
assertTrue(entries.contains("No_Users_In_Site.txt"));
assertTrue(entries.contains("People.acp"));
assertTrue(entries.contains(shortName + "-people.xml"));
}
示例13: registerKey
import org.alfresco.util.GUID; //导入依赖的package包/类
public void registerKey(String keyAlias, Key key)
{
if(isKeyRegistered(keyAlias))
{
throw new IllegalArgumentException("Key " + keyAlias + " is already registered");
}
// register the key by creating an attribute that stores a guid and its encrypted value
String guid = GUID.generate();
KeyMap keys = new KeyMap();
keys.setKey(keyAlias, key);
Encryptor encryptor = getEncryptor(keys);
Serializable encrypted = encryptor.sealObject(keyAlias, null, guid);
Pair<String, Serializable> keyCheck = new Pair<String, Serializable>(guid, encrypted);
attributeService.createAttribute(keyCheck, TOP_LEVEL_KEY, keyAlias);
logger.info("Registered key " + keyAlias);
}
示例14: before
import org.alfresco.util.GUID; //导入依赖的package包/类
@Override protected void before() throws Throwable
{
// Set up required services
ApplicationContext ctxt = getApplicationContext();
final RetryingTransactionHelper transactionHelper = (RetryingTransactionHelper) ctxt.getBean("retryingTransactionHelper");
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
{
@Override public Void execute() throws Throwable
{
if (log.isDebugEnabled())
{
log.debug("Creating " + personCount + " users for test purposes...");
}
for (int i = 0; i < personCount; i++)
{
final String userName = GUID.generate();
NodeRef personNode = createPerson(userName);
usersPersons.put(userName, personNode);
}
return null;
}
});
}
示例15: testEncodeMD4
import org.alfresco.util.GUID; //导入依赖的package包/类
@Test
public void testEncodeMD4() throws Exception
{
String salt = GUID.generate();
MD4PasswordEncoderImpl md4 = new MD4PasswordEncoderImpl();
String sourceEncoded = md4.encodePassword(SOURCE_PASSWORD, salt);
String sourceEncodedSaltFree = md4.encodePassword(SOURCE_PASSWORD, null);
String encoded = encoder.encode("md4", SOURCE_PASSWORD, salt);
//The salt is ignored for MD4 so the passwords will match
assertTrue(encoder.matches("md4", SOURCE_PASSWORD, encoded, salt));
assertTrue(encoder.matchesPassword(SOURCE_PASSWORD, encoded, salt, Arrays.asList("md4")));
assertNotEquals("The salt must be ignored for MD4", sourceEncoded, encoded);
assertNotEquals("The salt must be ignored for MD4", sourceEncoded, encoder.encodePassword(SOURCE_PASSWORD, salt, Arrays.asList("md4")));
encoded = encoder.encode("md4", SOURCE_PASSWORD, null);
assertEquals(sourceEncodedSaltFree, encoded);
assertTrue(encoder.matches("md4", SOURCE_PASSWORD, sourceEncodedSaltFree, null));
assertTrue(encoder.matchesPassword(SOURCE_PASSWORD, sourceEncodedSaltFree, null, Arrays.asList("md4")));
assertEquals(sourceEncodedSaltFree, encoder.encodePassword(SOURCE_PASSWORD, null, Arrays.asList("md4")));
encoded = encoder.encode("sha256", SOURCE_PASSWORD, null);
assertNotEquals(sourceEncodedSaltFree, encoded);
}