use of com.tomasio.projects.trainning.dto.DocumentDTO in project trainning by fernandotomasio.
the class AlfrescoContentDAO method findDocumentByUUID.
@SuppressWarnings("unused")
@Override
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