List of usage examples for org.apache.commons.logging Log error
void error(Object message);
From source file:com.flexive.tests.browser.AbstractBackendBrowserTest.java
/** * checks if the given text is present on the current content page * @param text the text to check//from w w w . jav a 2 s . c o m * @param expectedResult should it be present (<code>null</code> == don't care) * @param LOG the Log where to log errors * @param frameToLook the Frame to search the text * @return true if the result is as expected */ protected boolean checkText(String text, Boolean expectedResult, Log LOG, Frame frameToLook) { int trys = 10; boolean succesfull = false; while (trys-- > 0) { try { selectFrame(frameToLook); succesfull = selenium.isTextPresent(text); break; } catch (SeleniumException se) { sleep(400); } } try { succesfull = succesfull ^ (!expectedResult); } catch (NullPointerException npe) { return succesfull; } if (!succesfull) { LOG.error("can't find text \"" + text + "\""); LOG.error(writeHTMLtoHD("checkText", LOG)); printFXMessages(LOG); } return succesfull; }
From source file:com.boylesoftware.web.AbstractWebApplication.java
/** * Clean-up the application object.//from ww w .j ava 2 s . c o m */ private void cleanup() { // get the log final Log log = LogFactory.getLog(AbstractWebApplication.class); log.debug("destroying the web-application"); // shutdown the executors if (this.executors != null) { log.debug("shutting down the request processing executors..."); this.executors.shutdown(); try { boolean success = true; if (!this.executors.awaitTermination(30, TimeUnit.SECONDS)) { log.warn("could not shutdown the request processing" + " executors in 30 seconds, trying to force" + " shutdown..."); this.executors.shutdownNow(); if (!this.executors.awaitTermination(30, TimeUnit.SECONDS)) { log.error("could not shutdown the request processing" + " executors"); success = false; } } if (success) log.debug("request processing executors shut down"); } catch (final InterruptedException e) { log.warn("waiting for the request processing executors to" + " shutdown was interrupted"); this.executors.shutdownNow(); Thread.currentThread().interrupt(); } finally { this.executors = null; } } // destroy custom application log.debug("destroying custom application"); try { this.destroy(); } catch (final Exception e) { log.error("error destroying custom application", e); } // forget the router configuration this.routerConfiguration = null; // close and forget the entity manager factory final EntityManagerFactory emf = this.services.getEntityManagerFactory(); if (emf != null) { this.services.setEntityManagerFactory(null); try { log.debug("closing persistence manager factory"); emf.close(); } catch (final Exception e) { log.error("error shutting down the application", e); } } // forget user locale finder this.services.setUserLocaleFinder(null); // close and forget the validator factory final ValidatorFactory vf = this.services.getValidatorFactory(); if (vf != null) { this.services.setValidatorFactory(null); try { log.debug("closing validator factory"); vf.close(); } catch (final Exception e) { log.error("error shutting down the application", e); } } // forget the authentication service this.services.setAuthenticationService(null); }
From source file:com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.Resolver.java
/** * processes a <code>BlockDef</code> and resolves references in it * * @param block the <code>BlockDef</code> to process *//* w w w . j av a2s . c o m*/ protected void handleBlock(BlockDef block) { SymTabAST node = block.getTreeNode(); switch (node.getType()) { case TokenTypes.LITERAL_FOR: handleFor(block); break; case TokenTypes.LITERAL_IF: handleIf(block); break; case TokenTypes.LITERAL_WHILE: handleWhileAndSynchronized(block); break; case TokenTypes.LITERAL_DO: handleDoWhile(block); break; case TokenTypes.LITERAL_TRY: case TokenTypes.LITERAL_FINALLY: SymTabAST slist = node.findFirstToken(TokenTypes.SLIST); handleSList(slist, block); break; case TokenTypes.LITERAL_CATCH: handleCatch(block); break; case TokenTypes.LITERAL_SWITCH: handleSwitch(block); break; case TokenTypes.SLIST: handleSList(node, block); break; case TokenTypes.EXPR: resolveExpression(node, block, null, true); break; case TokenTypes.INSTANCE_INIT: case TokenTypes.STATIC_INIT: handleSList((SymTabAST) node.getFirstChild(), block); break; case TokenTypes.LITERAL_SYNCHRONIZED: handleWhileAndSynchronized(block); break; case TokenTypes.LITERAL_ASSERT: handleAssert(block); break; default: if (mInitialized) { final Log log = mLogFactory.getInstance(this.getClass()); log.error("Unhandled block " + block + " of type " + node.getType()); } } }
From source file:com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.Resolver.java
/** * Resolves Java expressions, returning the type to which the expression * evalutes. If this is the reference creation phase, any references found during resolution are created and * resolved./*from w ww .ja va2 s. c o m*/ * * @param expression the <code>SymTabAST</code> representing the expression * @param location the <code>Scope</code> in which the expression occours. * @param context the <code>Scope</code> in which the search for the * definition will start * @param referencePhase whether or not this is the reference phase of * table construction * * @return the <code>ClassDef</code> representing the type to which the * expression evalutes. */ public IClass resolveExpression(SymTabAST expression, Scope location, IClass context, boolean referencePhase) { IClass result = null; try { switch (expression.getType()) { case TokenTypes.TYPECAST: result = resolveTypecast(expression, location, context, referencePhase); break; case TokenTypes.EXPR: case TokenTypes.LITERAL_RETURN: if (expression.getFirstChild() != null) { result = resolveExpression((SymTabAST) expression.getFirstChild(), location, context, referencePhase); } else { // YOU WRITE BAD CODE! } break; case TokenTypes.ELIST: SymTabAST child = (SymTabAST) (expression.getFirstChild()); while (child != null) { if (child.getType() != TokenTypes.COMMA) { resolveExpression(child, location, context, referencePhase); } child = (SymTabAST) (child.getNextSibling()); } break; case TokenTypes.IDENT: result = resolveIdent(expression, location, context, referencePhase); break; case TokenTypes.TYPE: result = resolveType(expression, location, context, referencePhase); break; case TokenTypes.METHOD_CALL: //case TokenTypes.SUPER_CTOR_CALL : result = resolveMethod(expression, location, context, referencePhase); break; case TokenTypes.LITERAL_THIS: result = resolveLiteralThis(expression, location, context); break; case TokenTypes.LITERAL_SUPER: result = resolveLiteralSuper(expression, location, context); break; case TokenTypes.DOT: result = resolveDottedName(expression, location, context, referencePhase); break; case TokenTypes.LITERAL_NEW: case TokenTypes.CTOR_CALL: case TokenTypes.SUPER_CTOR_CALL: result = resolveNew(expression, location, context, referencePhase); break; case TokenTypes.LITERAL_BOOLEAN: case TokenTypes.LITERAL_DOUBLE: case TokenTypes.LITERAL_FLOAT: case TokenTypes.LITERAL_LONG: case TokenTypes.LITERAL_INT: case TokenTypes.LITERAL_SHORT: case TokenTypes.LITERAL_BYTE: case TokenTypes.LITERAL_CHAR: result = resolvePrimitiveType(expression, location, context, referencePhase); break; case TokenTypes.NUM_INT: case TokenTypes.NUM_LONG: result = resolveNumInt(expression, location, context); break; case TokenTypes.NUM_FLOAT: case TokenTypes.NUM_DOUBLE: result = resolveNumFloat(expression, location, context); break; case TokenTypes.STRING_LITERAL: result = resolveStringLiteral(expression, location, context); break; case TokenTypes.CHAR_LITERAL: result = resolveCharLiteral(expression, location, context); break; case TokenTypes.ASSIGN: case TokenTypes.PLUS_ASSIGN: case TokenTypes.MINUS_ASSIGN: case TokenTypes.STAR_ASSIGN: case TokenTypes.DIV_ASSIGN: case TokenTypes.MOD_ASSIGN: case TokenTypes.SR_ASSIGN: case TokenTypes.BSR_ASSIGN: case TokenTypes.SL_ASSIGN: case TokenTypes.BAND_ASSIGN: case TokenTypes.BXOR_ASSIGN: case TokenTypes.BOR_ASSIGN: resolveAssignment(expression, location, context, referencePhase); break; case TokenTypes.LOR: case TokenTypes.LAND: case TokenTypes.NOT_EQUAL: case TokenTypes.EQUAL: case TokenTypes.LT: case TokenTypes.GT: case TokenTypes.LE: case TokenTypes.GE: result = resolveBooleanExpression(expression, location, context, referencePhase); break; case TokenTypes.LITERAL_INSTANCEOF: result = resolveInstanceOf(expression, location, context, referencePhase); break; case TokenTypes.LITERAL_TRUE: case TokenTypes.LITERAL_FALSE: result = resolveBooleanLiteral(expression, location, context); break; case TokenTypes.LNOT: result = resolveBooleanUnary(expression, location, context, referencePhase); break; case TokenTypes.INC: case TokenTypes.POST_INC: case TokenTypes.DEC: case TokenTypes.POST_DEC: case TokenTypes.UNARY_PLUS: case TokenTypes.UNARY_MINUS: result = resolveUnaryExpression(expression, location, context, referencePhase); break; case TokenTypes.PLUS: case TokenTypes.MINUS: case TokenTypes.DIV: case TokenTypes.STAR: case TokenTypes.BAND: case TokenTypes.BOR: case TokenTypes.BXOR: case TokenTypes.MOD: result = resolveArithmeticExpression(expression, location, context, referencePhase); break; case TokenTypes.LITERAL_BREAK: case TokenTypes.LITERAL_CONTINUE: resolveGoto(expression, location, context, referencePhase); break; case TokenTypes.LPAREN: result = resolveExpression( //TODO: child || sibling? (SymTabAST) (expression.getNextSibling()), //(SymTabAST) (expression.getFirstChild()), location, context, referencePhase); break; case TokenTypes.INDEX_OP: result = resolveArrayAccess(expression, location, context, referencePhase); break; case TokenTypes.LITERAL_NULL: result = new NullClass(); break; case TokenTypes.QUESTION: result = resolveQuestion(expression, location, context, referencePhase); break; case TokenTypes.LITERAL_CLASS: result = resolveLiteralClass(); break; case TokenTypes.ARRAY_INIT: resolveArrayInitializer(expression, location, context, referencePhase); break; case TokenTypes.LITERAL_THROW: resolveThrowExpression(expression, location, context, referencePhase); break; case TokenTypes.SL: case TokenTypes.SR: case TokenTypes.BSR: result = resolveShiftOperator(expression, location, context, referencePhase); break; case TokenTypes.BNOT: resolveBitwiseNot(expression, location, context, referencePhase); break; case TokenTypes.LITERAL_ASSERT: // resolveAssert( // expression, // location, // context, // referencePhase); break; case TokenTypes.RPAREN: case TokenTypes.EMPTY_STAT: // case TokenTypes.ML_COMMENT: // case TokenTypes.SL_COMMENT: case TokenTypes.VARIABLE_DEF: case TokenTypes.METHOD_DEF: case TokenTypes.CLASS_DEF: case TokenTypes.LITERAL_FOR: case TokenTypes.LITERAL_WHILE: case TokenTypes.LITERAL_IF: case TokenTypes.LITERAL_VOID: // case TokenTypes.LITERAL_INTERFACE: case TokenTypes.LITERAL_DO: case TokenTypes.LITERAL_SWITCH: case TokenTypes.LITERAL_STATIC: case TokenTypes.LITERAL_TRANSIENT: case TokenTypes.LITERAL_NATIVE: // case TokenTypes.LITERAL_threadsafe: case TokenTypes.LITERAL_SYNCHRONIZED: case TokenTypes.LITERAL_VOLATILE: case TokenTypes.LITERAL_TRY: case TokenTypes.LITERAL_CATCH: case TokenTypes.LITERAL_FINALLY: case TokenTypes.LABELED_STAT: case TokenTypes.LCURLY: case TokenTypes.RCURLY: case TokenTypes.SLIST: case TokenTypes.SEMI: case TokenTypes.COMMA: case TokenTypes.ARRAY_DECLARATOR: break; default: //TODO: throw exception if (mInitialized) { final Log log = mLogFactory.getInstance(this.getClass()); log.error("Unhandled expression type: " + expression.getType()); } break; } } catch (Exception e) { result = new UnknownClass(expression.getText(), expression); // TODO: This really should be logged // if (mInitialized) { // final Log log = mLogFactory.getInstance(this.getClass()); // log.error("Error resolving near " + expression); // } } return result; }
From source file:com.flexive.tests.browser.AbstractBackendBrowserTest.java
/** * prints the current FXMessages to the log * @param LOG the Log to print to//from w ww. j a v a 2 s. com */ private void printFXMessages(Log LOG) { String tmpHTML = selenium.getHTMLSource("<div ", "<tbody>", "</tbody>", "<tr>", "<td>", "</td>"); int begin = tmpHTML.indexOf("<div id=\"fxMessages\""); if (begin > 0) { int end; begin = tmpHTML.indexOf("<tbody>", begin); end = tmpHTML.indexOf("</tbody>", begin); if (begin * end > 1) { String tmpTbody = tmpHTML.substring(begin, end); String[] trS = tmpTbody.split("<tr>"); String[] tdS; String tmpMSG; for (String tr : trS) { tdS = tr.split("<td>"); if (tdS.length == 3) { tmpMSG = tdS[2].substring(0, tdS[2].lastIndexOf("</td>")); if (tdS[1].indexOf("error") > 0) { LOG.error(tmpMSG); throw new RuntimeException(tmpMSG); } else { LOG.warn(tmpMSG); } } } } } }
From source file:com.dhcc.framework.web.context.DhccContextLoader.java
protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac, ServletContext sc) {/*w w w . j a v a2 s. com*/ Log logger = LogFactory.getLog(DhccContextLoader.class); if (ObjectUtils.identityToString(wac).equals(wac.getId())) { // The application context id is still set to its original default value // -> assign a more useful id based on available information String idParam = sc.getInitParameter(CONTEXT_ID_PARAM); if (idParam != null) { wac.setId(idParam); } else { // Generate default id... if (sc.getMajorVersion() == 2 && sc.getMinorVersion() < 5) { // Servlet <= 2.4: resort to name specified in web.xml, if any. wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(sc.getServletContextName())); } else { wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + ObjectUtils.getDisplayString(sc.getContextPath())); } } } wac.setServletContext(sc); String initParameter = sc.getInitParameter(CONFIG_LOCATION_PARAM); if (isMicrokernelStart(sc)) { initParameter = "classpath:codeTemplate/applicationSetupContext.xml"; logger.error("because cant't connect to db or setup flg is 0 so init application as Microkernel "); } else { logger.info("initParameter==" + initParameter); } if (initParameter != null) { wac.setConfigLocation(initParameter); } customizeContext(sc, wac); wac.refresh(); }
From source file:com.cisco.dvbu.ps.common.util.CommonUtils.java
public static void writeOutput(String message, String prefix, String options, Log logger, boolean debug1, boolean debug2, boolean debug3) { // Determine if there is a prefix to prepend if (prefix == null) { prefix = ""; } else {/* w ww .j ava 2 s .co m*/ prefix = prefix + "::"; } //Write out the log if not suppressed if (!options.contains("-suppress")) { //Write to log when -error if (options.contains("-error")) { if (logger.isErrorEnabled()) { logger.error(prefix + message); } } //Write to log when -info if (options.contains("-info")) { if (logger.isInfoEnabled()) { logger.info(prefix + message); } } //Write to log when -debug1 if (options.contains("-debug1") && debug1) { // logger.isInfoEnabled() is checked on purpose. Don't change it. if (logger.isInfoEnabled()) { logger.info("DEBUG1::" + prefix + message); } } //Write to log when -debug2 if (options.contains("-debug2") && debug2) { // logger.isInfoEnabled() is checked on purpose. Don't change it. if (logger.isInfoEnabled()) { logger.info("DEBUG2::" + prefix + message); } } //Write to log when -debug3 if (options.contains("-debug3") && debug3) { // logger.isInfoEnabled() is checked on purpose. Don't change it. if (logger.isInfoEnabled()) { logger.info("DEBUG3::" + prefix + message); } } } }
From source file:com.github.cmisbox.core.Queue.java
public void manageEvent(LocalEvent event) { Log log = LogFactory.getLog(this.getClass()); log.debug("managing: " + event); // any platform // - a folder can be renamed before containing files are managed: on // folder rename all children must be updated while still in queue; // linux//from w w w . j a v a2 s . c om // - if a file or folder is moved out of a watched folder it is reported // as a rename to null (check if it's still there) // mac osx // - recursive folder operations (e.g. unzip an archive or move a folder // inside a watched folder) are not reported, only root folder is // reported as create // - folder rename causes children to be notified as deleted (with old // path) try { if (event.isSynch()) { this.synchAllWatches(); return; } File f = new File(event.getFullFilename()); if (event.isCreate()) { StoredItem item = this.getSingleItem(event.getLocalPath()); if ((item != null) && (item.getLocalModified().longValue() >= f.lastModified())) { return; } String parent = f.getParent().substring(Config.getInstance().getWatchParent().length()); CmisObject obj = CMISRepository.getInstance().addChild(this.getSingleItem(parent).getId(), f); Storage.getInstance().add(f, obj); } else if (event.isDelete()) { StoredItem item = this.getSingleItem(event.getLocalPath()); if (f.exists()) { throw new Exception( String.format("File %s reported to be deleted but stil exists", f.getAbsolutePath())); } CMISRepository.getInstance().delete(item.getId()); Storage.getInstance().delete(item, true); } else if (event.isModify()) { if (f.isFile()) { StoredItem item = this.getSingleItem(event.getLocalPath()); if (item.getLocalModified().longValue() < f.lastModified()) { Document doc = CMISRepository.getInstance().update(item, f); Storage.getInstance().localUpdate(item, f, doc); } else { log.debug("file" + f + " modified in the past"); } } } else if (event.isRename()) { StoredItem item = this.getSingleItem(event.getLocalPath()); CmisObject obj = CMISRepository.getInstance().rename(item.getId(), f); Storage.getInstance().localUpdate(item, f, obj); } } catch (Exception e) { log.error(e); if (log.isDebugEnabled()) { e.printStackTrace(); } if (UI.getInstance().isAvailable()) { UI.getInstance().notify(e.toString()); UI.getInstance().setStatus(Status.KO); } } }
From source file:it.doqui.index.ecmengine.business.personalization.multirepository.bootstrap.MultiTAdminServiceImpl.java
public void deployTenants(final TenantDeployer deployer, Log logger) { if (deployer == null) { throw new AlfrescoRuntimeException("Deployer must be provided"); }/*from w ww.j a v a2s .com*/ if (logger == null) { throw new AlfrescoRuntimeException("Logger must be provided"); } if (tenantService.isEnabled()) { UserTransaction userTransaction = transactionService.getUserTransaction(); authenticationComponent.setSystemUserAsCurrentUser(); List<org.alfresco.repo.tenant.Tenant> tenants = null; try { userTransaction.begin(); tenants = getAllTenants(); userTransaction.commit(); } catch (Throwable e) { // rollback the transaction try { if (userTransaction != null) { userTransaction.rollback(); } } catch (Exception ex) { } try { authenticationComponent.clearCurrentSecurityContext(); } catch (Exception ex) { } throw new AlfrescoRuntimeException("Failed to get tenants", e); } String currentUser = AuthenticationUtil.getCurrentUserName(); if (tenants != null) { try { for (org.alfresco.repo.tenant.Tenant tenant : tenants) { if (tenant.isEnabled()) { try { // switch to admin in order to deploy within context of tenant domain // assumes each tenant has default "admin" user AuthenticationUtil.runAs(new RunAsWork<Object>() { public Object doWork() { // init the service within tenant context deployer.init(); return null; } }, getTenantAdminUser(tenant.getTenantDomain())); } catch (Throwable e) { logger.error("Deployment failed" + e); StringWriter stringWriter = new StringWriter(); e.printStackTrace(new PrintWriter(stringWriter)); logger.error(stringWriter.toString()); // tenant deploy failure should not necessarily affect other tenants } } } } finally { if (currentUser != null) { AuthenticationUtil.setCurrentUser(currentUser); } } } } }
From source file:it.doqui.index.ecmengine.business.personalization.multirepository.bootstrap.MultiTAdminServiceImpl.java
public void undeployTenants(final TenantDeployer deployer, Log logger) { if (deployer == null) { throw new AlfrescoRuntimeException("Deployer must be provided"); }// w ww. j a v a 2s. c o m if (logger == null) { throw new AlfrescoRuntimeException("Logger must be provided"); } if (tenantService.isEnabled()) { UserTransaction userTransaction = transactionService.getUserTransaction(); authenticationComponent.setSystemUserAsCurrentUser(); List<org.alfresco.repo.tenant.Tenant> tenants = null; try { userTransaction.begin(); tenants = getAllTenants(); userTransaction.commit(); } catch (Throwable e) { // rollback the transaction try { if (userTransaction != null) { userTransaction.rollback(); } } catch (Exception ex) { } try { authenticationComponent.clearCurrentSecurityContext(); } catch (Exception ex) { } throw new AlfrescoRuntimeException("Failed to get tenants", e); } String currentUser = AuthenticationUtil.getCurrentUserName(); if (tenants != null) { try { for (org.alfresco.repo.tenant.Tenant tenant : tenants) { if (tenant.isEnabled()) { try { // switch to admin in order to deploy within context of tenant domain // assumes each tenant has default "admin" user AuthenticationUtil.runAs(new RunAsWork<Object>() { public Object doWork() { // destroy the service within tenant context deployer.destroy(); return null; } }, getTenantAdminUser(tenant.getTenantDomain())); } catch (Throwable e) { logger.error("Undeployment failed" + e); StringWriter stringWriter = new StringWriter(); e.printStackTrace(new PrintWriter(stringWriter)); logger.error(stringWriter.toString()); // tenant undeploy failure should not necessarily affect other tenants } } } } finally { if (currentUser != null) { AuthenticationUtil.setCurrentUser(currentUser); } } } } }