Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/24/08 14:37:02 (6 months ago)
Author:
bwolfe
Message:

Merging api-refactoring to trunk [3595]:[4355]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/trunk/src/api/org/openmrs/api/context/Context.java

    r4158 r4358  
    3737import org.openmrs.api.EncounterService; 
    3838import org.openmrs.api.FormService; 
     39import org.openmrs.api.LocationService; 
    3940import org.openmrs.api.ObsService; 
    4041import org.openmrs.api.OrderService; 
     
    131132         */ 
    132133        public static void setUserContext(UserContext ctx) {  
    133                 if (log.isDebugEnabled()) 
    134                         log.debug("Setting user context " + ctx); 
     134                if (log.isTraceEnabled()) 
     135                        log.trace("Setting user context " + ctx); 
    135136                 
    136137                Object[] arr = new Object[] {ctx}; 
     
    142143         */ 
    143144        public static void clearUserContext() { 
    144                 if (log.isDebugEnabled()) 
    145                         log.debug("Clearing user context " + userContextHolder.get()); 
     145                if (log.isTraceEnabled()) 
     146                        log.trace("Clearing user context " + userContextHolder.get()); 
    146147                 
    147148                userContextHolder.remove(); 
     
    157158                Object[] arr = userContextHolder.get(); 
    158159                 
    159                 if (log.isDebugEnabled()) 
    160                         log.debug("Getting user context " + arr + " from userContextHolder " + userContextHolder); 
     160                if (log.isTraceEnabled()) 
     161                        log.trace("Getting user context " + arr + " from userContextHolder " + userContextHolder); 
    161162                 
    162163                if (arr == null) { 
    163                         log.debug("userContext is null. Creating new userContext"); 
     164                        log.trace("userContext is null. Creating new userContext"); 
    164165            setUserContext(new UserContext()); 
    165166        } 
     
    178179                } 
    179180                 
    180                 if (log.isDebugEnabled()) 
    181                         log.debug("serviceContext: " + serviceContext); 
     181                if (log.isTraceEnabled()) 
     182                        log.trace("serviceContext: " + serviceContext); 
    182183                 
    183184                return ServiceContext.getInstance(); 
     
    215216         */ 
    216217        public static void becomeUser(String systemId) throws ContextAuthenticationException { 
    217                 if (log.isDebugEnabled()) 
    218                         log.debug("systemId: " + systemId); 
     218                if (log.isInfoEnabled()) 
     219                        log.info("systemId: " + systemId); 
    219220                 
    220221                getUserContext().becomeUser(systemId); 
     
    227228         */ 
    228229        public static Properties getRuntimeProperties() { 
    229                 if (log.isDebugEnabled()) 
    230                         log.debug("getting runtime properties. size: " + runtimeProperties.size()); 
     230                if (log.isTraceEnabled()) 
     231                        log.trace("getting runtime properties. size: " + runtimeProperties.size()); 
    231232                 
    232233                Properties props = new Properties(); 
     
    257258        public static EncounterService getEncounterService() { 
    258259                return getServiceContext().getEncounterService(); 
     260        } 
     261         
     262        /** 
     263         * @return location services 
     264         */ 
     265        public static LocationService getLocationService() { 
     266                return getServiceContext().getLocationService(); 
    259267        } 
    260268 
     
    501509         
    502510        /** 
     511         * Throws an exception if the currently authenticated user does not have the specified privilege.  
     512         *  
     513         * @param privilege 
     514         * @throws ContextAuthenticationException 
     515         */ 
     516        public static void requirePrivilege(String privilege) throws ContextAuthenticationException { 
     517                if (!hasPrivilege(privilege)) 
     518                        throw new ContextAuthenticationException(); 
     519        } 
     520         
     521        /** 
    503522         * Convenience method.  Passes through to @see org.openmrs.api.context.UserContext#addProxyPrivilege(java.lang.String) 
    504523         */ 
     
    534553         */ 
    535554        public static void openSession() { 
    536                 log.debug("opening session"); 
     555                log.trace("opening session"); 
    537556                getContextDAO().openSession(); 
    538557        } 
     
    543562         */ 
    544563        public static void closeSession() { 
    545                 log.debug("closing session"); 
     564                log.trace("closing session"); 
    546565                getContextDAO().closeSession(); 
    547566        } 
     
    551570         */ 
    552571        public static void clearSession() { 
    553                 log.debug("clearing session"); 
     572                log.trace("clearing session"); 
    554573                getContextDAO().clearSession(); 
     574        } 
     575         
     576        /** 
     577         * Used to clear a cached object out of a session in the middle of a unit of work. 
     578         *  
     579         * Future updates to this object will not be saved.  Future gets of this object will 
     580         * not fetch this cached copy 
     581         *  
     582         * @param obj The object to evict/remove from the session 
     583         */ 
     584        public static void evictFromSession(Object obj) { 
     585                log.trace("clearing session"); 
     586                getContextDAO().evictFromSession(obj); 
    555587        } 
    556588