List of usage examples for org.apache.commons.logging Log info
void info(Object message);
From source file:org.opendatakit.odktables.util.ServiceUtils.java
@SuppressWarnings({ "rawtypes", "unused" }) public static void examineRequest(ServletContext sc, HttpServletRequest req) { Log logger = LogFactory.getLog(ServiceUtils.class); Enumeration headers = req.getHeaderNames(); StringBuilder b = new StringBuilder(); while (headers.hasMoreElements()) { String headerName = (String) headers.nextElement(); Enumeration fieldValues = req.getHeaders(headerName); while (fieldValues.hasMoreElements()) { String fieldValue = (String) fieldValues.nextElement(); b.append(headerName).append(": ").append(fieldValue).append("\n"); }/*from w w w.j a va2 s . c om*/ } String contentType = req.getContentType(); logger.info("Content type: " + contentType); String charEncoding = req.getCharacterEncoding(); logger.info("Character encoding: " + charEncoding); String headerSet = b.toString(); logger.info("Headers: " + headerSet); Cookie[] cookies = req.getCookies(); logger.info("Cookies: " + cookies); String method = req.getMethod(); logger.info("Method: " + method); String ctxtPath = req.getContextPath(); logger.info("Context Path: " + ctxtPath); String pathInfo = req.getPathInfo(); logger.info("Path Info: " + pathInfo); String query = req.getQueryString(); logger.info("Query String: " + query); String ace = req.getHeader(ApiConstants.ACCEPT_CONTENT_ENCODING_HEADER); boolean sessionId = req.isRequestedSessionIdValid(); }
From source file:org.opendatakit.persistence.table.OdkTablesUserInfoTable.java
public static synchronized final OdkTablesUserInfoTable getOdkTablesUserInfo(String uriUser, Set<GrantedAuthority> grants, CallingContext callingContext) throws ODKDatastoreException, ODKTaskLockException, ODKEntityPersistException, ODKOverQuotaException, PermissionDeniedException { Datastore ds = callingContext.getDatastore(); OdkTablesUserInfoTable prototype = OdkTablesUserInfoTable.assertRelation(callingContext); Log log = LogFactory.getLog(FileManifestManager.class); log.info("TablesUserPermissionsImpl: " + uriUser); RoleHierarchy roleHierarchy = (RoleHierarchy) callingContext.getHierarchicalRoleRelationships(); Collection<? extends GrantedAuthority> roles = roleHierarchy.getReachableGrantedAuthorities(grants); boolean hasSynchronize = roles .contains(new SimpleGrantedAuthority(GrantedAuthorityName.ROLE_SYNCHRONIZE_TABLES.name())); boolean hasSuperUser = roles .contains(new SimpleGrantedAuthority(GrantedAuthorityName.ROLE_SUPER_USER_TABLES.name())); boolean hasAdminister = roles .contains(new SimpleGrantedAuthority(GrantedAuthorityName.ROLE_ADMINISTER_TABLES.name())); if (hasSynchronize || hasSuperUser || hasAdminister) { String uriForUser = null; String externalUID = null; if (uriUser.equals(User.ANONYMOUS_USER)) { externalUID = User.ANONYMOUS_USER; uriForUser = User.ANONYMOUS_USER; } else {// ww w. j ava 2s . co m RegisteredUsersTable user = RegisteredUsersTable.getUserByUri(uriUser, ds, callingContext.getCurrentUser()); // Determine the external UID that will identify this user externalUID = null; if (user.getUsername() != null) { externalUID = SecurityConsts.USERNAME_COLON + user.getUsername(); } uriForUser = uriUser; } OdkTablesUserInfoTable odkTablesUserInfo = null; odkTablesUserInfo = OdkTablesUserInfoTable.getCurrentUserInfo(uriForUser, callingContext); if (odkTablesUserInfo == null) { // // GAIN LOCK OdkTablesLockTemplate tablesUserPermissions = new OdkTablesLockTemplate(externalUID, ODKTablesTaskLockType.TABLES_USER_PERMISSION_CREATION, OdkTablesLockTemplate.DelayStrategy.SHORT, callingContext); try { tablesUserPermissions.acquire(); // attempt to re-fetch the record. // If this succeeds, then we had multiple suitors; the other one beat // us. odkTablesUserInfo = OdkTablesUserInfoTable.getCurrentUserInfo(uriForUser, callingContext); if (odkTablesUserInfo != null) { return odkTablesUserInfo; } // otherwise, create a record odkTablesUserInfo = ds.createEntityUsingRelation(prototype, callingContext.getCurrentUser()); odkTablesUserInfo.setUriUser(uriForUser); odkTablesUserInfo.setOdkTablesUserId(externalUID); odkTablesUserInfo.persist(callingContext); return odkTablesUserInfo; } finally { tablesUserPermissions.release(); } } else { return odkTablesUserInfo; } } else { throw new PermissionDeniedException("User does not have access to ODK Tables"); } }
From source file:org.opendatakit.persistence.table.ServerPreferencesPropertiesTable.java
public static final void setServerPreferencesProperty(CallingContext cc, String keyName, String value) throws ODKEntityNotFoundException, ODKOverQuotaException { Log logger = LogFactory.getLog(ServerPreferencesPropertiesTable.class); try {/*from w w w . ja v a2s . co m*/ ServerPreferencesPropertiesTable relation = assertRelation(cc); Query query = cc.getDatastore().createQuery(relation, "ServerPreferences.getServerPreferences", cc.getCurrentUser()); query.addFilter(KEY, Query.FilterOperation.EQUAL, keyName); List<? extends CommonFieldsBase> results = query.executeQuery(); if (!results.isEmpty()) { if (results.get(0) instanceof ServerPreferencesPropertiesTable) { ServerPreferencesPropertiesTable preferences = (ServerPreferencesPropertiesTable) results .get(0); if (!preferences.setStringField(VALUE, value)) { throw new IllegalStateException( "Unexpected truncation of ServerPreferencesProperty: " + keyName + " value"); } preferences.persist(cc); return; } throw new IllegalStateException("Expected ServerPreferencesProperties entity"); } // nothing there -- put the value... ServerPreferencesPropertiesTable preferences = cc.getDatastore().createEntityUsingRelation(relation, cc.getCurrentUser()); logger.info("Setting Server Preference " + keyName + " to " + value); if (!preferences.setStringField(KEY, keyName)) { throw new IllegalStateException( "Unexpected truncation of ServerPreferencesProperty: " + keyName + " keyName"); } if (!preferences.setStringField(VALUE, value)) { throw new IllegalStateException( "Unexpected truncation of ServerPreferencesProperty: " + keyName + " value"); } preferences.persist(cc); return; } catch (ODKOverQuotaException e) { throw e; } catch (ODKDatastoreException e) { throw new ODKEntityNotFoundException(e); } }
From source file:org.opendatakit.security.Realm.java
@Override public void afterPropertiesSet() throws Exception { if (realmString == null) { throw new IllegalStateException("realmString (e.g., mydomain.org ODK Aggregate 1.0) must be specified"); }/*from w w w. java2s. co m*/ Log log = LogFactory.getLog(Realm.class); log.info("Hostname: " + hostname); log.info("RealmString: " + realmString); log.info("java.library.path: " + System.getProperty("java.library.path")); }
From source file:org.opendatakit.security.spring.UserServiceImpl.java
@Override public void afterPropertiesSet() throws Exception { if (realm == null) { throw new IllegalStateException("realm must be configured"); }/* www .ja va 2 s. c o m*/ if (datastore == null) { throw new IllegalStateException("datastore must be configured"); } Log log = LogFactory.getLog(UserServiceImpl.class); log.info("superUserUsername: " + superUserUsername); log.info("Executing UserServiceImpl.afterPropertiesSet"); reloadPermissions(); }
From source file:org.openmrs.module.openhmis.cashier.api.util.RoundingUtil.java
public static void setupRoundingDeptAndItem(Log log) { /*// w w w . j a v a 2s . c o m * Automatically add rounding item & department */ AdministrationService adminService = Context.getService(AdministrationService.class); String nearest = adminService.getGlobalProperty(ModuleSettings.ROUND_TO_NEAREST_PROPERTY); if (nearest != null && !nearest.isEmpty() && !nearest.equals("0")) { MessageSourceService msgService = Context.getMessageSourceService(); IDepartmentDataService deptService = Context.getService(IDepartmentDataService.class); IItemDataService itemService = Context.getService(IItemDataService.class); Integer itemId; Integer deptId; deptId = parseDepartmentId(adminService); itemId = parseItemId(adminService); if (deptId == null && itemId == null) { Department department = new Department(); String name = msgService.getMessage("openhmis.cashier.rounding.itemName"); String description = msgService.getMessage("openhmis.cashier.rounding.itemDescription"); department.setName(name); department.setDescription(description); department.setRetired(true); department.setRetireReason("Used by Cashier Module for rounding adjustments."); deptService.save(department); log.info("Created department for rounding item (ID = " + department.getId() + ")..."); adminService.saveGlobalProperty( new GlobalProperty(ModuleSettings.ROUNDING_DEPT_ID, department.getId().toString())); Item item = new Item(); item.setName(name); item.setDescription(description); item.setDepartment(department); ItemPrice price = item.addPrice(name, BigDecimal.ZERO); item.setDefaultPrice(price); itemService.save(item); log.info("Created item for rounding (ID = " + item.getId() + ")..."); adminService.saveGlobalProperty( new GlobalProperty(ModuleSettings.ROUNDING_ITEM_ID, item.getId().toString())); } } }
From source file:org.openmrs.module.tracnetreporting.impl.TracNetIndicatorServiceImpl.java
/** * Exports data to the Excel File// w w w .j a v a 2s .co m * * @throws IOException * @see org.openmrs.module.tracnetreporting.service.TracNetIndicatorService#exportDataToExcelFile(java.util.Map) */ @SuppressWarnings({ "deprecation", "unchecked" }) public void exportDataToExcelFile(HttpServletRequest request, HttpServletResponse response, Map<String, Integer> indicatorsList, String filename, String title, String startDate, String endDate) throws IOException { HSSFWorkbook workbook = new HSSFWorkbook(); response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); HSSFSheet sheet = workbook.createSheet(title); int count = 0; sheet.setDisplayRowColHeadings(true); // Setting Style HSSFFont font = workbook.createFont(); HSSFCellStyle cellStyle = workbook.createCellStyle(); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); font.setColor(HSSFFont.COLOR_RED); cellStyle.setFillForegroundColor((short) 0xA); // Title HSSFRow row = sheet.createRow((short) 0); HSSFCell cell = row.createCell((short) 0); cell.setCellValue(""); row.setRowStyle(cellStyle); row.createCell((short) 1).setCellValue("" + title + "(Between " + startDate + " and " + endDate + ")"); // Headers row = sheet.createRow((short) 2); row.createCell((short) 0).setCellValue("#"); row.createCell((short) 1).setCellValue("INDICATOR NAME"); row.createCell((short) 2).setCellValue("INDICATOR"); Log log = LogFactory.getLog(this.getClass()); log.info("00000000000000000000000000000000000000000000000000000000000000000"); // log.info(); List<String> indicator_msg = null; indicator_msg = (ArrayList<String>) request.getSession().getAttribute(request.getParameter("id") + "_msg"); for (String indicator : indicatorsList.keySet()) { count++; row = sheet.createRow((short) count + 3); row.createCell((short) 0).setCellValue(indicator.toString().substring(4)); row.createCell((short) 1).setCellValue(indicator_msg.get(count - 1));// .substring(3) row.createCell((short) 2).setCellValue(indicatorsList.get(indicator).toString()); // log.info("========================>>> "+count); } OutputStream outputStream = response.getOutputStream(); workbook.write(outputStream); outputStream.flush(); outputStream.close(); }
From source file:org.openqa.selenium.server.log.LoggingManager.java
public static synchronized Log configureLogging(RemoteControlConfiguration configuration, boolean debugMode) { final Log seleniumServerJettyLogger; final Logger currentLogger; if (configuration.dontTouchLogging()) { return LogFactory.getLog("org.openqa.selenium.server.SeleniumServer"); }/*ww w .ja v a2s . co m*/ currentLogger = Logger.getLogger(""); resetLoggerToOriginalState(); overrideSimpleFormatterWithTerseOneForConsoleHandler(currentLogger, debugMode); addInMemoryLogger(currentLogger, configuration); addPerSessionLogger(currentLogger, configuration, debugMode); if (debugMode) { currentLogger.setLevel(Level.FINE); } seleniumServerJettyLogger = LogFactory.getLog("org.openqa.selenium.server.SeleniumServer"); if (null != configuration.getLogOutFile()) { addNewSeleniumFileHandler(currentLogger, configuration); seleniumServerJettyLogger.info("Writing debug logs to " + configuration.getLogOutFile()); } return seleniumServerJettyLogger; }
From source file:org.openqa.selenium.server.SeleniumServer.java
public static synchronized Log configureLogging(LoggingOptions options, boolean debugMode) { final Log seleniumServerJettyLogger; if (options.dontTouchLogging()) { return LogFactory.getLog("org.openqa.selenium.server.SeleniumServer"); }/* w w w. ja v a2 s .c o m*/ LoggingManager.configureLogging(options, debugMode); seleniumServerJettyLogger = LogFactory.getLog("org.openqa.selenium.server.SeleniumServer"); if (null != options.getLogOutFile()) { seleniumServerJettyLogger.info("Writing debug logs to " + options.getLogOutFile()); } return seleniumServerJettyLogger; }
From source file:org.openspaces.grid.gsm.rebalancing.RebalancingUtils.java
static Collection<FutureStatelessProcessingUnitInstance> incrementNumberOfStatelessInstancesAsync( final ProcessingUnit pu, final GridServiceContainer[] containers, final Log logger, final long duration, final TimeUnit timeUnit) { if (pu.getMaxInstancesPerVM() != 1) { throw new IllegalArgumentException("Only one instance per VM is allowed"); }/*from ww w . j av a2s .co m*/ List<GridServiceContainer> unusedContainers = getUnusedContainers(pu, containers); final Admin admin = pu.getAdmin(); final Map<GridServiceContainer, FutureStatelessProcessingUnitInstance> futureInstances = new HashMap<GridServiceContainer, FutureStatelessProcessingUnitInstance>(); final AtomicInteger targetNumberOfInstances = new AtomicInteger(pu.getNumberOfInstances()); final long start = System.currentTimeMillis(); final long end = start + timeUnit.toMillis(duration); for (GridServiceContainer container : unusedContainers) { final GridServiceContainer targetContainer = container; futureInstances.put(container, new FutureStatelessProcessingUnitInstance() { AtomicReference<Throwable> throwable = new AtomicReference<Throwable>(); ProcessingUnitInstance newInstance; public boolean isTimedOut() { return System.currentTimeMillis() > end; } public boolean isDone() { end(); return isTimedOut() || throwable.get() != null || newInstance != null; } public ProcessingUnitInstance get() throws ExecutionException, IllegalStateException, TimeoutException { end(); if (getException() != null) { throw getException(); } if (newInstance == null) { if (isTimedOut()) { throw new TimeoutException("Relocation timeout"); } throw new IllegalStateException("Async operation is not done yet."); } return newInstance; } public Date getTimestamp() { return new Date(start); } public ExecutionException getException() { end(); Throwable t = throwable.get(); if (t != null) { return new ExecutionException(t.getMessage(), t); } return null; } public GridServiceContainer getTargetContainer() { return targetContainer; } public ProcessingUnit getProcessingUnit() { return pu; } public String getFailureMessage() throws IllegalStateException { if (isTimedOut()) { return "deployment timeout of processing unit " + pu.getName() + " on " + gscToString(targetContainer); } if (getException() != null) { return getException().getMessage(); } throw new IllegalStateException("Relocation has not encountered any failure."); } private void end() { if (!targetContainer.isDiscovered()) { throwable.set(new RemovedContainerProcessingUnitDeploymentException(pu, targetContainer)); } else if (throwable.get() != null || newInstance != null) { //do nothing. idempotent method } else { incrementInstance(); ProcessingUnitInstance[] instances = targetContainer .getProcessingUnitInstances(pu.getName()); if (instances.length > 0) { newInstance = instances[0]; } } } private void incrementInstance() { final String uuid = "[incrementUid:" + UUID.randomUUID().toString() + "] "; int numberOfInstances = pu.getNumberOfInstances(); int maxNumberOfInstances = getContainersOnMachines(pu).length; if (numberOfInstances < maxNumberOfInstances) { if (targetNumberOfInstances.get() == numberOfInstances + 1) { if (logger.isInfoEnabled()) { logger.info("Waiting for pu.numberOfInstances to increment from " + numberOfInstances + " to " + targetNumberOfInstances.get() + ". " + "Number of relevant containers " + maxNumberOfInstances); } } else if (admin.getGridServiceManagers().getSize() > 1 && !((InternalProcessingUnit) pu).isBackupGsmInSync()) { if (logger.isInfoEnabled()) { logger.info("Waiting for backup gsm to sync with active gsm"); } } else { targetNumberOfInstances.set(numberOfInstances + 1); if (logger.isInfoEnabled()) { logger.info(uuid + " Planning to increment pu.numberOfInstances from " + numberOfInstances + " to " + targetNumberOfInstances.get() + ". " + "Number of relevant containers " + maxNumberOfInstances); } ((InternalAdmin) admin).scheduleAdminOperation(new Runnable() { public void run() { try { // this is an async operation // pu.getNumberOfInstances() still shows the old value. pu.incrementInstance(); if (logger.isInfoEnabled()) { logger.info(uuid + " pu.incrementInstance() called"); } } catch (AdminException e) { throwable.set(e); } catch (Throwable e) { logger.error(uuid + " Unexpected Exception: " + e.getMessage(), e); throwable.set(e); } } }); } } } }); } return futureInstances.values(); }