use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.
the class TurmasEfetivasController method saveCertificado.
@RequestMapping("/save_certificado")
public String saveCertificado(Model model, @Valid CertificadoConclusaoForm certificado, BindingResult bindingResult, @RequestParam(value = "file", required = false) MultipartFile file, WebRequest request, final RedirectAttributes redirectAttributes) {
String folderId = "614fca6b-f633-4430-a810-74096b460518";
String folderName = "Certificados";
String documentsRoot = "SGC/Certificados";
if (bindingResult.hasErrors()) {
return "turmas_efetivas/form_certificado";
}
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
ConclusaoDTO conclusao = atividadesEnsinoService.findConclusao(Long.parseLong(certificado.getConclusaoId()));
CertificadoConclusaoDTO certificadoDTO = new CertificadoConclusaoDTO();
certificadoDTO.setNumero(certificado.getNumero());
try {
certificadoDTO.setDataEmissao(df.parse(certificado.getDataEmissao()));
} catch (ParseException ex) {
Logger.getLogger(TurmasEfetivasController.class.getName()).log(Level.SEVERE, null, ex);
}
certificadoDTO.setObservacao(certificado.getObservacao());
certificadoDTO.setConclusao(conclusao);
if (!file.isEmpty()) {
DocumentDTO dto = new DocumentDTO();
dto.setTitle("Certificado Nº " + certificado.getNumero());
dto.setDescription("Certificado Nº " + certificado.getNumero() + " Do aluno Matricula: " + conclusao.getMatricula() + " Emitido na data: " + certificado.getDataEmissao() + " Com a seguinte Observação: " + certificado.getObservacao());
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);
}
String contentId = ecmService.createDocumentWithUUIDParent(dto, folderId);
if (contentId == null || contentId.equals("")) {
// erro certificado não upload
redirectAttributes.addFlashAttribute("errorMessage", "Nao foi possível fazer o UPLOAD no Arquivo do Certificado!");
} else {
certificadoDTO.setContentId(contentId);
}
// gravar o certificado no BD
try {
atividadesEnsinoService.createCertificadoConclusao(certificadoDTO);
redirectAttributes.addFlashAttribute("successMessage", "Certificado de Conclusão cadastrado com sucesso.");
} catch (CoreException e) {
redirectAttributes.addFlashAttribute("errorMessage", e.getMessage());
}
}
model.addAttribute("tab", "certificados");
return "redirect:detail/certificados";
}
use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.
the class ECMServiceSimpleImpl method findDocumentByUUID.
@Override
public DocumentDTO findDocumentByUUID(String uuid) {
ContentDAO dao = factory.getContentDAO();
DocumentDTO document = dao.findDocumentByUUID(uuid);
return document;
}
use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.
the class ImportTurmasImplEfetivasFromTabelao method recuperarDocumentos.
private void recuperarDocumentos(String codCurso, String numeroTurma, TurmaEfetiva turmaCriada, Connection conn) {
SimpleDateFormat df = new SimpleDateFormat("yyyy");
ContentDAO contentDAO = new AlfrescoContentDAO();
TurmaDAO turmaDAO = new HibernateTurmaDAO();
String documentsRoot = "SGC/Documentos de Treinamentos/testes";
String oldFolderName = "D-CTP/Documentos de Treinamentos/2013/" + codCurso + "-" + numeroTurma;
String newFolderName = df.format(turmaCriada.getExercicio()) + "_" + turmaCriada.getCurso().getCodigo() + "_" + turmaCriada.getNumeroTurma() + "_" + turmaCriada.getId();
try {
WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
boolean existsOldFolder = contentExistsByPath(oldFolderName);
if (existsOldFolder) {
WebServiceFactory.setEndpointAddress("http://10.32.63.32:8080/alfresco/api");
FolderDTO folder = new FolderDTO();
folder.setName(newFolderName);
String folderId = contentDAO.createFolder(folder, documentsRoot);
turmaCriada.setFolderId(folderId);
turmaDAO.update(turmaCriada);
WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
ContentDTO[] contents = findAllContentByPath(oldFolderName);
for (ContentDTO content : contents) {
WebServiceFactory.setEndpointAddress("http://dctp.decea.intraer:8080/ecm/api");
DocumentDTO document = findDocumentByUUID(content.getUid());
document.setMimeType("application/pdf");
WebServiceFactory.setEndpointAddress("http://10.32.63.32:8080/alfresco/api");
contentDAO.createDocumentWithUUIDParent(document, folderId);
}
}
} catch (Exception ex) {
Logger.getLogger(ImportTurmasImplEfetivasFromTabelao.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.
the class AlfrescoContentDAO method findDocumentSWFByUUID.
@Override
public DocumentDTO findDocumentSWFByUUID(String uuid) {
DocumentDTO content = new DocumentDTO();
try {
AuthenticationUtils.startSession(USERNAME, PASSWORD);
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
Reference referenceSource = new Reference();
referenceSource.setStore(STORE);
referenceSource.setUuid(uuid);
Reference referenceDestination = new Reference();
referenceDestination.setStore(STORE);
referenceDestination.setUuid(ConfigHelper.getValue("repostitory.swf.folder"));
Node[] nodes = null;
nodes = repositoryService.get(new Predicate(new Reference[] { referenceSource }, STORE, null));
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
Content c = contentService.transform(referenceSource, Constants.PROP_CONTENT, referenceDestination, Constants.PROP_CONTENT, new ContentFormat("application/x-shockwave-flash", "UTF-8"));
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;
}
use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.
the class Main method main.
public static void main(String[] args) throws Exception {
// WebServiceFactory.setEndpointAddress("http://localhost:8084/alfresco/api");
ContentDAO service = new AlfrescoContentDAO();
DocumentDTO content = service.findDocumentSWFByUUID("6c8c1aad-79f6-46ce-a6f6-2380f7341271");
OutputStream out = new FileOutputStream("DOCUMENT.pdf");
out.write(content.getContentStream());
out.close();
// DocumentDTO document = new DocumentDTO();
// FolderDTO folder = new FolderDTO();
//
// document.setDescription("Description");
// document.setTitle("Title");
// document.setName("meusteste5s5.pdf");
// document.setMimeType("application/pdf");
// document.setCharset("UTF-8");
//
//
// InputStream viewStream = new FileInputStream(new File("/home/fernandofot/identidade.pdf"));
// byte[] bytes = org.apache.commons.io.IOUtils.toByteArray(viewStream);
//
// document.setContentStream(bytes);
//
// ContentDTO [] contents = service.findAllContentByPath("D-CTP");
// for(ContentDTO content: contents){
// System.out.println(content.getTitle());
// }
// service.addDocumentToTreinamento(document,"COMGAR", "2018", "AP005", "2");
// Open the file and convert to byte array
//
//
// folder.setDescription("My description folder");
// folder.setName("CTP001-3");
// folder.setTitle("Minha Linda Pasta");
//
//
//
//
//
// ECMService service = new AlfrescoECMService();
//
// ContentDTO content = service.findDocumentoByUUID("5e587e0b-f0ca-4264-abdc-dc791197b7f7");
// content.setName("new_name.pdf");
// content.setTitle("New Title");
// content.setDescription("New Description");
// DocumentDTO documento = (DocumentDTO) content;
// System.out.println(documento.getContentStream().length);
// ContentDTO [] docs = service.findDocumentosByTreinamento("CTP004", "5", "2015");
// for (ContentDTO documentDTO : docs) {
// System.out.println(documentDTO.getName());
// }
// ContentDTO [] documentos = service.findDocumentosByTreinamento("TEL007", "1", "2017");
//
// for (ContentDTO contentDTO : documentos) {
// System.out.println(contentDTO.getName());
// }
// String uid = service.createDocument(document, "D-CTP/Documentos de Treinamentos/CTP001-3");
// System.out.println(uid);
// String uid = service.createFolder(folder, "D-CTP/Documentos de Treinamentos");
// System.out.println(uuid);
// service.findContentByUUID(uid);
// System.out.println(service.contentExistsByPath("D-CTP/Documentos de Treinamentos"));
}
Aggregations