use of org.opencastproject.util.NotFoundException in project opencast by opencast.
the class OsgiJpaAclTransitionDb method updateEpisodeAclTransition.
@Override
public EpisodeACLTransition updateEpisodeAclTransition(Organization org, long transitionId, Date applicationDate, Option<Long> managedAclId, Option<ConfiguredWorkflowRef> workflow) throws AclTransitionDbException, NotFoundException {
EntityManager em = null;
EntityTransaction tx = null;
try {
em = emf.createEntityManager();
tx = em.getTransaction();
tx.begin();
EpisodeAclTransitionEntity entity = getEpisodeEntity(transitionId, org.getId(), em);
if (entity == null)
throw new NotFoundException("Episode transition " + transitionId + " not found!");
entity.update(entity.getEpisodeId(), org.getId(), applicationDate, getManagedAcl(em, managedAclId, org), workflow);
em.merge(entity);
tx.commit();
return entity;
} catch (NotFoundException e) {
throw e;
} catch (AclTransitionDbException e) {
throw e;
} catch (Exception e) {
if (tx != null && tx.isActive())
tx.rollback();
boolean isContraintViolation = Util.isConstraintViolationException(e);
if (isContraintViolation)
throw new AclTransitionDbDuplicatedException();
else {
logger.error("Could not update the scheduled episode ACL: {}", e.getMessage());
throw new AclTransitionDbException(e);
}
} finally {
if (em != null)
em.close();
}
}
use of org.opencastproject.util.NotFoundException in project opencast by opencast.
the class OsgiJpaAclTransitionDb method deleteEpisodeAclTransition.
@Override
public void deleteEpisodeAclTransition(Organization org, long transitionId) throws NotFoundException {
EntityManager em = null;
EntityTransaction tx = null;
try {
em = emf.createEntityManager();
tx = em.getTransaction();
tx.begin();
EpisodeAclTransitionEntity entity = getEpisodeEntity(transitionId, org.getId(), em);
if (entity == null)
throw new NotFoundException();
em.remove(entity);
tx.commit();
} finally {
if (em != null)
em.close();
}
}
use of org.opencastproject.util.NotFoundException in project opencast by opencast.
the class OsgiJpaAclTransitionDb method updateSeriesAclTransition.
@Override
public SeriesACLTransition updateSeriesAclTransition(Organization org, long transitionId, Date applicationDate, long managedAclId, boolean override, Option<ConfiguredWorkflowRef> workflow) throws AclTransitionDbException, NotFoundException {
EntityManager em = null;
EntityTransaction tx = null;
try {
em = emf.createEntityManager();
tx = em.getTransaction();
tx.begin();
SeriesAclTransitionEntity entity = getSeriesEntity(transitionId, org.getId(), em);
if (entity == null)
throw new NotFoundException("Series transition " + transitionId + " not found!");
entity.update(entity.getSeriesId(), org.getId(), applicationDate, getManagedAcl(em, some(managedAclId), org).get(), workflow, override);
em.merge(entity);
tx.commit();
return entity;
} catch (NotFoundException e) {
throw e;
} catch (AclTransitionDbException e) {
throw e;
} catch (Exception e) {
if (tx != null && tx.isActive())
tx.rollback();
boolean isContraintViolation = Util.isConstraintViolationException(e);
if (isContraintViolation)
throw new AclTransitionDbDuplicatedException();
else {
logger.error("Could not update the scheduled series ACL: {}", e.getMessage());
throw new AclTransitionDbException(e);
}
} finally {
if (em != null)
em.close();
}
}
use of org.opencastproject.util.NotFoundException in project opencast by opencast.
the class AbstractAclServiceRestEndpoint method updateAcl.
@PUT
@Path("/acl/{aclId}")
@Produces(MediaType.APPLICATION_JSON)
@RestQuery(name = "updateacl", description = "Update an ACL", returnDescription = "Update an ACL", pathParameters = { @RestParameter(name = "aclId", isRequired = true, description = "The ACL identifier", type = INTEGER) }, restParameters = { @RestParameter(name = "name", isRequired = true, description = "The ACL name", type = STRING), @RestParameter(name = "acl", isRequired = true, description = "The access control list", type = STRING) }, reponses = { @RestResponse(responseCode = SC_OK, description = "The ACL has successfully been updated"), @RestResponse(responseCode = SC_NOT_FOUND, description = "The ACL has not been found"), @RestResponse(responseCode = SC_BAD_REQUEST, description = "Unable to parse the ACL"), @RestResponse(responseCode = SC_INTERNAL_SERVER_ERROR, description = "Error during updating the ACL") })
public String updateAcl(@PathParam("aclId") long aclId, @FormParam("name") String name, @FormParam("acl") String accessControlList) throws NotFoundException {
final Organization org = getSecurityService().getOrganization();
final AccessControlList acl = parseAcl.apply(accessControlList);
final ManagedAclImpl managedAcl = new ManagedAclImpl(aclId, name, org.getId(), acl);
if (!aclService().updateAcl(managedAcl)) {
logger.info("No ACL with id '{}' could be found under organization '{}'", aclId, org.getId());
throw new NotFoundException();
}
return JsonConv.full(managedAcl).toJson();
}
use of org.opencastproject.util.NotFoundException in project opencast by opencast.
the class AbstractAclServiceRestEndpoint method updateEpisodeTransition.
@PUT
@Path("/episode/{transitionId}")
@Produces(MediaType.APPLICATION_JSON)
@RestQuery(name = "updateepisodetransition", description = "Update an existing episode transition", returnDescription = "Update an existing episode transition", pathParameters = { @RestParameter(name = "transitionId", isRequired = true, description = "The transition id", type = STRING) }, restParameters = { @RestParameter(name = "applicationDate", isRequired = true, description = "The date to applicate", type = STRING), @RestParameter(name = "managedAclId", isRequired = false, description = "The managed access control list id", type = INTEGER), @RestParameter(name = "workflowDefinitionId", isRequired = false, description = "The workflow definition identifier", type = STRING), @RestParameter(name = "workflowParams", isRequired = false, description = "The workflow parameters as JSON", type = STRING) }, reponses = { @RestResponse(responseCode = SC_OK, description = "The episode transition has successfully been updated"), @RestResponse(responseCode = SC_INTERNAL_SERVER_ERROR, description = "Error during updating an episode transition") })
public String updateEpisodeTransition(@PathParam("transitionId") long transitionId, @FormParam("applicationDate") String applicationDate, @FormParam("managedAclId") Long managedAclId, @FormParam("workflowDefinitionId") String workflowDefinitionId, @FormParam("workflowParams") String workflowParams) throws NotFoundException {
try {
final Date at = new Date(DateTimeSupport.fromUTC(applicationDate));
final Option<ConfiguredWorkflowRef> workflow = createConfiguredWorkflowRef(workflowDefinitionId, workflowParams);
final EpisodeACLTransition t = aclService().updateEpisodeTransition(transitionId, option(managedAclId), at, workflow);
return JsonConv.full(t).toJson();
} catch (AclServiceException e) {
logger.warn("Error updating episode transition:", e);
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.warn("Unable to parse the application date");
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
}
}
Aggregations