use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class CatalogImageService method getCatalogImages.
/**
* Gets the list of catalog images
*
* @param tenantId the URN of a tenant
* @brief List Catalog Images
* @return a list of catalog images
* @throws DatabaseException when a DB error occurs
*/
@GET
@Path("")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public CatalogImageList getCatalogImages(@DefaultValue("") @QueryParam(SearchConstants.TENANT_ID_PARAM) String tenantId) throws DatabaseException {
StorageOSUser user = getUserFromContext();
if (StringUtils.isBlank(tenantId)) {
tenantId = user.getTenantId();
}
verifyAuthorizedInTenantOrg(uri(tenantId), getUserFromContext());
List<CatalogImage> catalogImages = catalogImageManager.getCatalogImages(uri(tenantId));
CatalogImageList list = new CatalogImageList();
for (CatalogImage catalogImage : catalogImages) {
NamedRelatedResourceRep resourceRep = toNamedRelatedResource(ResourceTypeEnum.CATALOG_IMAGE, catalogImage.getId(), catalogImage.getLabel());
list.getCatalogImages().add(resourceRep);
}
return list;
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class CatalogImageService method createCatalogImage.
/**
* Creates a new catalog image
*
* @param createParam
* the parameter to create a new catalog image
* @prereq none
* @brief Create Catalog Image
* @return none
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN })
@Path("")
public CatalogImageRestRep createCatalogImage(CatalogImageCreateParam createParam) {
StorageOSUser user = getUserFromContext();
verifyAuthorizedInTenantOrg(createParam.getTenant(), user);
validateParam(createParam.getTenant(), createParam, null);
CatalogImage catalogImage = createNewObject(createParam.getTenant(), createParam);
catalogImageManager.createCatalogImage(catalogImage);
auditOpSuccess(OperationTypeEnum.CREATE_CATALOG_IMAGE, catalogImage.auditParameters());
return map(catalogImage);
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class ExecutionWindowService method updateExecutionWindow.
/**
* Update execution window
*
* @param param Execution Window update parameters
* @param id the URN the execution window
* @prereq none
* @brief Update Execution Window
* @return No data returned in response body
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN })
public ExecutionWindowRestRep updateExecutionWindow(@PathParam("id") URI id, ExecutionWindowUpdateParam param) {
ExecutionWindow executionWindow = getExecutionWindowById(id, true);
StorageOSUser user = getUserFromContext();
verifyAuthorizedInTenantOrg(uri(executionWindow.getTenant()), user);
validateParam(param, executionWindow, user.getTenantId());
updateObject(executionWindow, param);
executionWindowManager.updateExecutionWindow(executionWindow);
auditOpSuccess(OperationTypeEnum.UPDATE_EXECUTION_WINDOW, executionWindow.auditParameters());
executionWindow = executionWindowManager.getExecutionWindowById(executionWindow.getId());
return map(executionWindow);
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class ScheduledEventService method cancelScheduledEvent.
/**
* Cancel a scheduled event which should be in APPROVAL or APPROVED status.
* @param id Scheduled Event URI
* @return OK if cancellation completed successfully
*/
@POST
@Path("/{id}/cancel")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response cancelScheduledEvent(@PathParam("id") String id) {
ScheduledEvent scheduledEvent = queryResource(uri(id));
ArgValidator.checkEntity(scheduledEvent, uri(id), true);
StorageOSUser user = getUserFromContext();
verifyAuthorizedInTenantOrg(uri(scheduledEvent.getTenant()), user);
if (!(scheduledEvent.getEventStatus().equals(ScheduledEventStatus.APPROVAL) || scheduledEvent.getEventStatus().equals(ScheduledEventStatus.APPROVED) || scheduledEvent.getEventStatus().equals(ScheduledEventStatus.REJECTED))) {
throw APIException.badRequests.unexpectedValueForProperty(ScheduledEvent.EVENT_STATUS, "APPROVAL|APPROVED|REJECTED", scheduledEvent.getEventStatus().name());
}
Order order = client.orders().findById(scheduledEvent.getLatestOrderId());
ArgValidator.checkEntity(order, uri(id), true);
order.setOrderStatus(OrderStatus.CANCELLED.name());
client.save(order);
scheduledEvent.setEventStatus(ScheduledEventStatus.CANCELLED);
client.save(scheduledEvent);
try {
log.info("Cancelled a scheduledEvent {}:{}", scheduledEvent.getId(), ScheduleInfo.deserialize(org.apache.commons.codec.binary.Base64.decodeBase64(scheduledEvent.getScheduleInfo().getBytes(UTF_8))).toString());
} catch (Exception e) {
log.error("Failed to parse scheduledEvent.");
}
return Response.ok().build();
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class ScheduledEventService method createEvent.
/**
* Create a scheduled event for one or a series of future orders.
* Also a latest order is created and set to APPROVAL or SCHEDULED status
* @param createParam including schedule time info and order parameters
* @return ScheduledEventRestRep
*/
@POST
@Path("")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ScheduledEventRestRep createEvent(ScheduledEventCreateParam createParam) {
StorageOSUser user = getUserFromContext();
URI tenantId = createParam.getOrderCreateParam().getTenantId();
if (tenantId != null) {
verifyAuthorizedInTenantOrg(tenantId, user);
} else {
tenantId = uri(user.getTenantId());
}
ArgValidator.checkFieldNotNull(createParam.getOrderCreateParam().getCatalogService(), "catalogService");
CatalogService catalogService = catalogServiceManager.getCatalogServiceById(createParam.getOrderCreateParam().getCatalogService());
if (catalogService == null) {
throw APIException.badRequests.orderServiceNotFound(asString(createParam.getOrderCreateParam().getCatalogService()));
}
validateParam(createParam.getScheduleInfo());
validOrderParam(createParam.getScheduleInfo(), createParam.getOrderCreateParam().getParameters());
validateAutomaticExpirationNumber(createParam.getOrderCreateParam().getAdditionalScheduleInfo());
ScheduledEvent newObject = null;
try {
newObject = createScheduledEvent(user, tenantId, createParam, catalogService);
} catch (APIException ex) {
log.error(ex.getMessage(), ex);
throw ex;
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return map(newObject);
}
Aggregations