Search in sources :

Example 11 with DocumentDTO

use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.

the class CommonsController method saveDocumento.

public String saveDocumento(DocumentoForm form, MultipartFile multipartFile) throws IOException {
    DocumentDTO document = new DocumentDTO();
    document.setContentStream(multipartFile.getBytes());
    document.setDescription(form.getDescription());
    document.setMimeType(multipartFile.getContentType());
    document.setName(generateFileCode() + "-" + multipartFile.getOriginalFilename());
    document.setDescription(form.getDescription());
    document.setTitle(form.getTitle());
    String documentUID = ecmService.createDocumentWithUUIDParent(document, form.getFolderUID());
    return documentUID;
}
Also used : DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO)

Example 12 with DocumentDTO

use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.

the class CurriculosMinimosController method savePublicacao.

public void savePublicacao(PublicacaoCMForm form) {
    CurriculoMinimoDTO curriculo = teachingDocumentsService.findCurriculoMinimo(form.getCurriculoMinimoId());
    curriculo.setNumeroBCACM(form.getNumeroBCA());
    Calendar dataBCA = Calendar.getInstance();
    dataBCA.setTime(form.getDataBCA());
    curriculo.setDataBCACM(dataBCA);
    SimpleDateFormat df = new SimpleDateFormat("ddMMyy");
    Map services = new HashMap<>();
    services.put("teachingDocumentsService", teachingDocumentsService);
    services.put("ecmService", ecmService);
    Map params = new HashMap<>();
    params.put("curriculoMinimoId", String.valueOf(curriculo.getId()));
    DOC001PDF report = new DOC001PDF(params, services);
    DocumentDTO document = new DocumentDTO();
    document.setContentStream(report.build());
    document.setTitle("Currículo Mínimo do Curso " + curriculo.getCurso().getCodigo());
    document.setName(curriculo.getCurso().getCodigo() + "-" + df.format(curriculo.getDataBCACM().getTime()) + ".pdf");
    document.setMimeType("application/pdf");
    String documentUID = ecmService.createDocumentWithUUIDParent(document, "cc325a72-77d9-4737-964d-e65e0eb0c32a");
    if (documentUID != null) {
        curriculo.setCurriculoMinimoDocumentUID(documentUID);
        teachingDocumentsService.updateCurriculoMinimo(curriculo);
    }
}
Also used : HashMap(java.util.HashMap) Calendar(java.util.Calendar) DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) DOC001PDF(com.tomasio.projects.trainning.reports.DOC001PDF) CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with DocumentDTO

use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.

the class ECMServiceSimpleImpl method findDocumentSWFByUUID.

@Override
public DocumentDTO findDocumentSWFByUUID(String uuid) {
    ContentDAO dao = factory.getContentDAO();
    DocumentDTO document = dao.findDocumentSWFByUUID(uuid);
    return document;
}
Also used : DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) ContentDAO(com.tomasio.projects.trainning.dao.ContentDAO)

Example 14 with DocumentDTO

use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.

the class DOC001PDF method readPdfAsImage.

private Image readPdfAsImage(String documentUID) throws DocumentException {
    try {
        DocumentDTO portaria = ecmService.findDocumentByUUID(documentUID);
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        document.newPage();
        PdfReader reader = new PdfReader(portaria.getContentStream());
        int n = reader.getNumberOfPages();
        PdfImportedPage page;
        for (int i = 1; i <= n; i++) {
            page = writer.getImportedPage(reader, i);
            Image imagePage = Image.getInstance(page);
            imagePage.scaleToFit(PageSize.A4.getWidth(), PageSize.A4.getHeight());
            PdfContentByte cb = writer.getDirectContent();
            cb.addTemplate(page, 0, 0);
            return imagePage;
        }
    } catch (IOException ex) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}
Also used : DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) IOException(java.io.IOException) Image(com.itextpdf.text.Image)

Example 15 with DocumentDTO

use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.

the class ImportTurmasImplEfetivasFromTabelao method findDocumentByUUID.

