use of org.opencastproject.series.api.SeriesException in project opencast by opencast.
the class SeriesServiceImpl method updateSeries.
@Override
public DublinCoreCatalog updateSeries(DublinCoreCatalog dc) throws SeriesException, UnauthorizedException {
try {
for (DublinCoreCatalog dublinCore : isNew(notNull(dc, "dc"))) {
final String id = dublinCore.getFirst(DublinCore.PROPERTY_IDENTIFIER);
if (!dublinCore.hasValue(DublinCore.PROPERTY_CREATED)) {
DublinCoreValue date = EncodingSchemeUtils.encodeDate(new Date(), Precision.Minute);
dublinCore.set(DublinCore.PROPERTY_CREATED, date);
logger.debug("Setting series creation date to '{}'", date.getValue());
}
if (dublinCore.hasValue(DublinCore.PROPERTY_TITLE)) {
if (dublinCore.getFirst(DublinCore.PROPERTY_TITLE).length() > 255) {
dublinCore.set(DublinCore.PROPERTY_TITLE, dublinCore.getFirst(DublinCore.PROPERTY_TITLE).substring(0, 255));
logger.warn("Title was longer than 255 characters. Cutting excess off.");
}
}
logger.debug("Updating series {}", id);
index.updateIndex(dublinCore);
try {
final AccessControlList acl = persistence.getAccessControlList(id);
if (acl != null) {
index.updateSecurityPolicy(id, acl);
}
} catch (NotFoundException ignore) {
// Ignore not found since this is the first indexing
}
try {
index.updateOptOutStatus(id, persistence.isOptOut(id));
} catch (NotFoundException ignore) {
// Ignore not found since this is the first indexing
}
// Make sure store to persistence comes after index, return value can be null
DublinCoreCatalog updated = persistence.storeSeries(dublinCore);
messageSender.sendObjectMessage(SeriesItem.SERIES_QUEUE, MessageSender.DestinationType.Queue, SeriesItem.updateCatalog(dublinCore));
return (updated == null) ? null : dublinCore;
}
return dc;
} catch (Exception e) {
throw rethrow(e);
}
}
use of org.opencastproject.series.api.SeriesException in project opencast by opencast.
the class SeriesServiceImpl method deleteSeriesProperty.
@Override
public void deleteSeriesProperty(String seriesID, String propertyName) throws SeriesException, NotFoundException, UnauthorizedException {
try {
persistence.deleteSeriesProperty(seriesID, propertyName);
messageSender.sendObjectMessage(SeriesItem.SERIES_QUEUE, MessageSender.DestinationType.Queue, SeriesItem.updateProperty(seriesID, propertyName, null));
} catch (SeriesServiceDatabaseException e) {
logger.error("Failed to delete series property for series with series id '{}' and property name '{}': {}", seriesID, propertyName, ExceptionUtils.getStackTrace(e));
throw new SeriesException(e);
}
}
use of org.opencastproject.series.api.SeriesException in project opencast by opencast.
the class SeriesServiceImpl method updateAccessControl.
// todo method signature does not fit the three different possible return values
@Override
public boolean updateAccessControl(final String seriesId, final AccessControlList accessControl) throws NotFoundException, SeriesException {
if (StringUtils.isEmpty(seriesId)) {
throw new IllegalArgumentException("Series ID parameter must not be null or empty.");
}
if (accessControl == null) {
throw new IllegalArgumentException("ACL parameter must not be null");
}
if (needsUpdate(seriesId, accessControl)) {
logger.debug("Updating ACL of series {}", seriesId);
boolean updated;
// not found is thrown if it doesn't exist
try {
index.updateSecurityPolicy(seriesId, accessControl);
} catch (SeriesServiceDatabaseException e) {
logger.error("Could not update series {} with access control rules: {}", seriesId, e.getMessage());
throw new SeriesException(e);
}
try {
updated = persistence.storeSeriesAccessControl(seriesId, accessControl);
messageSender.sendObjectMessage(SeriesItem.SERIES_QUEUE, MessageSender.DestinationType.Queue, SeriesItem.updateAcl(seriesId, accessControl));
} catch (SeriesServiceDatabaseException e) {
logger.error("Could not update series {} with access control rules: {}", seriesId, e.getMessage());
throw new SeriesException(e);
}
return updated;
} else {
// todo not the right return code
return true;
}
}
use of org.opencastproject.series.api.SeriesException in project opencast by opencast.
the class SolrIndexManager method createSeriesInputDocument.
/**
* Creates a solr input document for the series metadata of the media package.
*
* @param seriesId
* the id of the series
* @param acl
* the access control list for this mediapackage
* @return an input document ready to be posted to solr or null
*/
private SolrInputDocument createSeriesInputDocument(String seriesId, AccessControlList acl) throws IOException, UnauthorizedException {
if (seriesId == null)
return null;
DublinCoreCatalog dc = null;
try {
dc = seriesService.getSeries(seriesId);
} catch (SeriesException e) {
logger.debug("No series dublincore found for series id " + seriesId);
return null;
} catch (NotFoundException e) {
logger.debug("No series dublincore found for series id " + seriesId);
return null;
}
SolrInputDocument doc = new SolrInputDocument();
// Populate document with existing data
try {
StringBuffer query = new StringBuffer("q=");
query = query.append(Schema.ID).append(":").append(SolrUtils.clean(seriesId));
SolrParams params = SolrRequestParsers.parseQueryString(query.toString());
QueryResponse solrResponse = solrServer.query(params);
if (solrResponse.getResults().size() > 0) {
SolrDocument existingSolrDocument = solrResponse.getResults().get(0);
for (String fieldName : existingSolrDocument.getFieldNames()) {
doc.addField(fieldName, existingSolrDocument.getFieldValue(fieldName));
}
}
} catch (Exception e) {
logger.error("Error trying to load series " + seriesId, e);
}
// Fill document
Schema.setId(doc, seriesId);
// OC specific fields
Schema.setOrganization(doc, securityService.getOrganization().getId());
Schema.setOcMediatype(doc, SearchResultItemType.Series.toString());
Schema.setOcModified(doc, new Date());
// DC fields
addSeriesMetadata(doc, dc);
// Authorization
setAuthorization(doc, securityService, acl);
return doc;
}
use of org.opencastproject.series.api.SeriesException in project opencast by opencast.
the class CalendarGenerator method getSeriesDublinCoreAsString.
/**
* Returns series DC associated with this event or null if {@link SeriesService} is not available or does not contain
* entry for series with specified ID.
*
* @param seriesID
* {@link DublinCoreCatalog} to be retrieved
* @return DC serialized to string or null
* @throws UnauthorizedException
* if the current user is not allowed to view this series
* @throws NotFoundException
* if the series cannot be found
*/
private String getSeriesDublinCoreAsString(String seriesID) throws UnauthorizedException, NotFoundException {
if (StringUtils.isBlank(seriesID))
return null;
if (seriesService == null) {
logger.warn("No SeriesService available");
return null;
}
DublinCoreCatalog seriesDC = series.get(seriesID);
if (seriesDC == null) {
try {
seriesDC = seriesService.getSeries(seriesID);
series.put(seriesID, seriesDC);
} catch (SeriesException e) {
logger.error("Error loading DublinCoreCatalog for series '{}': {}", seriesID, ExceptionUtils.getStackTrace(e));
return null;
}
}
try {
return seriesDC.toXmlString();
} catch (IOException e) {
logger.error("Error serializing DublinCoreCatalog of series '{}': {}", seriesID, ExceptionUtils.getStackTrace(e));
return null;
}
}
Aggregations