Search in sources :

Example 1 with NotFoundException

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();
    }
}
Also used : EntityTransaction(javax.persistence.EntityTransaction) EntityManager(javax.persistence.EntityManager) NotFoundException(org.opencastproject.util.NotFoundException) AclTransitionDbException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbException) AclTransitionDbDuplicatedException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbDuplicatedException) AclTransitionDbDuplicatedException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbDuplicatedException) NoResultException(javax.persistence.NoResultException) AclServiceNoReferenceException(org.opencastproject.authorization.xacml.manager.api.AclServiceNoReferenceException) NotFoundException(org.opencastproject.util.NotFoundException) AclTransitionDbException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbException)

Example 2 with NotFoundException

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();
    }
}
Also used : EntityTransaction(javax.persistence.EntityTransaction) EntityManager(javax.persistence.EntityManager) NotFoundException(org.opencastproject.util.NotFoundException)

Example 3 with NotFoundException

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();
    }
}
Also used : EntityTransaction(javax.persistence.EntityTransaction) EntityManager(javax.persistence.EntityManager) NotFoundException(org.opencastproject.util.NotFoundException) AclTransitionDbException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbException) AclTransitionDbDuplicatedException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbDuplicatedException) AclTransitionDbDuplicatedException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbDuplicatedException) NoResultException(javax.persistence.NoResultException) AclServiceNoReferenceException(org.opencastproject.authorization.xacml.manager.api.AclServiceNoReferenceException) NotFoundException(org.opencastproject.util.NotFoundException) AclTransitionDbException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbException)

Example 4 with NotFoundException

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();
}
Also used : JsonConv.fullAccessControlList(org.opencastproject.authorization.xacml.manager.endpoint.JsonConv.fullAccessControlList) AccessControlList(org.opencastproject.security.api.AccessControlList) Organization(org.opencastproject.security.api.Organization) ManagedAclImpl(org.opencastproject.authorization.xacml.manager.impl.ManagedAclImpl) NotFoundException(org.opencastproject.util.NotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) RestQuery(org.opencastproject.util.doc.rest.RestQuery) PUT(javax.ws.rs.PUT)

Example 5 with NotFoundException

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);
    }
}
Also used : AclServiceException(org.opencastproject.authorization.xacml.manager.api.AclServiceException) WebApplicationException(javax.ws.rs.WebApplicationException) NotFoundException(org.opencastproject.util.NotFoundException) ConfiguredWorkflowRef(org.opencastproject.workflow.api.ConfiguredWorkflowRef) EpisodeACLTransition(org.opencastproject.authorization.xacml.manager.api.EpisodeACLTransition) Date(java.util.Date) AclTransitionDbDuplicatedException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbDuplicatedException) SeriesException(org.opencastproject.series.api.SeriesException) WebApplicationException(javax.ws.rs.WebApplicationException) AclServiceException(org.opencastproject.authorization.xacml.manager.api.AclServiceException) AclServiceNoReferenceException(org.opencastproject.authorization.xacml.manager.api.AclServiceNoReferenceException) NotFoundException(org.opencastproject.util.NotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) RestQuery(org.opencastproject.util.doc.rest.RestQuery) PUT(javax.ws.rs.PUT)

Aggregations

NotFoundException (org.opencastproject.util.NotFoundException)382 IOException (java.io.IOException)137 UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)130 SchedulerException (org.opencastproject.scheduler.api.SchedulerException)79 MediaPackage (org.opencastproject.mediapackage.MediaPackage)69 MediaPackageException (org.opencastproject.mediapackage.MediaPackageException)67 EntityManager (javax.persistence.EntityManager)55 SeriesException (org.opencastproject.series.api.SeriesException)53 Path (javax.ws.rs.Path)52 WebApplicationException (javax.ws.rs.WebApplicationException)52 RestQuery (org.opencastproject.util.doc.rest.RestQuery)51 ConfigurationException (org.osgi.service.cm.ConfigurationException)51 URI (java.net.URI)50 SchedulerConflictException (org.opencastproject.scheduler.api.SchedulerConflictException)50 SchedulerTransactionLockException (org.opencastproject.scheduler.api.SchedulerTransactionLockException)49 Date (java.util.Date)48 Test (org.junit.Test)47 File (java.io.File)46 HttpResponse (org.apache.http.HttpResponse)46 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)46