Search in sources :

Example 21 with SeriesServiceDatabaseException

use of org.opencastproject.series.impl.SeriesServiceDatabaseException in project opencast by opencast.

the class SeriesServiceSolrIndex method getAccessControl.

/*
   * (non-Javadoc)
   *
   * @see org.opencastproject.series.impl.SeriesServiceIndex#getAccessControl(java.lang.String)
   */
@Override
public AccessControlList getAccessControl(String seriesID) throws NotFoundException, SeriesServiceDatabaseException {
    SolrDocument seriesDoc = getSolrDocumentByID(seriesID);
    if (seriesDoc == null) {
        logger.debug("No series exists with ID '{}'", seriesID);
        throw new NotFoundException("No series with ID " + seriesID + " found.");
    }
    String serializedAC = (String) seriesDoc.get(SolrFields.ACCESS_CONTROL_KEY);
    AccessControlList accessControl;
    if (serializedAC == null) {
        accessControl = new AccessControlList();
    } else {
        try {
            accessControl = AccessControlParser.parseAcl(serializedAC);
        } catch (Exception e) {
            logger.error("Could not parse access control: {}", e.getMessage());
            throw new SeriesServiceDatabaseException(e);
        }
    }
    return accessControl;
}
Also used : AccessControlList(org.opencastproject.security.api.AccessControlList) SolrDocument(org.apache.solr.common.SolrDocument) SeriesServiceDatabaseException(org.opencastproject.series.impl.SeriesServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) SeriesException(org.opencastproject.series.api.SeriesException) SeriesServiceDatabaseException(org.opencastproject.series.impl.SeriesServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 22 with SeriesServiceDatabaseException

use of org.opencastproject.series.impl.SeriesServiceDatabaseException in project opencast by opencast.

the class SeriesServiceSolrIndex method updateOptOutStatus.

@Override
public void updateOptOutStatus(String seriesId, boolean optedOut) throws NotFoundException, SeriesServiceDatabaseException {
    SolrDocument seriesDoc = getSolrDocumentByID(seriesId);
    if (seriesDoc == null) {
        logger.debug("No series with ID " + seriesId + " found.");
        throw new NotFoundException("Series with ID " + seriesId + " was not found.");
    }
    final SolrInputDocument inputDoc = ClientUtils.toSolrInputDocument(seriesDoc);
    inputDoc.setField(SolrFields.OPT_OUT, optedOut);
    if (synchronousIndexing) {
        try {
            synchronized (solrServer) {
                solrServer.add(inputDoc);
                solrServer.commit();
            }
        } catch (Exception e) {
            throw new SeriesServiceDatabaseException("Unable to index opt out status", e);
        }
    } else {
        indexingExecutor.submit(new Runnable() {

            @Override
            public void run() {
                try {
                    synchronized (solrServer) {
                        solrServer.add(inputDoc);
                        solrServer.commit();
                    }
                } catch (Exception e) {
                    logger.warn("Unable to index opt out status for series {}: {}", inputDoc.getFieldValue(SolrFields.COMPOSITE_ID_KEY), ExceptionUtils.getStackTrace(e));
                }
            }
        });
    }
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) SolrDocument(org.apache.solr.common.SolrDocument) SeriesServiceDatabaseException(org.opencastproject.series.impl.SeriesServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) SeriesException(org.opencastproject.series.api.SeriesException) SeriesServiceDatabaseException(org.opencastproject.series.impl.SeriesServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 23 with SeriesServiceDatabaseException

use of org.opencastproject.series.impl.SeriesServiceDatabaseException in project opencast by opencast.

the class SeriesServiceSolrIndex method queryIdTitleMap.

@Override
public Map<String, String> queryIdTitleMap() throws SeriesServiceDatabaseException {
    SolrQuery solrQuery = new SolrQuery();
    solrQuery.setStart(0);
    solrQuery.setRows(Integer.MAX_VALUE);
    solrQuery.setQuery(buildSolrQueryString(new SeriesQuery(), false));
    solrQuery.addSortField(getSortField(SeriesQuery.Sort.TITLE) + "_sort", SolrQuery.ORDER.asc);
    Map<String, String> result;
    try {
        QueryResponse response = solrServer.query(solrQuery);
        SolrDocumentList items = response.getResults();
        result = new HashMap<String, String>();
        for (SolrDocument doc : items) {
            String seriesId = getSeriesIDfromCompositeID((String) doc.get(SolrFields.COMPOSITE_ID_KEY), securityService.getOrganization().getId());
            String seriesTitle = (String) doc.get(SolrFields.TITLE_KEY);
            result.put(seriesId, seriesTitle);
        }
        return result;
    } catch (Exception e) {
        logger.error("Could not retrieve results: {}", e.getMessage());
        throw new SeriesServiceDatabaseException(e);
    }
}
Also used : SeriesQuery(org.opencastproject.series.api.SeriesQuery) SolrDocument(org.apache.solr.common.SolrDocument) SeriesServiceDatabaseException(org.opencastproject.series.impl.SeriesServiceDatabaseException) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SolrDocumentList(org.apache.solr.common.SolrDocumentList) SolrQuery(org.apache.solr.client.solrj.SolrQuery) SolrServerException(org.apache.solr.client.solrj.SolrServerException) SeriesException(org.opencastproject.series.api.SeriesException) SeriesServiceDatabaseException(org.opencastproject.series.impl.SeriesServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 24 with SeriesServiceDatabaseException

use of org.opencastproject.series.impl.SeriesServiceDatabaseException in project opencast by opencast.

the class SeriesServiceSolrIndex method updateIndex.

/*
   * (non-Javadoc)
   *
   * @see
   * org.opencastproject.series.impl.SeriesServiceIndex#index(org.opencastproject.metadata.dublincore.DublinCoreCatalog)
   */
@Override
public void updateIndex(DublinCoreCatalog dc) throws SeriesServiceDatabaseException {
    final SolrInputDocument doc = createDocument(dc);
    if (synchronousIndexing) {
        try {
            synchronized (solrServer) {
                solrServer.add(doc);
                solrServer.commit();
            }
        } catch (Exception e) {
            throw new SeriesServiceDatabaseException("Unable to index series", e);
        }
    } else {
        indexingExecutor.submit(new Runnable() {

            @Override
            public void run() {
                try {
                    synchronized (solrServer) {
                        solrServer.add(doc);
                        solrServer.commit();
                    }
                } catch (Exception e) {
                    logger.warn("Unable to index series {}: {}", doc.getFieldValue(SolrFields.COMPOSITE_ID_KEY), e.getMessage());
                }
            }
        });
    }
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) SeriesServiceDatabaseException(org.opencastproject.series.impl.SeriesServiceDatabaseException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) SeriesException(org.opencastproject.series.api.SeriesException) SeriesServiceDatabaseException(org.opencastproject.series.impl.SeriesServiceDatabaseException) NotFoundException(org.opencastproject.util.NotFoundException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

SeriesServiceDatabaseException (org.opencastproject.series.impl.SeriesServiceDatabaseException)24 IOException (java.io.IOException)23 NotFoundException (org.opencastproject.util.NotFoundException)23 EntityManager (javax.persistence.EntityManager)15 NoResultException (javax.persistence.NoResultException)15 AccessControlParsingException (org.opencastproject.security.api.AccessControlParsingException)15 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)15 EntityTransaction (javax.persistence.EntityTransaction)11 SolrServerException (org.apache.solr.client.solrj.SolrServerException)8 MalformedURLException (java.net.MalformedURLException)7 SeriesException (org.opencastproject.series.api.SeriesException)7 SolrDocument (org.apache.solr.common.SolrDocument)6 AccessControlList (org.opencastproject.security.api.AccessControlList)5 Organization (org.opencastproject.security.api.Organization)4 User (org.opencastproject.security.api.User)4 SolrQuery (org.apache.solr.client.solrj.SolrQuery)3 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)3 SolrInputDocument (org.apache.solr.common.SolrInputDocument)3 DublinCoreCatalog (org.opencastproject.metadata.dublincore.DublinCoreCatalog)3 Query (javax.persistence.Query)2