use of org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub in project trainning by fernandotomasio.
the class ImportTurmasImplEfetivasFromTabelao method contentExistsByPath.
public boolean contentExistsByPath(String path) {
boolean result = false;
try {
AuthenticationUtils.startSession(USERNAME, PASSWORD);
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
Reference node = new Reference();
node.setStore(STORE);
node.setPath(encodePath(path));
Node[] nodes = null;
nodes = repositoryService.get(new Predicate(new Reference[] { node }, STORE, null));
if (nodes != null) {
return true;
}
} 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");
} finally {
// End the session
AuthenticationUtils.endSession();
}
return result;
}
use of org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub in project trainning by fernandotomasio.
the class AlfrescoContentDAO method contentExistsByPath.
// @Override
// public String addDocumentToTreinamento(DocumentDTO documento,
// String comando, String exercicio, String curso, String turma) {
// String pathTreinamentos = comando + "/" + TREINAMENTOS_SPACE;
// if (!contentExistsByPath(pathTreinamentos)) {
// FolderDTO folder = new FolderDTO();
// folder.setName(TREINAMENTOS_SPACE);
// createFolder(folder, DCTP_SPACE);
// }
//
// String pathExercicio = pathTreinamentos + "/" + exercicio;
//
// if (!contentExistsByPath(pathExercicio)) {
// FolderDTO folder = new FolderDTO();
// folder.setName(exercicio);
// createFolder(folder, pathTreinamentos);
//
// }
//
// String pathTurma = pathExercicio + "/" + curso + "-" + turma;
// if (!contentExistsByPath(pathTurma)) {
// FolderDTO folder = new FolderDTO();
// folder.setName(curso + "-" + turma);
// createFolder(folder, pathExercicio);
//
// }
//
// String uuid = createDocument(documento, pathTurma);
// return uuid;
//
// }
@Override
public boolean contentExistsByPath(String path) {
boolean result = false;
try {
AuthenticationUtils.startSession(USERNAME, PASSWORD);
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
Reference node = new Reference();
node.setStore(STORE);
node.setPath(encodePath(path));
Node[] nodes = null;
nodes = repositoryService.get(new Predicate(new Reference[] { node }, STORE, null));
if (nodes != null) {
return true;
}
} 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");
} finally {
// End the session
AuthenticationUtils.endSession();
}
return result;
}
use of org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub 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.repository.RepositoryServiceSoapBindingStub in project trainning by fernandotomasio.
the class AlfrescoContentDAO method findAllContentByPath.
@Override
public ContentDTO[] findAllContentByPath(String path) {
ContentDTO[] contents = null;
try {
AuthenticationUtils.startSession(USERNAME, PASSWORD);
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
// Get a reference to the space we have named
Reference reference = new Reference(STORE, null, encodePath(path));
Predicate predicate = new Predicate(new Reference[] { reference }, null, null);
Node[] nodes = repositoryService.get(predicate);
// Create a query object, looking for all items with alfresco in the
// name of text
Query query = new Query(Constants.QUERY_LANG_LUCENE, "+PARENT:\"workspace://SpacesStore/" + nodes[0].getReference().getUuid() + "\"");
// Execute the query
QueryResult queryResult = repositoryService.query(STORE, query, false);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows != null) {
contents = new ContentDTO[rows.length];
// Get the infomation from the result set
for (int i = 0; i < rows.length; i++) {
ResultSetRow row = (ResultSetRow) rows[i];
String nodeId = row.getNode().getId();
ContentDTO content = new ContentDTO();
content.setUid(nodeId);
for (NamedValue namedValue : row.getColumns()) {
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());
}
}
contents[i] = content;
// results.add(contentResult);
}
}
} 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");
} finally {
// End the session
AuthenticationUtils.endSession();
}
return contents;
}
use of org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub in project trainning by fernandotomasio.
the class AlfrescoContentDAO method findAllContentByUUID.
@Override
public ContentDTO[] findAllContentByUUID(String uuid) {
ContentDTO[] contents = null;
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));
// Create a query object, looking for all items with alfresco in the
// name of text
Query query = new Query(Constants.QUERY_LANG_LUCENE, "+PARENT:\"workspace://SpacesStore/" + nodes[0].getReference().getUuid() + "\"");
// Execute the query
QueryResult queryResult = repositoryService.query(STORE, query, false);
// Display the results
ResultSet resultSet = queryResult.getResultSet();
ResultSetRow[] rows = resultSet.getRows();
if (rows != null) {
contents = new ContentDTO[rows.length];
// Get the infomation from the result set
for (int i = 0; i < rows.length; i++) {
ResultSetRow row = (ResultSetRow) rows[i];
String nodeId = row.getNode().getId();
ContentDTO content = new ContentDTO();
content.setUid(nodeId);
for (NamedValue namedValue : row.getColumns()) {
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());
}
}
contents[i] = content;
// results.add(contentResult);
}
}
} 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");
} finally {
// End the session
AuthenticationUtils.endSession();
}
return contents;
}
Aggregations