use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.
the class ConfigService method getResetProps.
/**
* Get reset properties based on properties specified in request,
* current target property and metadata
* This method iterates the target property set.
* If a property is also in metadata
* either it is contained keysToReset if not null or keysToReset is null (meaning,
* reset all)
* compare its value with default, if different, put it in resetProps
*
* @param keysToReset property set to delete in request
* @param targetProps target properties
* @param metadata metadata
* @return reset property set with value set as defaults
*/
private PropertyInfoRestRep getResetProps(final PropertyList keysToReset, final Map<String, String> targetProps, final Map<String, PropertyMetadata> metadata) {
// validate if properties exist in metadata
if (keysToReset != null && keysToReset.getPropertyList() != null) {
for (String key : keysToReset.getPropertyList()) {
if (!targetProps.containsKey(key) || !metadata.containsKey(key)) {
throw APIException.badRequests.propertyIsNotValid(key);
}
}
}
PropertyInfoRestRep resetProps = new PropertyInfoRestRep();
for (Map.Entry<String, String> entry : targetProps.entrySet()) {
final String key = entry.getKey();
final String value = entry.getValue();
if (metadata.containsKey(key)) {
// property exist both in target and metadata
if (keysToReset == null || keysToReset.getPropertyList() == null || keysToReset.getPropertyList().contains(key)) {
// property also shows in request list and current value is not equal to default
final String defaultValue = metadata.get(key).getDefaultValue();
if (defaultValue != null && !value.equals(defaultValue)) {
// property has a default value and current value is not equal to default,
// reset it to default
resetProps.addProperty(key, defaultValue);
}
}
}
}
// validate the changed property against it's metadata to ensure property
// integrity.
validateAndUpdateProperties(resetProps.getAllProperties(), true);
return resetProps;
}
use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.
the class ConfigService method configureConnectEmcFtpsParams.
/**
* Configure ConnectEMC FTPS transport related properties
*
* @brief Configure ConnectEMC FTPS properties
* @prereq Cluster state should be STABLE
* @return ConnectEMC FTPS related properties
*/
@POST
@Path("connectemc/ftps/")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response configureConnectEmcFtpsParams(ConnectEmcFtps ftpsParams) throws Exception {
PropertyInfoUpdate ext = ConfigService.ConfigureConnectEmc.configureFtps(ftpsParams);
PropertyInfoRestRep targetPropInfo = getTargetPropsCommon();
PropertyInfoRestRep updateProps = getUpdateProps(ext, targetPropInfo.getAllProperties());
return updatePropertiesCommon(updateProps, null);
}
use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.
the class ConfigService method incrementCertificateVersion.
/**
* Update system configuration properties
*
* @brief Update system properties
* @prereq Cluster state should be STABLE
* @return Cluster information
*/
@PUT
@Path("internal/certificate-version")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response incrementCertificateVersion() throws Exception {
PropertyInfoRestRep targetPropInfo = getTargetPropsCommon();
String versionStr = targetPropInfo.getProperty(CERTIFICATE_VERSION);
Integer version = new Integer(versionStr);
PropertyInfoUpdate setProperty = new PropertyInfoUpdate();
setProperty.addProperty(CERTIFICATE_VERSION, (++version).toString());
_log.info("setProperties(): {}", setProperty);
PropertyInfoRestRep updateProps = getUpdateProps(setProperty, targetPropInfo.getAllProperties());
return updatePropertiesCommon(updateProps, null);
}
use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.
the class ConfigService method getVisiblePropertiesISOCommon.
// Keep this library for now.
private Response getVisiblePropertiesISOCommon() throws Exception {
_log.info("getVisiblePropertiesISO(): going to fetch ISO information");
PropertyInfoRestRep propertyInfo = new PropertyInfoRestRep(getTargetPropsCommon().getProperties());
if (propertyInfo.getAllProperties() == null || propertyInfo.getAllProperties().size() == 0) {
_log.error("getVisiblePropertiesISO(): No properties found");
throw APIException.internalServerErrors.targetIsNullOrEmpty("Properties");
}
InputStream isoStream = new ByteArrayInputStream(CreateISO.getBytes(getPropertiesOvf(), getMutatedProps()));
return Response.ok(isoStream).header("content-disposition", "attachment; filename = config.iso").build();
}
use of com.emc.storageos.model.property.PropertyInfoRestRep in project coprhd-controller by CoprHD.
the class ConfigService method configureConnectEmcEmailParams.
/**
* Configure ConnectEMC SMTP/Email transport related properties
*
* @brief Configure ConnectEMC SMTP/Email properties
* @prereq Cluster state should be STABLE
* @return Properties related to ConnectEMC Email
*/
@POST
@Path("connectemc/email/")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response configureConnectEmcEmailParams(ConnectEmcEmail emailParams) throws Exception {
PropertyInfoRestRep targetPropInfo = getTargetPropsCommon();
PropertyInfoUpdate ext = ConfigService.ConfigureConnectEmc.configureEmail(emailParams);
PropertyInfoRestRep updateProps = getUpdateProps(ext, targetPropInfo.getAllProperties());
return updatePropertiesCommon(updateProps, null);
}
Aggregations