com.jamonapi.Monitor Java Examples

The following examples show how to use com.jamonapi.Monitor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractAllocationAlgorithm.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public void persist(SpagoBICellWrapper cell, Object oldValue, Object newValue, Connection connection, Integer version) throws Exception {

		Monitor totalTimeMonitor = null;
		Monitor errorHitsMonitor = null;

		logger.debug("IN");
		try {
			totalTimeMonitor = MonitorFactory.start(getMonitorName() + ".persist.totalTime");
			this.persistInternal(cell, oldValue, newValue, connection, version);
		} catch (Exception e) {
			errorHitsMonitor = MonitorFactory.start(getMonitorName() + ".persist.errorHits");
			errorHitsMonitor.stop();
			throw e;
		} finally {
			if (totalTimeMonitor != null) {
				totalTimeMonitor.stop();
			}
			logger.debug("OUT");
		}

	}
 
Example #2
Source File: ObjectsAccessVerifier.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Control if the user can develop the document specified by the input id
 *
 * @param documentId
 *            The id of the document
 * @param profile
 *            The user profile
 * @return A boolean control value
 */
public static boolean canDevBIObject(Integer biObjectID, IEngUserProfile profile) {
	Monitor monitor = MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canDevBIObject(Integer biObjectID, IEngUserProfile profile)");
	boolean toReturn = false;
	try {
		logger.debug("IN: obj id = [" + biObjectID + "]; user id = [" + ((UserProfile) profile).getUserId() + "]");
		// if user is administrator, he can develop, no need to make any query to database
		if (profile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)) {
			logger.debug("User [" + ((UserProfile) profile).getUserId() + "] is administrator. He can develop every document");
			monitor.stop();
			return true;
		}
		BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectById(biObjectID);
		toReturn = canDevBIObject(obj, profile);
	} catch (Exception e) {
		logger.error(e);
		monitor.stop();
		return false;
	}
	logger.debug("OUT: returning " + toReturn);
	monitor.stop();
	return toReturn;
}
 
Example #3
Source File: ObjectsAccessVerifier.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Control if the current user can execute new object into the functionality identified by its id.
 *
 * @param folderId
 *            The id of the lowFunctionality
 * @param profile
 *            user profile
 * @return A boolean control value
 */
public static boolean canExec(Integer folderId, IEngUserProfile profile) {
	Monitor monitor = MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canExec");
	logger.debug("IN");
	LowFunctionality folder = null;
	try {
		folder = DAOFactory.getLowFunctionalityDAO().loadLowFunctionalityByID(folderId, false);
	} catch (Exception e) {
		logger.error("Exception in loadLowFunctionalityByID", e);

		return false;
	} finally {
		monitor.stop();
		logger.debug("OUT");
	}
	return canExecInternal(folder, profile);
}
 
Example #4
Source File: SchedulerServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Gets the job schedulation definition.
 * 
 * @param token
 *            the token
 * @param user
 *            the user
 * @param triggerName
 *            the trigger name
 * @param triggerGroup
 *            the trigger group
 * 
 * @return the job schedulation definition
 */
public String getJobSchedulationDefinition(String token, String user,
		String triggerName, String triggerGroup) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.scheduler.getJobSchedulationDefinition");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		return supplier.getJobSchedulationDefinition(triggerName,
				triggerGroup);
	} catch (SecurityException e) {
		logger.error("SecurityException", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}

}
 
Example #5
Source File: SchedulerServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Schedule job.
 * 
 * @param token
 *            the token
 * @param user
 *            the user
 * @param xmlRequest
 *            the xml request
 * 
 * @return the string
 */
public String scheduleJob(String token, String user, String xmlRequest) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.scheduler.scheduleJob");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		return supplier.scheduleJob(xmlRequest);
	} catch (SecurityException e) {
		logger.error("SecurityException", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}

}
 
Example #6
Source File: SchedulerServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Gets the job definition.
 * 
 * @param token
 *            the token
 * @param user
 *            the user
 * @param jobName
 *            the job name
 * @param jobGroup
 *            the job group
 * 
 * @return the job definition
 */
public String getJobDefinition(String token, String user, String jobName,
		String jobGroup) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.scheduler.getJobDefinition");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		return supplier.getJobDefinition(jobName, jobGroup);
	} catch (SecurityException e) {
		logger.error("SecurityException", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}

}
 
