private Logger getLogger(String name) throws UnifyException { UnifyComponentConfig unifyComponentConfig = getInternalUnifyComponentInfo(name).getUnifyComponentConfig(); if (unifyComponentConfig == null) { throw new UnifyException(UnifyCoreErrorConstants.COMPONENT_UNKNOWN_COMP, name); } return new UnifyContainerLoggerImpl(unifyComponentConfig.getType()); }
/** * Gets session context object. * * @return the session context * @throws UnifyException * if an error occurs */ public SessionContext getSessionContext() throws UnifyException { return getRequestContextManager().getRequestContext().getSessionContext(); }
private RequestContextManager getRequestContextManager() throws UnifyException { if (requestContextManager == null) { requestContextManager = (RequestContextManager) applicationContext.getContainer() .getComponent(ApplicationComponents.APPLICATION_REQUESTCONTEXTMANAGER); } return requestContextManager; } }
@Override public void initialize(UnifyComponentContext unifyComponentContext) throws UnifyException { if (this.unifyComponentContext != null) { throw new UnifyException(UnifyCoreErrorConstants.COMPONENT_ALREADY_INITIALIZED, getName()); } this.unifyComponentContext = unifyComponentContext; onInitialize(); }
/** * Returns privilege codes for supplied privilege category and current session * role. * * @param privilegeCategoryCode * the privilege category code * @return set of privilege codes * @throws UnifyException * if an error occurs */ public Set<String> getRolePrivilegeCodes(String privilegeCategoryCode) throws UnifyException { return applicationContext.getPrivilegeCodes(getSessionContext().getUserToken().getRoleCode(), privilegeCategoryCode); }
private void log(LoggingLevel loggingLevel, String message, Object... params) { try { Logger logger = unifyComponentContext.getLogger(); if (logger.isEnabled(loggingLevel)) { logger.log(loggingLevel, resolveApplicationMessage(message, params)); } } catch (UnifyException e) { e.printStackTrace(); } }
/** * Gets an attribute value from current session. * * @param name * the attribute name * @return the attribute value * @throws UnifyException * if an error occurs */ protected Object getSessionAttribute(String name) throws UnifyException { return unifyComponentContext.getSessionContext().getAttribute(name); }
/** * Checks if user in current session is logged in. * * @return a true if current session user is logged in otherwise false * @throws UnifyException * if an error occurs */ protected boolean isUserLoggedIn() throws UnifyException { return unifyComponentContext.getSessionContext().isUserLoggedIn(); }
/** * Removes an attribute from current session. * * @param name * the name of the attribute to remove * @return the value of attribute remove, otherwise null. * @throws UnifyException * if an error occurs */ protected Object removeSessionAttribute(String name) throws UnifyException { return unifyComponentContext.getSessionContext().removeAttribute(name); }
@Override public void loadRequestContext(UserSession userSession, String requestPath) throws UnifyException { requestContextThreadLocal.get().setRequestContext( new RequestContext(requestPath != null ? requestPath : "", userSession.getSessionContext())); }
/** * Gets the current session context. * * @return the session context * @throws UnifyException * if an error occurs. */ protected SessionContext getSessionContext() throws UnifyException { return unifyComponentContext.getRequestContext().getSessionContext(); }
/** * Gets the session locale * * @return the session locale * @throws UnifyException * if an error occurs */ protected Locale getSessionLocale() throws UnifyException { return unifyComponentContext.getRequestContext().getLocale(); }
/** * Returns true if component with name exists in context. * * @param name * the component name * @throws UnifyException * If component an error occurs. */ public boolean isComponent(String name) throws UnifyException { return applicationContext.getContainer().isComponent(name); }
/** * Releases a cluster synchronization lock. * * @param lockName * the lock name * @return a true value if lock was released * @throws UnifyException * if an error occurs */ public boolean releaseClusterLock(String lockName) throws UnifyException { return applicationContext.getContainer().releaseClusterLock(lockName); }
/** * Gets the context's container information. * * @return the container information object * @throws UnifyException * if an error occurs */ public UnifyContainerInfo getContainerInfo() throws UnifyException { return applicationContext.getContainer().getInfo(); }
/** * Removes an attribute value from current request. * * @param name * the attribute name * @return the attribute value * @throws UnifyException * if an error occurs */ protected Object removeRequestAttribute(String name) throws UnifyException { return unifyComponentContext.getRequestContext().removeAttribute(name); }
/** * Checks if request context has an attribute. * * @param name * the attribute name * @return a true value if attribute exists in request context otherwise false * @throws UnifyException * if an error occurs */ protected boolean isRequestAttribute(String name) throws UnifyException { return unifyComponentContext.getRequestContext().isAttribute(name); }
/** * Gets current thread request context object. * * @return the request context * @throws UnifyException * if an error occurs */ public RequestContext getRequestContext() throws UnifyException { return getRequestContextManager().getRequestContext(); }
/** * Tries to grab a cluster synchronization lock. Lock must be released after use * with {@link #releaseClusterLock(String)} * * @param lockName * the lock name * @return a true value is lock is obtained otherwise false * @throws UnifyException * if an error occurs */ public boolean grabClusterLock(String lockName) throws UnifyException { return applicationContext.getContainer().grabClusterLock(lockName); }
/** * Broadcasts a cluster command to other nodes. * * @param command * the command to braodcast * @param params * the command parameters * @throws UnifyException * if an error occurs */ public void broadcastToOtherNodes(String command, String... params) throws UnifyException { applicationContext.getContainer().broadcastToOtherNodes(command, params); }