本文整理汇总了Java中org.alfresco.service.cmr.model.FileInfo类的典型用法代码示例。如果您正苦于以下问题:Java FileInfo类的具体用法?Java FileInfo怎么用?Java FileInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileInfo类属于org.alfresco.service.cmr.model包,在下文中一共展示了FileInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMakeFoldersShortNames
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
/**
* Lucene only indexes terms that are 3 characters or more
*/
public void testMakeFoldersShortNames() throws Exception
{
// create a completely new path below the root
List<String> namePath = new ArrayList<String>(4);
namePath.add("A");
namePath.add("B");
namePath.add("C");
namePath.add("D");
FileInfo lastFileInfo = FileFolderServiceImpl.makeFolders(fileFolderService, rootNodeRef, namePath,
ContentModel.TYPE_FOLDER);
assertNotNull("First makeFolder failed", lastFileInfo);
// check that a repeat works
FileInfo lastFileInfoAgain = FileFolderServiceImpl.makeFolders(fileFolderService, rootNodeRef, namePath,
ContentModel.TYPE_FOLDER);
assertNotNull("Repeat makeFolders failed", lastFileInfoAgain);
assertEquals("Repeat created new leaf", lastFileInfo.getNodeRef(), lastFileInfoAgain.getNodeRef());
}
示例2: buildTransactions7
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
private void buildTransactions7()
{
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
PropertyMap props = new PropertyMap();
props.put(ContentModel.PROP_NAME, "Container7");
container7 = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_FOLDER,
props).getChildRef();
FileInfo contentInfo = fileFolderService.create(container7, "Content1", ContentModel.TYPE_CONTENT);
contents.add(contentInfo.getNodeRef());
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>();
aspectProperties.put(ContentModel.PROP_AUTHOR, "ste\"ve");
nodeService.addAspect(contentInfo.getNodeRef(), ContentModel.ASPECT_AUTHOR, aspectProperties);
return null;
}
});
}
示例3: testGetFlags
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
public void testGetFlags() throws Exception
{
NavigableMap<Long, FileInfo> fis = imapService.getFolderStatus(authenticationService.getCurrentUserName(), testImapFolderNodeRef, ImapViewMode.ARCHIVE).search;
if (fis != null && fis.size() > 0)
{
FileInfo messageFileInfo = fis.firstEntry().getValue();
reauthenticate(USER_NAME, USER_PASSWORD);
permissionService.setPermission(testImapFolderNodeRef, anotherUserName, PermissionService.WRITE, true);
imapService.setFlags(messageFileInfo, flags, true);
reauthenticate(anotherUserName, anotherUserName);
Flags fl = imapService.getFlags(messageFileInfo);
assertTrue(fl.contains(flags));
}
}
示例4: setFlags
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
/**
* Set flags to the specified imapFolder.
*
* @param messageInfo FileInfo of imap Folder.
* @param flags flags to set.
* @param value value to set.
*/
public void setFlags(FileInfo messageInfo, Flags flags, boolean value)
{
checkForFlaggableAspect(messageInfo.getNodeRef());
for (Flags.Flag flag : flags.getSystemFlags())
{
setFlag(messageInfo, flag, value);
}
}
示例5: buildTransactions5
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
private void buildTransactions5()
{
txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
PropertyMap props = new PropertyMap();
props.put(ContentModel.PROP_NAME, "Container6");
container6 = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
ContentModel.TYPE_FOLDER,
props).getChildRef();
FileInfo contentInfo = fileFolderService.create(container6, "Content1", ContentModel.TYPE_CONTENT);
contents.add(contentInfo.getNodeRef());
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>();
aspectProperties.put(ContentModel.PROP_AUTHOR, "steve");
nodeService.addAspect(contentInfo.getNodeRef(), ContentModel.ASPECT_AUTHOR, aspectProperties);
return null;
}
});
}
示例6: list
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
@Override
public List<FileInfo> list(NodeRef contextNodeRef)
{
if (canVirtualize(contextNodeRef))
{
Reference reference = smartStore.virtualize(contextNodeRef);
List<Reference> virtualNodes = smartStore.list(reference);
List<FileInfo> searchResult = asFileInfos(virtualNodes,
smartStore,
environment);
if (mergeActualNode(reference))
{
List<FileInfo> actualSearch = getTrait().list(actualNodeFrom(reference));
searchResult.addAll(actualSearch);
}
return searchResult;
}
else
{
return getTrait().list(contextNodeRef);
}
}
示例7: getRecentCount
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
/**
* Returns count of messages with {@link javax.mail.Flags.Flag#RECENT} flag.
* If {@code reset} parameter is {@code true} - removes {@link javax.mail.Flags.Flag#RECENT} flag from
* the message for current user.
*
* @param reset - if true the {@link javax.mail.Flags.Flag#RECENT} will be deleted for current user if exists.
* @return returns count of recent messages.
*/
@Override
public int getRecentCount(boolean reset)
{
int recent = getFolderStatus().recentCount;
if (reset && recent > 0)
{
CommandCallback<Void> command = new CommandCallback<Void>()
{
public Void command() throws Throwable
{
for (FileInfo fileInfo : folderStatus.search.values())
{
Flags flags = imapService.getFlags(fileInfo);
if (flags.contains(Flags.Flag.RECENT))
{
imapService.setFlag(fileInfo, Flags.Flag.RECENT, false);
}
}
return null;
}
};
try
{
command.run();
}
catch (AccessDeniedException ade)
{
if (logger.isDebugEnabled())
{
logger.debug("Access denied to reset RECENT FLAG");
}
}
}
return recent;
}
示例8: testTemplateServiceBinding
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
public void testTemplateServiceBinding() throws Exception
{
try
{
FileInfo xmlFile = createXmlFile(companyHome);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
templateService.processTemplate("xslt", "org/alfresco/repo/template/test_template1.xsl", model, writer);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
示例9: buildMessage
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
protected void buildMessage(FileInfo fileInfo, ServiceRegistry serviceRegistry) throws MessagingException
{
checkParameter(serviceRegistry, "ServiceRegistry");
this.content = null;
this.serviceRegistry = serviceRegistry;
this.imapService = serviceRegistry.getImapService();
this.messageFileInfo = fileInfo;
this.isMessageInSitesLibrary = imapService.getNodeSiteContainer(messageFileInfo.getNodeRef()) != null ? true : false;
RetryingTransactionHelper txHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper();
txHelper.setMaxRetries(MAX_RETRIES);
txHelper.setReadOnly(false);
txHelper.doInTransaction(new RetryingTransactionCallback<Object>() {
public Object execute() throws Throwable
{
buildMessageInternal();
return null;
}
}, false);
}
示例10: toFileInfo
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
/**
* Helper method to convert node reference instances to file info
*
* @param nodeRefs the node references
* @return Return a list of file info
* @throws InvalidTypeException if the node is not a valid type
*/
private List<FileInfo> toFileInfo(List<NodeRef> nodeRefs) throws InvalidTypeException
{
List<FileInfo> results = new ArrayList<FileInfo>(nodeRefs.size());
for (NodeRef nodeRef : nodeRefs)
{
try
{
FileInfo fileInfo = toFileInfo(nodeRef, true);
results.add(fileInfo);
}
catch (InvalidNodeRefException inre)
{
logger.warn("toFileInfo: "+inre);
// skip
}
}
return results;
}
示例11: testPutContentToFolder
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的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());
}
}
示例12: publishReadEvent
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
/**
* Notifies listeners that a read has taken place
* @param realNodeInfo FileInfo
* @param mimetype String
* @param size Long
* @param contentEncoding String
* @param range String
*/
protected void publishReadEvent(final FileInfo realNodeInfo, final String mimetype, final Long size, final String contentEncoding, final String range)
{
if (!StringUtils.hasText(range))
{
// Its not a range request
eventPublisher.publishEvent(new EventPreparator()
{
@Override
public Event prepareEvent(String user, String networkId, String transactionId)
{
return new ContentEventImpl(ContentEvent.DOWNLOAD, user, networkId, transactionId, realNodeInfo.getNodeRef().getId(), null,
realNodeInfo.getType().toString(), Client.asType(ClientType.webdav), realNodeInfo.getName(), mimetype,
size, contentEncoding);
}
});
}
}
示例13: getContentDispositionHeader
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
protected String getContentDispositionHeader(FileInfo nodeInfo)
{
String filename = nodeInfo.getName();
StringBuilder sb = new StringBuilder();
sb.append("attachment; filename=\"");
for(int i = 0; i < filename.length(); i++)
{
char c = filename.charAt(i);
if(isValidQuotedStringHeaderParamChar(c))
{
sb.append(c);
}
else
{
sb.append(" ");
}
}
sb.append("\"; filename*=UTF-8''");
sb.append(URLEncoder.encode(filename));
return sb.toString();
}
示例14: getWriter
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
@Override
public ContentWriter getWriter(NodeRef nodeRef)
{
FileInfo fileInfo = toFileInfo(nodeRef, false);
if (fileInfo.isFolder())
{
throw new InvalidTypeException("Unable to get a content writer for a folder: " + fileInfo);
}
final ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
// Ensure that a mimetype is set based on the filename (ALF-6560)
// This has been removed from the create code in 3.4 to prevent insert-update behaviour
// of the ContentData.
if (writer.getMimetype() == null)
{
final String name = fileInfo.getName();
writer.guessMimetype(name);
}
// Done
return writer;
}
示例15: testRenameDuplicate
import org.alfresco.service.cmr.model.FileInfo; //导入依赖的package包/类
public void testRenameDuplicate() throws Exception
{
FileInfo folderInfo = getByName(NAME_L0_FOLDER_A, true);
assertNotNull(folderInfo);
// rename duplicate. A file with that name already exists
String newName = NAME_L0_FILE_A;
try
{
folderInfo = fileFolderService.rename(folderInfo.getNodeRef(), newName);
fail("Existing file not detected");
}
catch (FileExistsException e)
{
// expected
}
}