Search in sources :

Example 1 with RelatedConfigTypeRep

use of com.emc.storageos.model.customconfig.RelatedConfigTypeRep in project coprhd-controller by CoprHD.

the class CustomConfigService method getCustomConfigTypes.

/**
 * List config types.
 *
 * @brief List of config types
 * @return The list of config types.
 */
@GET
@Path("/types")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public CustomConfigTypeList getCustomConfigTypes() {
    List<CustomConfigType> items = customConfigHandler.getCustomConfigTypes();
    List<RelatedConfigTypeRep> types = new ArrayList<RelatedConfigTypeRep>();
    for (CustomConfigType item : items) {
        RelatedConfigTypeRep type = new RelatedConfigTypeRep();
        // build config type Link
        String service = ResourceTypeEnum.CONFIG_TYPE.getService();
        StringBuilder build = (new StringBuilder(service)).append('/').append(item.getName());
        type.setConfigName(item.getName());
        try {
            type.setSelfLink(new RestLinkRep("self", new URI(build.toString())));
        } catch (URISyntaxException e) {
        // it should not happen
        }
        types.add(type);
    }
    return new CustomConfigTypeList(types);
}
Also used : CustomConfigType(com.emc.storageos.customconfigcontroller.CustomConfigType) RelatedConfigTypeRep(com.emc.storageos.model.customconfig.RelatedConfigTypeRep) ArrayList(java.util.ArrayList) RestLinkRep(com.emc.storageos.model.RestLinkRep) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) CustomConfigTypeList(com.emc.storageos.model.customconfig.CustomConfigTypeList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with RelatedConfigTypeRep

use of com.emc.storageos.model.customconfig.RelatedConfigTypeRep in project coprhd-controller by CoprHD.

the class DbObjectMapper method map.

public static CustomConfigRestRep map(CustomConfig from) {
    if (from == null) {
        return null;
    }
    CustomConfigRestRep to = new CustomConfigRestRep();
    to.setLink(new RestLinkRep("self", RestLinkFactory.newLink(from)));
    // build the config type Link
    String service = ResourceTypeEnum.CONFIG_TYPE.getService();
    StringBuilder build = (new StringBuilder(service)).append('/').append(from.getConfigType());
    try {
        RelatedConfigTypeRep type = new RelatedConfigTypeRep();
        type.setConfigName(from.getConfigType());
        type.setSelfLink(new RestLinkRep("self", new URI(build.toString())));
        to.setConfigType(type);
    } catch (URISyntaxException e) {
    // it should not happen
    }
    to.setId(from.getId());
    to.setName(from.getLabel());
    StringMap scopeMap = from.getScope();
    ScopeParam scopeParm = new ScopeParam();
    for (Map.Entry<String, String> entry : scopeMap.entrySet()) {
        scopeParm.setType(entry.getKey());
        scopeParm.setValue(entry.getValue());
    }
    to.setScope(scopeParm);
    to.setValue(from.getValue());
    to.setRegistered(from.getRegistered());
    to.setSystemDefault(from.getSystemDefault());
    return to;
}
Also used : RelatedConfigTypeRep(com.emc.storageos.model.customconfig.RelatedConfigTypeRep) StringMap(com.emc.storageos.db.client.model.StringMap) CustomConfigRestRep(com.emc.storageos.model.customconfig.CustomConfigRestRep) RestLinkRep(com.emc.storageos.model.RestLinkRep) ScopeParam(com.emc.storageos.model.customconfig.ScopeParam) URISyntaxException(java.net.URISyntaxException) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Map(java.util.Map) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 3 with RelatedConfigTypeRep

use of com.emc.storageos.model.customconfig.RelatedConfigTypeRep in project coprhd-controller by CoprHD.

the class CustomConfigs method getCustomConfigTypes.

public List<CustomConfigTypeRep> getCustomConfigTypes() {
    CustomConfigTypeList list = client.get(CustomConfigTypeList.class, PathConstants.CUSTOM_CONFIG_TYPE_URL);
    List<CustomConfigTypeRep> configTypes = new ArrayList<>();
    for (RelatedConfigTypeRep configTypeRep : list.getConfigTypes()) {
        CustomConfigTypeRep template = getCustomConfigType(configTypeRep.getConfigName());
        configTypes.add(template);
    }
    return configTypes;
}
Also used : CustomConfigTypeRep(com.emc.storageos.model.customconfig.CustomConfigTypeRep) RelatedConfigTypeRep(com.emc.storageos.model.customconfig.RelatedConfigTypeRep) ArrayList(java.util.ArrayList) CustomConfigTypeList(com.emc.storageos.model.customconfig.CustomConfigTypeList)

Aggregations

RelatedConfigTypeRep (com.emc.storageos.model.customconfig.RelatedConfigTypeRep)3 RestLinkRep (com.emc.storageos.model.RestLinkRep)2 CustomConfigTypeList (com.emc.storageos.model.customconfig.CustomConfigTypeList)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 CustomConfigType (com.emc.storageos.customconfigcontroller.CustomConfigType)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 CustomConfigRestRep (com.emc.storageos.model.customconfig.CustomConfigRestRep)1 CustomConfigTypeRep (com.emc.storageos.model.customconfig.CustomConfigTypeRep)1 ScopeParam (com.emc.storageos.model.customconfig.ScopeParam)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 Map (java.util.Map)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1