try {
// retrieving execution instance from session, no need to check if user is able to execute the current document
ExecutionInstance executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
BIObject obj = executionInstance.getBIObject();
UserProfile userProfile = (UserProfile) this.getUserProfile();
ISubObjectDAO dao = null;
try {
dao = DAOFactory.getSubObjectDAO();
} catch (EMFUserError e) {
logger.error("Error while istantiating DAO", e);
throw new SpagoBIServiceException(SERVICE_NAME, "Cannot access database", e);
}
String ids = this.getAttributeAsString(SUBOBJECT_ID);
// ids contains the id of the subobjects to be deleted separated by ,
String[] idArray = ids.split(",");
for (int i = 0; i < idArray.length; i++) {
Integer id = new Integer(idArray[i]);
SubObject subObject = null;
try {
subObject = dao.getSubObject(id);
} catch (EMFUserError e) {
logger.error("SubObject with id = " + id + " not found", e);
throw new SpagoBIServiceException(SERVICE_NAME, "Customized view not found", e);
}
if (subObject.getBiobjId().equals(obj.getId())) {
boolean canDeleteSubObject = false;
if (userProfile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)
|| subObject.getOwner().equals(userProfile.getUserId().toString())) {
canDeleteSubObject = true;
}
if (canDeleteSubObject) {
logger.info("User [id: " + userProfile.getUserUniqueIdentifier() + ", userId: " + userProfile.getUserId() + ", name: " + userProfile.getUserName() + "] " +
"is deleting customized view [id: " + subObject.getId() + ", name: " + subObject.getName() + "] ...");
try {
dao.deleteSubObject(id);
} catch (EMFUserError e) {
throw new SpagoBIServiceException(SERVICE_NAME, "Error while deleting customized view", e);
}
logger.debug("Customized view [id: " + subObject.getId() + ", name: " + subObject.getName() + "] deleted.");
} else {