Example #7
Source File: ContentServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Read sub object content.
 * 
 * @param token
 *            the token
 * @param user
 *            the user
 * @param subObjectId
 *            the sub object id
 * 
 * @return the content
 */
public Content readSubObjectContent(String token, String user,
		String subObjectId) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.content.readSubObjectContent");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		return readSubObjectContent(user, subObjectId);
	} catch (SecurityException e) {
		logger.error("SecurityException", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}

}
 
Example #8
Source File: ObjectsAccessVerifier.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Control if the current user can test new object into the functionality identified by its id.
 *
 * @param folderId
 *            The id of the lowFunctionality
 * @param profile
 *            user profile
 * @return A boolean control value
 */
public static boolean canTest(Integer folderId, IEngUserProfile profile) {
	Monitor monitor = MonitorFactory.start("spagobi.core.ObjectAccessVerifier.canTest");
	logger.debug("IN");
	LowFunctionality folder = null;
	try {
		folder = DAOFactory.getLowFunctionalityDAO().loadLowFunctionalityByID(folderId, false);
	} catch (Exception e) {
		logger.error("Exception in loadLowFunctionalityByID", e);

		return false;
	} finally {
		monitor.stop();
		logger.debug("OUT");
	}
	return canTestInternal(folder, profile);
}
 
Example #9
Source File: ContentServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Read template by label.
 * 
 * @param token
 *            the token
 * @param user
 *            the user
 * @param document
 *            the document
 * 
 * @return the content
 */
public Content readTemplateByLabel(String token, String user, String label,
		HashMap attributes) {

	Monitor monitor = MonitorFactory
			.start("spagobi.service.content.readTemplate");
	logger.debug("IN");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		ContentServiceImplSupplier c = new ContentServiceImplSupplier();
		return c.readTemplateByLabel(user, label, attributes);
	} catch (Exception e) {
		logger.error("Exception", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}
}
 
Example #10
Source File: JDBCDataProxy.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public ResultSet getData(IDataReader dataReader, Object... resources) {
	logger.debug("IN");
	Statement stmt = (Statement) resources[0];
	ResultSet resultSet = null;
	try {
		if (getMaxResults() > 0) {
			stmt.setMaxRows(getMaxResults());
		}
		String sqlQuery = getStatement();
		LogMF.info(logger, "Executing query:\n{0}", sqlQuery);
		Monitor timeToExecuteStatement = MonitorFactory.start("Knowage.JDBCDataProxy.executeStatement:" + sqlQuery);
		try {
			resultSet = stmt.executeQuery(sqlQuery);
		} finally {
			timeToExecuteStatement.stop();
		}
		LogMF.debug(logger, "Executed query:\n{0}", sqlQuery);
		return resultSet;
	} catch (SQLException e) {
		throw new SpagoBIRuntimeException(e);
	} finally {
		logger.debug("OUT");
	}
}
 
Example #11
Source File: PublishImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
    * Publish template.
    * 
    * @param token the token
    * @param user the user
    * @param attributes the attributes
    * 
    * @return the string
    */
   public String publishTemplate(String token, String user, HashMap attributes) {
// TODO IMPLEMENTARE I CONTROLLI
PublishImpl helper = new PublishImpl();
logger.debug("IN");
Monitor monitor =MonitorFactory.start("spagobi.service.content.publishTemplate");
try {
    validateTicket(token, user);
    this.setTenantByUserId(user);
    return helper.publishTemplate(user, attributes);
} catch (SecurityException e) {
    logger.error("SecurityException", e);
    return null;
} finally {
	this.unsetTenant();
    monitor.stop();
    logger.debug("OUT");
}

   }
 
Example #12
Source File: MapCatalogueImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
    * Map catalogue.
    * 
    * @param token the token
    * @param user the user
    * @param operation the operation
    * @param path the path
    * @param featureName the feature name
    * @param mapName the map name
    * 
    * @return the string
    */
   public String mapCatalogue(String token, String user, String operation,String path,String featureName,String mapName) {

logger.debug("IN");
Monitor monitor =MonitorFactory.start("spagobi.service.content.mapCatalogue");
try {
    validateTicket(token, user);
    this.setTenantByUserId(user);
    return mapCatalogue(user, operation, path, featureName, mapName);
} catch (SecurityException e) {
    logger.error("SecurityException", e);
    return null;
} finally {
	this.unsetTenant();
    monitor.stop();
    logger.debug("OUT");
}	

   }
 
