use of org.apache.directory.fortress.core.model.Props in project directory-fortress-core by apache.
the class ConfigMgrRestImpl method add.
/**
* {@inheritDoc}
*/
@Override
public Properties add(String name, Properties inProperties) throws SecurityException {
VUtil.assertNotNull(name, GlobalErrIds.FT_CONFIG_NAME_NULL, CLS_NM + ".add");
VUtil.assertNotNull(inProperties, GlobalErrIds.FT_CONFIG_PROPS_NULL, CLS_NM + ".add");
Properties retProperties;
FortRequest request = new FortRequest();
Props inProps = RestUtils.getProps(inProperties);
request.setEntity(inProps);
request.setValue(name);
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.CFG_ADD);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
Props outProps = (Props) response.getEntity();
retProperties = RestUtils.getProperties(outProps);
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retProperties;
}
use of org.apache.directory.fortress.core.model.Props in project directory-fortress-core by apache.
the class ConfigMgrRestImpl method read.
/**
* {@inheritDoc}
*/
@Override
public Properties read(String name) throws SecurityException {
VUtil.assertNotNull(name, GlobalErrIds.FT_CONFIG_NAME_NULL, CLS_NM + ".readRole");
Properties retProps;
FortRequest request = new FortRequest();
request.setValue(name);
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.CFG_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
Props props;
if (response.getErrorCode() == 0) {
props = (Props) response.getEntity();
retProps = RestUtils.getProperties(props);
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retProps;
}
use of org.apache.directory.fortress.core.model.Props in project directory-fortress-core by apache.
the class RestUtils method getProps.
/**
* @param properties
* @return Prop contains name value pairs.
*/
public static Props getProps(Properties properties) {
Props props = null;
if (properties != null) {
props = new ObjectFactory().createProps();
for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
String val = properties.getProperty(key);
Props.Entry entry = new Props.Entry();
entry.setKey(key);
entry.setValue(val);
props.getEntry().add(entry);
}
}
return props;
}
use of org.apache.directory.fortress.core.model.Props in project directory-fortress-core by apache.
the class RestUtils method getProperties.
/**
* @param inProps
* @return Properties
*/
public static Properties getProperties(Props inProps) {
Properties properties = null;
List<Props.Entry> props = inProps.getEntry();
if (props.size() > 0) {
properties = new Properties();
// int size = props.size();
for (Props.Entry entry : props) {
String key = entry.getKey();
String val = entry.getValue();
properties.setProperty(key, val);
}
}
return properties;
}
use of org.apache.directory.fortress.core.model.Props in project directory-fortress-core by apache.
the class ConfigMgrRestImpl method update.
/**
* {@inheritDoc}
*/
@Override
public Properties update(String name, Properties inProperties) throws SecurityException {
VUtil.assertNotNull(name, GlobalErrIds.FT_CONFIG_NAME_NULL, CLS_NM + ".update");
VUtil.assertNotNull(inProperties, GlobalErrIds.FT_CONFIG_PROPS_NULL, CLS_NM + ".update");
Properties retProperties;
FortRequest request = new FortRequest();
Props inProps = RestUtils.getProps(inProperties);
request.setEntity(inProps);
request.setValue(name);
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.CFG_UPDATE);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
Props outProps = (Props) response.getEntity();
retProperties = RestUtils.getProperties(outProps);
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retProperties;
}
Aggregations