本文整理汇总了Java中org.apache.chemistry.opencmis.commons.data.ContentStream.getMimeType方法的典型用法代码示例。如果您正苦于以下问题:Java ContentStream.getMimeType方法的具体用法?Java ContentStream.getMimeType怎么用?Java ContentStream.getMimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.chemistry.opencmis.commons.data.ContentStream
的用法示例。
在下文中一共展示了ContentStream.getMimeType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseMimeType
import org.apache.chemistry.opencmis.commons.data.ContentStream; //导入方法依赖的package包/类
private String parseMimeType(ContentStream contentStream)
{
String mimeType = null;
String tmp = contentStream.getMimeType();
if(tmp != null)
{
int idx = tmp.indexOf(";");
if(idx != -1)
{
mimeType = tmp.substring(0, idx).trim();
}
else
{
mimeType = tmp;
}
}
return mimeType;
}
示例2: ContentData
import org.apache.chemistry.opencmis.commons.data.ContentStream; //导入方法依赖的package包/类
public ContentData(ContentStream cs) throws IOException
{
length = cs.getLength();
mimeType = cs.getMimeType();
fileName = cs.getFileName();
bytes = FileCopyUtils.copyToByteArray(cs.getStream());
}
示例3: getDocumentFile
import org.apache.chemistry.opencmis.commons.data.ContentStream; //导入方法依赖的package包/类
@GET
@Path("/{id}/content")
public Response getDocumentFile(@PathParam("id") String pStrId) {
Session lSession = Util.getUserAlfrescoSession(httpRequest);
org.apache.chemistry.opencmis.client.api.Document lDocument = AlfrescoHelper.getDocumentById(lSession, pStrId);
ContentStream lContentStream = lDocument.getContentStream();
if(lContentStream == null){
return Response.status(Status.NOT_FOUND).build();
}
String lMimeType = lContentStream.getMimeType();
return Response.ok(lContentStream.getStream()).type(lMimeType).build();
}
示例4: getRendition
import org.apache.chemistry.opencmis.commons.data.ContentStream; //导入方法依赖的package包/类
public Downloadable<byte[]> getRendition(String type, String objectId, String name) {
List<Rendition> renditions = getDocumentById(objectId).getRenditions();
Optional<Rendition> rendition = renditions!=null ?
renditions.stream().filter(r -> type.equals(r.getTitle())).findFirst() : Optional.empty();
InputStream is;
String mimeType;
if (rendition.isPresent()) {
ContentStream cs = rendition.get().getContentStream();
is = cs.getStream();
mimeType = cs.getMimeType();
}
else {
is = getClass().getResourceAsStream("resources/img/default-generic-icon.png");
mimeType = "image/png";
}
byte[] buffer;
try {
buffer = IOUtils.toByteArray(is);
}
catch (IOException e) {
// rendition non trovata
buffer = new byte[0];
}
return new RenditionDownloadable (name, buffer, buffer.length, mimeType);
}
示例5: createDocument
import org.apache.chemistry.opencmis.commons.data.ContentStream; //导入方法依赖的package包/类
public RegistryObject createDocument(RegistryFolder parentFolder, String name, Properties properties, ContentStream contentStream, VersioningState versioningState) {
try {
Resource fileNode = repository.newResource();
// write content, if available
if(contentStream != null && contentStream.getStream() != null){
//set stream
fileNode.setProperty(CMISConstants.GREG_DATA, "true");
fileNode.setContentStream(contentStream.getStream());
}
//Put to registry AS A PWC (Look at getDestPathOfNode() )
String destinationPath = CommonUtil.getTargetPathOfNode(parentFolder, name);
repository.put(destinationPath, fileNode);
fileNode = repository.get(destinationPath);
// compile the properties
RegistryFolder.setProperties(repository, fileNode, getTypeDefinition(), properties);
//Set MIMETYPE
if (contentStream != null && contentStream.getMimeType() != null) {
fileNode.setProperty(CMISConstants.GREG_MIMETYPE, contentStream.getMimeType());
fileNode.setMediaType(contentStream.getMimeType());
}
repository.put(destinationPath, fileNode);
fileNode = repository.get(destinationPath);
if (versioningState == VersioningState.NONE) {
fileNode.setProperty(CMISConstants.GREG_UNVERSIONED_TYPE, "true");
repository.put(destinationPath, fileNode);
return new RegistryUnversionedDocument(repository, fileNode, typeManager, pathManager);
}
//Else, create as a PWC. See spec
//TODO Set the destination of this PWC to a temp and put it to it's intended location when checked in
fileNode.setProperty(CMISConstants.GREG_IS_CHECKED_OUT, "true");
//Put to registry
repository.put(destinationPath, fileNode);
RegistryObject gregFileNode = getGregNode(fileNode);
RegistryVersionBase gregVersion = gregFileNode.asVersion();
if(versioningState==VersioningState.CHECKEDOUT){
//Put to checked out tracker
Resource resource = null;
if(repository.resourceExists(CMISConstants.GREG_CHECKED_OUT_TRACKER)){
resource = repository.get(CMISConstants.GREG_CHECKED_OUT_TRACKER);
} else{
resource = repository.newResource();
//Have to set content, otherwise Greg will throw exception when browsing this file in Workbench
resource.setContent("tracker");
}
resource.setProperty(gregVersion.getNode().getPath(), "true");
repository.put(CMISConstants.GREG_CHECKED_OUT_TRACKER, resource);
//Set property saying this was created as a PWC
gregVersion.getNode().setProperty(CMISConstants.GREG_CREATED_AS_PWC, "true");
repository.put(gregVersion.getNode().getPath(), gregVersion.getNode());
gregVersion = getGregNode(repository.get(gregVersion.getNode().getPath())).asVersion();
return gregVersion.getPwc();
} else {
if( versioningState == VersioningState.MAJOR){
gregVersion.getNode().addProperty(CMISConstants.GREG_VERSION_STATE, CMISConstants.GREG_MAJOR_VERSION);
} else if (versioningState==VersioningState.MINOR){
gregVersion.getNode().addProperty(CMISConstants.GREG_VERSION_STATE, CMISConstants.GREG_MINOR_VERSION);
}
//put properties
repository.put(gregVersion.getNode().getPath(), gregVersion.getNode());
return gregVersion.checkin(null, null, "auto checkin");
}
}
catch (RegistryException e) {
log.debug(e.getMessage(), e);
throw new CmisStorageException(e.getMessage(), e);
}
}