Example #13
Source File: AbstractSvgViewerEngineResource.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public EngineStartServletIOManager getIOManager() {
	Monitor getIOManagerMonitor = MonitorFactory.start("GeoEngine.AbstractSvgViewerEngineResource.getIOManager");

	EngineStartServletIOManager ioManager = null;

	try {
		ioManager = new EngineStartServletIOManager(request, response);
		UserProfile userProfile = (UserProfile) ioManager.getParameterFromSession(IEngUserProfile.ENG_USER_PROFILE);
		if (userProfile == null) {
			String userId = request.getHeader("user");
			userProfile = (UserProfile) UserUtilities.getUserProfile(userId);
			ioManager.setUserProfile(userProfile);
		}
	} catch (Exception e) {
		throw new RuntimeException("An unexpected error occured while inizializing ioManager", e);
	}
	getIOManagerMonitor.stop();

	return ioManager;
}
 
Example #14
Source File: AuditServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
    * Log.
    * 
    * @param token String
    * @param user String
    * @param id String
    * @param start String
    * @param end String
    * @param state String
    * @param message String
    * @param errorCode String
    * 
    * @return String
    */
   public String log(String token,String user,String id,String start,String end,String state,String message,String errorCode){
logger.debug("IN");
Monitor monitor =MonitorFactory.start("spagobi.service.audit.log");
try {
    validateTicket(token, user);
    return log( user, id, start, end, state, message, errorCode);
} catch (SecurityException e) {
    logger.error("SecurityException", e);
    return null;
} finally {
    monitor.stop();
    logger.debug("OUT");
}	

   }
 
Example #15
Source File: AbstractAllocationAlgorithm.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public void apply(SpagoBICellWrapper cell, Object oldValue,
		Object newValue, SpagoBICellSetWrapper cellSetWrapper) {

	Monitor totalTimeMonitor = null;
	Monitor errorHitsMonitor = null;

	logger.debug("IN");
	try {
		totalTimeMonitor = MonitorFactory.start(getMonitorName() + ".apply.totalTime");
		this.applyInternal(cell, oldValue, newValue, cellSetWrapper);
	} catch (Exception e) {
		errorHitsMonitor = MonitorFactory.start(getMonitorName() + ".apply.errorHits");
		errorHitsMonitor.stop();
		logger.error("Error while applying transformation", e);
		throw new SpagoBIRuntimeException("Error while applying transformation", e);
	} finally {
		if (totalTimeMonitor != null) {
			totalTimeMonitor.stop();
		}
		logger.debug("OUT");
	}

}
 
Example #16
Source File: ContentServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Read template.
 * 
 * @param token
 *            the token
 * @param user
 *            the user
 * @param document
 *            the document
 * 
 * @return the content
 */
public Content readTemplate(String token, String user, String document,
		HashMap attributes) {

	Monitor monitor = MonitorFactory
			.start("spagobi.service.content.readTemplate");
	logger.debug("IN");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		ContentServiceImplSupplier c = new ContentServiceImplSupplier();
		return c.readTemplate(user, document, attributes);
	} catch (Exception e) {
		logger.error("Exception", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}
}
 
Example #17
Source File: MetamodelServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Returns the last modification date of the metamodel specified
 * 
 * @param token The token.
 * @param user The user.
 * @param name  The metamodel's name.
 * 
 * @return the last modification date of the metamodel specified
 */
public long getMetamodelContentLastModified(String token, String user, String name) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.metamodel.getMetamodelContentByName");
	try {
		long lastModified = -1;
		validateTicket(token, user);
		this.setTenantByUserId(user);
		MetamodelServiceImplSupplier supplier = new MetamodelServiceImplSupplier();			
		lastModified = supplier.getMetamodelContentLastModified(name);
		return lastModified;
	} catch (Exception e) {
		logger.error("Exception", e);
		return -1;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}				
}
 
Example #18
Source File: DefaultScrollableDataResult.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public SourceBean getSourceBean() throws EMFInternalError {
	Monitor monitor = MonitorFactory.start("model.data-access.default-scrollable-data-result.get-source-bean");
	try {
		int currentPosition = _rs.getRow();
		moveTo(1);
		SourceBean rowsSourceBean = new SourceBean(ScrollableDataResult.ROWS_TAG);
		DataRow dr = null;
		SourceBean dataRowSourceBean = null;
		int rowsNumber = this.getRowsNumber();
		for (int i = 1; i <= rowsNumber; i++) {
			dr = getDataRow(i);
			dataRowSourceBean = dr.getSourceBean();
			rowsSourceBean.setAttribute(dataRowSourceBean);
		} // for (int i = 1; i <= rowsNumber; i++)
		moveTo(currentPosition);
		return rowsSourceBean;
	} // try
	catch (Exception ex) {
		throw Utils.generateInternalError(ex, "DefaultScrollableDataResult::getSourceBean: ");
	} // catch (SourceBeanException sbe)
	finally {
		monitor.stop();
	} // finally
}
 
