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;
}
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));
}
}
});
}
}
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);
}
}
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());
}
}
});
}
}
Aggregations