Search in sources :

Example 6 with Predicate

use of org.alfresco.webservice.types.Predicate 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)

Example 7 with Predicate

use of org.alfresco.webservice.types.Predicate 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;
}
Also used : Reference(org.alfresco.webservice.types.Reference) Node(org.alfresco.webservice.types.Node) NamedValue(org.alfresco.webservice.types.NamedValue) ParseException(java.text.ParseException) RemoteException(java.rmi.RemoteException) DAOException(com.tomasio.projects.trainning.exception.DAOException) Predicate(org.alfresco.webservice.types.Predicate) ContentServiceSoapBindingStub(org.alfresco.webservice.content.ContentServiceSoapBindingStub) RepositoryFault(org.alfresco.webservice.repository.RepositoryFault) Content(org.alfresco.webservice.content.Content) DocumentDTO(com.tomasio.projects.trainning.dto.DocumentDTO) RepositoryServiceSoapBindingStub(org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub) AuthenticationFault(org.alfresco.webservice.authentication.AuthenticationFault) AlfrescoContentDAO(com.tomasio.projects.trainning.dao.AlfrescoContentDAO) RemoteException(java.rmi.RemoteException)

Example 8 with Predicate

use of org.alfresco.webservice.types.Predicate in project trainning by fernandotomasio.

the class ImportTurmasImplEfetivasFromTabelao method findAllContentByPath.

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
        org.alfresco.webservice.types.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) 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) AuthenticationFault(org.alfresco.webservice.authentication.AuthenticationFault) AlfrescoContentDAO(com.tomasio.projects.trainning.dao.AlfrescoContentDAO) RemoteException(java.rmi.RemoteException)

Example 9 with Predicate

use of org.alfresco.webservice.types.Predicate in project trainning by fernandotomasio.

the class AlfrescoContentDAO method contentExistsByUUID.

@Override
public boolean contentExistsByUUID(String uuid) {
    boolean result = false;
    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));
        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;
}
Also used : RepositoryFault(org.alfresco.webservice.repository.RepositoryFault) ParentReference(org.alfresco.webservice.types.ParentReference) Reference(org.alfresco.webservice.types.Reference) Node(org.alfresco.webservice.types.Node) RepositoryServiceSoapBindingStub(org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub) AuthenticationFault(org.alfresco.webservice.authentication.AuthenticationFault) RemoteException(java.rmi.RemoteException) Predicate(org.alfresco.webservice.types.Predicate)

Example 10 with Predicate

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

Aggregations

RemoteException (java.rmi.RemoteException)11 AuthenticationFault (org.alfresco.webservice.authentication.AuthenticationFault)11 RepositoryFault (org.alfresco.webservice.repository.RepositoryFault)11 Predicate (org.alfresco.webservice.types.Predicate)11 Reference (org.alfresco.webservice.types.Reference)11 RepositoryServiceSoapBindingStub (org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub)9 Node (org.alfresco.webservice.types.Node)9 ParentReference (org.alfresco.webservice.types.ParentReference)8 NamedValue (org.alfresco.webservice.types.NamedValue)7 AlfrescoContentDAO (com.tomasio.projects.trainning.dao.AlfrescoContentDAO)3 ContentDTO (com.tomasio.projects.trainning.dto.ContentDTO)3 DocumentDTO (com.tomasio.projects.trainning.dto.DocumentDTO)3 Content (org.alfresco.webservice.content.Content)3 ContentServiceSoapBindingStub (org.alfresco.webservice.content.ContentServiceSoapBindingStub)3 QueryResult (org.alfresco.webservice.repository.QueryResult)3 Query (org.alfresco.webservice.types.Query)3 ResultSetRow (org.alfresco.webservice.types.ResultSetRow)3 CML (org.alfresco.webservice.types.CML)2 ResultSet (org.alfresco.webservice.types.ResultSet)2 DAOException (com.tomasio.projects.trainning.exception.DAOException)1