Example #19
Source File: MetamodelServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
* return the metamodel by the id
* @param token. The token.
* @param user. The user.
* @param id. The metamodel's name.
* @return the content of the metamodel.
*/
  public DataHandler getMetamodelContentByName(String token, String user, String name){
logger.debug("IN");
Monitor monitor = MonitorFactory
		.start("spagobi.service.metamodel.getMetamodelContentByName");
try {
	DataHandler dataHandler = null;
	validateTicket(token, user);
	this.setTenantByUserId(user);
	MetamodelServiceImplSupplier supplier = new MetamodelServiceImplSupplier();			
	dataHandler = supplier.getMetamodelContentByName(name);
	return dataHandler;
} catch (Exception e) {
	logger.error("Exception", e);
	return null;
} finally {
	this.unsetTenant();
	monitor.stop();
	logger.debug("OUT");
}				
  }
 
Example #20
Source File: CachedEvaluationStrategy.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected IDataStore execute(List<AbstractSelectionField> projections, Filter filter, List<AbstractSelectionField> groups, List<Sorting> sortings,
		List<List<AbstractSelectionField>> summaryRowProjections, int offset, int fetchSize, int maxRowCount, Set<String> indexes) {
	Monitor totalCacheTiming = MonitorFactory.start("Knowage.DatasetManagementAPI.getDataStore:totalCache");
	IDataStore dataStore;
	try {
		dataStore = cache.get(profile, dataSet, projections, filter, groups, sortings, summaryRowProjections, offset, fetchSize, maxRowCount, indexes);
		if (dataSet.isRealtime())
			unsetNgsiConsumer();

		if (dataStore == null) {
			dataStore = manageDatasetNotInCache(projections, filter, groups, sortings, summaryRowProjections, offset, fetchSize, maxRowCount, indexes);
		} else {
			if (dataSet.isRealtime())
				subscribeNGSI();
		}

		dataStore.adjustMetadata(dataSet.getMetadata());
		dataSet.decode(dataStore);
	} catch (DataBaseException e) {
		throw new RuntimeException(e);
	} finally {
		totalCacheTiming.stop();
	}
	return dataStore;
}
 
Example #21
Source File: DataSourceServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Gets the all data source.
 *
 * @param token
 *            String
 * @param user
 *            String
 *
 * @return SpagoBiDataSource[]
 */
@Override
public SpagoBiDataSource[] getAllDataSource(String token, String user) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.datasource.getAllDataSource");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		return supplier.getAllDataSource();
	} catch (Exception e) {
		logger.error("Error while getting all datasources", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}

}
 
Example #22
Source File: SbiDocumentServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public SpagobiAnalyticalDriver[] getDocumentAnalyticalDrivers(String token, String user, Integer id, String language, String country){
	logger.debug("IN");
	Monitor monitor = MonitorFactory.start("spagobi.service.sbidocument.getDocumentParameters");
	try {
	    validateTicket(token, user);
	    this.setTenantByUserId(user);
	    return supplier.getDocumentAnalyticalDrivers(id, language, country);
	} catch (SecurityException e) {
	    logger.error("SecurityException", e);
	    return null;
	} finally {
		this.unsetTenant();
	    monitor.stop();
	    logger.debug("OUT");
	}	
}
 
Example #23
Source File: SbiDocumentServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public String getDocumentAnalyticalDriversJSON(String token, String user, Integer id, String language, String country){
	logger.debug("IN");
	Monitor monitor = MonitorFactory.start("spagobi.service.sbidocument.getDocumentParametersJSON");
	try {
	    validateTicket(token, user);
	    this.setTenantByUserId(user);
	    return supplier.getDocumentAnalyticalDriversJSON(id, language, country);
	} catch (SecurityException e) {
	    logger.error("SecurityException", e);
	    return null;
	} finally {
		this.unsetTenant();
	    monitor.stop();
	    logger.debug("OUT");
	}	
}
 
