use of org.candlepin.model.Content in project candlepin by candlepin.
the class OwnerContentResource method getContent.
@ApiOperation(notes = "Retrieves a single Content", value = "getContent")
@ApiResponses({ @ApiResponse(code = 400, message = "") })
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{content_id}")
public ContentDTO getContent(@Verify(Owner.class) @PathParam("owner_key") String ownerKey, @PathParam("content_id") String contentId) {
Owner owner = this.getOwnerByKey(ownerKey);
Content content = this.fetchContent(owner, contentId);
return this.translator.translate(content, ContentDTO.class);
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class OwnerContentResource method remove.
@ApiOperation(notes = "Deletes a Content", value = "remove")
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("/{content_id}")
public void remove(@PathParam("owner_key") String ownerKey, @PathParam("content_id") String contentId) {
Owner owner = this.getOwnerByKey(ownerKey);
Content content = this.fetchContent(owner, contentId);
if (content.isLocked()) {
throw new ForbiddenException(i18n.tr("content \"{0}\" is locked", content.getId()));
}
this.contentManager.removeContent(owner, content, true);
ownerManager.refreshOwnerForContentAccess(owner);
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class OwnerContentResource method listContent.
@ApiOperation(notes = "Retrieves list of Content", value = "list", response = Content.class, responseContainer = "list")
@GET
@Produces(MediaType.APPLICATION_JSON)
public CandlepinQuery<ContentDTO> listContent(@Verify(Owner.class) @PathParam("owner_key") String ownerKey) {
final Owner owner = this.getOwnerByKey(ownerKey);
CandlepinQuery<Content> query = this.ownerContentCurator.getContentByOwner(owner);
return this.translator.translateQuery(query, ContentDTO.class);
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class OwnerContentResource method createContent.
@ApiOperation(notes = "Creates a Content", value = "createContent")
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public ContentDTO createContent(@PathParam("owner_key") String ownerKey, @ApiParam(name = "content", required = true) ContentDTO content) {
Owner owner = this.getOwnerByKey(ownerKey);
Content entity = this.createContentImpl(owner, content);
ownerManager.refreshOwnerForContentAccess(owner);
return this.translator.translate(entity, ContentDTO.class);
}
use of org.candlepin.model.Content in project candlepin by candlepin.
the class OrphanCleanupJob method toExecute.
@Override
@Transactional
public void toExecute(JobExecutionContext ctx) throws JobExecutionException {
log.debug("Deleting orphaned entities...");
int count;
// Content
count = 0;
CandlepinQuery<Content> contentQuery = this.ownerContentCurator.getOrphanedContent().setLockMode(LockModeType.PESSIMISTIC_WRITE);
for (Content content : contentQuery) {
this.contentCurator.delete(content);
++count;
}
this.contentCurator.flush();
log.debug("{} orphaned content entities deleted", count);
// Products
count = 0;
CandlepinQuery<Product> productQuery = this.ownerProductCurator.getOrphanedProducts().setLockMode(LockModeType.PESSIMISTIC_WRITE);
for (Product product : productQuery) {
this.productCurator.delete(product);
++count;
}
this.productCurator.flush();
log.debug("{} orphaned product entities deleted", count);
}
Aggregations