public DocumentDTO findDocumentByUUID(String uuid) {
    DocumentDTO content = new DocumentDTO();
    try {
        AuthenticationUtils.startSession(USERNAME, PASSWORD);
        RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
        Reference node = new Reference();
        node.setStore(STORE);
        node.setUuid(uuid);
        Node[] nodes = null;
        nodes = repositoryService.get(new Predicate(new Reference[] { node }, STORE, null));
        ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
        Content[] readResult = contentService.read(new Predicate(new Reference[] { nodes[0].getReference() }, STORE, null), Constants.PROP_CONTENT);
        Content c = readResult[0];
        byte[] stream = ContentUtils.convertToByteArray(ContentUtils.getContentAsInputStream(c));
        content.setContentStream(stream);
        if (nodes != null) {
            for (NamedValue namedValue : nodes[0].getProperties()) {
                if (namedValue.getName().endsWith(Constants.PROP_CREATED) == true) {
                // contentResult.setCreateDate(namedValue.getValue());
                } else if (namedValue.getName().endsWith(Constants.PROP_NAME) == true) {
                    content.setName(namedValue.getValue());
                } else if (namedValue.getName().endsWith(Constants.PROP_DESCRIPTION) == true) {
                    content.setDescription(namedValue.getValue());
                } else if (namedValue.getName().endsWith(Constants.PROP_TITLE) == true) {
                    content.setTitle(namedValue.getValue());
                }
            }
        } else {
            return null;
        }
    } catch (AuthenticationFault e) {
        Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Autenticação");
    } catch (RepositoryFault e) {
        Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.INFO, "Conteúdo não disponível");
    } catch (RemoteException e) {
        Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Acesso a Serviço Web");
    } catch (Exception e) {
        Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de abertura do arquivo");
    } finally {
        // End the session
        AuthenticationUtils.endSession();
    }
    return content;
}
Also used : Reference(org.alfresco.webservice.types.Reference) Node(org.alfresco.webservice.types.Node) NamedValue(org.alfresco.webservice.types.NamedValue) ParseException(java.text.ParseException) RemoteException(java.rmi.RemoteException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Predicate(org.alfresco.webservice.types.Predicate) ContentServiceSoapBindingStub(org.alfresco.webservice.content.ContentServiceSoapBindingStub) RepositoryFault(org.alfresco.webservice.repository.RepositoryFault) Content(org.alfresco.webservice.content.Content) DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) RepositoryServiceSoapBindingStub(org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub) AuthenticationFault(org.alfresco.webservice.authentication.AuthenticationFault) AlfrescoContentDAO(com.tomasio.projects.trainning.dao.AlfrescoContentDAO) RemoteException(java.rmi.RemoteException)

Aggregations

DocumentDTO (com.tomasio.projects.trainning.dto.DocumentDTO)16 SimpleDateFormat (java.text.SimpleDateFormat)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ContentDAO (com.tomasio.projects.trainning.dao.ContentDAO)4 IOException (java.io.IOException)4 RemoteException (java.rmi.RemoteException)4 AlfrescoContentDAO (com.tomasio.projects.trainning.dao.AlfrescoContentDAO)3 ParseException (java.text.ParseException)3 AuthenticationFault (org.alfresco.webservice.authentication.AuthenticationFault)3 Content (org.alfresco.webservice.content.Content)3 ContentServiceSoapBindingStub (org.alfresco.webservice.content.ContentServiceSoapBindingStub)3 RepositoryFault (org.alfresco.webservice.repository.RepositoryFault)3 RepositoryServiceSoapBindingStub (org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub)3 NamedValue (org.alfresco.webservice.types.NamedValue)3 Node (org.alfresco.webservice.types.Node)3 Predicate (org.alfresco.webservice.types.Predicate)3 Reference (org.alfresco.webservice.types.Reference)3 CurriculoMinimoDTO (com.tomasio.projects.trainning.dto.CurriculoMinimoDTO)2 FolderDTO (com.tomasio.projects.trainning.dto.FolderDTO)2 DAOException (com.tomasio.projects.trainning.exception.DAOException)2