Example #24
Source File: DataSetServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public SpagoBiDataSet getDataSet(String token, String user, String documentId) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory.start("spagobi.service.dataset.getDataSet");
	try {
		validateTicket(token, user);
		IEngUserProfile profile = this.setTenantByUserId(user);
		return supplier.getDataSet(documentId, (UserProfile)profile);
	} catch (Exception e) {
		logger.error("Error while getting dataset for document with id " + documentId, e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}
}
 
Example #25
Source File: DataSourceServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Gets the data source.
 *
 * @param token
 *            String
 * @param user
 *            String
 * @param documentId
 *            String
 *
 * @return SpagoBiDataSource
 */
@Override
public SpagoBiDataSource getDataSource(String token, String user,
		String documentId) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.datasource.getDataSource");
	try {
		validateTicket(token, user);
		IEngUserProfile profile = this.setTenantByUserId(user);
		return supplier.getDataSource(documentId, (UserProfile)profile);
	} catch (Exception e) {
		logger.error("Error while getting datasource for document with id " + documentId, e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}

}
 
Example #26
Source File: DataSetServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 *
 * @param token
 *            String
 * @param user
 *            String
 * @return SpagoBiDataSet[]
 */
@Override
public SpagoBiDataSet[] getAllDataSet(String token, String user) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory.start("spagobi.service.dataset.getAllDataSet");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);
		return supplier.getAllDataSet();
	} catch (Exception e) {
		logger.error("Error while getting all datasets", e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}
}
 
Example #27
Source File: DataSetServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public SpagoBiDataSet saveDataSet(String token, String user, SpagoBiDataSet dataset) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory.start("spagobi.service.dataset.saveDataSet");
	try {
		validateTicket(token, user);
		this.setTenantByUserId(user);

		IEngUserProfile profile = GeneralUtilities.createNewUserProfile(user);
		Assert.assertNotNull(profile, "Impossible to find the user profile");

		return supplier.saveDataSet(dataset, profile, null);
	} catch (Exception e) {
		logger.error("Errors saving dataset " + dataset, e);
		return null;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}
}
 
Example #28
Source File: SecurityServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * User profile creation.
 * 
 * @param token
 *            the token
 * @param userId
 *            the user id
 * 
 * @return the user profile
 */
public SpagoBIUserProfile getUserProfile(String token, String userId) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.security.getUserProfile");
	try {
		validateTicket(token, userId);
		UserProfile userProfile = (UserProfile) UserUtilities.getUserProfile(userId);
		return userProfile.getSpagoBIUserProfile();
	} catch (Exception e) {
		logger.error("An exception occurred while creating user profile for user " + userId, e);
		return null;
	} finally {
		monitor.stop();
		logger.debug("OUT");
	}

}
 
Example #29
Source File: SecurityServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * check if user can access to the folder "idFolder".
 * 
 * @param token
 *            the token
 * @param userId
 *            the user id
 * @param idFolder
 *            the id folder
 * @param state
 *            the state
 * 
 * @return true, if checks if is authorized
 */
public boolean isAuthorized(String token, String userId, String idFolder,
		String state) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.security.isAuthorized");
	try {
		validateTicket(token, userId);
		UserProfile userProfile = (UserProfile) UserUtilities
				.getUserProfile(userId);
		this.setTenantByUserProfile(userProfile);
		return ObjectsAccessVerifier.canExec(new Integer(idFolder),
				userProfile);
	} catch (Exception e) {
		logger.error(
				"An exception occurred while checking authorization for user "
						+ userId + " to folder " + idFolder
						+ " with state " + state, e);
		return false;
	} finally {
		this.unsetTenant();
		monitor.stop();
		logger.debug("OUT");
	}
}
 
Example #30
Source File: SecurityServiceImpl.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * check if the user can execute the function.
 * 
 * @param token
 *            the token
 * @param userId
 *            the user id
 * @param function
 *            the function
 * 
 * @return true, if check authorization
 */
public boolean checkAuthorization(String token, String userId,
		String function) {
	logger.debug("IN");
	Monitor monitor = MonitorFactory
			.start("spagobi.service.security.checkAuthorization");
	try {
		validateTicket(token, userId);
		ISecurityServiceSupplier supplier = SecurityServiceSupplierFactory.createISecurityServiceSupplier();
		return supplier.checkAuthorization(userId, function);
	} catch (SecurityException e) {
		logger.error("SecurityException", e);
		return false;
	} finally {
		monitor.stop();
		logger.debug("OUT");
	}

}