if (configuration != null
&& type != null
&& !type.equals(PortalManagerImpl.BUILDTYPE_VALUE_ID)) {
String storePrefix = (String)configuration.get(PortalConstants.CONF_PROFILE_CACHE);
if (storePrefix != null) {
Store store = this.getProfileStore();
Enumeration keys = store.keys();
String currentKey;
String deleteGlobal = null;
String deleteRole = null;
String deleteUser = null;
if (type.equals(PortalManagerImpl.BUILDTYPE_VALUE_BASIC) ||
type.equals(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL)) {
if (type.equals(PortalManagerImpl.BUILDTYPE_VALUE_BASIC)) {
deleteGlobal = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL, null, null, false).substring(1);
}
deleteRole = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL, null, null, false);
deleteRole = deleteRole.substring(1, deleteRole.lastIndexOf(':')+1) + PortalManagerImpl.BUILDTYPE_VALUE_ROLE;
deleteUser = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL, null, null, false);
deleteUser = deleteUser.substring(1, deleteUser.lastIndexOf(':')+1) + PortalManagerImpl.BUILDTYPE_VALUE_ID;
} else { // role
deleteGlobal = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_ROLE, role, null, false).substring(1);
deleteUser = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_ID, role, "a", false);
deleteUser = deleteUser.substring(1, deleteUser.length()-1);
}
while (keys.hasMoreElements()) {
Object k = keys.nextElement();
if ( k instanceof String ) {
currentKey = (String)k;
if (deleteGlobal != null && currentKey.equals(deleteGlobal)) {
store.remove(currentKey);
} else if (deleteRole != null && currentKey.startsWith(deleteRole)) {
store.remove(currentKey);
} else if (deleteUser != null && currentKey.startsWith(deleteUser)) {
store.remove(currentKey);
}
}
}
}
} else if (configuration != null && type == null) {
// clean whole cache
String storePrefix = (String)configuration.get(PortalConstants.CONF_PROFILE_CACHE);
if (storePrefix != null) {
Store store = this.getProfileStore();
Enumeration keys = store.keys();
String currentKey;
String delete;
delete = this.getProfileID(PortalManagerImpl.BUILDTYPE_VALUE_GLOBAL, null, null, false);
delete = delete.substring(1, delete.lastIndexOf(':') + 1);
while (keys.hasMoreElements()) {
Object k = keys.nextElement();
if ( k instanceof String ) {
currentKey = (String)k;
if (currentKey.startsWith(delete)) {
store.remove(currentKey);
}
}
}
}
}