Search in sources :

Example 1 with DocumentDTO

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

the class PudsController method savePublicacao.

public void savePublicacao(PublicacaoPUDForm form) {
    CurriculoMinimoDTO curriculo = teachingDocumentsService.findCurriculoMinimo(form.getCurriculoMinimoId());
    curriculo.setNumeroBoletimPUD(form.getNumeroBoletim());
    Calendar dataBoletim = Calendar.getInstance();
    curriculo.setDataBoletimPUD(dataBoletim);
    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()));
    DOC002PDF report = new DOC002PDF(params, services);
    DocumentDTO document = new DocumentDTO();
    document.setContentStream(report.build());
    document.setTitle("PUD do Curso " + curriculo.getCurso().getCodigo());
    document.setName(curriculo.getCurso().getCodigo() + "-" + df.format(curriculo.getDataBoletimPUD().getTime()) + ".pdf");
    document.setMimeType("application/pdf");
    String documentUID = ecmService.createDocumentWithUUIDParent(document, "045c40a2-f22e-4c96-9a30-0de7909ef736");
    if (documentUID != null) {
        curriculo.setPudDocumentUID(documentUID);
        teachingDocumentsService.updateCurriculoMinimo(curriculo);
    }
}
Also used : HashMap(java.util.HashMap) Calendar(java.util.Calendar) DOC002PDF(com.tomasio.projects.trainning.reports.DOC002PDF) DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) CurriculoMinimoDTO(com.tomasio.projects.trainning.dto.CurriculoMinimoDTO) SimpleDateFormat(java.text.SimpleDateFormat) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with DocumentDTO

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

the class TurmasEfetivasController method saveDocumento.

@RequestMapping("/save_documento")
public String saveDocumento(Model model, @Valid Documento documento, BindingResult bindingResult, @RequestParam(value = "file", required = false) MultipartFile file, WebRequest request) {
    SimpleDateFormat df = new SimpleDateFormat("yyyy");
    String turmaId = request.getParameter("turmaId");
    TurmaEfetivaDTO turma = atividadesEnsinoService.findTurmaEfetiva(Long.parseLong(turmaId));
    String folderId = turma.getFolderId();
    String folderName = df.format(turma.getExercicio()) + "_" + turma.getCurso().getCodigo() + "_" + turma.getNumeroTurma() + "_" + turma.getId();
    String documentsRoot = "SGC/Documentos de Treinamentos";
    if (bindingResult.hasErrors()) {
        return "turmas_efetivas/form_documento";
    }
    if (!file.isEmpty()) {
        DocumentDTO dto = new DocumentDTO();
        dto.setTitle(documento.getTitle());
        dto.setDescription(documento.getDescription());
        dto.setName(file.getOriginalFilename());
        dto.setMimeType(file.getContentType());
        try {
            byte[] content = file.getBytes();
            dto.setContentStream(content);
        } catch (IOException ex) {
            Logger.getLogger(TurmasEfetivasController.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (folderId == null || folderId.equals("")) {
            FolderDTO folder = new FolderDTO();
            folder.setName(folderName);
            folderId = ecmService.createFolder(folder, documentsRoot);
            turma.setFolderId(folderId);
            atividadesEnsinoService.updateTurmaEfetiva(turma);
            model.addAttribute("turma", turma);
            ecmService.createDocumentWithUUIDParent(dto, folderId);
        } else {
            boolean folderExists = ecmService.contentExistsByUUID(folderId);
            if (folderExists) {
                ecmService.createDocumentWithUUIDParent(dto, folderId);
            } else {
                FolderDTO folder = new FolderDTO();
                folder.setName(folderName);
                folderId = ecmService.createFolder(folder, documentsRoot);
                turma.setFolderId(folderId);
                atividadesEnsinoService.updateTurmaEfetiva(turma);
                model.addAttribute("turma", turma);
                ecmService.createDocumentWithUUIDParent(dto, folderId);
            }
        }
    }
    model.addAttribute("tab", "documentos");
    return "redirect:detail/documentos";
}
Also used : TurmaEfetivaDTO(com.tomasio.projects.trainning.dto.TurmaEfetivaDTO) FolderDTO(com.tomasio.projects.trainning.dto.FolderDTO) DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) IOException(java.io.IOException) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with DocumentDTO

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

the class EcmController method swf.

@RequestMapping("/swf")
public void swf(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("application/x-shockwave-flash");
    response.addHeader("Content-Disposition", "attachment; filename=" + "content.swf");
    // PrintWriter out = response.getWriter();
    ServletOutputStream out = response.getOutputStream();
    String uuid = request.getParameter("uuid");
    DocumentDTO content = service.findDocumentSWFByUUID(uuid);
    if (content != null) {
        out.write(content.getContentStream());
    }
    out.close();
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with DocumentDTO

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

the class EcmController method download.

@RequestMapping("/download")
public void download(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String uuid = request.getParameter("uuid");
    DocumentDTO content = service.findDocumentByUUID(uuid);
    // response.setContentType("application/pdf");
    String[] slices = content.getName().split(".");
    String extension = null;
    if (slices.length > 0) {
        extension = slices[slices.length - 1];
    }
    if (extension != null) {
        if (extension.toUpperCase().equals("doc".toUpperCase())) {
            response.setContentType("application/msword");
        } else if (extension.toUpperCase().equals("pdf".toUpperCase())) {
            response.setContentType("application/pdf");
        } else if (extension.toUpperCase().equals("png".toUpperCase())) {
            response.setContentType("image/png");
        } else if (extension.toUpperCase().equals("jpg".toUpperCase())) {
            response.setContentType("image/jpeg");
        } else if (extension.toUpperCase().equals("jpeg".toUpperCase())) {
            response.setContentType("image/jpeg");
        } else if (extension.toUpperCase().equals("docx".toUpperCase())) {
            response.setContentType("application/msword");
        } else if (extension.toUpperCase().equals("odt".toUpperCase())) {
            response.setContentType("application/msword");
        } else if (extension.toUpperCase().equals("txt".toUpperCase())) {
            response.setContentType("text/plain");
        } else if (extension.toUpperCase().equals("xls".toUpperCase())) {
            response.setContentType("application/excel");
        } else if (extension.toUpperCase().equals("ppt".toUpperCase())) {
            response.setContentType("application/mspowerpoint");
        } else if (extension.toUpperCase().equals("pptx".toUpperCase())) {
            response.setContentType("application/mspowerpoint");
        }
    }
    response.addHeader("Content-Disposition", "attachment; filename=" + content.getName());
    ServletOutputStream out = response.getOutputStream();
    out.write(content.getContentStream());
    out.close();
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with DocumentDTO

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

the class ImagesController method uploadFile.

@RequestMapping("/upload")
public void uploadFile(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "upload", required = false) MultipartFile file) throws IOException {
    PrintWriter out = response.getWriter();
    String folderId = request.getParameter("folder");
    DocumentDTO dto = new DocumentDTO();
    dto.setName(file.getOriginalFilename());
    dto.setMimeType(file.getContentType());
    try {
        byte[] content = file.getBytes();
        dto.setContentStream(content);
    } catch (IOException ex) {
        Logger.getLogger(TurmasEfetivasController.class.getName()).log(Level.SEVERE, null, ex);
    }
    ecmService.createDocumentWithUUIDParent(dto, folderId);
    out.print("upload realizado com sucesso!");
}
Also used : DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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