Search in sources :

Example 6 with SwordServerException

use of org.swordapp.server.SwordServerException in project mycore by MyCoRe-Org.

the class MCRSwordSolrObjectIDSupplier method getCount.

@Override
public long getCount() throws SwordServerException {
    try {
        // make a copy to prevent multi threading issues
        final SolrQuery queryCopy = this.solrQuery.getCopy();
        // only need the numFound
        queryCopy.setStart(0);
        queryCopy.setRows(0);
        final QueryResponse queryResponse = MCRSolrClientFactory.getSolrClient().query(queryCopy);
        return queryResponse.getResults().getNumFound();
    } catch (SolrServerException | IOException e) {
        throw new SwordServerException("Error while getting count with MCRSword2SolrObjectIDSupplier and Query: " + this.solrQuery, e);
    }
}
Also used : SwordServerException(org.swordapp.server.SwordServerException) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Example 7 with SwordServerException

use of org.swordapp.server.SwordServerException in project mycore by MyCoRe-Org.

the class MCRSwordSolrObjectIDSupplier method get.

@Override
public List<MCRObjectID> get(int from, int count) throws SwordServerException {
    final SolrQuery queryCopy = this.solrQuery.getCopy();
    queryCopy.setStart(from);
    queryCopy.setRows(count);
    try {
        final QueryResponse queryResponse = MCRSolrClientFactory.getSolrClient().query(queryCopy);
        return queryResponse.getResults().stream().map(r -> (String) r.getFieldValue("id")).map(MCRObjectID::getInstance).collect(Collectors.toList());
    } catch (SolrServerException | IOException e) {
        throw new SwordServerException("Error while getting id list with MCRSword2SolrObjectIDSupplier and Query: " + this.solrQuery, e);
    }
}
Also used : SwordServerException(org.swordapp.server.SwordServerException) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Aggregations

SwordServerException (org.swordapp.server.SwordServerException)7 IOException (java.io.IOException)4 SwordError (org.swordapp.server.SwordError)4 MCRAccessException (org.mycore.access.MCRAccessException)3 Dataset (edu.harvard.iq.dataverse.Dataset)2 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)2 Dataverse (edu.harvard.iq.dataverse.Dataverse)2 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)2 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)2 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)2 FileVisitResult (java.nio.file.FileVisitResult)2 Path (java.nio.file.Path)2 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)2 List (java.util.List)2 EJBException (javax.ejb.EJBException)2 ParseException (org.apache.abdera.parser.ParseException)2 SolrQuery (org.apache.solr.client.solrj.SolrQuery)2 SolrServerException (org.apache.solr.client.solrj.SolrServerException)2 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)2 MCRDerivate (org.mycore.datamodel.metadata.MCRDerivate)2