use of org.alfresco.webservice.content.ContentServiceSoapBindingStub 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 org.alfresco.webservice.content.ContentServiceSoapBindingStub 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;
}
use of org.alfresco.webservice.content.ContentServiceSoapBindingStub in project trainning by fernandotomasio.
the class AlfrescoContentDAO method createDocumentWithUUIDParent.
@Override
public String createDocumentWithUUIDParent(DocumentDTO document, String uuidParent) {
try {
AuthenticationUtils.startSession(USERNAME, PASSWORD);
ParentReference parentReference = new ParentReference(STORE, uuidParent, null, Constants.ASSOC_CONTAINS, null);
parentReference.setChildName("{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + document.getName());
// Define the content format for the content we are adding
ContentFormat contentFormat = new ContentFormat(document.getMimeType(), document.getCharset());
// Construct CML statement to create content node
// Note: Assign "1" as a local id, so we can refer to it in
// subsequent
// CML statements within the same CML block
NamedValue[] contentProps = new NamedValue[1];
contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, document.getName());
CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_CONTENT, contentProps);
// Construct CML statement to add titled aspect
NamedValue[] titledProps = new NamedValue[2];
titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, document.getTitle());
titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, document.getDescription());
CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED, titledProps, null, "1");
// Construct CML Block
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
cml.setAddAspect(new CMLAddAspect[] { addAspect });
// Issue CML statement via Repository Web Service and retrieve
// result
// Note: Batching of multiple statements into a single web call
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
Reference content = result[0].getDestination();
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
contentService.write(content, Constants.PROP_CONTENT, document.getContentStream(), contentFormat);
return content.getUuid();
} catch (AuthenticationFault e) {
Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Autenticação");
return null;
} catch (RepositoryFault e) {
Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.INFO, "Conteúdo não disponível");
return null;
} catch (RemoteException e) {
Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Acesso a Serviço Web");
return null;
} finally {
// End the session
AuthenticationUtils.endSession();
}
}
use of org.alfresco.webservice.content.ContentServiceSoapBindingStub 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;
}
use of org.alfresco.webservice.content.ContentServiceSoapBindingStub in project trainning by fernandotomasio.
the class AlfrescoContentDAO method createDocument.
@Override
public String createDocument(DocumentDTO document, String path) {
try {
AuthenticationUtils.startSession(USERNAME, PASSWORD);
ParentReference parentReference = new ParentReference(STORE, null, encodePath(path), Constants.ASSOC_CONTAINS, null);
parentReference.setChildName("{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + document.getName());
// Define the content format for the content we are adding
ContentFormat contentFormat = new ContentFormat(document.getMimeType(), document.getCharset());
// Construct CML statement to create content node
// Note: Assign "1" as a local id, so we can refer to it in
// subsequent
// CML statements within the same CML block
NamedValue[] contentProps = new NamedValue[1];
contentProps[0] = Utils.createNamedValue(Constants.PROP_NAME, document.getName());
CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_CONTENT, contentProps);
// Construct CML statement to add titled aspect
NamedValue[] titledProps = new NamedValue[2];
titledProps[0] = Utils.createNamedValue(Constants.PROP_TITLE, document.getTitle());
titledProps[1] = Utils.createNamedValue(Constants.PROP_DESCRIPTION, document.getDescription());
CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_TITLED, titledProps, null, "1");
// Construct CML Block
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
cml.setAddAspect(new CMLAddAspect[] { addAspect });
// Issue CML statement via Repository Web Service and retrieve
// result
// Note: Batching of multiple statements into a single web call
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
Reference content = result[0].getDestination();
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();
contentService.write(content, Constants.PROP_CONTENT, document.getContentStream(), contentFormat);
return content.getUuid();
} catch (AuthenticationFault e) {
Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Autenticação");
return null;
} catch (RepositoryFault e) {
Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.INFO, "Conteúdo não disponível");
return null;
} catch (RemoteException e) {
Logger.getLogger(AlfrescoContentDAO.class.getName()).log(Level.SEVERE, "Erro de Acesso a Serviço Web");
return null;
} finally {
// End the session
AuthenticationUtils.endSession();
}
}
Aggregations