本文整理汇总了Java中org.alfresco.service.cmr.model.FileInfo.getNodeRef方法的典型用法代码示例。如果您正苦于以下问题:Java FileInfo.getNodeRef方法的具体用法?Java FileInfo.getNodeRef怎么用?Java FileInfo.getNodeRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.model.FileInfo
的用法示例。
在下文中一共展示了FileInfo.getNodeRef方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postFileFolderActivity
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
private void postFileFolderActivity(
String activityType,
String siteId,
String tenantDomain,
String path,
NodeRef parentNodeRef,
FileInfo contentNodeInfo) throws WebDAVServerException
{
String fileName = contentNodeInfo.getName();
NodeRef nodeRef = contentNodeInfo.getNodeRef();
try
{
poster.postFileFolderActivity(activityType, path, tenantDomain, siteId,
parentNodeRef, nodeRef, fileName,
appTool, Client.asType(ClientType.webdav),contentNodeInfo);
}
catch (AlfrescoRuntimeException are)
{
logger.error("Failed to post activity.", are);
throw new WebDAVServerException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
示例2: testAlf6560MimetypeSetting
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
public void testAlf6560MimetypeSetting() throws Exception
{
FileInfo fileInfo = fileFolderService.create(workingRootNodeRef, "Something.html", ContentModel.TYPE_CONTENT);
NodeRef fileNodeRef = fileInfo.getNodeRef();
// Write the content but without setting the mimetype
ContentWriter writer = fileFolderService.getWriter(fileNodeRef);
writer.putContent("CONTENT");
ContentReader reader = fileFolderService.getReader(fileNodeRef);
assertEquals("Mimetype was not automatically set", MimetypeMap.MIMETYPE_HTML, reader.getMimetype());
// Now ask for encoding too
writer = fileFolderService.getWriter(fileNodeRef);
writer.guessEncoding();
OutputStream out = writer.getContentOutputStream();
out.write( "<html><body>hall\u00e5 v\u00e4rlden</body></html>".getBytes("UnicodeBig") );
out.close();
reader = fileFolderService.getReader(fileNodeRef);
assertEquals("Mimetype was not automatically set", MimetypeMap.MIMETYPE_HTML, reader.getMimetype());
assertEquals("Encoding was not automatically set", "UTF-16BE", reader.getEncoding());
}
示例3: findNodeRef
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
/**
* Gets the node ref for the specified path within this repo store
*
* @param documentPath String
* @return node ref
*/
protected NodeRef findNodeRef(String documentPath)
{
NodeRef node = null;
try
{
String[] pathElements = documentPath.split("/");
List<String> pathElementsList = Arrays.asList(pathElements);
FileInfo file = fileService.resolveNamePath(getBaseNodeRef(), pathElementsList);
node = file.getNodeRef();
}
catch (FileNotFoundException e)
{
// NOTE: return null
}
return node;
}
示例4: getHomeFolder
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
/**
* Helper method for {@link HomeFolderProvider2#getHomeFolder(NodeRef)}
* implementations to return a {@link HomeSpaceNodeRef}
* @param referenceRootNode indicates that a reference to the root node
* should be returned if the home folder property on the person
* has not yet been set.
*/
public HomeSpaceNodeRef getHomeFolder(HomeFolderProvider2 provider, NodeRef person, boolean referenceRootNode)
{
HomeSpaceNodeRef homeSpaceNodeRef = null;
NodeRef existingHomeFolder = DefaultTypeConverter.INSTANCE.convert(
NodeRef.class, nodeService.getProperty(
person, ContentModel.PROP_HOMEFOLDER));
if (existingHomeFolder != null)
{
homeSpaceNodeRef = new HomeSpaceNodeRef(existingHomeFolder,
HomeSpaceNodeRef.Status.VALID);
}
else if (referenceRootNode)
{
homeSpaceNodeRef = new HomeSpaceNodeRef(getRootPathNodeRef(provider),
HomeSpaceNodeRef.Status.REFERENCED);
}
else
{
// If the preferred home folder already exists, append "-N"
NodeRef root = getRootPathNodeRef(provider);
List<String> homeFolderPath = provider.getHomeFolderPath(person);
modifyHomeFolderNameIfItExists(root, homeFolderPath);
// Create folder
FileInfo fileInfo = createTree(provider, getRootPathNodeRef(provider), homeFolderPath,
provider.getTemplateNodeRef(), fileFolderService);
NodeRef homeFolderNodeRef = fileInfo.getNodeRef();
return new HomeSpaceNodeRef(homeFolderNodeRef, HomeSpaceNodeRef.Status.CREATED);
}
return homeSpaceNodeRef;
}
示例5: addFile
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
private NodeRef addFile(NodeRef parentNodeRef, String filename, int depth)
{
System.out.println(makeTabs(depth) + "Creating file " + filename + " in parent " + parentNodeRef);
FileInfo info = fileFolderService.create(parentNodeRef, filename, ContentModel.TYPE_CONTENT);
String name = info.getName();
if (!name.equals(filename))
{
String msg = "A filename '" + filename + "' was not persisted: " + info;
logger.error(msg);
rollbackMessages.add(msg);
}
return info.getNodeRef();
}
示例6: getTranslatedFileInfo
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
/**
* Converts the file info where an alternative translation should be used.
*
* @param fileInfo the basic file or folder info
* @return Returns a replacement if required
*/
private FileInfo getTranslatedFileInfo(FileInfo fileInfo)
{
// Ignore null
if (fileInfo == null)
{
return null;
}
// Ignore folders
if (fileInfo.isFolder())
{
return fileInfo;
}
NodeRef nodeRef = fileInfo.getNodeRef();
// Get the best translation for the node
NodeRef translatedNodeRef = getTranslatedNodeRef(nodeRef);
// Convert to FileInfo, if required
FileInfo translatedFileInfo = null;
if (nodeRef.equals(translatedNodeRef))
{
// No need to do any more work
translatedFileInfo = fileInfo;
}
else
{
// Get the FileInfo
translatedFileInfo = fileFolderService.getFileInfo(translatedNodeRef);
}
return translatedFileInfo;
}
示例7: createDirectory
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
public NodeRef createDirectory(NodeRef base, String path)
{
Pair<NodeRef, String> parentChild = getParentChildRelative(base, path);
FileInfo created = fFileFolderService.create(parentChild.getFirst(),
parentChild.getSecond(),
ContentModel.TYPE_FOLDER);
return created.getNodeRef();
}
示例8: testGetNamePathDoesNotReturnPathContainingNonLeafFileNode
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
public void testGetNamePathDoesNotReturnPathContainingNonLeafFileNode() throws Exception
{
FileInfo parentFolderInfo = getByName(NAME_L0_FOLDER_A, true);
assertNotNull(parentFolderInfo);
NodeRef parentFolderRef = parentFolderInfo.getNodeRef();
// create hierarchy: folder > file
FileInfo dirInfo = fileFolderService.create(parentFolderRef, "newDir", ContentModel.TYPE_FOLDER);
FileInfo fileInfo = fileFolderService.create(dirInfo.getNodeRef(), "newFile", ContentModel.TYPE_CONTENT);
// generate a path where the file is the last element: ok
List<FileInfo> path = fileFolderService.getNamePath(parentFolderRef, fileInfo.getNodeRef());
assertEquals(2, path.size());
// create hierarchy: folder > file > file
FileInfo fileInfo2 = fileFolderService.create(fileInfo.getNodeRef(), "newFile2", ContentModel.TYPE_CONTENT);
// generate a path where a file is not the last element in the path: not ok
try
{
fileFolderService.getNamePath(parentFolderRef, fileInfo2.getNodeRef());
fail("Shouldn't create path for non-leaf file.");
}
catch(InvalidTypeException e)
{
// Good
}
}
示例9: ActivityInfo
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
public ActivityInfo(String parentPath, NodeRef parentNodeRef, String siteId, FileInfo fileInfo)
{
super();
this.nodeRef = fileInfo.getNodeRef();
this.parentPath = parentPath;
this.parentNodeRef = parentNodeRef;
this.siteId = siteId;
this.fileName = fileInfo.getName();
this.isFolder = fileInfo.isFolder();
this.fileInfo = fileInfo;
}
示例10: convertPathToNodeRef
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
protected NodeRef convertPathToNodeRef(String targetPath) throws FileNotFoundException
{
NodeRef result = null;
NodeRef companyHome = repository.getCompanyHome();
String cleanTargetPath = targetPath.replaceAll("/+", "/");
if (cleanTargetPath.startsWith(COMPANY_HOME_PATH))
cleanTargetPath = cleanTargetPath.substring(COMPANY_HOME_PATH.length());
if (cleanTargetPath.startsWith("/"))
cleanTargetPath = cleanTargetPath.substring(1);
if (cleanTargetPath.endsWith("/"))
cleanTargetPath = cleanTargetPath.substring(0, cleanTargetPath.length() - 1);
if (cleanTargetPath.length() == 0)
result = companyHome;
else
{
FileInfo info = fileFolderService.resolveNamePath(companyHome, Arrays.asList(cleanTargetPath.split("/")));
if(info == null)
throw new WebScriptException("could not determine NodeRef for path :'"+cleanTargetPath+"'");
result = info.getNodeRef();
}
return(result);
}
示例11: testETHREEOH_3088_MoveIntoSelf
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
public void testETHREEOH_3088_MoveIntoSelf() throws Exception
{
FileInfo folderInfo = fileFolderService.create(workingRootNodeRef, "NotGood.txt", ContentModel.TYPE_FOLDER);
NodeRef folderNodeRef = folderInfo.getNodeRef();
// Move into self
try
{
fileFolderService.move(folderNodeRef, folderNodeRef, null);
fail("Failed to detect cyclic relationship");
}
catch (CyclicChildRelationshipException e)
{
// Expected
}
}
示例12: applyHidden
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
private void applyHidden(FileInfo fileInfo, HiddenFileInfo filter)
{
NodeRef nodeRef = fileInfo.getNodeRef();
if(!hasHiddenAspect(nodeRef))
{
// the file matches a pattern, apply the hidden and aspect control aspects
addHiddenAspect(nodeRef, filter);
}
else
{
nodeService.setProperty(nodeRef, ContentModel.PROP_VISIBILITY_MASK, filter.getVisibilityMask());
nodeService.setProperty(nodeRef, ContentModel.PROP_CASCADE_HIDDEN, filter.cascadeHiddenAspect());
nodeService.setProperty(nodeRef, ContentModel.PROP_CASCADE_INDEX_CONTROL, filter.cascadeIndexControlAspect());
}
if(!hasIndexControlAspect(nodeRef))
{
addIndexControlAspect(nodeRef);
}
if(fileInfo.isFolder() && (filter.cascadeHiddenAspect() || filter.cascadeIndexControlAspect()))
{
PagingRequest pagingRequest = new PagingRequest(0, Integer.MAX_VALUE, null);
PagingResults<FileInfo> results = fileFolderService.list(nodeRef, true, true, null, null, pagingRequest);
List<FileInfo> files = results.getPage();
// apply the hidden aspect to all folders and folders and then recursively to all sub-folders, unless the sub-folder
// already has the hidden aspect applied (it may have been applied for a different pattern).
for(FileInfo file : files)
{
behaviourFilter.disableBehaviour(file.getNodeRef(), ContentModel.ASPECT_LOCKABLE);
try
{
applyHidden(file, filter);
}
finally
{
behaviourFilter.enableBehaviour(file.getNodeRef(), ContentModel.ASPECT_LOCKABLE);
}
}
}
}
示例13: testLoad_04
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
/**
* 10 files; 10 per txn; force storage; identical
*/
@Test
public void testLoad_04() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
int created = fileFolderLoader.createFiles(
writeFolderPath,
10, 10, 1024L, 1024L, 1L, true,
10, 256L);
assertEquals("Incorrect number of files generated.", 10, created);
// Count
assertEquals(10, nodeService.countChildAssocs(writeFolderNodeRef, true));
// Check the files
List<FileInfo> fileInfos = fileFolderService.listFiles(writeFolderNodeRef);
String lastText = null;
String lastDescr = null;
String lastUrl = null;
for (FileInfo fileInfo : fileInfos)
{
NodeRef fileNodeRef = fileInfo.getNodeRef();
// The URLs must all be unique as we wrote the physical binaries
ContentReader reader = fileFolderService.getReader(fileNodeRef);
assertEquals("UTF-8", reader.getEncoding());
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, reader.getMimetype());
assertEquals(1024L, reader.getSize());
if (lastUrl == null)
{
lastUrl = reader.getContentUrl();
}
else
{
assertNotEquals("We expect unique URLs: ", lastUrl, reader.getContentUrl());
lastUrl = reader.getContentUrl();
}
// Check content
if (lastText == null)
{
lastText = reader.getContentString();
}
else
{
String currentStr = reader.getContentString();
assertEquals("All text must be identical due to same seed. ", lastText, currentStr);
lastText = currentStr;
}
// Check description
if (lastDescr == null)
{
lastDescr = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION));
assertEquals("cm:description length is incorrect. ", 256, lastDescr.getBytes().length);
}
else
{
String currentDescr = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION));
assertEquals("All descriptions must be identical due to varying seed. ", lastDescr, currentDescr);
lastDescr = currentDescr;
}
}
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
示例14: resolveNodeByPath
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
protected NodeRef resolveNodeByPath(final NodeRef parentNodeRef, String path, boolean checkForCompanyHome)
{
final List<String> pathElements = getPathElements(path);
if (!pathElements.isEmpty() && checkForCompanyHome)
{
/*
if (nodeService.getRootNode(parentNodeRef.getStoreRef()).equals(parentNodeRef))
{
// special case
NodeRef chNodeRef = repositoryHelper.getCompanyHome();
String chName = (String) nodeService.getProperty(chNodeRef, ContentModel.PROP_NAME);
if (chName.equals(pathElements.get(0)))
{
pathElements = pathElements.subList(1, pathElements.size());
parentNodeRef = chNodeRef;
}
}
*/
}
FileInfo fileInfo = null;
try
{
if (!pathElements.isEmpty())
{
fileInfo = fileFolderService.resolveNamePath(parentNodeRef, pathElements);
}
else
{
fileInfo = fileFolderService.getFileInfo(parentNodeRef);
if (fileInfo == null)
{
throw new EntityNotFoundException(parentNodeRef.getId());
}
}
}
catch (FileNotFoundException fnfe)
{
// convert checked exception
throw new NotFoundException("The entity with relativePath: " + path + " was not found.");
}
catch (AccessDeniedException ade)
{
// return 404 instead of 403 (as per security review - uuid vs path)
throw new NotFoundException("The entity with relativePath: " + path + " was not found.");
}
return fileInfo.getNodeRef();
}
示例15: testLoad_15_16bytes
import org.alfresco.service.cmr.model.FileInfo; //导入方法依赖的package包/类
/**
* Load 15 files; 1K size; 1 document sample; force binary storage
*/
@SuppressWarnings("unchecked")
public void testLoad_15_16bytes() throws Exception
{
JSONObject body = new JSONObject();
body.put(FileFolderLoaderPost.KEY_FOLDER_PATH, loadHomePath);
body.put(FileFolderLoaderPost.KEY_MIN_FILE_SIZE, 16L);
body.put(FileFolderLoaderPost.KEY_MAX_FILE_SIZE, 16L);
body.put(FileFolderLoaderPost.KEY_MAX_UNIQUE_DOCUMENTS, 1L);
body.put(FileFolderLoaderPost.KEY_FORCE_BINARY_STORAGE, Boolean.TRUE);
Response response = null;
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser("maggi");
response = sendRequest(
new PostRequest(URL, body.toString(), "application/json"),
Status.STATUS_OK,
"maggi");
}
finally
{
AuthenticationUtil.popAuthentication();
}
assertEquals("{\"count\":100}", response.getContentAsString());
// Check file(s)
assertEquals(100, nodeService.countChildAssocs(loadHomeNodeRef, true));
// Consistent binary text
String contentUrlCheck = SpoofedTextContentReader.createContentUrl(Locale.ENGLISH, 0L, 16L);
ContentReader readerCheck = new SpoofedTextContentReader(contentUrlCheck);
String textCheck = readerCheck.getContentString();
// Size should be default
List<FileInfo> fileInfos = fileFolderService.list(loadHomeNodeRef);
for (FileInfo fileInfo : fileInfos)
{
NodeRef fileNodeRef = fileInfo.getNodeRef();
ContentReader reader = fileFolderService.getReader(fileNodeRef);
// Expect storage in store
assertTrue(reader.getContentUrl().startsWith(FileContentStore.STORE_PROTOCOL));
// Check text
String text = reader.getContentString();
assertEquals("Text not the same.", textCheck, text);
}
}