public ReusableContentStream(ContentStream contentStream) throws Exception { setLength(contentStream.getBigLength()); setMimeType(contentStream.getMimeType()); setFileName(contentStream.getFileName()); file = TempFileProvider.createTempFile(contentStream.getStream(), "cmis", "contentStream"); }
@Override public ContentStream convertContentStream(ContentStream contentStream) { if (contentStream == null) { return null; } BigInteger length = (contentStream.getLength() < 0 ? null : BigInteger.valueOf(contentStream.getLength())); return getBindingsObjectFactory().createContentStream(contentStream.getFileName(), length, contentStream.getMimeType(), contentStream.getStream()); }
static Stream createStream(final ContentStream contentStream) { return ECMHelper.createStream(contentStream.getStream(), contentStream.getMimeType(), contentStream.getLength()); }
protected CmisConnectorBinary(ContentStream contentStream, String sourceName, String documentId, MimeTypeDetector mimeTypeDetector) { // the internal key can be some random string since this in an external binary.... super(new BinaryKey(UUID.randomUUID().toString()), sourceName, documentId, contentStream.getLength(), contentStream.getFileName(), mimeTypeDetector); this.contentStream = contentStream; }
@Override protected InputStream internalStream() throws Exception { return contentStream.getStream(); } }
public void write(OutputStream out) throws IOException { InputStream stream = contentStream == null ? null : contentStream.getStream(); String filename = contentStream.getFileName(); if (filename == null || filename.length() == 0) { filename = "content"; String mediaType = contentStream.getMimeType(); if (mediaType == null || mediaType.indexOf('/') < 1 || mediaType.indexOf('\n') > -1 || mediaType.indexOf('\r') > -1) {
/** * Constructor for objects. */ public AtomEntryWriter(ObjectData object, CmisVersion cmisVersion, ContentStream contentStream) { if ((object == null) || (object.getProperties() == null)) { throw new CmisInvalidArgumentException("Object and properties must not be null!"); } if ((contentStream != null) && (contentStream.getMimeType() == null)) { throw new CmisInvalidArgumentException("Media type must be set if a stream is present!"); } this.object = object; this.cmisVersion = cmisVersion; this.contentStream = contentStream; if (contentStream != null && contentStream.getStream() != null) { InputStream in = contentStream.getStream(); // avoid double buffering if (!(in instanceof BufferedInputStream) && !(in instanceof ByteArrayInputStream)) { stream = new BufferedInputStream(in, BUFFER_SIZE); } else { stream = in; } } else { stream = null; } this.typeDef = null; this.bulkUpdate = null; }
@Override public String getContentType() { return contentStream.getMimeType(); } }));
try a = TempFileProvider.createTempFile(csa.getStream(), "csA", ".txt"); b = TempFileProvider.createTempFile(csb.getStream(), "csB", ".txt"); c = TempFileProvider.createTempFile(null, "csC", ".txt"); if ((csa.getLength() > -1) && (a == null || csa.getLength() != a.length())) throw new CmisStorageException("Expected " + csa.getLength() + " bytes but retrieved " + (a == null ? -1 : a.length()) + " bytes!");
writer.writeNamespace(XMLConstants.PREFIX_CMIS, XMLConstants.NAMESPACE_CMIS); writer.writeNamespace(XMLConstants.PREFIX_RESTATOM, XMLConstants.NAMESPACE_RESTATOM); if (contentStream != null && contentStream.getFileName() != null) { writer.writeNamespace(XMLConstants.PREFIX_APACHE_CHEMISTY, XMLConstants.NAMESPACE_APACHE_CHEMISTRY); TAG_CONTENT_MEDIATYPE, contentStream.getMimeType()); if (contentStream.getFileName() != null) { XMLUtils.write(writer, XMLConstants.PREFIX_APACHE_CHEMISTY, XMLConstants.NAMESPACE_APACHE_CHEMISTRY, TAG_CONTENT_FILENAME, contentStream.getFileName());
SELECT_ALL_NO_CACHE_OC); contentStream.getStream().close(); } catch (Exception e) { addResult(createResult(UNEXPECTED_EXCEPTION, "Document could not be created! Exception: " + e.getMessage(), addResult(assertEquals(name, contentStream.getFileName(), null, f)); addResult(assertEquals(result.getContentStreamFileName(), contentStream.getFileName(), null, f));
content.getStream().close(); RedirectingContentStream rcs = (RedirectingContentStream) content; if (content.getStream() != null) { IOUtils.closeQuietly(content.getStream()); content.getStream().close(); if (content.getBigLength() != null && content.getBigLength().signum() >= 0) { response.setHeader("Content-Length", content.getBigLength().toString());
@Override public String getName() { return contentStream.getFileName(); }
public long getLength() { return cmisContentStream.getLength(); }
public InputStream getStream() { return cmisContentStream.getStream(); }
public void write(OutputStream out) throws IOException { InputStream stream = contentStream == null ? null : contentStream.getStream(); String filename = contentStream.getFileName(); if (filename == null || filename.length() == 0) { filename = "content"; String mediaType = contentStream.getMimeType(); if (mediaType == null || mediaType.indexOf('/') < 1 || mediaType.indexOf('\n') > -1 || mediaType.indexOf('\r') > -1) {
/** * Constructor for objects. */ public AtomEntryWriter(ObjectData object, CmisVersion cmisVersion, ContentStream contentStream) { if (object == null || object.getProperties() == null) { throw new CmisInvalidArgumentException("Object and properties must not be null!"); } if (contentStream != null && contentStream.getMimeType() == null) { throw new CmisInvalidArgumentException("Media type must be set if a stream is present!"); } this.object = object; this.cmisVersion = cmisVersion; this.contentStream = contentStream; if (contentStream != null && contentStream.getStream() != null) { InputStream in = contentStream.getStream(); // avoid double buffering if (!(in instanceof BufferedInputStream) && !(in instanceof ByteArrayInputStream)) { stream = new BufferedInputStream(in, BUFFER_SIZE); } else { stream = in; } } else { stream = null; } this.typeDef = null; this.bulkUpdate = null; }
@Override public T retrieve(String path, String documentName, Session session) throws Exception { // Disable cache session.getDefaultContext().setCacheEnabled(false); Document object = (Document)FileUtils.getObject(path + documentName, session); ContentStream contentStream = object.getContentStream(); Class<T> classP = getClassP(); T document = classP.newInstance(); document.setContentStream(IOUtils.toByteArray(contentStream.getStream())); document.setContentStreamFilename(documentName); document.setContentStreamLenght(contentStream.getLength()); document.setContentStreamMimeType(contentStream.getMimeType()); // Enable cache session.getDefaultContext().setCacheEnabled(true); return document; }
public String getMimeType() { return cmisContentStream.getMimeType(); }
writer.attribute("", XMLConstants.PREFIX_RESTATOM, XMLConstants.NAMESPACE_RESTATOM); if (contentStream != null && contentStream.getFileName() != null) { writer.attribute("", XMLConstants.PREFIX_APACHE_CHEMISTY, XMLConstants.NAMESPACE_APACHE_CHEMISTRY); writer.startTag(XMLConstants.NAMESPACE_RESTATOM, TAG_CONTENT); writeTag(writer, XMLConstants.NAMESPACE_RESTATOM, TAG_CONTENT_MEDIATYPE, contentStream.getMimeType()); if (contentStream.getFileName() != null) { XMLUtils.write(writer, XMLConstants.PREFIX_APACHE_CHEMISTY, XMLConstants.NAMESPACE_APACHE_CHEMISTRY, TAG_CONTENT_FILENAME, contentStream.getFileName());