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;
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations