@Test public void testStoreStreamCreatesNewDocument() throws Exception { final ByteArrayInputStream input = new ByteArrayInputStream("hello".getBytes()); makeConfigurationNotExisting(); storage.save(input); final Map<String, String> properties = new HashMap<String, String>(); properties.put("cmis:objectTypeId", "cmis:document"); properties.put("cmis:name", "configuration.zip"); verify(root).createDocument(eq(properties), any(ContentStream.class), eq(VersioningState.NONE)); }
@Override public void save(final InputStream stream) { if (stream == null) { throw new NullPointerException(); } final ContentStream contentStream = session.getObjectFactory().createContentStream(WORKSPACE_ZIP_NAME, -1, "application/zip", stream); try { final Document existingDocument = (Document) session.getObjectByPath("/" + WORKSPACE_ZIP_NAME); existingDocument.setContentStream(contentStream, true); } catch (final CmisObjectNotFoundException e) { session.getRootFolder().createDocument(CMIS_DOCUMENT_PROPERTIES, contentStream, VersioningState.NONE); } }
EcmStorage implements Storage { @Override public void save(final InputStream stream) { if (stream == null) { throw new NullPointerException(); } final ContentStream contentStream = session.getObjectFactory().createContentStream(WORKSPACE_ZIP_NAME, -1, "application/zip", stream); try { final Document existingDocument = (Document) session.getObjectByPath("/" + WORKSPACE_ZIP_NAME); existingDocument.setContentStream(contentStream, true); } catch (final CmisObjectNotFoundException e) { session.getRootFolder().createDocument(CMIS_DOCUMENT_PROPERTIES, contentStream, VersioningState.NONE); } } }
EcmStorage implements Storage { @Override public void save(final InputStream stream) { if (stream == null) { throw new NullPointerException(); } final ContentStream contentStream = session.getObjectFactory().createContentStream(WORKSPACE_ZIP_NAME, -1, "application/zip", stream); try { final Document existingDocument = (Document) session.getObjectByPath("/" + WORKSPACE_ZIP_NAME); existingDocument.setContentStream(contentStream, true); } catch (final CmisObjectNotFoundException e) { session.getRootFolder().createDocument(CMIS_DOCUMENT_PROPERTIES, contentStream, VersioningState.NONE); } } EcmStorage(final Session session);   EcmStorage(final EcmService ecmService); }
EcmStorage implements Storage { @Override public void save(final InputStream stream) { if (stream == null) { throw new NullPointerException(); } final ContentStream contentStream = session.getObjectFactory().createContentStream(WORKSPACE_ZIP_NAME, -1, "application/zip", stream); try { final Document existingDocument = (Document) session.getObjectByPath("/" + WORKSPACE_ZIP_NAME); existingDocument.setContentStream(contentStream, true); } catch (final CmisObjectNotFoundException e) { session.getRootFolder().createDocument(CMIS_DOCUMENT_PROPERTIES, contentStream, VersioningState.NONE); } } EcmStorage(final Session session);   EcmStorage(final EcmService ecmService); @Override void save(final InputStream stream); @Override InputStream load(); }
EcmStorage implements Storage { @Override public void save(final InputStream stream) { if (stream == null) { throw new NullPointerException(); } final ContentStream contentStream = session.getObjectFactory().createContentStream(WORKSPACE_ZIP_NAME, -1, "application/zip", stream); try { final Document existingDocument = (Document) session.getObjectByPath("/" + WORKSPACE_ZIP_NAME); existingDocument.setContentStream(contentStream, true); } catch (final CmisObjectNotFoundException e) { session.getRootFolder().createDocument(CMIS_DOCUMENT_PROPERTIES, contentStream, VersioningState.NONE); } } EcmStorage(final Session session);   EcmStorage(final EcmService ecmService); @Override void save(final InputStream stream); @Override InputStream load();  }