* throws when fails or registry error occurs
*/
public void importPolicyFromRegistry(String policyRegistryPath) throws IdentityException {
Registry registry;
PolicyDTO policyDTO = new PolicyDTO();
String policy = "";
BufferedReader bufferedReader = null;
InputStream inputStream = null;
// Finding from which registry by comparing prefix of resource path
String resourceUri = policyRegistryPath.substring(policyRegistryPath.lastIndexOf(':') + 1);
String registryIdentifier = policyRegistryPath.substring(0,
policyRegistryPath.lastIndexOf(':'));
if (IdentityRegistryResources.CONFIG_REGISTRY_IDENTIFIER.equals(registryIdentifier)) {
registry = getConfigSystemRegistry();
} else {
registry = getGovernanceUserRegistry();
}
try {
Resource resource = registry.get(resourceUri);
inputStream = resource.getContentStream();
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String stringLine;
StringBuffer buffer = new StringBuffer(policy);
while ((stringLine = bufferedReader.readLine()) != null) {
buffer.append(stringLine);
}
policy = buffer.toString();
policyDTO.setPolicy(policy.replaceAll(">\\s+<", "><"));
addPolicy(policyDTO);
} catch (RegistryException e) {
throw new IdentityException("Registry Error occurs while reading policy from registry");
} catch (IOException e) {
throw new IdentityException("I/O Error occurs while reading policy from registry");