Search in sources :

Example 1 with ResultSet

use of org.alfresco.webservice.types.ResultSet 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;
}
Also used : Query(org.alfresco.webservice.types.Query) ParentReference(org.alfresco.webservice.types.ParentReference) Reference(org.alfresco.webservice.types.Reference) Node(org.alfresco.webservice.types.Node) ResultSetRow(org.alfresco.webservice.types.ResultSetRow) NamedValue(org.alfresco.webservice.types.NamedValue) Predicate(org.alfresco.webservice.types.Predicate) ContentDTO(com.tomasio.projects.trainning.dto.ContentDTO) QueryResult(org.alfresco.webservice.repository.QueryResult) RepositoryFault(org.alfresco.webservice.repository.RepositoryFault) RepositoryServiceSoapBindingStub(org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub) ResultSet(org.alfresco.webservice.types.ResultSet) AuthenticationFault(org.alfresco.webservice.authentication.AuthenticationFault) RemoteException(java.rmi.RemoteException)

Example 2 with ResultSet

use of org.alfresco.webservice.types.ResultSet 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;
}
Also used : Query(org.alfresco.webservice.types.Query) ParentReference(org.alfresco.webservice.types.ParentReference) Reference(org.alfresco.webservice.types.Reference) Node(org.alfresco.webservice.types.Node) ResultSetRow(org.alfresco.webservice.types.ResultSetRow) NamedValue(org.alfresco.webservice.types.NamedValue) Predicate(org.alfresco.webservice.types.Predicate) ContentDTO(com.tomasio.projects.trainning.dto.ContentDTO) QueryResult(org.alfresco.webservice.repository.QueryResult) RepositoryFault(org.alfresco.webservice.repository.RepositoryFault) RepositoryServiceSoapBindingStub(org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub) ResultSet(org.alfresco.webservice.types.ResultSet) AuthenticationFault(org.alfresco.webservice.authentication.AuthenticationFault) RemoteException(java.rmi.RemoteException)

Aggregations

ContentDTO (com.tomasio.projects.trainning.dto.ContentDTO)2 RemoteException (java.rmi.RemoteException)2 AuthenticationFault (org.alfresco.webservice.authentication.AuthenticationFault)2 QueryResult (org.alfresco.webservice.repository.QueryResult)2 RepositoryFault (org.alfresco.webservice.repository.RepositoryFault)2 RepositoryServiceSoapBindingStub (org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub)2 NamedValue (org.alfresco.webservice.types.NamedValue)2 Node (org.alfresco.webservice.types.Node)2 ParentReference (org.alfresco.webservice.types.ParentReference)2 Predicate (org.alfresco.webservice.types.Predicate)2 Query (org.alfresco.webservice.types.Query)2 Reference (org.alfresco.webservice.types.Reference)2 ResultSet (org.alfresco.webservice.types.ResultSet)2 ResultSetRow (org.alfresco.webservice.types.ResultSetRow)2