/** * @return * The BusinessArchive * @throws InvalidBusinessArchiveFormatException * when the business archive is inconsistent in the current state */ public BusinessArchive done() throws InvalidBusinessArchiveFormatException { if (entity.getProcessDefinition() == null) { throw new InvalidBusinessArchiveFormatException("missing process definition"); } final ArrayList<String> errors = new ArrayList<>(); for (final DocumentDefinition document : entity.getProcessDefinition().getProcessContainer().getDocumentDefinitions()) { if (document.getFile() != null && !document.getFile().isEmpty()) { final byte[] resources = entity.getResource("documents/" + document.getFile()); if (resources == null) { errors.add("missing document in the business archive that is present in the process definition " + document.getFile()); } } } if (!errors.isEmpty()) { throw new InvalidBusinessArchiveFormatException(errors); } return entity; }
/** * @param documentDefinition */ public SDocumentDefinitionImpl(final DocumentDefinition documentDefinition) { super(documentDefinition.getName()); url = documentDefinition.getUrl(); file = documentDefinition.getFile(); description = documentDefinition.getDescription(); mimeType = documentDefinition.getContentMimeType(); fileName = documentDefinition.getFileName(); initialValue = ServerModelConvertor.convertExpression(documentDefinition.getInitialValue()); }
/** * @param documentDefinition */ public SDocumentDefinitionImpl(final DocumentDefinition documentDefinition) { super(documentDefinition.getName()); url = documentDefinition.getUrl(); file = documentDefinition.getFile(); description = documentDefinition.getDescription(); mimeType = documentDefinition.getContentMimeType(); fileName = documentDefinition.getFileName(); initialValue = ServerModelConvertor.convertExpression(documentDefinition.getInitialValue()); }
/** * @return * The BusinessArchive * @throws InvalidBusinessArchiveFormatException * when the business archive is inconsistent in the current state */ public BusinessArchive done() throws InvalidBusinessArchiveFormatException { if (entity.getProcessDefinition() == null) { throw new InvalidBusinessArchiveFormatException("missing process definition"); } final ArrayList<String> errors = new ArrayList<>(); for (final DocumentDefinition document : entity.getProcessDefinition().getProcessContainer().getDocumentDefinitions()) { if (document.getFile() != null && !document.getFile().isEmpty()) { final byte[] resources = entity.getResource("documents/" + document.getFile()); if (resources == null) { errors.add("missing document in the business archive that is present in the process definition " + document.getFile()); } } } if (!errors.isEmpty()) { throw new InvalidBusinessArchiveFormatException(errors); } return entity; }
assertEquals("testDoc", testDoc1.getName()); assertEquals("desc", testDoc1.getDescription()); assertEquals("testFile.txt", testDoc1.getFile()); assertEquals("text/plain", testDoc1.getContentMimeType()); assertEquals("plop", testDoc1.getInitialValue().getContent());