Search in sources :

Example 6 with CatalogServiceField

use of com.emc.storageos.db.client.model.uimodels.CatalogServiceField in project coprhd-controller by CoprHD.

the class CatalogServiceFieldTest method testPersistObject.

@Test
public void testPersistObject() throws Exception {
    _logger.info("Starting persist CatalogServiceField test");
    CatalogServiceField model = create("foo", "my value");
    model.setId(URIUtil.createId(CatalogServiceField.class));
    model.setOverride(true);
    save(model);
    model = findById(model.getId());
    Assert.assertNotNull(model);
    Assert.assertEquals("foo", model.getLabel());
    Assert.assertEquals("my value", model.getValue());
    Assert.assertTrue(model.getOverride());
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) BaseModelTest(com.emc.sa.model.BaseModelTest) Test(org.junit.Test)

Example 7 with CatalogServiceField

use of com.emc.storageos.db.client.model.uimodels.CatalogServiceField in project coprhd-controller by CoprHD.

the class CatalogServiceService method getCatalogService.

/**
 * Get info for catalog category
 *
 * @param id the URN of a Catalog Category
 * @prereq none
 * @brief Show catalog category
 * @return Catalog Category details
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
public CatalogServiceRestRep getCatalogService(@PathParam("id") URI id) {
    CatalogService catalogService = queryResource(id);
    ServiceDescriptor serviceDescriptor = getServiceDescriptor(catalogService);
    List<CatalogServiceField> catalogServiceFields = catalogServiceManager.getCatalogServiceFields(catalogService.getId());
    return map(catalogService, serviceDescriptor, catalogServiceFields);
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 8 with CatalogServiceField

use of com.emc.storageos.db.client.model.uimodels.CatalogServiceField 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);
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 9 with CatalogServiceField

use of com.emc.storageos.db.client.model.uimodels.CatalogServiceField in project coprhd-controller by CoprHD.

the class CatalogServiceMapper method updateObjectList.

public static List<CatalogServiceField> updateObjectList(CatalogService catalogService, List<CatalogServiceField> existingCatalogServiceFields, List<CatalogServiceFieldParam> params) {
    List<CatalogServiceField> updatedFields = Lists.newArrayList();
    Map<String, CatalogServiceField> existingFields = toMap(existingCatalogServiceFields);
    for (CatalogServiceFieldParam param : params) {
        if (existingFields.keySet().contains(param.getName())) {
            CatalogServiceField existingField = existingFields.get(param.getName());
            updateObject(existingField, param);
            updatedFields.add(existingField);
        } else {
            CatalogServiceField newField = createNewObject(catalogService, param);
            updatedFields.add(newField);
        }
    }
    return updatedFields;
}
Also used : CatalogServiceFieldParam(com.emc.vipr.model.catalog.CatalogServiceFieldParam) CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField)

Example 10 with CatalogServiceField

use of com.emc.storageos.db.client.model.uimodels.CatalogServiceField in project coprhd-controller by CoprHD.

the class CatalogServiceMapper method createNewObject.

public static CatalogServiceField createNewObject(CatalogService catalogService, CatalogServiceFieldParam param) {
    CatalogServiceField newObject = new CatalogServiceField();
    newObject.setId(URIUtil.createId(CatalogServiceField.class));
    newObject.setCatalogServiceId(new NamedURI(catalogService.getId(), catalogService.getLabel()));
    newObject.setLabel(param.getName());
    updateObject(newObject, param);
    return newObject;
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) NamedURI(com.emc.storageos.db.client.model.NamedURI)

Aggregations

CatalogServiceField (com.emc.storageos.db.client.model.uimodels.CatalogServiceField)13 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)6 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)5 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)4 NamedURI (com.emc.storageos.db.client.model.NamedURI)4 CatalogCategory (com.emc.storageos.db.client.model.uimodels.CatalogCategory)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 CatalogServiceAndFields (com.emc.storageos.db.client.model.uimodels.CatalogServiceAndFields)2 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 CatalogServiceFieldParam (com.emc.vipr.model.catalog.CatalogServiceFieldParam)2 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Consumes (javax.ws.rs.Consumes)2 BaseModelTest (com.emc.sa.model.BaseModelTest)1 CatalogServiceBulkRep (com.emc.vipr.model.catalog.CatalogServiceBulkRep)1 CatalogServiceFieldRestRep (com.emc.vipr.model.catalog.CatalogServiceFieldRestRep)1 Map (java.util.Map)1