/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
- *
+ *
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.Language;
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
-import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionEvaluator;
import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator;
import eu.etaxonomy.cdm.persistence.hibernate.permission.Role;
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
* This implementation of ICdmDataRepository depends on hibernate sessions to
* store the data correctly for the current session. No state is held in this
* class.
- *
+ *
* Only methods that either get or manipulate data are exposed here. So this
* class acts as a facade for the methods in cdmlib-service.
- *
+ *
* @author n.hoffmann
* @created 17.03.2009
* @version 1.0
* <p>
* getDefault
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.taxeditor.store.CdmStore} object.
*/
protected static CdmStore getDefault() {
/**
* Initialize with a specific datasource
- *
+ *
* @param datasource
* a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
*/
/**
* Initialize and provide
- *
+ *
* @param datasource
* @param dbSchemaValidation
* @param applicationContextBean
/**
* Closes the current application context
- *
+ *
* @param monitor
* a {@link org.eclipse.core.runtime.IProgressMonitor} object.
*/
Display.getDefault().asyncExec(new Runnable() {
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Runnable#run()
*/
@Override
/**
* All calls to the datastore require
- *
+ *
* @return
*/
private ICdmApplicationConfiguration getApplicationConfiguration() {
* <p>
* getCurrentApplicationController
* </p>
- *
+ *
* @return a
* {@link eu.etaxonomy.cdm.remote.api.application.CdmApplicationController}
* object.
/**
* Creates a new conversation, binds resources to the conversation and start
* a transaction for this conversation.
- *
+ *
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder}
* object.
*/
/**
* Generic method that will scan the getters of {@link ICdmApplicationConfiguration} for the given service
- * interface. If a matching getter is found the according service implementation is returned by
- * invoking the getter otherwise the method returns <code>null</code>.
- *
+ * interface. If a matching getter is found the according service implementation is returned by
+ * invoking the getter otherwise the method returns <code>null</code>.
+ *
* @param <T>
* @param serviceClass
* @return the configured implementation of <code>serviceClass</code> or <code>null</code>
* <p>
* getAuthenticationManager
* </p>
- *
+ *
* @return a
* {@link org.springframework.security.authentication.ProviderManager}
* object.
public static ProviderManager getAuthenticationManager() {
return getCurrentApplicationConfiguration().getAuthenticationManager();
}
-
+
/**
* <p>
* getAuthenticationManager
* </p>
- *
+ *
* @return a
* {@link ICdmPermissionEvaluator} object.
*/
* <p>
* getGeoService
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.cdm.ext.geo.IEditGeoService} object.
*/
public static IEditGeoService getGeoService() {
return (IEditGeoService) getCurrentApplicationConfiguration().getBean(
"editGeoService");
}
-
+
/*
* SECURITY RELATED CONVENIENCE METHODS
*/
-
+
/**
* @see org.springframework.security.access.PermissionEvaluator#hasPermission(org.springframework.security.core.Authentication, java.lang.Object, java.lang.Object)
*
* @param targetDomainObject
- * @param permission
+ * @param permission
* @return
*/
public static boolean currentAuthentiationHasPermission(CdmBase targetDomainObject, EnumSet<CRUD> permission){
//TODO use getCurrentApplicationConfiguration().currentAuthentiationHasPermission(CdmBase targetDomainObject, Operation permission) instead
SecurityContext context = SecurityContextHolder.getContext();
PermissionEvaluator pe = getPermissionEvaluator();
- return getPermissionEvaluator().hasPermission(context.getAuthentication(), targetDomainObject, permission);
+ boolean hasPermission = false;
+ try {
+ hasPermission = getPermissionEvaluator().hasPermission(context.getAuthentication(), targetDomainObject,
+ permission);
+ } catch (org.springframework.security.access.AccessDeniedException e) {
+ /* IGNORE */
+ }
+ return hasPermission;
}
/**
* @see org.springframework.security.access.PermissionEvaluator#hasPermission(org.springframework.security.core.Authentication, java.lang.Object, java.lang.Object)
*
* @param targetDomainObject
- * @param permission
+ * @param permission
* @return
*/
public static boolean currentAuthentiationHasPermission(Class<? extends CdmBase> targetType, EnumSet<CRUD> permission){
- return getPermissionEvaluator().hasPermission(getCurrentAuthentiation(), null, targetType.getName(), permission);
+ boolean hasPermission = false;
+ try {
+ hasPermission = getPermissionEvaluator().hasPermission(getCurrentAuthentiation(), null, targetType.getName(), permission);
+ } catch (org.springframework.security.access.AccessDeniedException e) {
+ /* IGNORE */
+ }
+ return hasPermission;
}
-
+
public static boolean currentAuthentiationHasOneOfRoles(Role ... roles){
- return getPermissionEvaluator().hasOneOfRoles(getCurrentAuthentiation(), roles);
+ boolean hasPermission = false;
+ try {
+ hasPermission = getPermissionEvaluator().hasOneOfRoles(getCurrentAuthentiation(), roles);
+ } catch (org.springframework.security.access.AccessDeniedException e) {
+ /* IGNORE */
+ }
+ return hasPermission;
}
-
+
public static Authentication getCurrentAuthentiation() {
SecurityContext context = SecurityContextHolder.getContext();
return context.getAuthentication();
}
-
+
/*
* LANGUAGE
*/
* <p>
* getDefaultLanguage
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.cdm.model.common.Language} object.
*/
public static Language getDefaultLanguage() {
* <p>
* setDefaultLanguage
* </p>
- *
+ *
* @param language
* a {@link eu.etaxonomy.cdm.model.common.Language} object.
*/
* <p>
* Getter for the field <code>loginManager</code>.
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.taxeditor.store.LoginManager} object.
*/
public static LoginManager getLoginManager() {
* <p>
* Getter for the field <code>contextManager</code>.
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.taxeditor.store.ContextManager} object.
*/
public static ContextManager getContextManager() {
* <p>
* Getter for the field <code>importHandler</code>.
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.taxeditor.io.ImportManager} object.
*/
public static ImportManager getImportManager() {
* <p>
* Getter for the field <code>exportHandler</code>.
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.taxeditor.io.ExportManager} object.
*/
public static ExportManager getExportManager() {
/**
* Whether this CdmStore is currently connected to a datasource
- *
+ *
* @return a boolean.
*/
public static boolean isActive() {
* <p>
* getDataSource
* </p>
- *
+ *
* @return a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
*/
public static ICdmDataSource getDataSource() {