use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class CatalogCategoryService method resetRootCatalogCategory.
/**
* Get the root catalog category for a tenant
*
* @prereq none
* @brief Get Root Catalog Category
* @return Root Catalog Category
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
@Path("/reset")
public Response resetRootCatalogCategory(@DefaultValue("") @QueryParam(SearchConstants.TENANT_ID_PARAM) String tenantId) {
StorageOSUser user = getUserFromContext();
if (StringUtils.isBlank(tenantId)) {
tenantId = user.getTenantId();
}
verifyAuthorizedInTenantOrg(uri(tenantId), user);
try {
catalogCategoryManager.restoreDefaultCatalog(uri(tenantId));
} catch (IOException e) {
log.error("Failed to reset catalog", e);
return Response.serverError().build();
}
return Response.ok().build();
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class CatalogServiceService method updateCatalogService.
/**
* Update catalog service
*
* @param param Catalog Service update parameters
* @param id the URN the catalog service
* @prereq none
* @brief Update Catalog Service
* @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 CatalogServiceRestRep updateCatalogService(@PathParam("id") URI id, CatalogServiceUpdateParam param) {
CatalogService catalogService = getCatalogServiceById(id, true);
List<CatalogServiceField> catalogServiceFields = catalogServiceManager.getCatalogServiceFields(id);
StorageOSUser user = getUserFromContext();
CatalogCategory parentCatalogCategory = catalogCategoryManager.getCatalogCategoryById(param.getCatalogCategory());
verifyAuthorizedInTenantOrg(uri(parentCatalogCategory.getTenant()), user);
validateParam(param, catalogService);
updateObject(catalogService, param, parentCatalogCategory);
List<CatalogServiceField> updatedCatalogServiceFields = updateObjectList(catalogService, catalogServiceFields, param.getCatalogServiceFields());
catalogServiceManager.updateCatalogService(catalogService, updatedCatalogServiceFields);
auditOpSuccess(OperationTypeEnum.UPDATE_CATALOG_SERVICE, catalogService.auditParameters());
// Refresh Objects
catalogService = catalogServiceManager.getCatalogServiceById(catalogService.getId());
catalogServiceFields = catalogServiceManager.getCatalogServiceFields(catalogService.getId());
ServiceDescriptor serviceDescriptor = getServiceDescriptor(catalogService);
return map(catalogService, serviceDescriptor, catalogServiceFields);
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class OrderService method getOtherSearchResults.
/**
* parameter: 'orderStatus' The status for the order
* parameter: 'startTime' Start time to search for orders
* parameter: 'endTime' End time to search for orders
*
* @return Return a list of matching orders or an empty list if no match was found.
*/
@Override
protected SearchResults getOtherSearchResults(Map<String, List<String>> parameters, boolean authorized) {
StorageOSUser user = getUserFromContext();
String tenantId = user.getTenantId();
if (parameters.containsKey(SearchConstants.TENANT_ID_PARAM)) {
tenantId = parameters.get(SearchConstants.TENANT_ID_PARAM).get(0);
}
verifyAuthorizedInTenantOrg(uri(tenantId), user);
if (!parameters.containsKey(SearchConstants.ORDER_STATUS_PARAM) && !parameters.containsKey(SearchConstants.START_TIME_PARAM) && !parameters.containsKey(SearchConstants.END_TIME_PARAM)) {
throw APIException.badRequests.invalidParameterSearchMissingParameter(getResourceClass().getName(), SearchConstants.ORDER_STATUS_PARAM + " or " + SearchConstants.START_TIME_PARAM + " or " + SearchConstants.END_TIME_PARAM);
}
if (parameters.containsKey(SearchConstants.ORDER_STATUS_PARAM) && (parameters.containsKey(SearchConstants.START_TIME_PARAM) || parameters.containsKey(SearchConstants.END_TIME_PARAM))) {
throw APIException.badRequests.parameterForSearchCouldNotBeCombinedWithAnyOtherParameter(getResourceClass().getName(), SearchConstants.ORDER_STATUS_PARAM, SearchConstants.START_TIME_PARAM + " or " + SearchConstants.END_TIME_PARAM);
}
List<Order> orders = Lists.newArrayList();
if (parameters.containsKey(SearchConstants.ORDER_STATUS_PARAM)) {
String orderStatus = parameters.get(SearchConstants.ORDER_STATUS_PARAM).get(0);
ArgValidator.checkFieldNotEmpty(orderStatus, SearchConstants.ORDER_STATUS_PARAM);
orders = orderManager.findOrdersByStatus(uri(tenantId), OrderStatus.valueOf(orderStatus));
} else if (parameters.containsKey(SearchConstants.START_TIME_PARAM) || parameters.containsKey(SearchConstants.END_TIME_PARAM)) {
Date startTime = null;
if (parameters.containsKey(SearchConstants.START_TIME_PARAM)) {
startTime = TimeUtils.getDateTimestamp(parameters.get(SearchConstants.START_TIME_PARAM).get(0));
}
Date endTime = null;
if (parameters.containsKey(SearchConstants.END_TIME_PARAM)) {
endTime = TimeUtils.getDateTimestamp(parameters.get(SearchConstants.END_TIME_PARAM).get(0));
}
if (startTime == null && endTime == null) {
throw APIException.badRequests.invalidParameterSearchMissingParameter(getResourceClass().getName(), SearchConstants.ORDER_STATUS_PARAM + " or " + SearchConstants.START_TIME_PARAM + " or " + SearchConstants.END_TIME_PARAM);
}
if (startTime.after(endTime)) {
throw APIException.badRequests.endTimeBeforeStartTime(startTime.toString(), endTime.toString());
}
int maxCount = -1;
List<String> c = parameters.get(SearchConstants.ORDER_MAX_COUNT);
if (c != null) {
String maxCountParam = parameters.get(SearchConstants.ORDER_MAX_COUNT).get(0);
maxCount = Integer.parseInt(maxCountParam);
}
orders = orderManager.findOrdersByTimeRange(uri(tenantId), startTime, endTime, maxCount);
}
ResRepFilter<SearchResultResourceRep> resRepFilter = (ResRepFilter<SearchResultResourceRep>) getPermissionFilter(getUserFromContext(), _permissionsHelper);
List<SearchResultResourceRep> searchResultResourceReps = Lists.newArrayList();
for (Order order : orders) {
RestLinkRep selfLink = new RestLinkRep("self", RestLinkFactory.newLink(getResourceType(), order.getId()));
SearchResultResourceRep searchResultResourceRep = new SearchResultResourceRep();
searchResultResourceRep.setId(order.getId());
searchResultResourceRep.setLink(selfLink);
if (authorized || resRepFilter.isAccessible(searchResultResourceRep)) {
searchResultResourceReps.add(searchResultResourceRep);
}
}
SearchResults result = new SearchResults();
result.setResource(searchResultResourceReps);
return result;
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class OrderService method getOrderExecutionState.
/**
* Gets the order execution
*
* @param orderId the URN of an order
* @brief Get Order Execution
* @return an order execution
* @throws DatabaseException when a DB error occurs
*/
@GET
@Path("/{id}/execution")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ExecutionStateRestRep getOrderExecutionState(@PathParam("id") String orderId) throws DatabaseException {
Order order = queryResource(uri(orderId));
StorageOSUser user = getUserFromContext();
verifyAuthorizedInTenantOrg(uri(order.getTenant()), user);
ExecutionState executionState = orderManager.getOrderExecutionState(order.getExecutionStateId());
return map(executionState);
}
use of com.emc.storageos.security.authentication.StorageOSUser in project coprhd-controller by CoprHD.
the class OrderService method getOrder.
@GET
@Path("/{id}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public OrderRestRep getOrder(@PathParam("id") String id) {
Order order = queryResource(uri(id));
StorageOSUser user = getUserFromContext();
verifyAuthorizedInTenantOrg(uri(order.getTenant()), user);
List<OrderParameter> orderParameters = orderManager.getOrderParameters(order.getId());
return map(order, orderParameters);
}
Aggregations