String viewpointIds;
String[] ids;
IViewpointDAO viewpointDAO;
Viewpoint viewpoint;
logger.debug("IN");
try {
viewpointIds = this.getAttributeAsString(VIEWPOINT_IDS);
logger.debug("Parameter [" + VIEWPOINT_IDS + "] is equals to [" + viewpointIds + "]");
Assert.assertTrue(!StringUtilities.isEmpty(viewpointIds), "Viewpoint's ids cannot be null or empty");
ids = viewpointIds.split(",");
executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
Assert.assertNotNull(executionInstance, "Execution instance cannot be null");
userProfile = this.getUserProfile();
Assert.assertNotNull(userProfile, "Impossible to retrive user profile");
biobjectId = executionInstance.getBIObject().getId();
Assert.assertNotNull(executionInstance, "Impossible to retrive analytical document id");
logger.debug("User: [" + userProfile.getUserUniqueIdentifier() + "]");
logger.debug("Document Id: [" + biobjectId + "]");
/*
Assert.assertTrue(userProfile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN),
"User [" + userProfile.getUserUniqueIdentifier()+ "] have not the rights to delete viewpoints");
*/
for(int i = 0; i < ids.length; i++) {
try {
viewpointDAO = DAOFactory.getViewpointDAO();
viewpoint = viewpointDAO.loadViewpointByNameAndBIObjectId( ids[i] , biobjectId);
Assert.assertNotNull(viewpoint, "Viewpoint [" + ids[i] + "] does not exist on the database");
viewpointDAO.eraseViewpoint( viewpoint.getVpId() );
logger.error("Viewpoint [" + ids[i] + "] succesfully deleted");
} catch (EMFUserError e) {
logger.error("Impossible to delete viewpoint with name [" + ids[i] + "] already exists", e);
throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to delete viewpoint with name [" + ids[i] + "] already exists", e);