- Timestamp:
- 05/24/08 14:37:02 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs/trunk/src/api/org/openmrs/api/context/Context.java
r4158 r4358 37 37 import org.openmrs.api.EncounterService; 38 38 import org.openmrs.api.FormService; 39 import org.openmrs.api.LocationService; 39 40 import org.openmrs.api.ObsService; 40 41 import org.openmrs.api.OrderService; … … 131 132 */ 132 133 public static void setUserContext(UserContext ctx) { 133 if (log.is DebugEnabled())134 log. debug("Setting user context " + ctx);134 if (log.isTraceEnabled()) 135 log.trace("Setting user context " + ctx); 135 136 136 137 Object[] arr = new Object[] {ctx}; … … 142 143 */ 143 144 public static void clearUserContext() { 144 if (log.is DebugEnabled())145 log. debug("Clearing user context " + userContextHolder.get());145 if (log.isTraceEnabled()) 146 log.trace("Clearing user context " + userContextHolder.get()); 146 147 147 148 userContextHolder.remove(); … … 157 158 Object[] arr = userContextHolder.get(); 158 159 159 if (log.is DebugEnabled())160 log. debug("Getting user context " + arr + " from userContextHolder " + userContextHolder);160 if (log.isTraceEnabled()) 161 log.trace("Getting user context " + arr + " from userContextHolder " + userContextHolder); 161 162 162 163 if (arr == null) { 163 log. debug("userContext is null. Creating new userContext");164 log.trace("userContext is null. Creating new userContext"); 164 165 setUserContext(new UserContext()); 165 166 } … … 178 179 } 179 180 180 if (log.is DebugEnabled())181 log. debug("serviceContext: " + serviceContext);181 if (log.isTraceEnabled()) 182 log.trace("serviceContext: " + serviceContext); 182 183 183 184 return ServiceContext.getInstance(); … … 215 216 */ 216 217 public static void becomeUser(String systemId) throws ContextAuthenticationException { 217 if (log.is DebugEnabled())218 log. debug("systemId: " + systemId);218 if (log.isInfoEnabled()) 219 log.info("systemId: " + systemId); 219 220 220 221 getUserContext().becomeUser(systemId); … … 227 228 */ 228 229 public static Properties getRuntimeProperties() { 229 if (log.is DebugEnabled())230 log. debug("getting runtime properties. size: " + runtimeProperties.size());230 if (log.isTraceEnabled()) 231 log.trace("getting runtime properties. size: " + runtimeProperties.size()); 231 232 232 233 Properties props = new Properties(); … … 257 258 public static EncounterService getEncounterService() { 258 259 return getServiceContext().getEncounterService(); 260 } 261 262 /** 263 * @return location services 264 */ 265 public static LocationService getLocationService() { 266 return getServiceContext().getLocationService(); 259 267 } 260 268 … … 501 509 502 510 /** 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 /** 503 522 * Convenience method. Passes through to @see org.openmrs.api.context.UserContext#addProxyPrivilege(java.lang.String) 504 523 */ … … 534 553 */ 535 554 public static void openSession() { 536 log. debug("opening session");555 log.trace("opening session"); 537 556 getContextDAO().openSession(); 538 557 } … … 543 562 */ 544 563 public static void closeSession() { 545 log. debug("closing session");564 log.trace("closing session"); 546 565 getContextDAO().closeSession(); 547 566 } … … 551 570 */ 552 571 public static void clearSession() { 553 log. debug("clearing session");572 log.trace("clearing session"); 554 573 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); 555 587 } 556 588