use of com.tomasio.projects.trainning.dao.AlfrescoContentDAO 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.dao.AlfrescoContentDAO 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