Package org.cyclos.impl
Class AbstractNetworkedServerComponent
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- Direct Known Subclasses:
BaseNetworkedHandlerImpl,BaseServiceImpl,BaseServiceSecurity
public class AbstractNetworkedServerComponent extends AbstractServerComponent
Base class for server components which operates with the network concept
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthHandlerauthHandlerprotected ConversionHandlerconversionHandlerprotected CustomFieldValueHandlercustomFieldValueHandlerprotected EntityManagerHandlerentityManagerHandlerprotected GroupsHandlergroupsHandlerprotected ProductsHandlerproductsHandlerprotected RestBeanPropertyMappingrestBeanPropertyMappingprotected UserLocatorHandleruserLocatorHandler-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description AbstractNetworkedServerComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanManage(BasicUser user)Returns whether the logged user manages the given userprotected BasicUsercheckManagesUser(BasicUser user)Ensures that the logged user can manage the given userprotected voidcheckPermission(Permission... permissions)UsinghasPermission(Permission...), throws an exception when none of the given permissions are granted to the logged userprotected BasicUsercheckRelatesToUser(BasicUser user)Ensures that the logged user is related to the given userprotected voidcheckValue(Permission permission, Object... values)Throws aPermissionDeniedExceptionifhasValue(Permission, Object...)returns falseprotected voidclearAlreadyValidated(Bean bean)Forces the given bean as being in the not already validated stateprotected EntityManagerHandlergetBaseEntityManagerHandler()protected ConfigurationAccessorgetConfiguration()protected BasicUsergetLoggedBasicUser()Returns the currently logged basic user, being a regular user or operator, or null when noneprotected UsergetLoggedUser()Returns the currently logged user, or the owner user when there's a logged operator, or null when noneprotected ProductsAccessorgetProducts()protected StringgetTranslatedName(NamedEntity entity)Returns the translated name for the given entity, according to the current data translation settingprotected StringgetTranslatedValue(BaseEntity entity, com.querydsl.core.types.dsl.StringPath property)Returns a translated property value for the given entity, according to the current data translation settingprotected booleanhasPermission(Permission... permissions)Checks whether the logged user has access to any of the specified permissionsprotected booleanhasValue(Permission permission, Object... values)Returns whether the logged user has access to ALL the given values for the given permission.protected booleaninSameNetwork(NetworkedEntity entity)Returns whether the given entity is defined on the same network as the current session, or global if the current session is global.protected booleaninSameNetworkOrGlobal(NetworkedEntity entity)Returns whether the given entity is global (network is null) or is defined on the same network as the current session, or global if the current session is global.protected booleanisAdmin()Checks whether there's a logged adminprotected booleanisAlreadyValidated(Bean bean)Returns whether the given bean was marked as already validated in this requestprotected booleanisBroker()Checks whether there's a logged brokerprotected booleanisGlobalAdmin()Returns whether there's a logged global adminprotected booleanisGlobalAdminInNetwork()Returns whether a global admin OR a global restricted has switched to a network.protected booleanisGuest()Checks whether there's no one logged in, and is a public accessprotected booleanisLoggedIn()Checks whether there's a logged user, no matter the user typeprotected booleanisMember()Checks whether there's a logged memberprotected booleanisMemberOnly()Checks whether there's a logged member only (i.e just member, not broker nor operator)protected booleanisNetworkAdmin()Returns whether there's a logged network adminprotected booleanisOperator()Checks whether there's a logged operatorprotected booleanisRelatedToUser(BasicUser user)Returns whether the logged user is related to the given userprotected booleanisSystem()Checks whether the current thread is running from a system taskprotected booleanisUserManager()Returns whether the logged user is a user manager (admin or broker)protected booleanisUserManagerOf(BasicUser user)Returns true if the logged user is a user manager of the given user.protected Stringmessage(MessageFormat messageFormat, MessageKey key, Object... arguments)protected Stringmessage(MessageKey key, Object... arguments)protected UserPermissionCheckpermission(BasicUser user)protected PermissionCheckpermission(Permission permission)protected UserPermissionCheckpermissionOptionalValue(User user)protected PermissionCheckpermissionOptionalValue(Permission permission)protected DatetoDate(DateTime dateTime)protected DateTimetoDateTime(Date date)protected voidvalidate(Validator validator, Object object)Invokes theValidator#validate(TranslationMessageServiceLocal, ConversionHandler, EntityManager, Object)method with the current context-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, delete, detach, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Field Detail
-
entityManagerHandler
@Autowired protected EntityManagerHandler entityManagerHandler
-
productsHandler
@Autowired protected ProductsHandler productsHandler
-
groupsHandler
@Autowired protected GroupsHandler groupsHandler
-
userLocatorHandler
@Autowired protected UserLocatorHandler userLocatorHandler
-
conversionHandler
@Autowired protected ConversionHandler conversionHandler
-
customFieldValueHandler
@Autowired protected CustomFieldValueHandler customFieldValueHandler
-
authHandler
@Autowired protected AuthHandler authHandler
-
restBeanPropertyMapping
@Autowired protected RestBeanPropertyMapping restBeanPropertyMapping
-
-
Method Detail
-
canManage
protected boolean canManage(BasicUser user)
Returns whether the logged user manages the given user
-
checkManagesUser
protected BasicUser checkManagesUser(BasicUser user) throws PermissionDeniedException
Ensures that the logged user can manage the given user- Throws:
PermissionDeniedException
-
checkPermission
protected void checkPermission(Permission... permissions) throws PermissionDeniedException
UsinghasPermission(Permission...), throws an exception when none of the given permissions are granted to the logged user- Throws:
PermissionDeniedException
-
checkRelatesToUser
protected BasicUser checkRelatesToUser(BasicUser user) throws PermissionDeniedException
Ensures that the logged user is related to the given user- Throws:
PermissionDeniedException
-
checkValue
protected void checkValue(Permission permission, Object... values) throws PermissionDeniedException
Throws aPermissionDeniedExceptionifhasValue(Permission, Object...)returns false- Throws:
PermissionDeniedException
-
clearAlreadyValidated
protected void clearAlreadyValidated(Bean bean)
Forces the given bean as being in the not already validated state
-
getBaseEntityManagerHandler
protected EntityManagerHandler getBaseEntityManagerHandler()
- Specified by:
getBaseEntityManagerHandlerin classAbstractServerComponent
-
getConfiguration
protected ConfigurationAccessor getConfiguration()
-
getLoggedBasicUser
protected BasicUser getLoggedBasicUser()
Returns the currently logged basic user, being a regular user or operator, or null when none
-
getLoggedUser
protected User getLoggedUser()
Returns the currently logged user, or the owner user when there's a logged operator, or null when none
-
getProducts
protected ProductsAccessor getProducts()
-
getTranslatedName
protected String getTranslatedName(NamedEntity entity)
Returns the translated name for the given entity, according to the current data translation setting
-
getTranslatedValue
protected String getTranslatedValue(BaseEntity entity, com.querydsl.core.types.dsl.StringPath property)
Returns a translated property value for the given entity, according to the current data translation setting
-
hasPermission
protected boolean hasPermission(Permission... permissions)
Checks whether the logged user has access to any of the specified permissions
-
hasValue
protected boolean hasValue(Permission permission, Object... values)
Returns whether the logged user has access to ALL the given values for the given permission. If the permission is not related to values, returns false
-
inSameNetwork
protected boolean inSameNetwork(NetworkedEntity entity)
Returns whether the given entity is defined on the same network as the current session, or global if the current session is global. If running as system, always returns true.
-
inSameNetworkOrGlobal
protected boolean inSameNetworkOrGlobal(NetworkedEntity entity)
Returns whether the given entity is global (network is null) or is defined on the same network as the current session, or global if the current session is global. If running as system, always returns true.
-
isAdmin
protected boolean isAdmin()
Checks whether there's a logged admin
-
isAlreadyValidated
protected boolean isAlreadyValidated(Bean bean)
Returns whether the given bean was marked as already validated in this request
-
isBroker
protected boolean isBroker()
Checks whether there's a logged broker
-
isGlobalAdmin
protected boolean isGlobalAdmin()
Returns whether there's a logged global admin
-
isGlobalAdminInNetwork
protected boolean isGlobalAdminInNetwork()
Returns whether a global admin OR a global restricted has switched to a network.
-
isGuest
protected boolean isGuest()
Checks whether there's no one logged in, and is a public access
-
isLoggedIn
protected boolean isLoggedIn()
Checks whether there's a logged user, no matter the user type
-
isMember
protected boolean isMember()
Checks whether there's a logged member
-
isMemberOnly
protected boolean isMemberOnly()
Checks whether there's a logged member only (i.e just member, not broker nor operator)
-
isNetworkAdmin
protected boolean isNetworkAdmin()
Returns whether there's a logged network admin
-
isOperator
protected boolean isOperator()
Checks whether there's a logged operator
-
isRelatedToUser
protected boolean isRelatedToUser(BasicUser user)
Returns whether the logged user is related to the given user
-
isSystem
protected boolean isSystem()
Checks whether the current thread is running from a system task
-
isUserManager
protected boolean isUserManager()
Returns whether the logged user is a user manager (admin or broker)
-
isUserManagerOf
protected boolean isUserManagerOf(BasicUser user)
Returns true if the logged user is a user manager of the given user. Note: A user cannot be a user manager of itself.
-
message
protected String message(MessageFormat messageFormat, MessageKey key, Object... arguments)
-
message
protected String message(MessageKey key, Object... arguments)
-
permission
protected UserPermissionCheck permission(BasicUser user)
- See Also:
AuthHandler#permission(User)
-
permission
protected PermissionCheck permission(Permission permission)
- See Also:
AuthHandler.permission(Permission)
-
permissionOptionalValue
protected PermissionCheck permissionOptionalValue(Permission permission)
-
permissionOptionalValue
protected UserPermissionCheck permissionOptionalValue(User user)
- See Also:
AuthHandler#permissionOptionalValue(User)
-
-