@Test public void emptyDigestDocumentToRemoteDocumentTest() { DSSDocument dssDocument = new DigestDocument(); assertThrows(DSSException.class, () -> RemoteDocumentConverter.toRemoteDocument(dssDocument)); }
public static RemoteDocument toRemoteDocument(DSSDocument originalDocument) { if (originalDocument == null) { return null; } if (originalDocument instanceof DigestDocument) { DigestDocument digestDocument = (DigestDocument) originalDocument; Digest digest = digestDocument.getExistingDigest(); if (digest.getAlgorithm() == null || digest.getValue() == null) { throw new DSSRemoteServiceException("Impossible to create a RemoteDocument from a DigestDocument with not defined Digest"); } return new RemoteDocument(digest.getValue(), digest.getAlgorithm(), originalDocument.getName()); } return new RemoteDocument(DSSUtils.toByteArray(originalDocument), originalDocument.getName()); }
RemoteDocumentConverter { public static RemoteDocument toRemoteDocument(DSSDocument originalDocument) { if (originalDocument == null) { return null; } if (originalDocument instanceof DigestDocument) { DigestDocument digestDocument = (DigestDocument) originalDocument; Digest digest = digestDocument.getExistingDigest(); if (digest.getAlgorithm() == null || digest.getValue() == null) { throw new DSSRemoteServiceException("Impossible to create a RemoteDocument from a DigestDocument with not defined Digest"); } return new RemoteDocument(digest.getValue(), digest.getAlgorithm(), originalDocument.getName()); } return new RemoteDocument(DSSUtils.toByteArray(originalDocument), originalDocument.getName()); } }
RemoteDocumentConverter { public static RemoteDocument toRemoteDocument(DSSDocument originalDocument) { if (originalDocument == null) { return null; } if (originalDocument instanceof DigestDocument) { DigestDocument digestDocument = (DigestDocument) originalDocument; Digest digest = digestDocument.getExistingDigest(); if (digest.getAlgorithm() == null || digest.getValue() == null) { throw new DSSRemoteServiceException("Impossible to create a RemoteDocument from a DigestDocument with not defined Digest"); } return new RemoteDocument(digest.getValue(), digest.getAlgorithm(), originalDocument.getName()); } return new RemoteDocument(DSSUtils.toByteArray(originalDocument), originalDocument.getName()); } private  RemoteDocumentConverter(); }
RemoteDocumentConverter { public static RemoteDocument toRemoteDocument(DSSDocument originalDocument) { if (originalDocument == null) { return null; } if (originalDocument instanceof DigestDocument) { DigestDocument digestDocument = (DigestDocument) originalDocument; Digest digest = digestDocument.getExistingDigest(); if (digest.getAlgorithm() == null || digest.getValue() == null) { throw new DSSRemoteServiceException("Impossible to create a RemoteDocument from a DigestDocument with not defined Digest"); } return new RemoteDocument(digest.getValue(), digest.getAlgorithm(), originalDocument.getName()); } return new RemoteDocument(DSSUtils.toByteArray(originalDocument), originalDocument.getName()); } private  RemoteDocumentConverter(); static List<DSSDocument> toDSSDocuments(List<RemoteDocument> remoteDocuments); static DSSDocument toDSSDocument(RemoteDocument remoteDocument); static List<RemoteDocument> toRemoteDocuments(List<DSSDocument> originalDocuments); static RemoteDocument toRemoteDocument(DSSDocument originalDocument); }
RemoteDocumentConverter { public static RemoteDocument toRemoteDocument(DSSDocument originalDocument) { if (originalDocument == null) { return null; } if (originalDocument instanceof DigestDocument) { DigestDocument digestDocument = (DigestDocument) originalDocument; Digest digest = digestDocument.getExistingDigest(); if (digest.getAlgorithm() == null || digest.getValue() == null) { throw new DSSRemoteServiceException("Impossible to create a RemoteDocument from a DigestDocument with not defined Digest"); } return new RemoteDocument(digest.getValue(), digest.getAlgorithm(), originalDocument.getName()); } return new RemoteDocument(DSSUtils.toByteArray(originalDocument), originalDocument.getName()); } private  RemoteDocumentConverter(); static List<DSSDocument> toDSSDocuments(List<RemoteDocument> remoteDocuments); static DSSDocument toDSSDocument(RemoteDocument remoteDocument); static List<RemoteDocument> toRemoteDocuments(List<DSSDocument> originalDocuments); static RemoteDocument toRemoteDocument(DSSDocument originalDocument);  }