use of org.opencastproject.series.api.SeriesException in project opencast by opencast.
the class SeriesRestService method putSeriesElement.
@PUT
@Path("{seriesId}/elements/{elementType}")
@RestQuery(name = "updateSeriesElement", description = "Updates an existing series element", returnDescription = "An empty response", pathParameters = { @RestParameter(name = "seriesId", description = "The series identifier", type = STRING, isRequired = true), @RestParameter(name = "elementType", description = "The element type", type = STRING, isRequired = true) }, reponses = { @RestResponse(responseCode = SC_NO_CONTENT, description = "Series element updated"), @RestResponse(responseCode = SC_CREATED, description = "Series element created"), @RestResponse(responseCode = SC_INTERNAL_SERVER_ERROR, description = "Error while processing the request") })
public Response putSeriesElement(@Context HttpServletRequest request, @PathParam("seriesId") String seriesId, @PathParam("elementType") String elementType) {
InputStream is = null;
try {
is = request.getInputStream();
final byte[] data = IOUtils.toByteArray(is);
if (seriesService.getSeriesElementData(seriesId, elementType).isSome()) {
if (seriesService.updateSeriesElement(seriesId, elementType, data)) {
return R.noContent();
} else {
return R.serverError();
}
} else {
if (seriesService.addSeriesElement(seriesId, elementType, data)) {
return R.created(URI.create(UrlSupport.concat(serverUrl, serviceUrl, seriesId, "elements", elementType)));
} else {
return R.serverError();
}
}
} catch (IOException e) {
logger.error("Error while trying to read from request: {}", ExceptionUtils.getStackTrace(e));
return R.serverError();
} catch (SeriesException e) {
logger.warn("Error while adding element to series '{}': {}", seriesId, ExceptionUtils.getStackTrace(e));
return R.serverError();
} finally {
IOUtils.closeQuietly(is);
}
}
use of org.opencastproject.series.api.SeriesException in project opencast by opencast.
the class SeriesServiceImpl method updateSeriesProperty.
@Override
public void updateSeriesProperty(String seriesID, String propertyName, String propertyValue) throws SeriesException, NotFoundException, UnauthorizedException {
try {
persistence.updateSeriesProperty(seriesID, propertyName, propertyValue);
messageSender.sendObjectMessage(SeriesItem.SERIES_QUEUE, MessageSender.DestinationType.Queue, SeriesItem.updateProperty(seriesID, propertyName, propertyValue));
} catch (SeriesServiceDatabaseException e) {
logger.error("Failed to get series property for series with series id '{}' and property name '{}' and value '{}': {}", seriesID, propertyName, propertyValue, ExceptionUtils.getStackTrace(e));
throw new SeriesException(e);
}
}
use of org.opencastproject.series.api.SeriesException in project opencast by opencast.
the class SeriesServiceImpl method updateOptOutStatus.
@Override
public void updateOptOutStatus(String seriesId, boolean optOut) throws NotFoundException, SeriesException {
try {
persistence.updateOptOutStatus(seriesId, optOut);
index.updateOptOutStatus(seriesId, optOut);
messageSender.sendObjectMessage(SeriesItem.SERIES_QUEUE, MessageSender.DestinationType.Queue, SeriesItem.updateOptOut(seriesId, optOut));
} catch (SeriesServiceDatabaseException e) {
logger.error("Failed to update opt out status of series with id '{}': {}", seriesId, ExceptionUtils.getStackTrace(e));
throw new SeriesException(e);
}
}
use of org.opencastproject.series.api.SeriesException in project opencast by opencast.
the class SeriesServiceImpl method deleteSeries.
/*
* (non-Javadoc)
*
* @see org.opencastproject.series.api.SeriesService#deleteSeries(java.lang.String)
*/
@Override
public void deleteSeries(final String seriesID) throws SeriesException, NotFoundException {
try {
persistence.deleteSeries(seriesID);
messageSender.sendObjectMessage(SeriesItem.SERIES_QUEUE, MessageSender.DestinationType.Queue, SeriesItem.delete(seriesID));
} catch (SeriesServiceDatabaseException e1) {
logger.error("Could not delete series with id {} from persistence storage", seriesID);
throw new SeriesException(e1);
}
try {
index.delete(seriesID);
} catch (SeriesServiceDatabaseException e) {
logger.error("Unable to delete series with id {}: {}", seriesID, e.getMessage());
throw new SeriesException(e);
}
}
use of org.opencastproject.series.api.SeriesException in project opencast by opencast.
the class ThemesEndpoint method deleteThemeOnSeries.
/**
* Deletes all related series theme entries
*
* @param themeId
* the theme id
*/
private void deleteThemeOnSeries(long themeId) throws UnauthorizedException {
SeriesSearchQuery query = new SeriesSearchQuery(securityService.getOrganization().getId(), securityService.getUser()).withTheme(themeId);
SearchResult<Series> results = null;
try {
results = searchIndex.getByQuery(query);
} catch (SearchIndexException e) {
logger.error("The admin UI Search Index was not able to get the series with theme '{}': {}", themeId, ExceptionUtils.getStackTrace(e));
throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
}
for (SearchResultItem<Series> item : results.getItems()) {
String seriesId = item.getSource().getIdentifier();
try {
seriesService.deleteSeriesProperty(seriesId, SeriesEndpoint.THEME_KEY);
} catch (NotFoundException e) {
logger.warn("Theme {} already deleted on series {}", themeId, seriesId);
} catch (SeriesException e) {
logger.error("Unable to remove theme from series {}: {}", seriesId, ExceptionUtils.getStackTrace(e));
throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
}
}
}
Aggregations