本文整理汇总了Java中org.alfresco.service.cmr.repository.ContentData.setMimetype方法的典型用法代码示例。如果您正苦于以下问题:Java ContentData.setMimetype方法的具体用法?Java ContentData.setMimetype怎么用?Java ContentData.setMimetype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.repository.ContentData
的用法示例。
在下文中一共展示了ContentData.setMimetype方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setMimetype
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
public void setMimetype(String mimetype)
{
mimetype = mimetype.toLowerCase();
this.contentData = ContentData.setMimetype(this.contentData, mimetype);
services.getNodeService().setProperty(nodeRef, this.property, this.contentData);
updateContentData(false);
}
示例2: sanitizeMimetype
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
private ContentData sanitizeMimetype(ContentData contentData)
{
String mimetype = contentData.getMimetype();
if (mimetype != null)
{
mimetype = mimetype.toLowerCase();
contentData = ContentData.setMimetype(contentData, mimetype);
}
return contentData;
}
示例3: putContent
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
private void putContent(NodeRef zipFileNodeRef, String resource)
{
URL url = AbstractContentTransformerTest.class.getClassLoader().getResource(resource);
final File file = new File(url.getFile());
contentService.getWriter(zipFileNodeRef, ContentModel.PROP_CONTENT, true).putContent(file);
ContentData contentData = (ContentData) nodeService.getProperty(zipFileNodeRef, ContentModel.PROP_CONTENT);
ContentData newContentData = ContentData.setMimetype(contentData, MimetypeMap.MIMETYPE_ZIP);
nodeService.setProperty(zipFileNodeRef, ContentModel.PROP_CONTENT, newContentData);
}
示例4: testEnsureCaseInsensitiveMimetypeStorage
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
* the caveat to {@link #testEnsureCaseSensitiveStorage()} is that mimetypes
* must be normalized to lowercase.
*
* @throws Exception
*/
public void testEnsureCaseInsensitiveMimetypeStorage() throws Exception
{
ContentData contentData = getContentData();
ContentData cdWithUpperMimetype = ContentData.setMimetype(contentData, "TEXT/MYFORMAT");
ContentData cdWithLowerMimetype = ContentData.setMimetype(contentData, "text/myformat");
// In both instances, the created entry should have a lowercase mimetype
Pair<Long, ContentData> result = create(cdWithUpperMimetype);
// Ensure the ContentData's mimetype was stored in lowercase
assertEquals("text/myformat", result.getSecond().getMimetype());
result = create(cdWithLowerMimetype);
assertEquals("text/myformat", result.getSecond().getMimetype());
}
示例5: testUpdate
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
public void testUpdate() throws Exception
{
ContentData contentData = getContentData();
Pair<Long, ContentData> resultPair = create(contentData);
Long id = resultPair.getFirst();
// Update
contentData = ContentData.setMimetype(contentData, "TEXT/HTML"); // Note the upper case mimetype
contentData = ContentData.setEncoding(contentData, "UTF-16");
// Don't update the content itself
update(id, contentData);
// Check
Pair<Long, ContentData> result = getAndCheck(id, contentData);
// Check the mimetype has been lowercased
assertEquals("text/html", result.getSecond().getMimetype());
}
示例6: cloneNode
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
* Clone node
*
* @param newName the new name of the node
* @param fromNode the node to copy from
* @param toNode the node to copy to
* @param ctx
*/
private void cloneNode(String newName, NodeRef fromNode, NodeRef toNode, ContentContext ctx)
{
if(logger.isDebugEnabled())
{
logger.debug("clone node from fromNode:" + fromNode + "toNode:" + toNode);
}
cloneNodeAspects(newName, fromNode, toNode, ctx);
// copy over the node creator and owner properties
// need to disable the auditable aspect first to prevent default audit behaviour
policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
try
{
nodeService.setProperty(toNode, ContentModel.PROP_CREATOR, nodeService.getProperty(fromNode, ContentModel.PROP_CREATOR));
ownableService.setOwner(toNode, ownableService.getOwner(fromNode));
}
finally
{
policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
}
Set<AccessPermission> permissions = permissionService.getAllSetPermissions(fromNode);
boolean inheritParentPermissions = permissionService.getInheritParentPermissions(fromNode);
permissionService.deletePermissions(fromNode);
permissionService.setInheritParentPermissions(toNode, inheritParentPermissions);
for(AccessPermission permission : permissions)
{
permissionService.setPermission(toNode, permission.getAuthority(), permission.getPermission(), (permission.getAccessStatus() == AccessStatus.ALLOWED));
}
// Need to take a new guess at the mimetype based upon the new file name.
ContentData content = (ContentData)nodeService.getProperty(toNode, ContentModel.PROP_CONTENT);
// Take a guess at the mimetype (if it has not been set by something already)
if (content != null && (content.getMimetype() == null || content.getMimetype().equals(MimetypeMap.MIMETYPE_BINARY)))
{
String mimetype = mimetypeService.guessMimetype(newName);
if(logger.isDebugEnabled())
{
logger.debug("set new mimetype to:" + mimetype);
}
ContentData replacement = ContentData.setMimetype(content, mimetype);
nodeService.setProperty(toNode, ContentModel.PROP_CONTENT, replacement);
}
// Extract metadata pending change for ALF-5082
Action action = getActionService().createAction(ContentMetadataExtracter.EXECUTOR_NAME);
if(action != null)
{
getActionService().executeAction(action, toNode);
}
}
示例7: copyContent
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
@Override
public void copyContent(NodeRef rootNode, String fromPath, String toPath) throws FileNotFoundException
{
if(logger.isDebugEnabled())
{
logger.debug("copyContent from:" + fromPath + " to:" + toPath);
}
NodeRef sourceNodeRef = getNodeForPath(rootNode, fromPath);
NodeRef targetNodeRef = getNodeForPath(rootNode, toPath);
Serializable prop = nodeService.getProperty(sourceNodeRef, ContentModel.PROP_CONTENT);
if(prop != null)
{
if(prop instanceof ContentData)
{
ContentData data = (ContentData)prop;
if(data.getMimetype().equalsIgnoreCase(MimetypeMap.MIMETYPE_BINARY))
{
if(logger.isDebugEnabled())
{
logger.debug("mimetype is binary - guess mimetype has failed");
}
Serializable targetProp = nodeService.getProperty(targetNodeRef, ContentModel.PROP_CONTENT);
if(targetProp != null && targetProp instanceof ContentData)
{
ContentData targetData = (ContentData)targetProp;
logger.debug("copy the existing mimetype");
prop = ContentData.setMimetype(data, targetData.getMimetype());
}
}
}
nodeService.setProperty(targetNodeRef, ContentModel.PROP_CONTENT, prop);
}
else
{
logger.debug("no content to save");
// No content to set - need to remove old content
ContentWriter writer = contentService.getWriter(targetNodeRef, ContentModel.PROP_CONTENT, true);
writer.putContent("");
}
}
示例8: copyContentData
import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
* Copy content data from file to file
*
* @param sess SrvSession
* @param tree TreeConnection
* @param fromNode NodeRef
* @param toNode NodeRef
* @param newName String
*/
private void copyContentData( SrvSession sess, TreeConnection tree, NodeRef fromNode, NodeRef toNode, String newName)
{
ContentData content = (ContentData) nodeService.getProperty(fromNode, ContentModel.PROP_CONTENT);
if ( newName != null)
content = ContentData.setMimetype( content, mimetypeService.guessMimetype( newName));
nodeService.setProperty(toNode, ContentModel.PROP_CONTENT, content);
}