You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by hn...@apache.org on 2010/12/08 21:49:05 UTC
svn commit: r1043668 [1/2] - in /shindig/trunk/java:
common/src/main/java/org/apache/shindig/auth/
common/src/main/java/org/apache/shindig/common/cache/
common/src/main/java/org/apache/shindig/common/logging/
common/src/main/java/org/apache/shindig/com...
Author: hnguy
Date: Wed Dec 8 20:49:04 2010
New Revision: 1043668
URL: http://svn.apache.org/viewvc?rev=1043668&view=rev
Log:
Applying SHINDIG-1477 - Externalize logging messages to resource bundle for i18n, submitted by Han Nguyen
Added:
shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/
shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/
shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/MessageKeys.java
shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/
shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/
shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties
shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource_en_US.properties
Modified:
shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java
shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCacheProvider.java
shindig/trunk/java/common/src/main/java/org/apache/shindig/common/xml/XmlUtil.java
shindig/trunk/java/common/src/main/java/org/apache/shindig/config/DynamicConfigProperty.java
shindig/trunk/java/common/src/main/java/org/apache/shindig/config/JsonContainerConfigLoader.java
shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/ApiServlet.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/AbstractSpecFactory.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/HashLockedDomainService.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureResourceLoader.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponseMetadataHelper.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthModule.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthRequest.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/GadgetHtmlParser.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/caja/CajaCssSanitizer.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/preload/PipelineExecutor.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/process/Processor.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/CajaResponseRewriter.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultServiceFetcher.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/Renderer.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriter.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingResponseRewriter.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/CssResponseRewriter.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/ImageAttributeRewriter.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/PipelineDataGadgetRewriter.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/ProxyingVisitor.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/TemplateRewriter.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/image/BasicImageRewriter.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/CajaContentRewriter.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ConcatProxyServlet.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/GadgetRenderingServlet.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/ProxyServlet.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/RpcServlet.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/DefaultTemplateProcessor.java
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/UriUtils.java
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/OAuthRequestTest.java
shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/oauth/OAuthResponseParamsTest.java
shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/eclipselink/Bootstrap.java
shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/hibernate/Bootstrap.java
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/opensocial/util/XSDValidator.java
Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java (original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java Wed Dec 8 20:49:04 2010
@@ -21,6 +21,7 @@ import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.servlet.InjectedFilter;
import java.io.BufferedReader;
@@ -56,12 +57,13 @@ public class AuthenticationServletFilter
// At some point change this to a container specific realm
private static final String realm = "shindig";
-
+
private List<AuthenticationHandler> handlers;
- private static final Logger LOG = Logger.getLogger(
- AuthenticationServletFilter.class.getName());
-
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.auth.AuthenticationServletFilter";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
+
@Inject
public void setAuthenticationHandlers(List<AuthenticationHandler> handlers) {
this.handlers = handlers;
@@ -99,8 +101,11 @@ public class AuthenticationServletFilter
callChain(chain, req, resp);
} catch (AuthenticationHandler.InvalidAuthenticationException iae) {
Throwable cause = iae.getCause();
- LOG.log(Level.INFO, iae.getMessage(), cause);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "doFilter", MessageKeys.ERROR_PARSING_SECURE_TOKEN, cause);
+ }
+
if (iae.getAdditionalHeaders() != null) {
for (Map.Entry<String,String> entry : iae.getAdditionalHeaders().entrySet()) {
resp.addHeader(entry.getKey(), entry.getValue());
Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCacheProvider.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCacheProvider.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCacheProvider.java (original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/common/cache/LruCacheProvider.java Wed Dec 8 20:49:04 2010
@@ -31,6 +31,8 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
+
/**
* A cache provider that always produces LRU caches.
*
@@ -44,7 +46,8 @@ import java.util.logging.Logger;
* {@code EhCacheCacheProvider}.
*/
public class LruCacheProvider implements CacheProvider {
- private static final Logger LOG = Logger.getLogger(LruCacheProvider.class.getName());
+ private static final String classname = "org.apache.shindig.common.cache.LruCacheProvider";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
private final int defaultCapacity;
private final Injector injector;
private final Map<String, Cache<?, ?>> caches = new MapMaker().makeMap();
@@ -66,13 +69,17 @@ public class LruCacheProvider implements
Key<String> guiceKey = Key.get(String.class, Names.named(key));
try {
if (injector.getBinding(guiceKey) == null) {
- LOG.warning("No LRU capacity configured for " + name);
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "getCapacity(String name)", MessageKeys.LRU_CAPACITY,new Object[] {"No",name});
+ }
} else {
String value = injector.getInstance(guiceKey);
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
- LOG.warning("Invalid LRU capacity configured for " + name);
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "getCapacity(String name)", MessageKeys.LRU_CAPACITY,new Object[] {"Invalid",name});
+ }
}
}
} catch ( ConfigurationException e ) {
Added: shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/MessageKeys.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/MessageKeys.java?rev=1043668&view=auto
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/MessageKeys.java (added)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/common/logging/i18n/MessageKeys.java Wed Dec 8 20:49:04 2010
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shindig.common.logging.i18n;
+
+/**
+ * Unique [key, value] pairs for i18n logging messages.
+ * The key is used as message key input in the log method and its value matched the key specified in the localized resource.properties file
+ */
+public interface MessageKeys {
+ public static final String MESSAGES = "org.apache.shindig.common.logging.i18n.resource";
+
+ //AuthenticationServletFilter
+ public static final String ERROR_PARSING_SECURE_TOKEN = "errorParsingSecureToken";
+ //XmlUtil
+ public static final String ERROR_PARSING_XML="commonErrorParsingXML";
+ public static final String ERROR_PARSING_EXTERNAL_ENTITIES="errorParsingExternalEntities";
+ public static final String ERROR_PARSING_EXTERNAL_DTD="errorParsingExternalDTD";
+ public static final String ERROR_PARSING_SECURE_XML="errorNotUsingSecureXML";
+ public static final String REUSE_DOC_BUILDERS="reuseDocumentBuilders";
+ public static final String NOT_REUSE_DOC_BUILDERS="notReuseDocBuilders";
+ //LruCacheProvier
+ public static final String LRU_CAPACITY="LRUCapacity";
+ //DynamicConfigProperty
+ public static final String EVAL_EL_FAILED="evalExpressionFailed";
+ //JsonContainerConfigLoader
+ public static final String READING_CONFIG="readingContainerConfig";
+ public static final String LOAD_FR_STRING="loadFromString";
+ public static final String LOAD_RESOURCES_FROM="loadResourcesFrom";
+ public static final String LOAD_FILES_FROM="loadFilesFrom";
+ //ApiServlet
+ public static final String API_SERVLET_PROTOCAL_EXCEPTION="apiServletProtocalException";
+ public static final String API_SERVLET_EXCEPTION="apiServletException";
+ //RegistryFeature
+ public static final String OVERRIDING_FEATURE="overridingFeature";
+ //XSDValidator
+ public static final String RESOLVE_RESOURCE="resolveResource";
+ public static final String FAILED_TO_VALIDATE="failedToValidate";
+
+
+ //FeatureResourceLoader
+ public static final String MISSING_FILE="missingFile";
+ public static final String UNABLE_RETRIVE_LIB="unableRetriveLib";
+ //BasicHttpFetcher
+ public static final String TIMEOUT_EXCEPTION="timeoutException";
+ public static final String EXCEPTION_OCCURRED="exceptionOccurred";
+ public static final String SLOW_RESPONSE="slowResponse";
+ //HttpResponseMetadataHelper
+ public static final String ERROR_GETTING_MD5="errorGettingMD5";
+ public static final String ERROR_PARSING_MD5="errorParsingMD5";
+ //OAuthModule
+ public static final String USING_RANDOM_KEY="usingRandomKey";
+ public static final String USING_FILE="usingFile";
+ public static final String LOAD_KEY_FILE_FROM="loadKeyFileFrom";
+ public static final String COULD_NOT_LOAD_KEY_FILE="couldNotLoadKeyFile";
+ public static final String COULD_NOT_LOAD_SIGN_KEY="couldNotLoadSignedKey";
+ public static final String FAILED_TO_INIT="failedToInit";
+ //OauthRequest
+ public static final String OAUTH_FETCH_FATAL_ERROR="oauthFetchFatalError";
+ public static final String BOGUS_EXPIRED="bogusExpired";
+ public static final String OAUTH_FETCH_ERROR_REPROMPT="oauthFetchErrorReprompt";
+ public static final String OAUTH_FETCH_UNEXPECTED_ERROR="oauthFetchUnexpectedError";
+ public static final String UNAUTHENTICATED_OAUTH="unauthenticatedOauth";
+ public static final String INVALID_OAUTH="invalidOauth";
+ //CajaCssSanitizer
+ public static final String FAILED_TO_PARSE="failedToParse";
+ public static final String UNABLE_TO_CONVERT_SCRIPT="unableToConvertScript";
+ //PipelineExecutor
+ public static final String ERROR_PRELOADING="errorPreloading";
+ //Processor
+ public static final String RENDER_BLACKLISTED_GADGET="renderBlacklistedGadget";
+ //CajaResponseRewriter
+ public static final String FAILED_TO_RETRIEVE="failedToRetrieve";
+ public static final String FAILED_TO_READ="failedToRead";
+ //DefaultServiceFetcher
+ public static final String HTTP_ERROR_FETCHING="httpErrorFetching";
+ public static final String FAILED_TO_FETCH_SERVICE="failedToFetchService";
+ public static final String FAILED_TO_PARSE_SERVICE="failedToParseService";
+ //Renderer
+ public static final String FAILED_TO_RENDER="FailedToRender";
+ //RenderingGadgetRewriter
+ public static final String UNKNOWN_FEATURES="unknownFeatures";
+ public static final String UNEXPECTED_ERROR_PRELOADING="unexpectedErrorPreloading";
+ //SanitizingResponseRewriter
+ public static final String REQUEST_TO_SANITIZE_WITHOUT_CONTENT="requestToSanitizeWithoutContent";
+ public static final String REQUEST_TO_SANITIZE_UNKNOW_CONTENT="requestToSanitizeUnknownContent";
+ public static final String UNABLE_SANITIZE_UNKNOWN_IMG="unableToSanitizeUnknownImg";
+ public static final String UNABLE_DETECT_IMG_TYPE="unableToDetectImgType";
+ //BasicImageRewriter
+ public static final String IO_ERROR_REWRITING_IMG="ioErrorRewritingImg";
+ public static final String UNKNOWN_ERROR_REWRITING_IMG="unknownErrorRewritingImg";
+ public static final String FAILED_TO_READ_IMG="failedToReadImg";
+ //CssResponseRewriter
+ public static final String CAJA_CSS_PARSE_FAILURE="cajaCssParseFailure";
+ //ImageAttributeRewriter
+ public static final String UNABLE_TO_PROCESS_IMG="unableToProcessImg";
+ public static final String UNABLE_TO_READ_RESPONSE="unableToReadResponse";
+ public static final String UNABLE_TO_FETCH_IMG="unableToFetchImg";
+ public static final String UNABLE_TO_PARSE_IMG="unableToParseImg";
+ //MutableContent
+ public static final String EXCEPTION_PARSING_CONTENT="exceptionParsingContent";
+ //PipelineDataGadgetRewriter
+ public static final String FAILED_TO_PARSE_PRELOAD="failedToParsePreload";
+ //ProxyingVisitor
+ public static final String URI_EXCEPTION_PARSING="uriExceptionParsing";
+ //TemplateRewriter
+ public static final String MALFORMED_TEMPLATE_LIB="malformedTemplateLib";
+ //CajaContentRewriter
+ public static final String CAJOLED_CACHE_CREATED="cajoledCacheCreated";
+ public static final String RETRIEVE_REFERENCE="retrieveReference";
+ public static final String UNABLE_TO_CAJOLE="unableToCajole";
+ //ConcatProxyServlet
+ public static final String CONCAT_PROXY_REQUEST_FAILED="concatProxyRequestFailed";
+ //GadgetRenderingServlet
+ public static final String MALFORMED_TTL_VALUE="malformedTtlValue";
+ //ProxyServlet
+ public static final String EMBEDED_IMG_WRONG_DOMAIN="embededImgWrongDomain";
+ //RpcServlet
+ public static final String BAD_REQUEST_400="badRequest400";
+ //DefaultTemplateProcessor
+ public static final String EL_FAILURE="elFailure";
+ //UriUtils
+ public static final String SKIP_ILLEGAL_HEADER="skipIllegalHeader";
+ //AbstractSpecFactory
+ public static final String UPDATE_SPEC_FAILURE_USE_CACHE_VERSION="updateSpecFailureUseCacheVersion";
+ public static final String UPDATE_SPEC_FAILURE_APPLY_NEG_CACHE="updateSpecFailureApplyNegCache";
+ //HashLockedDomainService
+ public static final String NO_LOCKED_DOMAIN_CONFIG="noLocakedDomainConfig";
+ //Bootstrap
+ public static final String STARTING_CONN_MANAGER_WITH="startingConnManagerWith";
+
+}
Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/common/xml/XmlUtil.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/common/xml/XmlUtil.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/common/xml/XmlUtil.java (original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/common/xml/XmlUtil.java Wed Dec 8 20:49:04 2010
@@ -17,6 +17,7 @@
*/
package org.apache.shindig.common.xml;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.uri.Uri;
import org.w3c.dom.Element;
@@ -42,7 +43,8 @@ import javax.xml.parsers.ParserConfigura
* loading of external files (xinclude, external entities, DTDs, etc.) are disabled.
*/
public final class XmlUtil {
- private static final Logger LOG = Logger.getLogger(XmlUtil.class.getName());
+ private static final String classname = "org.apache.shindig.common.xml.XmlUtil";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
// Handles xml errors so that they're not logged to stderr.
private static final ErrorHandler errorHandler = new ErrorHandler() {
public void error(SAXParseException exception) throws SAXException {
@@ -52,8 +54,9 @@ public final class XmlUtil {
throw exception;
}
public void warning(SAXParseException exception) {
- // warnings can be ignored.
- LOG.log(Level.INFO, "XmlUtil warning", exception);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "warning", MessageKeys.ERROR_PARSING_XML, exception);
+ }
}
};
@@ -90,7 +93,9 @@ public final class XmlUtil {
"http://xml.org/sax/features/external-general-entities", false);
} catch (IllegalArgumentException e) {
// Not supported by some very old parsers.
- LOG.info("XML parsers will load external general entities.");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "static block", MessageKeys.ERROR_PARSING_EXTERNAL_ENTITIES);
+ }
}
try {
@@ -98,7 +103,9 @@ public final class XmlUtil {
"http://xml.org/sax/features/external-parameter-entities", false);
} catch (IllegalArgumentException e) {
// Not supported by some very old parsers.
- LOG.info("XML parsers will load external parameter entities.");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "static block", MessageKeys.ERROR_PARSING_EXTERNAL_ENTITIES);
+ }
}
try {
@@ -106,29 +113,39 @@ public final class XmlUtil {
"http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
} catch (IllegalArgumentException e) {
// Only supported by Apache's XML parsers.
- LOG.info("XML parsers will load external DTDs.");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "static block", MessageKeys.ERROR_PARSING_EXTERNAL_DTD);
+ }
}
try {
builderFactory.setAttribute(XMLConstants.FEATURE_SECURE_PROCESSING, true);
} catch (IllegalArgumentException e) {
// Not supported by older parsers.
- LOG.info("Not using secure XML processing.");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "static block", MessageKeys.ERROR_PARSING_SECURE_XML);
+ }
}
try {
DocumentBuilder builder = builderFactory.newDocumentBuilder();
builder.reset();
canReuseBuilders = true;
- LOG.info("Reusing document builders");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "static block", MessageKeys.REUSE_DOC_BUILDERS);
+ }
} catch (UnsupportedOperationException e) {
// Only supported by newer parsers (xerces 2.8.x+ for instance).
canReuseBuilders = false;
- LOG.info("Not reusing document builders");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "static block", MessageKeys.NOT_REUSE_DOC_BUILDERS);
+ }
} catch (ParserConfigurationException e) {
// Only supported by newer parsers (xerces 2.8.x+ for instance).
canReuseBuilders = false;
- LOG.info("Not reusing document builders");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "static block", MessageKeys.NOT_REUSE_DOC_BUILDERS);
+ }
}
}
Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/config/DynamicConfigProperty.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/config/DynamicConfigProperty.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/config/DynamicConfigProperty.java (original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/config/DynamicConfigProperty.java Wed Dec 8 20:49:04 2010
@@ -18,6 +18,7 @@
*/
package org.apache.shindig.config;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.expressions.Expressions;
import java.util.logging.Level;
@@ -34,7 +35,8 @@ import javax.el.ValueExpression;
* Implements CharSequence strictly as a marker. Only toString is supported.
*/
public class DynamicConfigProperty implements CharSequence {
- private static final Logger LOG = Logger.getLogger(DynamicConfigProperty.class.getName());
+ private static final String classname = "org.apache.shindig.config.DynamicConfigProperty";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
private final ELContext context;
private final ValueExpression expression;
@@ -48,7 +50,12 @@ public class DynamicConfigProperty imple
try {
return (String) expression.getValue(context);
} catch (ELException e) {
- LOG.log(Level.WARNING, "Evaluation of " + expression.getExpressionString() + " failed", e);
+ if (LOG.isLoggable(Level.WARNING)) {
+ //log the i18n expression
+ LOG.logp(Level.WARNING, classname, "toString", MessageKeys.EVAL_EL_FAILED, new Object[] {expression.getExpressionString()});
+ //now log the stacktrace
+ LOG.logp(Level.WARNING, classname, "toString", MessageKeys.EVAL_EL_FAILED, e);
+ }
return "";
}
}
Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/config/JsonContainerConfigLoader.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/config/JsonContainerConfigLoader.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/config/JsonContainerConfigLoader.java (original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/config/JsonContainerConfigLoader.java Wed Dec 8 20:49:04 2010
@@ -23,6 +23,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.util.ResourceLoader;
import org.apache.shindig.config.ContainerConfig.Transaction;
import org.json.JSONArray;
@@ -55,7 +56,8 @@ import java.util.regex.Pattern;
*/
public class JsonContainerConfigLoader {
- private static final Logger LOG = Logger.getLogger(JsonContainerConfigLoader.class.getName());
+ private static final String classname = "org.apache.shindig.config.JsonContainerConfigLoader";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
private static final Pattern CRLF_PATTERN = Pattern.compile("[\r\n]+");
public static final char FILE_SEPARATOR = ',';
@@ -139,14 +141,18 @@ public class JsonContainerConfigLoader {
for (String location : StringUtils.split(path, FILE_SEPARATOR)) {
if (location.startsWith("res://")) {
location = location.substring(6);
- LOG.info("Loading resources from: " + location);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "loadContainers", MessageKeys.LOAD_RESOURCES_FROM, new Object[] {location});
+ }
if (path.endsWith(".txt")) {
loadResources(CRLF_PATTERN.split(ResourceLoader.getContent(location)), all);
} else {
loadResources(new String[] {location}, all);
}
} else {
- LOG.info("Loading files from: " + location);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "loadContainers", MessageKeys.LOAD_FILES_FROM, new Object[] {location});
+ }
File file = new File(location);
loadFiles(new File[] {file}, all);
}
@@ -171,7 +177,9 @@ public class JsonContainerConfigLoader {
for (File file : files) {
try {
if (file == null) continue;
- LOG.info("Reading container config: " + file.getName());
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "loadFiles", MessageKeys.READING_CONFIG, new Object[] {file.getName()});
+ }
if (file.isDirectory()) {
loadFiles(file.listFiles(), all);
} else if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".js")
@@ -202,7 +210,9 @@ public class JsonContainerConfigLoader {
throws ContainerConfigException {
try {
for (String entry : files) {
- LOG.info("Reading container config: " + entry);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "loadResources", MessageKeys.READING_CONFIG, new Object[] {entry});
+ }
String content = ResourceLoader.getContent(entry);
if (content == null || content.length() == 0)
throw new IOException("The file " + entry + "is empty");
@@ -223,7 +233,9 @@ public class JsonContainerConfigLoader {
try {
return jsonToMap(new JSONObject(json));
} catch (JSONException e) {
- LOG.warning("Trouble parsing " + json);
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "loadFromString", MessageKeys.READING_CONFIG, new Object[] {json});
+ }
throw new ContainerConfigException("Trouble parsing " + json, e);
}
}
Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/ApiServlet.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/ApiServlet.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/ApiServlet.java (original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/protocol/ApiServlet.java Wed Dec 8 20:49:04 2010
@@ -19,6 +19,7 @@ package org.apache.shindig.protocol;
import org.apache.shindig.auth.AuthInfoUtil;
import org.apache.shindig.auth.SecurityToken;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.servlet.InjectedServlet;
import org.apache.shindig.config.ContainerConfig;
import org.apache.shindig.protocol.conversion.BeanConverter;
@@ -47,8 +48,8 @@ import com.google.inject.name.Names;
* Common base class for API servlets.
*/
public abstract class ApiServlet extends InjectedServlet {
-
- private static final Logger LOG = Logger.getLogger(ApiServlet.class.getName());
+ private static final String classname = "org.apache.shindig.protocol.ApiServlet";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
protected static final String FORMAT_PARAM = "format";
protected static final String JSON_FORMAT = "json";
@@ -139,10 +140,14 @@ public abstract class ApiServlet extends
protected ResponseItem responseItemFromException(Throwable t) {
if (t instanceof ProtocolException) {
ProtocolException pe = (ProtocolException) t;
- LOG.log(Level.INFO, "Returning a response error as result of a protocol exception", pe);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "responseItemFromException", MessageKeys.API_SERVLET_PROTOCAL_EXCEPTION,pe);
+ }
return new ResponseItem(pe.getCode(), pe.getMessage(), pe.getResponse());
}
- LOG.log(Level.WARNING, "Returning a response error as result of an exception", t);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "responseItemFromException", MessageKeys.API_SERVLET_EXCEPTION,t);
+ }
return new ResponseItem(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, t.getMessage());
}
Added: shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties?rev=1043668&view=auto
==============================================================================
--- shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties (added)
+++ shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource.properties Wed Dec 8 20:49:04 2010
@@ -0,0 +1,172 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+##AuthenticationServletFilter
+errorParsingSecureToken=The input secure token or credential is malform and can not be parsed.
+
+##XmlUtil
+errorParsingXML=Error parsing the XML. This can be ignored.
+errorParsingExternalEntities=XML parsers will load external general entities.
+errorParsingExternalDTD=XML parsers will load external DTDs.
+errorNotUsingSecureXML=Not using secure XML processing.
+reuseDocumentBuilders=Reusing document builders.
+notReuseDocBuilders=Not reusing document builders.
+
+##LruCacheProvider
+LRUCapacity={0} LRU capacity configured for {1}.
+
+##DynamicConfigProperty
+evalExpressionFailed=Evaluation of {0} failed.
+
+##JsonContainerConfigLoader
+readingContainerConfig=Reading container config: {0}.
+loadFromString=Trouble parsing {0}.
+
+##JsonContainerConfigLoader, FeatureRegistry
+loadResourcesFrom=Loading resources from {0}.
+
+##JsonContainerConfigLoader, FeatureRegistry
+loadFilesFrom=Loading files from{0}
+
+##ApiServlet
+apiServletProtocalException=Returning a response error as result of a protocol exception.
+apiServletException=Returning a response error as result of a protocol exception.
+
+##FeatureRegistry
+overridingFeature=Overriding feature: {0} with definition at: {1}
+
+##FeatureResourceLoader
+missingFile=File existed before but is now missing! Name: {0}
+unableRetriveLib=Unable to retrieve remote library from: {0}
+
+##BasicHttpFetcher
+timeoutException=Timeout for {0} Exception: {1} - {2} - {3} ms
+exceptionOccurred=Got Exception fetching {0} - {1} ms
+slowResponse=Slow response from {0} {1} ms
+
+##HttpResponseMetadataHelper
+errorGettingMD5=Error getting MD5 digest, ignored
+errorParsingMD5=Error parsing MD5 string as UTF8
+
+##OAuthModule
+usingRandomKey=Using random key for OAuth client-side state encryption
+usingFile=Using file {0} for OAuth client-side state encryption
+loadKeyFileFrom=Loading OAuth signing key from {0}
+couldNotLoadKeyFile=Couldn't load key file {0}
+couldNotLoadSignedKey=Couldn''t load OAuth signing key. To create a key, run:\n openssl req -newkey rsa:1024 -days 365 -nodes -x509 -keyout testkey.pem \\\n -out testkey.pem -subj '/CN=mytestkey'\n openssl pkcs8 -in testkey.pem -out oauthkey.pem -topk8 -nocrypt -outform PEM\n\n Then edit shindig.properties and add these lines:\n {0} =<path-to-oauthkey.pem>\n {1} =mykey\n
+failedToInit=Failed to initialize OAuth consumers from {0}
+
+##OAuthRequest
+oauthFetchFatalError=OAuth fetch fatal error \n {0}
+oauthFetchErrorReprompt=OAuth fetch error, reprompting for user approval \n {0}
+bogusExpired=server returned bogus expiration \n {0}
+oauthFetchUnexpectedError=OAuth fetch unexpected fatal error \n {0}
+unauthenticatedOauth=Unauthenticated OAuth fetch \n {0}
+invalidOauth=Invalid OAuth fetch request \n {0}
+
+##CajaCssSanitizer
+failedToParse=Failed to parse stylesheet
+unableToConvertScript=Unable to convert script node to an osml tag
+
+##PipelineExecutor
+errorPreloading=Unexpected error when preloading
+
+##Processor
+renderBlacklistedGadget=Attempted to render blacklisted gadget: {0}
+
+##CajaResponseRewriter, CajaContentRewriter
+failedToRetrieve=Failed to retrieve {0}
+failedToRead=Failed to read {0}
+
+##DefaultServiceFetcher
+httpErrorFetching=HTTP Error {0} fetching service methods from endpoint {1}
+failedToFetchService=Failed to fetch services methods from endpoint {0}. Error {1}
+failedToParseService=Failed to parse services methods from endpoint {0} {1}
+
+##Renderer
+FailedToRender=Failed to render gadget {0}: {1}
+
+##RenderingGadgetRewriter
+unknownFeatures=Unknown feature(s) in extern &libs=: {0}
+unexpectedErrorPreloading=Unexpected error when preloading
+
+##SanitizingResponseRewriter
+requestToSanitizeWithoutContent=Request to sanitize without content type for{0}
+requestToSanitizeUnknownContent=Request to sanitize unknown content type {0} for {1}
+unableToSanitizeUnknownImg=Unable to sanitize unknown image type {0}
+unableToDetectImgType=Unable to detect image type for {0} for sanitized content
+
+##BasicImageRewriter
+ioErrorRewritingImg=IO Error rewriting image {0} - {1}
+unknownErrorRewritingImg=Unknown error rewriting image {0} {1}
+failedToReadImg=Failed to read image. Skipping {0} {1}
+
+##CssResponseRewriter
+cajaCssParseFailure=Caja CSS parse failure: {0} for {1}
+
+##ImageAttributeRewriter
+unableToProcessImg=Unable to process the image resource {0}
+unableToReadResponse=Unable to read reponnse for the image resource {0}
+unableToFetchImg=Unable to fetch the image resource {0}
+unableToParseImg=Unable to parse the image resource {0}
+
+##MutableContent
+exceptionParsingContent=Got GadgetException when parsing content
+
+##PipelineDataGadgetRewriter
+failedToParsePreload=Failed to parse preload in {0}
+
+##ProxyingVisitor
+uriExceptionParsing=Uri exception when parsing: {0}
+
+##TemplateRewriter
+malformedTemplateLib=Exceptions due to malformed template libraries
+
+##CajaContnetRewriter
+cajoledCacheCreated=Cajoled cache created
+retrieveReference=Retrieving: {0}
+unableToCajole=Unable to cajole gadget: {0}
+
+##ConcatProxyServlet
+concatProxyRequestFailed=Concat proxy request failed {0}
+
+##GadgetRenderingServlet
+malformedTtlValue=Bad TTL value {0} was ignored
+
+##ProxyServlet
+embededImgWrongDomain=Embed request for url {0} made to wrong domain {1}
+
+##DefaultTemplateProcessor
+elFailure=EL failure for gadget {0}: {1}
+
+##UriUtils
+skipIllegalHeader=Skipping illegal header: {0} : {1}
+
+##AbstractSpecFactory
+updateSpecFailureUseCacheVersion=Failed to update {0}. Using cached version.
+updateSpecFailureApplyNegCache=Failed to update {0}. Applying negative cache.
+
+##HashLockedDomainService
+noLocakedDomainConfig=No locked domain configuration for {0}
+
+##Bootstrap
+startingConnManagerWith=Starting connection manager with properties {0}
+
+##XSDValidator
+resolveResource=resolveResource( {0}, {1}, {2}, {3} )
+failedToValidate=Failed to validate {0}
Added: shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource_en_US.properties
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource_en_US.properties?rev=1043668&view=auto
==============================================================================
--- shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource_en_US.properties (added)
+++ shindig/trunk/java/common/src/main/resources/org/apache/shindig/common/logging/i18n/resource_en_US.properties Wed Dec 8 20:49:04 2010
@@ -0,0 +1,172 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+##AuthenticationServletFilter
+errorParsingSecureToken=The input secure token or credential is malform and can not be parsed.
+
+##XmlUtil
+errorParsingXML=Error parsing the XML. This can be ignored.
+errorParsingExternalEntities=XML parsers will load external general entities.
+errorParsingExternalDTD=XML parsers will load external DTDs.
+errorNotUsingSecureXML=Not using secure XML processing.
+reuseDocumentBuilders=Reusing document builders.
+notReuseDocBuilders=Not reusing document builders.
+
+##LruCacheProvider
+LRUCapacity={0} LRU capacity configured for {1}.
+
+##DynamicConfigProperty
+evalExpressionFailed=Evaluation of {0} failed.
+
+##JsonContainerConfigLoader
+readingContainerConfig=Reading container config: {0}.
+loadFromString=Trouble parsing {0}.
+
+##JsonContainerConfigLoader, FeatureRegistry
+loadResourcesFrom=Loading resources from {0}.
+
+##JsonContainerConfigLoader, FeatureRegistry
+loadFilesFrom=Loading files from{0}
+
+##ApiServlet
+apiServletProtocalException=Returning a response error as result of a protocol exception.
+apiServletException=Returning a response error as result of a protocol exception.
+
+##FeatureRegistry
+overridingFeature=Overriding feature: {0} with definition at: {1}
+
+##FeatureResourceLoader
+missingFile=File existed before but is now missing! Name: {0}
+unableRetriveLib=Unable to retrieve remote library from: {0}
+
+##BasicHttpFetcher
+timeoutException=Timeout for {0} Exception: {1} - {2} - {3} ms
+exceptionOccurred=Got Exception fetching {0} - {1} ms
+slowResponse=Slow response from {0} {1} ms
+
+##HttpResponseMetadataHelper
+errorGettingMD5=Error getting MD5 digest, ignored
+errorParsingMD5=Error parsing MD5 string as UTF8
+
+##OAuthModule
+usingRandomKey=Using random key for OAuth client-side state encryption
+usingFile=Using file {0} for OAuth client-side state encryption
+loadKeyFileFrom=Loading OAuth signing key from {0}
+couldNotLoadKeyFile=Couldn't load key file {0}
+couldNotLoadSignedKey=Couldn''t load OAuth signing key. To create a key, run:\n openssl req -newkey rsa:1024 -days 365 -nodes -x509 -keyout testkey.pem \\\n -out testkey.pem -subj '/CN=mytestkey'\n openssl pkcs8 -in testkey.pem -out oauthkey.pem -topk8 -nocrypt -outform PEM\n\n Then edit shindig.properties and add these lines:\n {0} =<path-to-oauthkey.pem>\n {1} =mykey\n
+failedToInit=Failed to initialize OAuth consumers from {0}
+
+##OAuthRequest
+oauthFetchFatalError=OAuth fetch fatal error \n {0}
+oauthFetchErrorReprompt=OAuth fetch error, reprompting for user approval \n {0}
+bogusExpired=server returned bogus expiration \n {0}
+oauthFetchUnexpectedError=OAuth fetch unexpected fatal error \n {0}
+unauthenticatedOauth=Unauthenticated OAuth fetch \n {0}
+invalidOauth=Invalid OAuth fetch request \n {0}
+
+##CajaCssSanitizer
+failedToParse=Failed to parse stylesheet
+unableToConvertScript=Unable to convert script node to an osml tag
+
+##PipelineExecutor
+errorPreloading=Unexpected error when preloading
+
+##Processor
+renderBlacklistedGadget=Attempted to render blacklisted gadget: {0}
+
+##CajaResponseRewriter, CajaContentRewriter
+failedToRetrieve=Failed to retrieve {0}
+failedToRead=Failed to read {0}
+
+##DefaultServiceFetcher
+httpErrorFetching=HTTP Error {0} fetching service methods from endpoint {1}
+failedToFetchService=Failed to fetch services methods from endpoint {0}. Error {1}
+failedToParseService=Failed to parse services methods from endpoint {0} {1}
+
+##Renderer
+FailedToRender=Failed to render gadget {0}: {1}
+
+##RenderingGadgetRewriter
+unknownFeatures=Unknown feature(s) in extern &libs=: {0}
+unexpectedErrorPreloading=Unexpected error when preloading
+
+##SanitizingResponseRewriter
+requestToSanitizeWithoutContent=Request to sanitize without content type for{0}
+requestToSanitizeUnknownContent=Request to sanitize unknown content type {0} for {1}
+unableToSanitizeUnknownImg=Unable to sanitize unknown image type {0}
+unableToDetectImgType=Unable to detect image type for {0} for sanitized content
+
+##BasicImageRewriter
+ioErrorRewritingImg=IO Error rewriting image {0} - {1}
+unknownErrorRewritingImg=Unknown error rewriting image {0} {1}
+failedToReadImg=Failed to read image. Skipping {0} {1}
+
+##CssResponseRewriter
+cajaCssParseFailure=Caja CSS parse failure: {0} for {1}
+
+##ImageAttributeRewriter
+unableToProcessImg=Unable to process the image resource {0}
+unableToReadResponse=Unable to read reponnse for the image resource {0}
+unableToFetchImg=Unable to fetch the image resource {0}
+unableToParseImg=Unable to parse the image resource {0}
+
+##MutableContent
+exceptionParsingContent=Got GadgetException when parsing content
+
+##PipelineDataGadgetRewriter
+failedToParsePreload=Failed to parse preload in {0}
+
+##ProxyingVisitor
+uriExceptionParsing=Uri exception when parsing: {0}
+
+##TemplateRewriter
+malformedTemplateLib=Exceptions due to malformed template libraries
+
+##CajaContnetRewriter
+cajoledCacheCreated=Cajoled cache created
+retrieveReference=Retrieving: {0}
+unableToCajole=Unable to cajole gadget: {0}
+
+##ConcatProxyServlet
+concatProxyRequestFailed=Concat proxy request failed {0}
+
+##GadgetRenderingServlet
+malformedTtlValue=Bad TTL value {0} was ignored
+
+##ProxyServlet
+embededImgWrongDomain=Embed request for url {0} made to wrong domain {1}
+
+##DefaultTemplateProcessor
+elFailure=EL failure for gadget {0}: {1}
+
+##UriUtils
+skipIllegalHeader=Skipping illegal header: {0} : {1}
+
+##AbstractSpecFactory
+updateSpecFailureUseCacheVersion=Failed to update {0}. Using cached version.
+updateSpecFailureApplyNegCache=Failed to update {0}. Applying negative cache.
+
+##HashLockedDomainService
+noLocakedDomainConfig=No locked domain configuration for {0}
+
+##Bootstrap
+startingConnManagerWith=Starting connection manager with properties {0}
+
+##XSDValidator
+resolveResource=resolveResource( {0}, {1}, {2}, {3} )
+failedToValidate=Failed to validate {0}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/AbstractSpecFactory.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/AbstractSpecFactory.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/AbstractSpecFactory.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/AbstractSpecFactory.java Wed Dec 8 20:49:04 2010
@@ -20,6 +20,7 @@ package org.apache.shindig.gadgets;
import org.apache.shindig.common.cache.Cache;
import org.apache.shindig.common.cache.SoftExpiringCache;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.common.xml.XmlException;
import org.apache.shindig.config.ContainerConfig;
@@ -38,7 +39,9 @@ import java.util.logging.Logger;
* Automatically updates objects as needed asynchronously to provide optimal throughput.
*/
public abstract class AbstractSpecFactory<T> {
- private static final Logger LOG = Logger.getLogger(AbstractSpecFactory.class.getName());
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.AbstractSpecFactory";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
private final Class<T> clazz;
private final ExecutorService executor;
private final RequestPipeline pipeline;
@@ -216,10 +219,14 @@ public abstract class AbstractSpecFactor
cache.addElement(query.specUri, newSpec, refresh);
} catch (GadgetException e) {
if (old != null) {
- LOG.log(Level.INFO, "Failed to update {0}. Using cached version.", query.specUri);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "SpecUpdater", MessageKeys.UPDATE_SPEC_FAILURE_USE_CACHE_VERSION, new Object[] {query.specUri});
+ }
cache.addElement(query.specUri, old, refresh);
} else {
- LOG.log(Level.INFO, "Failed to update {0}. Applying negative cache.", query.specUri);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "SpecUpdater", MessageKeys.UPDATE_SPEC_FAILURE_APPLY_NEG_CACHE, new Object[] {query.specUri});
+ }
cache.addElement(query.specUri, e, refresh);
}
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/HashLockedDomainService.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/HashLockedDomainService.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/HashLockedDomainService.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/HashLockedDomainService.java Wed Dec 8 20:49:04 2010
@@ -17,6 +17,7 @@
*/
package org.apache.shindig.gadgets;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.util.Base32;
import org.apache.shindig.config.ContainerConfig;
@@ -29,6 +30,7 @@ import org.apache.commons.codec.digest.D
import java.util.Collection;
import java.util.Map;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -42,7 +44,10 @@ import java.util.logging.Logger;
*/
@Singleton
public class HashLockedDomainService implements LockedDomainService, ContainerConfig.ConfigObserver {
- private static final Logger LOG = Logger.getLogger(HashLockedDomainService.class.getName());
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.HashLockedDomainService";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
+
private final boolean enabled;
private boolean lockSecurityTokens = false;
private final Map<String, String> lockedSuffixes;
@@ -72,7 +77,9 @@ public class HashLockedDomainService imp
for (String container : changed) {
String suffix = config.getString(container, LOCKED_DOMAIN_SUFFIX_KEY);
if (suffix == null) {
- LOG.warning("No locked domain configuration for " + container);
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "HashLockedDomainService", MessageKeys.NO_LOCKED_DOMAIN_CONFIG, new Object[] {container});
+ }
} else {
lockedSuffixes.put(container, suffix);
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java Wed Dec 8 20:49:04 2010
@@ -30,6 +30,7 @@ import com.google.inject.Singleton;
import com.google.inject.name.Named;
import org.apache.shindig.common.Pair;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.common.uri.UriBuilder;
import org.apache.shindig.common.util.ResourceLoader;
@@ -61,9 +62,10 @@ import java.util.logging.Level;
public class FeatureRegistry {
public static final String RESOURCE_SCHEME = "res";
public static final String FILE_SCHEME = "file";
-
- private static final Logger LOG
- = Logger.getLogger("org.apache.shindig.gadgets");
+
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.features.FeatureRegistry";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
// Map keyed by FeatureNode object created as a lookup for transitive feature deps.
private final Map<FeatureCacheKey, List<FeatureResource>> cache = new MapMaker().makeMap();
@@ -132,8 +134,9 @@ public class FeatureRegistry {
// Accommodate res:// URIs.
location = location.substring(1);
}
- LOG.info("Loading resources from: " + uriLoc.toString());
-
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "register", MessageKeys.LOAD_RESOURCES_FROM, new Object[] {uriLoc.toString()});
+ }
if (location.endsWith(".txt")) {
// Text file contains a list of other resource files to load
for (String resource : getResourceContent(location).split("[\r\n]+")) {
@@ -151,8 +154,9 @@ public class FeatureRegistry {
loadResources(resources, featureMapBuilder);
} else {
// Load files in directory structure.
- LOG.info("Loading files from: " + location);
-
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "register", MessageKeys.LOAD_FILES_FROM, new Object[] {location});
+ }
loadFile(new File(uriLoc.getPath()), featureMapBuilder);
}
}
@@ -443,7 +447,7 @@ public class FeatureRegistry {
// Duplicate feature = OK, just indicate it's being overridden.
if (featureMapBuilder.containsKey(parsed.getName())) {
if (LOG.isLoggable(Level.WARNING)) {
- LOG.warning("Overriding feature: " + parsed.getName() + " with def at: " + parent);
+ LOG.logp(Level.WARNING, classname, "doFilter", MessageKeys.OVERRIDING_FEATURE, new Object[] {parsed.getName(),parent});
}
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureResourceLoader.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureResourceLoader.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureResourceLoader.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureResourceLoader.java Wed Dec 8 20:49:04 2010
@@ -21,6 +21,7 @@ import com.google.common.base.Preconditi
import com.google.inject.Inject;
import com.google.inject.name.Named;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.common.util.ResourceLoader;
import org.apache.shindig.common.util.TimeSource;
@@ -32,14 +33,17 @@ import org.apache.shindig.gadgets.http.H
import java.io.File;
import java.io.IOException;
import java.util.Map;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Class that loads FeatureResource objects used to populate JS feature code.
*/
public class FeatureResourceLoader {
- private static final Logger LOG
- = Logger.getLogger("org.apache.shindig.gadgets");
+
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.features.FeatureResourceLoader";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
private HttpFetcher fetcher;
private TimeSource timeSource = new TimeSource();
@@ -186,7 +190,9 @@ public class FeatureResourceLoader {
lastModified = file.lastModified();
} else if (content != null) {
// Content existed before, file removed - log error.
- LOG.warning("File existed before but is now missing! Name: " + filePath);
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "get", MessageKeys.MISSING_FILE, new Object[] {filePath});
+ }
}
}
}
@@ -251,10 +257,14 @@ public class FeatureResourceLoader {
if (response.getHttpStatusCode() == HttpResponse.SC_OK) {
content = response.getResponseAsString();
} else {
- LOG.warning("Unable to retrieve remote library from " + uri);
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "getContent", MessageKeys.UNABLE_RETRIVE_LIB, new Object[] {uri});
+ }
}
} catch (GadgetException e) {
- LOG.warning("Unable to retrieve remote library from " + uri);
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "getContent", MessageKeys.UNABLE_RETRIVE_LIB, new Object[] {uri});
+ }
}
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/BasicHttpFetcher.java Wed Dec 8 20:49:04 2010
@@ -68,6 +68,7 @@ import org.apache.http.params.HttpParams
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.ByteArrayBuffer;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.gadgets.GadgetException;
@@ -110,9 +111,11 @@ public class BasicHttpFetcher implements
// mutable fields must be volatile
private volatile int maxObjSize;
private volatile long slowResponseWarning;
-
- private static final Logger LOG = Logger.getLogger(BasicHttpFetcher.class.getName());
-
+
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.http.BasicHttpFeatcher";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
+
private final Set<Class<?>> TIMEOUT_EXCEPTIONS = ImmutableSet.<Class<?>>of(ConnectionPoolTimeoutException.class,
SocketTimeoutException.class, SocketException.class, HttpHostConnectException.class, NoHttpResponseException.class,
InterruptedException.class, UnknownHostException.class);
@@ -370,12 +373,15 @@ public class BasicHttpFetcher implements
// Find timeout exceptions, respond accordingly
if (TIMEOUT_EXCEPTIONS.contains(e.getClass())) {
- LOG.info("Timeout for " + request.getUri() + " Exception: " + e.getClass().getName() + " - " + e.getMessage() + " - " + (now - started) + "ms");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "fetch", MessageKeys.TIMEOUT_EXCEPTION, new Object[] {request.getUri(),classname,e.getMessage(),now-started});
+ }
return HttpResponse.timeout();
+ }
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "fetch", MessageKeys.EXCEPTION_OCCURRED, new Object[] {request.getUri(),now-started});
+ LOG.logp(Level.INFO, classname, "fetch", "", e);
}
-
- LOG.log(Level.INFO, "Got Exception fetching " + request.getUri() + " - " + (now - started) + "ms", e);
-
// Separate shindig error from external error
throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e,
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -398,7 +404,9 @@ public class BasicHttpFetcher implements
* @param finished the time the request finished, in milliseconds.
*/
protected void slowResponseWarning(HttpRequest request, long started, long finished) {
- LOG.warning("Slow response from " + request.getUri() + ' ' + (finished - started) + "ms");
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "slowResponseWarning", MessageKeys.SLOW_RESPONSE, new Object[] {request.getUri(),finished-started});
+ }
}
/**
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponseMetadataHelper.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponseMetadataHelper.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponseMetadataHelper.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponseMetadataHelper.java Wed Dec 8 20:49:04 2010
@@ -20,12 +20,14 @@ package org.apache.shindig.gadgets.http;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.util.Base32;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -38,9 +40,10 @@ public class HttpResponseMetadataHelper
public static final String IMAGE_HEIGHT = "ImageHeight";
public static final String IMAGE_WIDTH = "ImageWidth";
- private static final Logger LOG =
- Logger.getLogger(HttpResponseMetadataHelper.class.getName());
-
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.http.HttpResponseMetadataHelperr";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
+
/**
* Return a copy of input response with additional metadata values.
* @param response source response
@@ -68,10 +71,14 @@ public class HttpResponseMetadataHelper
return new String(Base32.encodeBase32(md5val), "UTF-8");
} catch (NoSuchAlgorithmException e) {
// Should not happen
- LOG.info("Error getting MD5 digest, ignored");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "getHash", MessageKeys.ERROR_GETTING_MD5);
+ }
} catch (UnsupportedEncodingException e) {
// Should not happen
- LOG.info("Error parsing MD5 string as UTF8");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "getHash", MessageKeys.ERROR_PARSING_MD5);
+ }
}
return null;
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthModule.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthModule.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthModule.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthModule.java Wed Dec 8 20:49:04 2010
@@ -20,6 +20,7 @@ package org.apache.shindig.gadgets.oauth
import org.apache.shindig.common.crypto.BasicBlobCrypter;
import org.apache.shindig.common.crypto.BlobCrypter;
import org.apache.shindig.common.crypto.Crypto;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.util.ResourceLoader;
import org.apache.shindig.gadgets.http.HttpFetcher;
import org.apache.shindig.gadgets.oauth.BasicOAuthStoreConsumerKeyAndSecret.KeyType;
@@ -44,7 +45,10 @@ import java.util.logging.Logger;
*/
public class OAuthModule extends AbstractModule {
- private static final Logger LOG = Logger.getLogger(OAuthModule.class.getName());
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.oauth.OAuthModule";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
+
private static final String OAUTH_CONFIG = "config/oauth.json";
private static final String OAUTH_SIGNING_KEY_FILE = "shindig.signing.key-file";
@@ -73,9 +77,14 @@ public class OAuthModule extends Abstrac
throws IOException {
if (StringUtils.isBlank(stateCrypterPath)) {
LOG.info("Using random key for OAuth client-side state encryption");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "OAuthCrypterProvider constructor", MessageKeys.USING_RANDOM_KEY);
+ }
crypter = new BasicBlobCrypter(Crypto.getRandomBytes(BasicBlobCrypter.MASTER_KEY_MIN_LEN));
} else {
- LOG.info("Using file " + stateCrypterPath + " for OAuth client-side state encryption");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "OAuthCrypterProvider constructor", MessageKeys.USING_FILE, new Object[] {stateCrypterPath});
+ }
crypter = new BasicBlobCrypter(new File(stateCrypterPath));
}
}
@@ -120,26 +129,26 @@ public class OAuthModule extends Abstrac
BasicOAuthStoreConsumerKeyAndSecret key = null;
if (!StringUtils.isBlank(signingKeyFile)) {
try {
- LOG.info("Loading OAuth signing key from " + signingKeyFile);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "loadDefaultKey", MessageKeys.LOAD_KEY_FILE_FROM, new Object[] {signingKeyFile});
+ }
String privateKey = IOUtils.toString(ResourceLoader.open(signingKeyFile), "UTF-8");
privateKey = BasicOAuthStore.convertFromOpenSsl(privateKey);
key = new BasicOAuthStoreConsumerKeyAndSecret(null, privateKey, KeyType.RSA_PRIVATE,
signingKeyName, null);
} catch (Throwable t) {
- LOG.log(Level.WARNING, "Couldn't load key file " + signingKeyFile, t);
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "loadDefaultKey", MessageKeys.COULD_NOT_LOAD_KEY_FILE, new Object[] {signingKeyFile});
+ LOG.logp(Level.WARNING, classname, "loadDefaultKey", "",t);
+ }
}
}
if (key != null) {
store.setDefaultKey(key);
} else {
- LOG.log(Level.WARNING, "Couldn't load OAuth signing key. To create a key, run:\n" +
- " openssl req -newkey rsa:1024 -days 365 -nodes -x509 -keyout testkey.pem \\\n" +
- " -out testkey.pem -subj '/CN=mytestkey'\n" +
- " openssl pkcs8 -in testkey.pem -out oauthkey.pem -topk8 -nocrypt -outform PEM\n" +
- '\n' +
- "Then edit shindig.properties and add these lines:\n" +
- OAUTH_SIGNING_KEY_FILE + "=<path-to-oauthkey.pem>\n" +
- OAUTH_SIGNING_KEY_NAME + "=mykey\n");
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "loadDefaultKey", MessageKeys.COULD_NOT_LOAD_SIGN_KEY, new Object[] {OAUTH_SIGNING_KEY_FILE,OAUTH_SIGNING_KEY_NAME});
+ }
}
}
@@ -148,7 +157,10 @@ public class OAuthModule extends Abstrac
String oauthConfigString = ResourceLoader.getContent(OAUTH_CONFIG);
store.initFromConfigString(oauthConfigString);
} catch (Throwable t) {
- LOG.log(Level.WARNING, "Failed to initialize OAuth consumers from " + OAUTH_CONFIG, t);
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "loadConsumers", MessageKeys.FAILED_TO_INIT, new Object[] {OAUTH_CONFIG});
+ LOG.log(Level.WARNING, "", t);
+ }
}
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthRequest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthRequest.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthRequest.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthRequest.java Wed Dec 8 20:49:04 2010
@@ -34,6 +34,7 @@ import org.apache.commons.lang.StringUti
import org.apache.shindig.auth.OAuthConstants;
import org.apache.shindig.auth.OAuthUtil;
import org.apache.shindig.common.crypto.Crypto;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.common.uri.UriBuilder;
import org.apache.shindig.common.util.CharsetUtil;
@@ -52,6 +53,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.regex.Pattern;
/**
@@ -72,6 +75,9 @@ import java.util.regex.Pattern;
*/
public class OAuthRequest {
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.oauth.OAuthRequest";
+
// Maximum number of attempts at the protocol before giving up.
private static final int MAX_ATTEMPTS = 2;
@@ -178,7 +184,7 @@ public class OAuthRequest {
return fetchNoThrow();
} catch (RuntimeException e) {
// We log here to record the request/response pairs that created the failure.
- responseParams.logDetailedWarning("OAuth fetch unexpected fatal error", e);
+ responseParams.logDetailedWarning(classname,"fetch",MessageKeys.OAUTH_FETCH_UNEXPECTED_ERROR, e);
throw e;
}
}
@@ -198,11 +204,11 @@ public class OAuthRequest {
} catch (OAuthRequestException e) {
// No data for us.
if (OAuthError.UNAUTHENTICATED.name().equals(e.getError())) {
- responseParams.logDetailedInfo("Unauthenticated OAuth fetch", e);
+ responseParams.logDetailedInfo(classname,"fetchNoThrow",MessageKeys.UNAUTHENTICATED_OAUTH, e);
} else if (OAuthError.BAD_OAUTH_TOKEN_URL.name().equals(e.getError())) {
- responseParams.logDetailedInfo("Invalid OAuth fetch request", e);
+ responseParams.logDetailedInfo(classname,"fetchNoThrow",MessageKeys.INVALID_OAUTH, e);
} else {
- responseParams.logDetailedWarning("OAuth fetch fatal error", e);
+ responseParams.logDetailedWarning(classname,"fetchNoThrow",MessageKeys.OAUTH_FETCH_FATAL_ERROR, e);
}
responseParams.setSendTraceToClient(true);
response = new HttpResponseBuilder()
@@ -214,10 +220,11 @@ public class OAuthRequest {
// OK, got some data back, annotate it as necessary.
if (response.getHttpStatusCode() >= 400) {
- responseParams.logDetailedWarning("OAuth fetch fatal error");
+ responseParams.logDetailedWarning(classname,"fetchNoThrow",MessageKeys.OAUTH_FETCH_FATAL_ERROR);
+
responseParams.setSendTraceToClient(true);
} else if (responseParams.getAznUrl() != null && responseParams.sawErrorResponse()) {
- responseParams.logDetailedWarning("OAuth fetch error, reprompting for user approval");
+ responseParams.logDetailedWarning(classname,"fetchNoThrow",MessageKeys.OAUTH_FETCH_ERROR_REPROMPT);
responseParams.setSendTraceToClient(true);
}
@@ -775,7 +782,7 @@ public class OAuthRequest {
} catch (NumberFormatException e) {
// Hrm. Bogus server. We can safely ignore this, we'll just wait for the server to
// tell us when the access token has expired.
- responseParams.logDetailedWarning("server returned bogus expiration");
+ responseParams.logDetailedWarning(classname,"exchangeRequestToken",MessageKeys.BOGUS_EXPIRED);
}
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/oauth/OAuthResponseParams.java Wed Dec 8 20:49:04 2010
@@ -25,6 +25,7 @@ import org.apache.shindig.auth.SecurityT
import org.apache.shindig.common.Pair;
import org.apache.shindig.common.crypto.BlobCrypter;
import org.apache.shindig.common.crypto.BlobCrypterException;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.gadgets.http.HttpRequest;
import org.apache.shindig.gadgets.http.HttpResponse;
import org.apache.shindig.gadgets.http.HttpResponseBuilder;
@@ -97,30 +98,30 @@ public class OAuthResponseParams {
/**
* Log a warning message that includes the details of the request.
*/
- public void logDetailedWarning(String note) {
+ public void logDetailedWarning(String classname, String method, String msgKey) {
if (LOG.isLoggable(Level.FINE)) {
- LOG.log(Level.FINE, note + '\n' + getDetails(null));
+ LOG.log(Level.FINE,getDetails(null));
} else if (LOG.isLoggable(Level.WARNING)) {
- LOG.log(Level.WARNING, note);
+ LOG.logp(Level.WARNING, classname, method, msgKey, new Object[] {getDetails(null)});
}
}
/**
* Log a warning message that includes the details of the request and the thrown exception.
*/
- public void logDetailedWarning(String note, Throwable e) {
+ public void logDetailedWarning(String classname, String method, String msgKey, Throwable e) {
if (LOG.isLoggable(Level.FINE)) {
- LOG.log(Level.FINE, note + '\n' + getDetails(e), e);
+ LOG.log(Level.FINE, getDetails(e), e);
} else if (LOG.isLoggable(Level.WARNING)) {
- LOG.log(Level.WARNING, note + ": " + e.getMessage());
+ LOG.logp(Level.WARNING, classname, method, msgKey, new Object[] {e.getMessage()});
}
}
- public void logDetailedInfo(String note, Throwable e) {
+ public void logDetailedInfo(String classname, String method, String msgKey, Throwable e) {
if (LOG.isLoggable(Level.FINE)) {
- LOG.log(Level.FINE, note + '\n' + getDetails(e), e);
+ LOG.log(Level.FINE, getDetails(e), e);
} else if (LOG.isLoggable(Level.INFO)) {
- LOG.log(Level.INFO, note + ": " + e.getMessage());
+ LOG.logp(Level.INFO, classname, method, msgKey, new Object[] {e.getMessage()});
}
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/GadgetHtmlParser.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/GadgetHtmlParser.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/GadgetHtmlParser.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/GadgetHtmlParser.java Wed Dec 8 20:49:04 2010
@@ -24,6 +24,7 @@ import com.google.inject.Provider;
import org.apache.shindig.common.cache.Cache;
import org.apache.shindig.common.cache.CacheProvider;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.util.HashUtil;
import org.apache.shindig.gadgets.GadgetException;
import org.apache.shindig.gadgets.parse.nekohtml.NekoSimplifiedHtmlParser;
@@ -38,6 +39,7 @@ import org.w3c.dom.NodeList;
import java.io.IOException;
import java.util.LinkedList;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -46,7 +48,10 @@ import java.util.logging.Logger;
@ImplementedBy(NekoSimplifiedHtmlParser.class)
public abstract class GadgetHtmlParser {
- private static final Logger LOG = Logger.getLogger(GadgetHtmlParser.class.getName());
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.parse.GadgetHtmlParser";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
+
public static final String PARSED_DOCUMENTS = "parsedDocuments";
public static final String PARSED_FRAGMENTS = "parsedFragments";
@@ -323,7 +328,9 @@ public abstract class GadgetHtmlParser {
next.getAttributes(), sb, /*withXmlClose*/ false);
} catch (IOException e) {
- LOG.info("Unable to convert script node to an osml tag");
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "reprocessScriptForOpenSocial", MessageKeys.UNABLE_TO_CONVERT_SCRIPT);
+ }
}
NodeList scriptKids = next.getChildNodes();
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/caja/CajaCssSanitizer.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/caja/CajaCssSanitizer.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/caja/CajaCssSanitizer.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/parse/caja/CajaCssSanitizer.java Wed Dec 8 20:49:04 2010
@@ -18,6 +18,7 @@
package org.apache.shindig.gadgets.parse.caja;
import com.google.common.base.Strings;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.gadgets.GadgetContext;
import org.apache.shindig.gadgets.GadgetException;
@@ -51,9 +52,10 @@ import java.util.logging.Logger;
* - Force @url references to have the HTTP/HTTPS protocol
*/
public class CajaCssSanitizer {
-
- private static final Logger LOG = Logger.getLogger(CajaCssSanitizer.class.getName());
-
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.parse.caja.CajaCssSanitizer";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
+
private static final Set<String> ALLOWED_URI_SCHEMES = ImmutableSet.of("http", "https");
private final CajaCssParser parser;
@@ -84,7 +86,10 @@ public class CajaCssSanitizer {
return parser.serialize(stylesheet);
} catch (GadgetException ge) {
// Failed to parse stylesheet so log and continue
- LOG.log(Level.INFO, "Failed to parse stylesheet", ge);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "sanitize", MessageKeys.FAILED_TO_PARSE);
+ LOG.log(Level.INFO, ge.getMessage(), ge);
+ }
return "";
}
}
@@ -108,7 +113,10 @@ public class CajaCssSanitizer {
content = parser.serialize(stylesheet);
} catch (GadgetException ge) {
// Failed to parse stylesheet so log and continue
- LOG.log(Level.INFO, "Failed to parse stylesheet", ge);
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "sanitize", MessageKeys.FAILED_TO_PARSE);
+ LOG.log(Level.INFO, ge.getMessage(), ge);
+ }
}
if (Strings.isNullOrEmpty(content)) {
// Remove the owning node
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/preload/PipelineExecutor.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/preload/PipelineExecutor.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/preload/PipelineExecutor.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/preload/PipelineExecutor.java Wed Dec 8 20:49:04 2010
@@ -19,6 +19,7 @@
package org.apache.shindig.gadgets.preload;
import org.apache.shindig.common.JsonUtil;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.expressions.Expressions;
import org.apache.shindig.expressions.RootELResolver;
import org.apache.shindig.gadgets.GadgetContext;
@@ -45,7 +46,10 @@ import com.google.inject.Inject;
public class PipelineExecutor {
// TODO: support configuration
private static final int MAX_BATCH_COUNT = 3;
- private static final Logger LOG = Logger.getLogger(PipelineExecutor.class.getName());
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.preload.PipelineExecutor";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
+
private final PipelinedDataPreloader preloader;
private final PreloaderService preloaderService;
@@ -145,7 +149,10 @@ public class PipelineExecutor {
}
} catch (PreloadException pe) {
// This will be thrown in the event of some unexpected exception. We can move on.
- LOG.log(Level.WARNING, "Unexpected error when preloading", pe);
+ if (LOG.isLoggable(Level.WARNING)) {
+ LOG.logp(Level.WARNING, classname, "execute", MessageKeys.ERROR_PRELOADING);
+ LOG.log(Level.WARNING, "", pe);
+ }
}
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/process/Processor.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/process/Processor.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/process/Processor.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/process/Processor.java Wed Dec 8 20:49:04 2010
@@ -17,6 +17,7 @@
*/
package org.apache.shindig.gadgets.process;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.config.ContainerConfig;
import org.apache.shindig.gadgets.Gadget;
@@ -32,6 +33,7 @@ import org.apache.shindig.gadgets.variab
import com.google.inject.Inject;
import com.google.inject.Singleton;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletResponse;
@@ -41,7 +43,9 @@ import javax.servlet.http.HttpServletRes
*/
@Singleton
public class Processor {
- private static final Logger LOG = Logger.getLogger(Processor.class.getName());
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.oauth.Processor";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
private final GadgetSpecFactory gadgetSpecFactory;
private final VariableSubstituter substituter;
private final ContainerConfig containerConfig;
@@ -81,7 +85,9 @@ public class Processor {
}
if (blacklist.isBlacklisted(context.getUrl())) {
- LOG.info("Attempted to render blacklisted gadget: " + context.getUrl());
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "process", MessageKeys.RENDER_BLACKLISTED_GADGET, new Object[] {context.getUrl()});
+ }
throw new ProcessingException("The requested gadget is unavailable",
HttpServletResponse.SC_FORBIDDEN);
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/CajaResponseRewriter.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/CajaResponseRewriter.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/CajaResponseRewriter.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/CajaResponseRewriter.java Wed Dec 8 20:49:04 2010
@@ -49,6 +49,7 @@ import com.google.caja.reporting.SimpleM
import com.google.inject.Inject;
import org.apache.commons.io.IOUtils;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.gadgets.Gadget;
import org.apache.shindig.gadgets.GadgetException;
@@ -65,6 +66,7 @@ import org.apache.shindig.gadgets.uri.Pr
import java.io.IOException;
import java.io.StringReader;
import java.util.Map;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -73,8 +75,10 @@ import java.util.logging.Logger;
* @since 2.0.0
*/
public class CajaResponseRewriter implements ResponseRewriter {
- private static final Logger LOG = Logger.getLogger(CajaResponseRewriter.class.getName());
-
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.render.CajaResponseRewriter";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
+
private final RequestPipeline requestPipeline;
@Inject
@@ -190,10 +194,14 @@ public class CajaResponseRewriter implem
return FetchedData.fromBytes(responseBytes, mimeType, response.getEncoding(),
new InputSource(ref.getUri()));
} catch (GadgetException e) {
- LOG.info("Failed to retrieve: " + ref.toString());
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "proxyFetcher", MessageKeys.FAILED_TO_RETRIEVE, new Object[] {ref.toString()});
+ }
return null;
} catch (IOException e) {
- LOG.info("Failed to read: " + ref.toString());
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.logp(Level.INFO, classname, "proxyFetcher", MessageKeys.FAILED_TO_READ, new Object[] {ref.toString()});
+ }
return null;
}
}
Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultServiceFetcher.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultServiceFetcher.java?rev=1043668&r1=1043667&r2=1043668&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultServiceFetcher.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/DefaultServiceFetcher.java Wed Dec 8 20:49:04 2010
@@ -25,6 +25,7 @@ import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.apache.shindig.common.logging.i18n.MessageKeys;
import org.apache.shindig.common.uri.Uri;
import org.apache.shindig.config.ContainerConfig;
import org.apache.shindig.gadgets.GadgetException;
@@ -48,7 +49,9 @@ import com.google.inject.Inject;
*/
public class DefaultServiceFetcher {
- static final Logger logger = Logger.getLogger(Renderer.class.getName());
+ //class name for logging purpose
+ private static final String classname = "org.apache.shindig.gadgets.render.DefaultServiceFetcher";
+ private static final Logger LOG = Logger.getLogger(classname,MessageKeys.MESSAGES);
static final String JSON_RESPONSE_WRAPPER_ELEMENT = "result";
@@ -126,15 +129,18 @@ public class DefaultServiceFetcher {
if (response.getHttpStatusCode() == HttpResponse.SC_OK) {
return getServicesFromJsonResponse(response.getResponseAsString());
} else {
- logger.log(Level.SEVERE, "HTTP Error " + response.getHttpStatusCode() +
- " fetching service methods from endpoint " + endpoint);
+ if (LOG.isLoggable(Level.SEVERE)) {
+ LOG.logp(Level.SEVERE, classname, "retrieveServices", MessageKeys.HTTP_ERROR_FETCHING, new Object[] {response.getHttpStatusCode(),endpoint});
+ }
}
} catch (GadgetException ge) {
- logger.log(Level.SEVERE, "Failed to fetch services methods from endpoint " + endpoint +
- ". Error " + ge.getMessage());
+ if (LOG.isLoggable(Level.SEVERE)) {
+ LOG.logp(Level.SEVERE, classname, "retrieveServices", MessageKeys.FAILED_TO_FETCH_SERVICE, new Object[] {endpoint,ge.getMessage()});
+ }
} catch (JSONException je) {
- logger.log(Level.SEVERE, "Failed to parse services methods from endpoint " + endpoint +
- ". " + je.getMessage());
+ if (LOG.isLoggable(Level.SEVERE)) {
+ LOG.logp(Level.SEVERE, classname, "retrieveServices", MessageKeys.FAILED_TO_PARSE_SERVICE, new Object[] {endpoint,je.getMessage()});
+ }
}
return ImmutableSet.of();
}