Java源码示例:org.alfresco.util.GUID
示例1
public void testCreateSite() throws Exception
{
String shortName = GUID.generate();
// Create a new site
JSONObject result = createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
assertEquals("myPreset", result.get("sitePreset"));
assertEquals(shortName, result.get("shortName"));
assertEquals("myTitle", result.get("title"));
assertEquals("myDescription", result.get("description"));
assertNotNull(result.get("node"));
assertNotNull(result.get("tagScope"));
assertEquals(SiteVisibility.PUBLIC.toString(), result.get("visibility"));
assertTrue(result.getBoolean("isPublic"));
// Check for duplicate names
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 400);
}
示例2
@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);
}
示例3
public void testCreateWithRollback() throws Exception
{
final String encoding = GUID.generate();
// Create an encoding
RetryingTransactionCallback<Pair<Long, String>> callback = new RetryingTransactionCallback<Pair<Long, String>>()
{
public Pair<Long, String> execute() throws Throwable
{
get(encoding, true, true);
// Now force a rollback
throw new RuntimeException("Forced");
}
};
try
{
txnHelper.doInTransaction(callback);
fail("Transaction didn't roll back");
}
catch (RuntimeException e)
{
// Expected
}
// Check that it doesn't exist
get(encoding, false, false);
}
示例4
@SuppressWarnings("unchecked")
private LuceneIndexer getThreadLocalIndexer(StoreRef storeRef)
{
Map<StoreRef, LuceneIndexer> indexers = (Map<StoreRef, LuceneIndexer>) AlfrescoTransactionSupport.getResource(indexersKey);
if (indexers == null)
{
indexers = new HashMap<StoreRef, LuceneIndexer>();
AlfrescoTransactionSupport.bindResource(indexersKey, indexers);
}
LuceneIndexer indexer = indexers.get(storeRef);
if (indexer == null)
{
indexer = createIndexer(storeRef, GUID.generate());
indexers.put(storeRef, indexer);
}
return indexer;
}
示例5
/**
* Tests node creation with a pre-determined {@link ContentModel#PROP_NODE_UUID uuid}.
*/
@Test
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);
}
示例6
/**
* @throws UnsupportedOperationException Always
*/
@Extend(traitAPI=NodeServiceTrait.class,extensionAPI=NodeServiceExtension.class)
public void deleteStore(StoreRef storeRef) throws InvalidStoreRefException
{
// Cannot delete the root node but we can delete, without archive, all immediate children
NodeRef rootNodeRef = nodeDAO.getRootNode(storeRef).getSecond();
List<ChildAssociationRef> childAssocRefs = getChildAssocs(rootNodeRef);
for (ChildAssociationRef childAssocRef : childAssocRefs)
{
NodeRef childNodeRef = childAssocRef.getChildRef();
// We do NOT want to archive these, so mark them as temporary
deleteNode(childNodeRef, false);
}
// Rename the store. This takes all the nodes with it.
StoreRef deletedStoreRef = new StoreRef(StoreRef.PROTOCOL_DELETED, GUID.generate());
nodeDAO.moveStore(storeRef, deletedStoreRef);
// Done
if (logger.isDebugEnabled())
{
logger.debug("Marked store for deletion: " + storeRef + " --> " + deletedStoreRef);
}
}
示例7
@SuppressWarnings("unused")
public OnContentUpdatePolicyEvent createOnContentUpdateEvent(NodeRef sourceNodeRef, boolean newContent)
{
OnContentUpdatePolicyEvent event = new OnContentUpdatePolicyEvent();
// Raw event specific
event.setId(GUID.generate());
event.setType(EventType.CONTENT_UPDATED.toString());
event.setAuthenticatedUser(AuthenticationUtil.getFullyAuthenticatedUser());
event.setExecutingUser(AuthenticationUtil.getRunAsUser());
event.setTimestamp(System.currentTimeMillis());
event.setSchema(1);
// On content update policy event specific
event.setNodeRef(sourceNodeRef.toString());
event.setNewContent(newContent);
return event;
}
示例8
public void testDeleteMembership() throws Exception
{
// Create a site
String shortName = GUID.generate();
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
// Build the JSON membership object
JSONObject membership = new JSONObject();
membership.put("role", SiteModel.SITE_CONSUMER);
JSONObject person = new JSONObject();
person.put("userName", USER_TWO);
membership.put("person", person);
// Post the membership
sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200);
// Delete the membership
sendRequest(new DeleteRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 200);
// Check that the membership has been deleted
sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 404);
}
示例9
NodeRef createContentNodeFromQuickFile(String fileName) throws FileNotFoundException
{
NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
NodeRef folderNodeRef = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(getName() + GUID.generate()),
ContentModel.TYPE_FOLDER).getChildRef();
File file = ResourceUtils.getFile("classpath:quick/" + fileName);
NodeRef contentRef = nodeService.createNode(
folderNodeRef,
ContentModel.ASSOC_CONTAINS,
ContentModel.ASSOC_CONTAINS,
ContentModel.TYPE_CONTENT,
Collections.singletonMap(ContentModel.PROP_NAME, fileName))
.getChildRef();
ContentWriter contentWriter = contentService.getWriter(contentRef, ContentModel.PROP_CONTENT, true);
contentWriter.setMimetype(mimetypeService.guessMimetype(fileName));
contentWriter.putContent(file);
return contentRef;
}
示例10
@Test
public void testPutContentToAnExistingFile() throws Exception
{
FileInfo testFileInfo = fileFolderService.create(companyHomeNodeRef, "file-" + GUID.generate(), ContentModel.TYPE_CONTENT);
try
{
executeMethod(WebDAV.METHOD_PUT, testFileInfo.getName(), testDataFile, null);
assertTrue("File does not exist.", nodeService.exists(testFileInfo.getNodeRef()));
assertEquals("Filename is not correct.", testFileInfo.getName(), nodeService.getProperty(testFileInfo.getNodeRef(), ContentModel.PROP_NAME));
assertTrue("Expected return status is " + HttpServletResponse.SC_NO_CONTENT + ", but returned is " + response.getStatus(),
HttpServletResponse.SC_NO_CONTENT == response.getStatus());
InputStream updatedFileIS = fileFolderService.getReader(testFileInfo.getNodeRef()).getContentInputStream();
byte[] updatedFile = IOUtils.toByteArray(updatedFileIS);
updatedFileIS.close();
assertTrue("The content has to be equal", ArrayUtils.isEquals(testDataFile, updatedFile));
}
catch (Exception e)
{
fail("Failed to upload a file: " + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
}
finally
{
nodeService.deleteNode(testFileInfo.getNodeRef());
}
}
示例11
public void testContentUrlCrud() throws Exception
{
assertNull("Expect null return fetching a URL by ID", contentDataDAO.getContentUrl(0L));
assertNull("Expect null return fetching a URL", contentDataDAO.getContentUrl("store://someURL"));
// Update and create
ContentUrlEntity contentUrlEntity = contentDataDAO.getOrCreateContentUrl("store://" + GUID.generate());
// Check that it exists, now
contentUrlEntity = contentDataDAO.getContentUrl(contentUrlEntity.getContentUrl());
assertNotNull(contentUrlEntity);
assertNotNull(contentDataDAO.getContentUrl(contentUrlEntity.getId()));
// test with size
long size = 100l;
String url = "store://" + GUID.generate();
contentUrlEntity = contentDataDAO.getOrCreateContentUrl(url, size);
contentUrlEntity = contentDataDAO.getContentUrl(contentUrlEntity.getContentUrl());
assertNotNull(contentUrlEntity);
assertNotNull(contentDataDAO.getContentUrl(contentUrlEntity.getId()));
assertEquals("The size does not match.", size, contentUrlEntity.getSize());
assertEquals("The content URL does not match.", url, contentUrlEntity.getContentUrl());
}
示例12
@Test
public void testCreateAndUpdateInTheSameTransaction()
{
retryingTransactionHelper.doInTransaction(() -> {
NodeRef node1 = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(TEST_NAMESPACE, GUID.generate()),
ContentModel.TYPE_CONTENT).getChildRef();
nodeService.setProperty(node1, ContentModel.PROP_DESCRIPTION, "test description");
return null;
});
//Create and update node are done in the same transaction so one event is expected
// to be generated
checkNumOfEvents(1);
}
示例13
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);
}
示例14
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;
}
示例15
@Before
public void before() throws Exception
{
File tempDir = TempFileProvider.getTempDir();
// create a primary file store
String storeDir = tempDir.getAbsolutePath() + File.separatorChar + GUID.generate();
primaryStore = new FileContentStore(ctx, storeDir);
// create some secondary file stores
secondaryStores = new ArrayList<ContentStore>(3);
for (int i = 0; i < 4; i++)
{
storeDir = tempDir.getAbsolutePath() + File.separatorChar + GUID.generate();
FileContentStore store = new FileContentStore(ctx, storeDir);
secondaryStores.add(store);
}
// Create the aggregating store
aggregatingStore = new AggregatingContentStore();
aggregatingStore.setPrimaryStore(primaryStore);
aggregatingStore.setSecondaryStores(secondaryStores);
}
示例16
@BeforeClass public static void setup() throws Exception
{
ServiceRegistry serviceRegistry = (ServiceRegistry) APP_CONTEXT_INIT.getApplicationContext().getBean(ServiceRegistry.SERVICE_REGISTRY);
transactionService = serviceRegistry.getTransactionService();
txnHelper = transactionService.getRetryingTransactionHelper();
cannedQueryDAO = (CannedQueryDAO) APP_CONTEXT_INIT.getApplicationContext().getBean("cannedQueryDAO");
cannedQueryDAOForTesting = (CannedQueryDAO) APP_CONTEXT_INIT.getApplicationContext().getBean("cannedQueryDAOForTesting");
mimetypeDAO = (MimetypeDAO) APP_CONTEXT_INIT.getApplicationContext().getBean("mimetypeDAO");
RetryingTransactionCallback<String> createMimetypeCallback = new RetryingTransactionCallback<String>()
{
@Override
public String execute() throws Throwable
{
String mimetypePrefix = GUID.generate();
mimetypeDAO.getOrCreateMimetype(mimetypePrefix + "-aaa");
mimetypeDAO.getOrCreateMimetype(mimetypePrefix + "-bbb");
return mimetypePrefix;
}
};
mimetypePrefix = txnHelper.doInTransaction(createMimetypeCallback);
}
示例17
@Test
public void testUserChain() throws Exception
{
String rawPassword = "[email protected]";
String salt = GUID.generate();
ShaPasswordEncoderImpl sha = new ShaPasswordEncoderImpl(256);
String shaEncoded = sha.encodePassword(rawPassword, salt);
assertTrue(encoder.matches("sha256", rawPassword, shaEncoded, salt));
List<String> nowHashed = new ArrayList<String>();
nowHashed.add("sha256");
nowHashed.add("bcrypt10");
String nowEncoded = encoder.encode("bcrypt10", shaEncoded, salt);
String nowEncoded2 = encoder.encode("bcrypt10", shaEncoded, salt);
String nowEncoded3 = encoder.encode("bcrypt10", shaEncoded, salt);
assertTrue(encoder.matchesPassword(rawPassword, nowEncoded, salt, nowHashed));
assertTrue(encoder.matchesPassword(rawPassword, nowEncoded2, salt, nowHashed));
assertTrue(encoder.matchesPassword(rawPassword, nowEncoded3, salt, nowHashed));
}
示例18
@Override
public Iterator<NodeDescription> iterator()
{
return new Iterator<NodeDescription>()
{
private int pos;
public boolean hasNext()
{
return this.pos < RandomPersonCollection.this.size;
}
public NodeDescription next()
{
this.pos++;
return newPerson("U" + GUID.generate());
}
public void remove()
{
throw new UnsupportedOperationException();
}
};
}
示例19
public ReplicationDefinition createReplicationDefinition(
String replicationDefinitionName, String description) {
if (log.isDebugEnabled())
{
StringBuilder msg = new StringBuilder();
msg.append("Creating replication definition ")
.append(replicationDefinitionName);
log.debug(msg.toString());
}
return new ReplicationDefinitionImpl(GUID.generate(), replicationDefinitionName, description);
}
示例20
/**
* @return
*/
private TransferManifestNormalNode createContentNode(/*String transferId*/) throws Exception
{
TransferManifestNormalNode node = new TransferManifestNormalNode();
String uuid = GUID.generate();
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, uuid);
node.setNodeRef(nodeRef);
node.setUuid(uuid);
byte[] dummyContent = "This is some dummy content.".getBytes("UTF-8");
node.setType(ContentModel.TYPE_CONTENT);
/**
* Get guest home
*/
NodeRef parentFolder = guestHome;
String nodeName = uuid + ".testnode" + getNameSuffix();
List<ChildAssociationRef> parents = new ArrayList<ChildAssociationRef>();
ChildAssociationRef primaryAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, parentFolder, QName
.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName), node.getNodeRef(), true, -1);
parents.add(primaryAssoc);
node.setParentAssocs(parents);
node.setParentPath(nodeService.getPath(parentFolder));
node.setPrimaryParentAssoc(primaryAssoc);
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_NODE_UUID, uuid);
props.put(ContentModel.PROP_NAME, nodeName);
ContentData contentData = new ContentData("/" + uuid, "text/plain", dummyContent.length, "UTF-8");
props.put(ContentModel.PROP_CONTENT, contentData);
node.setProperties(props);
return node;
}
示例21
public void testUpdateOrCreateAttribute()
{
final String KEY_RND_STR_1 = "string1"+ GUID.generate();
final String KEY_RND_STR_2 = "string2"+ GUID.generate();
try
{
attributeService.updateOrCreateAttribute(KEY_RND_STR_2, null, null, KEY_RND_STR_1, null, null);
try
{
attributeService.updateOrCreateAttribute(KEY_RND_STR_2, null, null, KEY_RND_STR_1, null, null);
fail("Duplicate attribute creation should not be allowed");
}
catch (DuplicateAttributeException expected)
{
}
//First call creates it, the second updates it. No errors.
attributeService.updateOrCreateAttribute(KEY_RND_STR_1, null, null, KEY_RND_STR_2, null, null);
attributeService.updateOrCreateAttribute(KEY_RND_STR_2, null, null, KEY_RND_STR_2, null, null);
}
finally
{
attributeService.removeAttribute(KEY_RND_STR_1, null, null);
attributeService.removeAttribute(KEY_RND_STR_2, null, null);
}
}
示例22
private TransferManifestNormalNode createFolderNode(String folderName) throws Exception
{
TransferManifestNormalNode node = new TransferManifestNormalNode();
String uuid = GUID.generate();
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, uuid);
node.setNodeRef(nodeRef);
node.setUuid(uuid);
node.setType(ContentModel.TYPE_FOLDER);
NodeRef parentFolder = repositoryHelper.getGuestHome();
String nodeName = folderName == null ? uuid + ".folder" + getNameSuffix() : folderName;
List<ChildAssociationRef> parents = new ArrayList<ChildAssociationRef>();
ChildAssociationRef primaryAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, parentFolder, QName
.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName), node.getNodeRef(), true, -1);
parents.add(primaryAssoc);
node.setParentAssocs(parents);
node.setParentPath(nodeService.getPath(parentFolder));
node.setPrimaryParentAssoc(primaryAssoc);
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_NODE_UUID, uuid);
props.put(ContentModel.PROP_NAME, nodeName);
node.setProperties(props);
return node;
}
示例23
public TransactionAwareSingleton()
{
txnKey = GUID.generate();
ReentrantReadWriteLock serverReadWriteLock = new ReentrantReadWriteLock();
singletonReadLock = serverReadWriteLock.readLock();
singletonWriteLock = serverReadWriteLock.writeLock();
}
示例24
/**
* MNT-2641: The {@link ContentModel#ASPECT_WORKING_COPY} aspect cannot be removed from a working copy
*/
@Test
public void testDeleteWorkingCopyAspect()
{
// Create a FolderA
final NodeRef folderA = createFolder("DeleteCopiedFromAspectFromWorkingCopy_" + GUID.generate());
// Create content in FolderA
final NodeRef orig = createContent("original_" + GUID.generate(), folderA);
// Check out the document
NodeRef workingCopy = this.cociService.checkout(orig);
assertNotNull(workingCopy);
assertTrue("cm:workingCopy aspect not found on working copy.",
nodeService.hasAspect(workingCopy, ContentModel.ASPECT_WORKING_COPY));
assertTrue("cm:copiedFrom aspect not found on working copy.",
nodeService.hasAspect(workingCopy, ContentModel.ASPECT_COPIEDFROM));
TestTransaction.flagForCommit();
TestTransaction.end();
// try to delete cm:copiedfrom aspect from working copy - must be allowed
nodeService.removeAspect(workingCopy, ContentModel.ASPECT_COPIEDFROM);
// Try to delete cm:workingcopy aspect from working copy - must be denied
try
{
nodeService.removeAspect(workingCopy, ContentModel.ASPECT_WORKING_COPY);
fail("Should not be able to remove cm:workingcopy");
}
catch (UnsupportedOperationException e)
{
// Expected
}
}
示例25
public RenditionDefinition createRenditionDefinition(QName renditionDefinitionName, String renderingEngineName)
{
if (log.isDebugEnabled())
{
StringBuilder msg = new StringBuilder();
msg.append("Creating rendition definition ")
.append(renditionDefinitionName)
.append(" ")
.append(renderingEngineName);
log.debug(msg.toString());
}
return new RenditionDefinitionImpl(GUID.generate(), renditionDefinitionName, renderingEngineName);
}
示例26
public CompositeRenditionDefinition createCompositeRenditionDefinition(QName renditionName)
{
if (log.isDebugEnabled())
{
StringBuilder msg = new StringBuilder();
msg.append("Creating composite rendition definition ")
.append(renditionName);
log.debug(msg.toString());
}
return new CompositeRenditionDefinitionImpl(GUID.generate(), renditionName);
}
示例27
private ChildAssociationRef createRenditionNodeAssoc(NodeRef sourceNode, RenditionDefinition renditionDefinition)
{
QName renditionName = renditionDefinition.getRenditionName();
// The ThumbnailService puts a cm:name property on its thumbnail nodes.
Map<QName, Serializable> nodeProps = new HashMap<QName, Serializable>();
nodeProps.put(ContentModel.PROP_NAME, renditionName.getLocalName());
nodeProps.put(ContentModel.PROP_CONTENT_PROPERTY_NAME, getRenditionContentProp(renditionDefinition));
QName assocName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, GUID.generate());
NodeRef parentNode = renditionDefinition.getRenditionParent();
QName assocType = renditionDefinition.getRenditionAssociationType();
QName nodeType = getRenditionNodeType(renditionDefinition);
// Ensure that the creation of rendition children does not cause updates
// to the modified, modifier properties on the source node
behaviourFilter.disableBehaviour(parentNode, ContentModel.ASPECT_AUDITABLE);
ChildAssociationRef childAssoc = null;
try
{
childAssoc = nodeService.createNode(parentNode, assocType, assocName, nodeType, nodeProps);
if (logger.isDebugEnabled())
{
logger.debug("Created node " + childAssoc + " as child of " + parentNode + " with assoc-type " + assocType);
}
}
finally
{
behaviourFilter.enableBehaviour(parentNode, ContentModel.ASPECT_AUDITABLE);
}
return childAssoc;
}
示例28
/**
* Test of Get TransferTargets
*
* @throws Exception
*/
@Test
public void testGetTransferTargets() throws Exception
{
String nameA = "Test Transfer Target " + GUID.generate();
String nameB = "Test Transfer Target " + GUID.generate();
String title = "title";
String description = "description";
String endpointProtocol = "http";
String endpointHost = "localhost";
int endpointPort = 8080;
String endpointPath = "rhubarb";
String username = "admin";
char[] password = "password".toCharArray();
/**
* Now go ahead and create our first transfer target
*/
TransferTarget targetA = transferService.createAndSaveTransferTarget(nameA, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
TransferTarget targetB = transferService.createAndSaveTransferTarget(nameB, title, description, endpointProtocol, endpointHost, endpointPort, endpointPath, username, password);
Set<TransferTarget> targets = transferService.getTransferTargets();
assertTrue("targets is empty", targets.size() > 0);
assertTrue("didn't find target A", targets.contains(targetA) );
assertTrue("didn't find target B", targets.contains(targetB));
for(TransferTarget target : targets)
{
System.out.println("found target: " + target.getName());
}
}
示例29
public static String createNewFileStoreUrl(int minuteBucketCount)
{
StringBuilder sb = new StringBuilder(20);
sb.append(FileContentStore.STORE_PROTOCOL);
sb.append(ContentStore.PROTOCOL_DELIMITER);
sb.append(createTimeBasedPath(minuteBucketCount));
sb.append(GUID.generate()).append(".bin");
return sb.toString();
}
示例30
/**
* Listing for a user
*/
public void testMNT_3053() throws Exception
{
String siteName = null;
do
{
siteName = GUID.generate();
}
while (siteService.getSite(siteName) != null);
sendRequest(new GetRequest("/calendar/events/" + siteName + "/user"), 404);
}