public DocumentNotFoundException(DocumentNotFoundException e) { super(e.getMessage()); this.id = e.getId(); }
private DocumentContent getDocumentContent(final String documentId) throws DocumentNotFoundException { DocumentContent documentContent = null; final ClassLoader ori = Thread.currentThread().getContextClassLoader(); try { // it's necessary to set the Classloader to avoid exception while using // the Studio // java.lang.IllegalArgumentException: interface // org.hibernate.engine.jdbc.WrappedBlob is not visible from class loader final CommonClassLoader commonClassLoader = EnvTool.getClassDataLoader().getCommonClassLoader(); Thread.currentThread().setContextClassLoader(commonClassLoader); documentContent = getDbSession().getDocumentContent(Long.valueOf(documentId)); } finally { if (ori != null) { Thread.currentThread().setContextClassLoader(ori); } } if (documentContent == null) { throw new DocumentNotFoundException(documentId); } return documentContent; }
@Override public Document getDocument(final String documentId) throws DocumentNotFoundException { final DocumentVersion documentVersion = getDbSession().getDocumentVersion(Long.valueOf(documentId)); if (documentVersion == null) { throw new DocumentNotFoundException(documentId); } final DocumentDescriptor documentDescriptor = getDbSession().getDocumentDescriptor( Long.valueOf(documentVersion.getVersionSeriesId())); return toDocument(documentDescriptor, documentVersion); }
public DocumentNotFoundException(DocumentNotFoundException e) { super(e.getMessage()); this.id = e.getId(); }
@Override public byte[] getDocumentContent(final DocumentUUID documentUUID) throws DocumentNotFoundException { final DocumentationManager manager = EnvTool.getDocumentationManager(); final String documentId = documentUUID.getValue(); final org.ow2.bonita.services.Document document = manager.getDocument(documentId); if (document == null) { throw new DocumentNotFoundException(documentId); } return manager.getContent(document); }
@Override public void removeAttachment(final ProcessInstanceUUID instanceUUID, final String name) throws InstanceNotFoundException { FacadeUtil.checkArgsNotNull(instanceUUID, name); final InternalProcessInstance instance = EnvTool.getJournalQueriers().getProcessInstance(instanceUUID); if (instance == null) { throw new InstanceNotFoundException("bai_RAPII_1", instanceUUID); } if (instance.getNbOfAttachments() <= 0) { throw new BonitaRuntimeException(new DocumentNotFoundException(name)); } final DocumentationManager manager = EnvTool.getDocumentationManager(); final List<org.ow2.bonita.services.Document> documents = DocumentService.getDocuments(manager, instanceUUID, name); if (!documents.isEmpty()) { final org.ow2.bonita.services.Document document = documents.get(0); try { manager.deleteDocument(document.getId(), true); // Keep mapping with number of attachments. instance.setNbOfAttachments(instance.getNbOfAttachments() - 1); } catch (final DocumentNotFoundException e) { throw new BonitaRuntimeException(e); } } }