You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by ro...@apache.org on 2010/07/06 17:36:49 UTC
svn commit: r960918 [1/3] - in /incubator/wink/trunk:
wink-client/src/main/java/org/apache/wink/client/
wink-client/src/main/java/org/apache/wink/client/handlers/
wink-client/src/main/java/org/apache/wink/client/internal/
wink-client/src/main/java/org/...
Author: rott
Date: Tue Jul 6 15:36:47 2010
New Revision: 960918
URL: http://svn.apache.org/viewvc?rev=960918&view=rev
Log:
WINK-297: externalize all hard-coded strings for translation, ensure all key/value pairs are used, formatting is correct, add a test
Added:
incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/i18n/
incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/i18n/MessagesTest.java
Modified:
incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/ClientConfig.java
incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/RestClient.java
incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/BasicAuthSecurityHandler.java
incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java
incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AbstractConnectionHandler.java
incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/ClientResponseImpl.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/UriBuilderImpl.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationFileLoader.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/http/AcceptCharset.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/http/AcceptEncoding.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/DefaultLifecycleManager.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/LifecycleManagerUtils.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/model/ModelUtils.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FileProvider.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/SourceProvider.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/AcceptEncodingHeaderDelegate.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CacheControlHeaderDelegate.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/DateHeaderDelegate.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/EntityTagHeaderDelegate.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/MediaTypeHeaderDelegate.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/NewCookieHeaderDelegate.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/InjectableFactory.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/ValueConvertor.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ProviderMetadataCollector.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/registry/metadata/ResourceMetadataCollector.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/uritemplate/JaxRsUriTemplateProcessor.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/uritemplate/UriTemplateProcessor.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/utils/GenericsUtils.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/utils/OpenSearchUtils.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/utils/UriHelper.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/app/AppCategories.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/app/AppService.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/atom/AtomContent.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/atom/AtomFeed.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/multipart/OutPart.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/opensearch/OpenSearchDescription.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/rss/RssChannel.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/rss/RssEnclosure.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/rss/RssFeed.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/rss/RssItem.java
incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/utils/ProviderUtils.java
incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties
incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java
incubator/wink/trunk/wink-providers/wink-json-provider/src/main/java/org/apache/wink/providers/json/JsonArrayProvider.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/DeploymentConfiguration.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/RequestProcessor.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/application/ApplicationProcessor.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/RequestImpl.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/contexts/ServerMediaTypeCharsetAdjuster.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FindRootResourceHandler.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/FlushResultHandler.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/handlers/PopulateResponseMediaTypeHandler.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRecordFactory.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ResourceRegistry.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/registry/ServletContextAccessor.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/AdminServlet.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestFilter.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/RestServlet.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/contentencode/ContentEncodingRequestFilter.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/servlet/contentencode/ContentEncodingResponseFilter.java
incubator/wink/trunk/wink-server/src/main/java/org/apache/wink/server/internal/utils/ServletFileLoader.java
Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/ClientConfig.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/ClientConfig.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/ClientConfig.java (original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/ClientConfig.java Tue Jul 6 15:36:47 2010
@@ -63,11 +63,11 @@ public class ClientConfig implements Clo
private boolean loadWinkApplications = true;
private static final String WINK_CLIENT_CONNECTTIMEOUT =
- "wink.client.connectTimeout";
+ "wink.client.connectTimeout"; //$NON-NLS-1$
private static final String WINK_CLIENT_READTIMEOUT =
- "wink.client.readTimeout";
+ "wink.client.readTimeout"; //$NON-NLS-1$
private static final String WINK_SUPPORT_DTD_EXPANSION =
- "wink.supportDTDEntityExpansion";
+ "wink.supportDTDEntityExpansion"; //$NON-NLS-1$
private static int WINK_CLIENT_CONNECTTIMEOUT_DEFAULT = 60000;
private static int WINK_CLIENT_READTIMEOUT_DEFAULT = 60000;
@@ -181,7 +181,7 @@ public class ClientConfig implements Clo
try {
return Integer.valueOf(getProperties().getProperty(WINK_CLIENT_CONNECTTIMEOUT)).intValue();
} catch (NumberFormatException e) {
- logger.debug("Value in properties for key " + WINK_CLIENT_CONNECTTIMEOUT + " is invalid. Reverting to default: " + WINK_CLIENT_CONNECTTIMEOUT_DEFAULT);
+ logger.debug("Value in properties for key {} is invalid. Reverting to default: {}", WINK_CLIENT_CONNECTTIMEOUT, WINK_CLIENT_CONNECTTIMEOUT_DEFAULT); //$NON-NLS-1$
getProperties().setProperty(WINK_CLIENT_CONNECTTIMEOUT, String.valueOf(WINK_CLIENT_CONNECTTIMEOUT_DEFAULT));
return getReadTimeout(); // this is safe, because it's unit tested. :)
}
@@ -211,7 +211,7 @@ public class ClientConfig implements Clo
try {
return Integer.valueOf(getProperties().getProperty(WINK_CLIENT_READTIMEOUT)).intValue();
} catch (NumberFormatException e) {
- logger.debug("Value in properties for key " + WINK_CLIENT_READTIMEOUT + " is invalid. Reverting to default: " + WINK_CLIENT_READTIMEOUT_DEFAULT);
+ logger.debug("Value in properties for key {} is invalid. Reverting to default: {}", WINK_CLIENT_READTIMEOUT, WINK_CLIENT_READTIMEOUT_DEFAULT); //$NON-NLS-1$
getProperties().setProperty(WINK_CLIENT_READTIMEOUT, String.valueOf(WINK_CLIENT_READTIMEOUT_DEFAULT));
return getReadTimeout(); // this is safe, because it's unit tested. :)
}
@@ -438,25 +438,25 @@ public class ClientConfig implements Clo
String connectTimeoutString = System.getProperty(WINK_CLIENT_CONNECTTIMEOUT, String.valueOf(WINK_CLIENT_CONNECTTIMEOUT_DEFAULT));
int toSet = Integer.parseInt(connectTimeoutString);
properties.put(WINK_CLIENT_CONNECTTIMEOUT, String.valueOf(toSet));
- logger.debug("Wink client connectTimeout default value is {}.", toSet);
+ logger.debug("Wink client connectTimeout default value is {}.", toSet); //$NON-NLS-1$
} catch (Exception e) {
- logger.debug("Error processing {} system property: {}", WINK_CLIENT_CONNECTTIMEOUT, e);
+ logger.debug("Error processing {} system property: {}", WINK_CLIENT_CONNECTTIMEOUT, e); //$NON-NLS-1$
}
try {
String readTimeoutString = System.getProperty(WINK_CLIENT_READTIMEOUT, String.valueOf(WINK_CLIENT_READTIMEOUT_DEFAULT));
int toSet = Integer.parseInt(readTimeoutString);
properties.put(WINK_CLIENT_READTIMEOUT, String.valueOf(toSet));
- logger.debug("Wink client readTimeout default value is {}.", toSet);
+ logger.debug("Wink client readTimeout default value is {}.", toSet); //$NON-NLS-1$
} catch (Exception e) {
- logger.debug("Error processing {} system property: {}", WINK_CLIENT_READTIMEOUT, e);
+ logger.debug("Error processing {} system property: {}", WINK_CLIENT_READTIMEOUT, e); //$NON-NLS-1$
}
try {
String supportDTD = System.getProperty(WINK_SUPPORT_DTD_EXPANSION, String.valueOf(WINK_CLIENT_SUPPORT_DTD_EXPANSION_DEFAULT));
boolean toSet = Boolean.valueOf(supportDTD); // require "true" or "false", not "yes" or "no" or other variants (see parseBoolean vs. valueOf javadoc)
properties.put(WINK_SUPPORT_DTD_EXPANSION, String.valueOf(toSet));
- logger.debug("Wink client readTimeout default value is {}.", String.valueOf(toSet));
+ logger.debug("Wink client readTimeout default value is {}.", String.valueOf(toSet)); //$NON-NLS-1$
} catch (Exception e) {
- logger.debug("Error processing {} system property: {}", WINK_SUPPORT_DTD_EXPANSION, e);
+ logger.debug("Error processing {} system property: {}", WINK_SUPPORT_DTD_EXPANSION, e); //$NON-NLS-1$
}
}
return properties;
Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/RestClient.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/RestClient.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/RestClient.java (original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/RestClient.java Tue Jul 6 15:36:47 2010
@@ -151,11 +151,11 @@ public class RestClient {
} catch (Exception e) {
logger.warn(Messages.getMessage("exceptionOccurredDuringClassProcessing", //$NON-NLS-1$
cls));
- logger.warn(Messages.getMessage("listExceptionDuringClassProcessing"), e);
+ logger.warn(Messages.getMessage("listExceptionDuringClassProcessing"), e); //$NON-NLS-1$
} catch (NoClassDefFoundError e) {
logger.warn(Messages.getMessage("exceptionOccurredDuringClassProcessing", //$NON-NLS-1$
cls.getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringClassProcessing"), e);
+ logger.warn(Messages.getMessage("listExceptionDuringClassProcessing"), e); //$NON-NLS-1$
}
} else {
logger.warn(Messages.getMessage("classNotAProvider", cls)); //$NON-NLS-1$
@@ -197,16 +197,16 @@ public class RestClient {
try {
providersRegistry.addProvider(obj, priority);
} catch (Exception e) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringInstanceProcessing",
+ logger.warn(Messages.getMessage("exceptionOccurredDuringInstanceProcessing", //$NON-NLS-1$
obj.getClass().getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringInstanceProcessing"), e);
+ logger.warn(Messages.getMessage("listExceptionDuringInstanceProcessing"), e); //$NON-NLS-1$
} catch (NoClassDefFoundError e) {
- logger.warn(Messages.getMessage("exceptionOccurredDuringInstanceProcessing",
+ logger.warn(Messages.getMessage("exceptionOccurredDuringInstanceProcessing", //$NON-NLS-1$
obj.getClass().getCanonicalName()));
- logger.warn(Messages.getMessage("listExceptionDuringInstanceProcessing"), e);
+ logger.warn(Messages.getMessage("listExceptionDuringInstanceProcessing"), e); //$NON-NLS-1$
}
} else {
- logger.warn(Messages.getMessage("classNotAProvider", cls));
+ logger.warn(Messages.getMessage("classNotAProvider", cls)); //$NON-NLS-1$
}
}
}
Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/BasicAuthSecurityHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/BasicAuthSecurityHandler.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/BasicAuthSecurityHandler.java (original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/handlers/BasicAuthSecurityHandler.java Tue Jul 6 15:36:47 2010
@@ -25,6 +25,7 @@ import org.apache.commons.codec.binary.B
import org.apache.wink.client.ClientAuthenticationException;
import org.apache.wink.client.ClientRequest;
import org.apache.wink.client.ClientResponse;
+import org.apache.wink.common.internal.i18n.Messages;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -112,8 +113,8 @@ public class BasicAuthSecurityHandler im
if (response.getStatusCode() == 401) {
logger
.debug("After sending request with Authorization header, still got 401 response"); //$NON-NLS-1$
- throw new ClientAuthenticationException(
- "Service failed to authenticate user: " + userid); //$NON-NLS-1$
+ throw new ClientAuthenticationException(Messages
+ .getMessage("serviceFailedToAuthenticateUser", userid)); //$NON-NLS-1$
} else {
logger.debug("Got a non-401 response, so returning response"); //$NON-NLS-1$
return response;
@@ -121,8 +122,8 @@ public class BasicAuthSecurityHandler im
} else {
logger.debug("userid and/or password were not set so throwing exception"); //$NON-NLS-1$
// no user credential available
- throw new ClientAuthenticationException(
- "Missing client authentication credential for user: " + userid); //$NON-NLS-1$
+ throw new ClientAuthenticationException(Messages
+ .getMessage("missingClientAuthenticationCredentialForUser", userid)); //$NON-NLS-1$
}
} // end if block
Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java (original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/ResourceImpl.java Tue Jul 6 15:36:47 2010
@@ -217,7 +217,8 @@ public class ResourceImpl implements Res
ClientResponse response = context.doChain(request);
int statusCode = response.getStatusCode();
if (ClientUtils.isErrorCode(statusCode)) {
- logger.debug(Messages.getMessage("clientResponseIsErrorCode", statusCode));
+ logger.debug(Messages.getMessage("clientResponseIsErrorCode", String //$NON-NLS-1$
+ .valueOf(statusCode)));
throw new ClientWebException(request, response);
}
return response;
Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AbstractConnectionHandler.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AbstractConnectionHandler.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AbstractConnectionHandler.java (original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/AbstractConnectionHandler.java Tue Jul 6 15:36:47 2010
@@ -109,9 +109,9 @@ public abstract class AbstractConnection
contentMediaType,
runtimeContext);
if (writer == null) {
- throw new RuntimeException(String
- .format(Messages.getMessage("clientNoWriterForTypeAndMediaType"), String
- .valueOf(type), contentType));
+ throw new RuntimeException(Messages.getMessage("clientNoWriterForTypeAndMediaType", //$NON-NLS-1$
+ String.valueOf(type),
+ contentType));
}
writer.writeTo(entity,
type,
Modified: incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/ClientResponseImpl.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/ClientResponseImpl.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/ClientResponseImpl.java (original)
+++ incubator/wink/trunk/wink-client/src/main/java/org/apache/wink/client/internal/handlers/ClientResponseImpl.java Tue Jul 6 15:36:47 2010
@@ -69,8 +69,7 @@ public class ClientResponseImpl extends
if (entity == null) {
return null;
}
- throw new ClassCastException(String
- .format(Messages.getMessage("clientCannotConvertEntity"),
+ throw new ClassCastException(Messages.getMessage("clientCannotConvertEntity", //$NON-NLS-1$
entity.getClass().getName(),
type.getName()));
}
@@ -120,7 +119,7 @@ public class ClientResponseImpl extends
contentMediaType,
runtimeContext);
if (reader == null) {
- throw new RuntimeException(Messages.getMessage("clientNoReaderForTypeAndMediaType",
+ throw new RuntimeException(Messages.getMessage("clientNoReaderForTypeAndMediaType", //$NON-NLS-1$
String.valueOf(type),
contentType));
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/UriBuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/UriBuilderImpl.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/UriBuilderImpl.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/UriBuilderImpl.java Tue Jul 6 15:36:47 2010
@@ -36,6 +36,7 @@ import javax.ws.rs.core.PathSegment;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriBuilderException;
+import org.apache.wink.common.internal.i18n.Messages;
import org.apache.wink.common.internal.uri.UriEncoder;
import org.apache.wink.common.internal.uritemplate.JaxRsUriTemplateProcessor;
import org.apache.wink.common.internal.utils.UriHelper;
@@ -209,7 +210,7 @@ public class UriBuilderImpl extends UriB
private void buildPath(Map<String, ? extends Object> values, StringBuilder out) {
if (logger.isDebugEnabled()) {
- logger.debug("buildPath({}, {}) entry", new Object[] {values, out, //$NON-NLS-1$
+ logger.debug("buildPath({}, {}) entry", new Object[] {values, out //$NON-NLS-1$
});
}
if (segments == null || segments.size() == 0) {
@@ -349,19 +350,20 @@ public class UriBuilderImpl extends UriB
}
return uri;
} catch (URISyntaxException e) {
- throw new IllegalArgumentException("schemeSpecificPart is invalid", e);
+ throw new IllegalArgumentException(Messages
+ .getMessage("isInvalid", "schemeSpecificPart"), e); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Set<String> names = getVariableNamesList();
if (values == null || names.size() > values.length) {
- throw new IllegalArgumentException("missing variable values");
+ throw new IllegalArgumentException(Messages.getMessage("missingVariable", "values")); //$NON-NLS-1$ //$NON-NLS-2$
}
Map<String, Object> valuesMap = new HashMap<String, Object>();
int i = 0;
for (String name : names) {
if (values[i] == null) {
- throw new IllegalArgumentException("value for variable " + name + " is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", name)); //$NON-NLS-1$
}
// put only the first occurrence of the value in the map
if (valuesMap.get(name) == null) {
@@ -376,7 +378,8 @@ public class UriBuilderImpl extends UriB
}
for (; i < values.length; ++i) {
if (values[i] == null) {
- throw new IllegalArgumentException("value argument at " + i + "index is null");
+ throw new IllegalArgumentException(Messages
+ .getMessage("valueAtIndexIsNull", String.valueOf(i))); //$NON-NLS-1$
}
}
return buildInternal(valuesMap);
@@ -401,14 +404,14 @@ public class UriBuilderImpl extends UriB
}
Set<String> names = getVariableNamesList();
if (values == null || (names.size() > values.size())) {
- throw new IllegalArgumentException("missing variable values");
+ throw new IllegalArgumentException(Messages.getMessage("missingVariable", "values")); //$NON-NLS-1$ //$NON-NLS-2$
}
logger.debug("names are {}", names); //$NON-NLS-1$
Map<String, Object> valuesMap = new HashMap<String, Object>();
for (String name : names) {
Object value = values.get(name);
if (value == null) {
- throw new IllegalArgumentException("value for variable " + name + " is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", name)); //$NON-NLS-1$
}
// put only the first occurrence of the value in the map
if (valuesMap.get(name) == null) {
@@ -450,7 +453,7 @@ public class UriBuilderImpl extends UriB
uriBuilder.fragment(this.fragment);
uriBuilder.segments(this.segments);
uriBuilder.query(this.query);
- logger.debug("clone() exit"); //$NON-NLS-1$
+ logger.debug("clone() exit returning {}", uriBuilder); //$NON-NLS-1$
return uriBuilder;
}
@@ -488,8 +491,8 @@ public class UriBuilderImpl extends UriB
@Override
public UriBuilder host(String host) throws IllegalArgumentException {
logger.debug("host({}) entry", host); //$NON-NLS-1$
- if ("".equals(host)) {
- throw new IllegalArgumentException("host is empty");
+ if ("".equals(host)) { //$NON-NLS-1$
+ throw new IllegalArgumentException(Messages.getMessage("variableIsEmpty", "host")); //$NON-NLS-1$ //$NON-NLS-2$
}
this.host = host;
logger.debug("host() exit"); //$NON-NLS-1$
@@ -503,10 +506,10 @@ public class UriBuilderImpl extends UriB
.asList(values));
}
if (name == null) {
- throw new IllegalArgumentException("name is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "name")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (values == null) {
- throw new IllegalArgumentException("values is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "values")); //$NON-NLS-1$ //$NON-NLS-2$
}
PathSegmentImpl lastSegment = getLastPathSegment();
for (Object value : values) {
@@ -539,23 +542,23 @@ public class UriBuilderImpl extends UriB
public UriBuilder path(String path) throws IllegalArgumentException {
logger.debug("path({}) entry", path); //$NON-NLS-1$
if (path == null) {
- throw new IllegalArgumentException("path is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "path")); //$NON-NLS-1$ //$NON-NLS-2$
}
- if ("".equals(path)) {
+ if ("".equals(path)) { //$NON-NLS-1$
// do nothing if there is an empty path
return this;
}
if (isFirstCall) {
- if (path.indexOf(":") != -1) {
+ if (path.indexOf(":") != -1) { //$NON-NLS-1$
// we need to parse this as scheme:scheme-specific-part#fragment
// for
// a hierarchical URI
// if a non-valid URI is passed in, the path is parsed as normal
- String[] segments = path.split(":", 2);
- if (segments.length == 2 && segments[0].length() > 0 && segments[0].indexOf("{") == -1) {
+ String[] segments = path.split(":", 2); //$NON-NLS-1$
+ if (segments.length == 2 && segments[0].length() > 0 && segments[0].indexOf("{") == -1) { //$NON-NLS-1$
String scheme = segments[0];
- segments = segments[1].split("#", 2);
+ segments = segments[1].split("#", 2); //$NON-NLS-1$
if (segments[0].length() > 0) {
String schemeSpecificPart = segments[0];
String fragment = null;
@@ -564,7 +567,7 @@ public class UriBuilderImpl extends UriB
scheme(scheme);
schemeSpecificPart(schemeSpecificPart);
fragment(fragment);
- logger.debug("replacePath() exit");
+ logger.debug("replacePath() exit"); //$NON-NLS-1$
return this;
}
}
@@ -574,10 +577,10 @@ public class UriBuilderImpl extends UriB
// strip off the authority prefix if present
String _path = path;
- if (path.startsWith("//")) {
+ if (path.startsWith("//")) { //$NON-NLS-1$
if (path.length() > 2) {
_path = path.substring(2);
- getPathSegments().add(new PathSegmentImpl("/"));
+ getPathSegments().add(new PathSegmentImpl("/")); //$NON-NLS-1$
} else {
logger.debug("path() exit"); //$NON-NLS-1$
return this;
@@ -602,12 +605,12 @@ public class UriBuilderImpl extends UriB
public UriBuilder path(Class resource) throws IllegalArgumentException {
logger.debug("path({}) entry", resource); //$NON-NLS-1$
if (resource == null) {
- throw new IllegalArgumentException("resource is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "resource")); //$NON-NLS-1$ //$NON-NLS-2$
}
isFirstCall = false;
Path pathAnnotation = ((Class<?>)resource).getAnnotation(Path.class);
if (pathAnnotation == null) {
- throw new IllegalArgumentException("resource is not annotated with Path");
+ throw new IllegalArgumentException(Messages.getMessage("resourceNotAnnotated", "Path")); //$NON-NLS-1$ //$NON-NLS-2$
}
String path = pathAnnotation.value();
logger.debug("path annotation value is {}", path); //$NON-NLS-1$
@@ -620,11 +623,11 @@ public class UriBuilderImpl extends UriB
public UriBuilder path(Method method) throws IllegalArgumentException {
logger.debug("path({}) entry", method); //$NON-NLS-1$
if (method == null) {
- throw new IllegalArgumentException("method is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "method")); //$NON-NLS-1$ //$NON-NLS-2$
}
Path pathAnnotation = method.getAnnotation(Path.class);
if (pathAnnotation == null) {
- throw new IllegalArgumentException("method is not annotated with Path");
+ throw new IllegalArgumentException(Messages.getMessage("methodNotAnnotated", "Path")); //$NON-NLS-1$ //$NON-NLS-2$
}
String path = pathAnnotation.value();
logger.debug("path method annotation is {}", path); //$NON-NLS-1$
@@ -638,10 +641,10 @@ public class UriBuilderImpl extends UriB
public UriBuilder path(Class resource, String method) throws IllegalArgumentException {
logger.debug("path({}, {}) entry", resource, method); //$NON-NLS-1$
if (resource == null) {
- throw new IllegalArgumentException("resource is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "resource")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (method == null) {
- throw new IllegalArgumentException("method is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "method")); //$NON-NLS-1$ //$NON-NLS-2$
}
Method foundMethod = null;
@@ -651,15 +654,15 @@ public class UriBuilderImpl extends UriB
Path pathAnnotation = m.getAnnotation(Path.class);
if (pathAnnotation != null) {
if (foundMethod != null) {
- throw new IllegalArgumentException(
- "more than one method with Path annotation exists");
+ throw new IllegalArgumentException(Messages
+ .getMessage("moreThanOneMethodAnnotated", "Path")); //$NON-NLS-1$ //$NON-NLS-2$
}
foundMethod = m;
}
}
}
if (foundMethod == null) {
- throw new IllegalArgumentException("no method with Path annotation exists");
+ throw new IllegalArgumentException(Messages.getMessage("noMethodAnnotated", "Path")); //$NON-NLS-1$ //$NON-NLS-2$
}
path(foundMethod);
logger.debug("path() exit"); //$NON-NLS-1$
@@ -672,7 +675,7 @@ public class UriBuilderImpl extends UriB
logger.debug("port({}) entry", port); //$NON-NLS-1$
}
if (port < -1) {
- throw new IllegalArgumentException("port is not valid");
+ throw new IllegalArgumentException(Messages.getMessage("invalidPort")); //$NON-NLS-1$
}
this.port = port;
logger.debug("port() exit"); //$NON-NLS-1$
@@ -686,16 +689,16 @@ public class UriBuilderImpl extends UriB
.asList(values));
}
if (name == null) {
- throw new IllegalArgumentException("name is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "name")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (values == null) {
- throw new IllegalArgumentException("values is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "values")); //$NON-NLS-1$ //$NON-NLS-2$
}
MultivaluedMap<String, String> query = getQuery();
logger.debug("query map is {}", query); //$NON-NLS-1$
for (Object value : values) {
if (value == null) {
- throw new IllegalArgumentException(); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "value")); //$NON-NLS-1$ //$NON-NLS-2$
}
query.add(name, value != null ? value.toString() : null);
}
@@ -730,7 +733,7 @@ public class UriBuilderImpl extends UriB
.asList(values));
}
if (name == null) {
- throw new IllegalArgumentException("name is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "name")); //$NON-NLS-1$ //$NON-NLS-2$
}
PathSegmentImpl lastPathSegment = getLastPathSegment();
if (values == null || values.length == 0) {
@@ -751,25 +754,25 @@ public class UriBuilderImpl extends UriB
logger.debug("replacePath({}) entry", path); //$NON-NLS-1$
if (isFirstCall) {
if (path == null) {
- throw new IllegalArgumentException("path is null"); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "path")); //$NON-NLS-1$ //$NON-NLS-2$
}
isFirstCall = false;
}
if (path == null) {
- logger.debug("path is null. resetting");
+ logger.debug("path is null. resetting"); //$NON-NLS-1$
reset();
- logger.debug("replacePath() exit");
+ logger.debug("replacePath() exit"); //$NON-NLS-1$
return this;
}
getPathSegments().clear();
- if (path.indexOf(":") != -1) {
+ if (path.indexOf(":") != -1) { //$NON-NLS-1$
// we need to parse this as scheme:scheme-specific-part#fragment for
// a hierarchical URI
// if a non-valid URI is passed in, the path is parsed as normal
- String[] segments = path.split(":", 2);
- if (segments.length == 2 && segments[0].length() > 0 && segments[0].indexOf("{") == -1) {
+ String[] segments = path.split(":", 2); //$NON-NLS-1$
+ if (segments.length == 2 && segments[0].length() > 0 && segments[0].indexOf("{") == -1) { //$NON-NLS-1$
String scheme = segments[0];
- segments = segments[1].split("#", 2);
+ segments = segments[1].split("#", 2); //$NON-NLS-1$
if (segments[0].length() > 0) {
String schemeSpecificPart = segments[0];
String fragment = null;
@@ -778,12 +781,12 @@ public class UriBuilderImpl extends UriB
scheme(scheme);
schemeSpecificPart(schemeSpecificPart);
fragment(fragment);
- logger.debug("replacePath() exit");
+ logger.debug("replacePath() exit"); //$NON-NLS-1$
return this;
}
}
}
- if (path != null && !"".equals(path)) {
+ if (path != null && !"".equals(path)) { //$NON-NLS-1$
path(path);
}
logger.debug("replacePath() exit"); //$NON-NLS-1$
@@ -795,7 +798,7 @@ public class UriBuilderImpl extends UriB
logger.debug("replaceQuery({}) entry", query); //$NON-NLS-1$
getQuery().clear();
if (query != null) {
- query = query.replaceAll(" ", "%20");
+ query = query.replaceAll(" ", "%20"); //$NON-NLS-1$ //$NON-NLS-2$
MultivaluedMap<String, String> queries = UriHelper.parseQuery(query);
// should values be URL encoded or query encoded?
@@ -824,7 +827,7 @@ public class UriBuilderImpl extends UriB
.asList(values));
}
if (name == null) {
- throw new IllegalArgumentException("name is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "name")); //$NON-NLS-1$ //$NON-NLS-2$
}
// remove any exiting values
getQuery().remove(name);
@@ -848,7 +851,7 @@ public class UriBuilderImpl extends UriB
public UriBuilder schemeSpecificPart(String ssp) throws IllegalArgumentException {
logger.debug("schemeSpecificPart({}) entry", ssp); //$NON-NLS-1$
if (ssp == null) {
- throw new IllegalArgumentException("schemeSpecificPart is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "ssp")); //$NON-NLS-1$ //$NON-NLS-2$
}
if (!ssp.startsWith("/")) { //$NON-NLS-1$
@@ -864,7 +867,8 @@ public class UriBuilderImpl extends UriB
// uri templates will be automatically encoded
uri = new URI(scheme, ssp, fragment);
} catch (URISyntaxException e) {
- throw new IllegalArgumentException("schemeSpecificPart is invalid", e);
+ throw new IllegalArgumentException(Messages
+ .getMessage("isInvalid", "schemeSpecificPart"), e); //$NON-NLS-1$ //$NON-NLS-2$
}
resetSchemeSpecificPart();
@@ -882,7 +886,7 @@ public class UriBuilderImpl extends UriB
if (uri.getRawPath() != null) {
String path = uri.getRawPath();
if(this.host == null && uri.getRawAuthority() != null)
- path = UriEncoder.decodeString(uri.getRawAuthority()) + "/" + path;
+ path = UriEncoder.decodeString(uri.getRawAuthority()) + "/" + path; //$NON-NLS-1$
path(UriEncoder.decodeString(path));
}
logger.debug("schemeSpecificPart() exit"); //$NON-NLS-1$
@@ -895,16 +899,17 @@ public class UriBuilderImpl extends UriB
logger.debug("segment({}) entry", (segments == null) ? null : Arrays.asList(segments)); //$NON-NLS-1$
}
if (segments == null) {
- throw new IllegalArgumentException("segments is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "segments")); //$NON-NLS-1$ //$NON-NLS-2$
}
List<PathSegment> pathSegments = getPathSegments();
for (int i = 0; i < segments.length; ++i) {
if (segments[i] == null) {
- throw new IllegalArgumentException("segment at index " + i + " is null");
+ throw new IllegalArgumentException(Messages
+ .getMessage("segmentAtIndexIsNull", String.valueOf(i))); //$NON-NLS-1$
}
- if (segments[i].contains("/")) {
- String segValue = segments[i].replace("/", "%2F");
+ if (segments[i].contains("/")) { //$NON-NLS-1$
+ String segValue = segments[i].replace("/", "%2F"); //$NON-NLS-1$ //$NON-NLS-2$
pathSegments.add(new PathSegmentImpl(segValue));
} else {
pathSegments.add(new PathSegmentImpl(segments[i]));
@@ -926,7 +931,7 @@ public class UriBuilderImpl extends UriB
public UriBuilder uri(URI uri) throws IllegalArgumentException {
logger.debug("Entering uri({})", uri); //$NON-NLS-1$
if (uri == null) {
- throw new IllegalArgumentException("uri is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "uri")); //$NON-NLS-1$ //$NON-NLS-2$
}
isFirstCall = false;
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationFileLoader.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationFileLoader.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationFileLoader.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/application/ApplicationFileLoader.java Tue Jul 6 15:36:47 2010
@@ -132,12 +132,12 @@ public class ApplicationFileLoader {
if (ResourceMetadataCollector.isStaticResource(cls) || ProviderMetadataCollector
.isProvider(cls)) {
if (logger.isDebugEnabled()) {
- logger.debug(Messages.getMessage("loadingClassToApplication", line));
+ logger.debug(Messages.getMessage("loadingClassToApplication", line)); //$NON-NLS-1$
}
classes.add(cls);
} else {
if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("classNotAResourceNorProvider", cls
+ logger.warn(Messages.getMessage("classNotAResourceNorProvider", cls //$NON-NLS-1$
.getName()));
}
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/http/AcceptCharset.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/http/AcceptCharset.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/http/AcceptCharset.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/http/AcceptCharset.java Tue Jul 6 15:36:47 2010
@@ -87,7 +87,7 @@ public class AcceptCharset {
@Override
public String toString() {
- return charset + ";q=" + qValue;
+ return charset + ";q=" + qValue; //$NON-NLS-1$
}
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/http/AcceptEncoding.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/http/AcceptEncoding.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/http/AcceptEncoding.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/http/AcceptEncoding.java Tue Jul 6 15:36:47 2010
@@ -55,7 +55,7 @@ public class AcceptEncoding {
@Override
public String toString() {
- return "ValuedEncoding(" + qValue + "," + encoding + ")";
+ return "ValuedEncoding(" + qValue + "," + encoding + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/DefaultLifecycleManager.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/DefaultLifecycleManager.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/DefaultLifecycleManager.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/DefaultLifecycleManager.java Tue Jul 6 15:36:47 2010
@@ -65,6 +65,7 @@ class DefaultLifecycleManager<T> impleme
}
public ObjectFactory<T> createObjectFactory(final Class<T> cls) {
+ logger.trace("Entry {}", cls); //$NON-NLS-1$
if (cls == null) {
throw new NullPointerException(Messages.getMessage("variableIsNull", "cls")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -76,24 +77,25 @@ class DefaultLifecycleManager<T> impleme
.getMessage("cannotCreateDefaultFactoryForDR", String.valueOf(cls))); //$NON-NLS-1$
}
+ ObjectFactory<T> ret = null;
if (ApplicationMetadataCollector.isApplication(cls)) {
// by default application subclasses are singletons
- return LifecycleManagerUtils.createSingletonObjectFactory(cls);
- }
-
- if (ProviderMetadataCollector.isProvider(cls)) {
+ ret = LifecycleManagerUtils.createSingletonObjectFactory(cls);
+ } else if (ProviderMetadataCollector.isProvider(cls)) {
// by default providers are singletons
- return LifecycleManagerUtils.createSingletonObjectFactory(cls);
- }
-
- if (ResourceMetadataCollector.isStaticResource(cls)) {
+ ret = LifecycleManagerUtils.createSingletonObjectFactory(cls);
+ } else if (ResourceMetadataCollector.isStaticResource(cls)) {
// by default resources are prototypes (created per request)
- return LifecycleManagerUtils.createPrototypeObjectFactory(cls);
+ ret = LifecycleManagerUtils.createPrototypeObjectFactory(cls);
}
- // unknown object, should never reach this code
- throw new IllegalArgumentException(Messages
- .getMessage("cannotCreateDefaultFactoryFor", String.valueOf(cls))); //$NON-NLS-1$
+ if (ret != null) {
+ logger.trace("Exit {}", ret); //$NON-NLS-1$
+ return ret;
+ } else
+ // unknown object, should never reach this code
+ throw new IllegalArgumentException(Messages
+ .getMessage("cannotCreateDefaultFactoryFor", String.valueOf(cls))); //$NON-NLS-1$
}
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/LifecycleManagerUtils.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/LifecycleManagerUtils.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/LifecycleManagerUtils.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/lifecycle/LifecycleManagerUtils.java Tue Jul 6 15:36:47 2010
@@ -77,13 +77,13 @@ public class LifecycleManagerUtils {
} else if (ApplicationMetadataCollector.isApplication(cls)) {
classMetadata = ApplicationMetadataCollector.collectMetadata(cls);
} else {
- throw new IllegalArgumentException("Cannot create factory for class " + cls);
+ throw new IllegalArgumentException(Messages.getMessage("cannotCreateFactoryForClass", cls)); //$NON-NLS-1$
}
// validate that there is a valid constructor if needed
if (validateConstructor && classMetadata.getConstructor().getConstructor() == null) {
- throw new IllegalStateException("No valid constructor found for " + cls
- .getCanonicalName());
+ throw new IllegalStateException(Messages.getMessage("noValidConstructorFoundFor", cls //$NON-NLS-1$
+ .getCanonicalName()));
}
return classMetadata;
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/model/ModelUtils.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/model/ModelUtils.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/model/ModelUtils.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/model/ModelUtils.java Tue Jul 6 15:36:47 2010
@@ -97,7 +97,7 @@ public class ModelUtils {
spf.setValidating(false);
datatypeFactory = DatatypeFactory.newInstance();
} catch (Exception e) {
- throw new RestException("Error setting up Atom JAXB utils", e);
+ throw new RestException(Messages.getMessage("errorSettingUpAtom", e)); //$NON-NLS-1$
}
}
@@ -339,9 +339,9 @@ public class ModelUtils {
return read;
}
- throw new ClassCastException("Cannot cast " + value.getClass().getName()
- + " to "
- + type.getName());
+ throw new ClassCastException(Messages.getMessage("cannotCastTo", //$NON-NLS-1$
+ value.getClass().getName(),
+ type.getName()));
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FileProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FileProvider.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FileProvider.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/FileProvider.java Tue Jul 6 15:36:47 2010
@@ -76,7 +76,7 @@ public class FileProvider implements Mes
OutputStream entityStream) throws IOException, WebApplicationException {
if (!t.canRead() || t.isDirectory()) {
if (logger.isWarnEnabled()) {
- logger.warn(Messages.getMessage("cannotUseFileAsResponse", t.getAbsoluteFile()));
+ logger.warn(Messages.getMessage("cannotUseFileAsResponse", t.getAbsoluteFile())); //$NON-NLS-1$
}
throw new WebApplicationException();
} else {
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/SourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/SourceProvider.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/SourceProvider.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/SourceProvider.java Tue Jul 6 15:36:47 2010
@@ -148,7 +148,7 @@ public abstract class SourceProvider imp
public InputSource resolveEntity(String name, String baseURI)
throws SAXException, IOException {
// we don't support entity resolution here
- throw new SAXParseException(Messages.getMessage("entityRefsNotSupported"), null, null); //$NON-NLS-1$
+ throw new SAXParseException(Messages.getMessage("entityRefsNotSupported"), null); //$NON-NLS-1$
}
});
try {
@@ -160,7 +160,7 @@ public abstract class SourceProvider imp
}
try {
// workaround for JDK5 bug that causes NPE in checking done due to above FEATURE_SECURE_PROCESSING
- documentBuilderFactory.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
+ documentBuilderFactory.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false); //$NON-NLS-1$
} catch (ParserConfigurationException e) {
// possible if not on apache parser? ignore...
}
@@ -181,7 +181,7 @@ public abstract class SourceProvider imp
Properties props = winkConfig.getProperties();
if (props != null) {
// use valueOf method to require the word "true"
- if (!Boolean.valueOf(props.getProperty("wink.supportDTDEntityExpansion"))) {
+ if (!Boolean.valueOf(props.getProperty("wink.supportDTDEntityExpansion"))) { //$NON-NLS-1$
setupDocumentBuilderToFilterDTD(dbuilder);
}
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/AbstractJAXBProvider.java Tue Jul 6 15:36:47 2010
@@ -107,11 +107,14 @@ public abstract class AbstractJAXBProvid
* creates contexts between noon and 5:00pm. So, uhhh, don't do that.
*/
private static class JAXBContextResolverKey {
+ private static final Logger logger = LoggerFactory.getLogger(JAXBContextResolverKey.class);
+
protected ContextResolver<JAXBContext> _resolver;
protected Type _type;
private int hashCode = -1;
public JAXBContextResolverKey(ContextResolver<JAXBContext> resolver, Type type) {
+ logger.debug("Constructing JAXBContextResolverKey with {} and {}", resolver, type); //$NON-NLS-1$
// resolver may be null, which is ok; we'll protect against NPEs in
// equals and hashCode overrides
_resolver = resolver;
@@ -120,20 +123,27 @@ public abstract class AbstractJAXBProvid
@Override
public boolean equals(Object o) {
+ logger.debug("equals({}) entry", o); //$NON-NLS-1$
if ((o == null) || (!(o instanceof JAXBContextResolverKey))) {
+ logger.debug("equals() exit due to null or not instance of JAXBContextResolverKey"); //$NON-NLS-1$
return false;
}
JAXBContextResolverKey obj = (JAXBContextResolverKey)o;
// check for both null or both NOT null
boolean result =
((obj._resolver == null) && (_resolver == null)) || ((obj._resolver != null) && (_resolver != null));
+ logger.debug("null check result is {}", result); //$NON-NLS-1$
// we can use hashCode() to compare _resolver
- return result && (obj.hashCode() == hashCode()) && (obj._type.equals(_type));
+ boolean finalResult = result && (obj.hashCode() == hashCode()) && (obj._type.equals(_type));
+ logger.debug("final result is {}", finalResult); //$NON-NLS-1$
+ return finalResult;
}
@Override
public int hashCode() {
+ logger.debug("hashCode() entry"); //$NON-NLS-1$
if (hashCode != -1) {
+ logger.debug("returning hashCode {}", hashCode); //$NON-NLS-1$
return hashCode;
}
if (_resolver == null) {
@@ -142,6 +152,7 @@ public abstract class AbstractJAXBProvid
hashCode = 0; // don't use _type's hashCode, as the instances
// may differ between JAXBContextResolverKey
// instances
+ logger.debug("resolver is null so returning hashCode {}", hashCode); //$NON-NLS-1$
return hashCode;
}
// Resolver instances may be unique due to the way we proxy the call
@@ -153,10 +164,12 @@ public abstract class AbstractJAXBProvid
// transaction level, rather than at the application, or worse, JVM
// level.
String resolverName = _resolver.getClass().getName();
+ logger.debug("resolverName is {}", resolverName); //$NON-NLS-1$
byte[] bytes = resolverName.getBytes();
for (int i = 0; i < bytes.length; i++) {
hashCode += bytes[i];
}
+ logger.debug("returning hashCode to be {}", hashCode); //$NON-NLS-1$
return hashCode;
}
@@ -179,11 +192,11 @@ public abstract class AbstractJAXBProvid
// JAXBContext cache can be turned off through system property
static private final String propVal =
System
- .getProperty("org.apache.wink.jaxbcontextcache");
+ .getProperty("org.apache.wink.jaxbcontextcache"); //$NON-NLS-1$
// non-final, protected only to make it unittestable
static protected boolean contextCacheOn =
!((propVal != null) && (propVal
- .equalsIgnoreCase("off")));
+ .equalsIgnoreCase("off"))); //$NON-NLS-1$
/**
* Get the unmarshaller. You must call {@link #releaseJAXBUnmarshaller(JAXBContext, Unmarshaller) to put it back
@@ -248,13 +261,13 @@ public abstract class AbstractJAXBProvid
Properties props = winkConfig.getProperties();
if (props != null) {
// use valueOf method to require the word "true"
- supportDTD = Boolean.valueOf(props.getProperty("wink.supportDTDEntityExpansion"));
+ supportDTD = Boolean.valueOf(props.getProperty("wink.supportDTDEntityExpansion")); //$NON-NLS-1$
}
}
if (!supportDTD) {
throw new XMLStreamException(Messages.getMessage("entityRefsNotSupported")); //$NON-NLS-1$
} else {
- logger.debug("DTD entity reference expansion is enabled. This may present a security risk.");
+ logger.debug("DTD entity reference expansion is enabled. This may present a security risk."); //$NON-NLS-1$
}
}
}
@@ -306,9 +319,9 @@ public abstract class AbstractJAXBProvid
try {
xmlStreamReader.close();
} catch (XMLStreamException e) {
- logger.debug("XMLStreamReader already closed.", e);
+ logger.debug("XMLStreamReader already closed.", e); //$NON-NLS-1$
} catch (RuntimeException e) {
- logger.debug("RuntimeException occurred: ", e);
+ logger.debug("RuntimeException occurred: ", e); //$NON-NLS-1$
}
}
}
@@ -464,7 +477,7 @@ public abstract class AbstractJAXBProvid
protected JAXBContext getContext(Class<?> type, Type genericType, MediaType mediaType)
throws JAXBException {
-
+ logger.debug("getContext({}, {}, {}) entry", new Object[] { type, genericType, mediaType }); //$NON-NLS-1$
ContextResolver<JAXBContext> contextResolver =
providers.getContextResolver(JAXBContext.class, mediaType);
@@ -472,11 +485,16 @@ public abstract class AbstractJAXBProvid
JAXBContextResolverKey key = null;
if (contextCacheOn) {
+ logger.debug("contextCacheOn is true"); //$NON-NLS-1$
// it's ok and safe for contextResolver to be null at this point.
// JAXBContextResolverKey can handle it
key = new JAXBContextResolverKey(contextResolver, type);
+ logger.debug("created JAXBContextResolverKey {} for ({}, {}, {})", new Object[] { key, type, genericType, mediaType }); //$NON-NLS-1$
context = jaxbContextCache.get(key);
+ logger.debug("retrieved context {}", context); //$NON-NLS-1$
if (context != null) {
+ logger.debug("retrieved context {}@{}", context.getClass().getName(), System.identityHashCode(context)); //$NON-NLS-1$
+ logger.debug("returned context {}", context); //$NON-NLS-1$
return context;
}
}
@@ -490,13 +508,17 @@ public abstract class AbstractJAXBProvid
}
if (contextCacheOn) {
+ logger.debug("put key {} and context {} into jaxbContextCache", key, context); //$NON-NLS-1$
jaxbContextCache.put(key, context);
}
+ logger.debug("returned context {}", context); //$NON-NLS-1$
+ logger.debug("retrieved context {}@{}", context.getClass().getName(), System.identityHashCode(context)); //$NON-NLS-1$
return context;
}
private JAXBContext getDefaultContext(Class<?> type, Type genericType) throws JAXBException {
+ logger.debug("getDefaultContext({}, {}) entry", type, genericType); //$NON-NLS-1$
JAXBContext context = jaxbDefaultContexts.get(type);
if (context == null) {
@@ -511,13 +533,17 @@ public abstract class AbstractJAXBProvid
// If that fails,
// we'll know
// soon enough
+ logger.debug("Using genericType to create context"); //$NON-NLS-1$
context = JAXBContext.newInstance((Class<?>)genericType);
} else {
+ logger.debug("Using type to create context"); //$NON-NLS-1$
context = JAXBContext.newInstance(type);
}
jaxbDefaultContexts.put(type, context);
}
+ logger.debug("getDefaultContext() exit returning", context); //$NON-NLS-1$
+ logger.debug("returning context {}@{}", context.getClass().getName(), System.identityHashCode(context)); //$NON-NLS-1$
return context;
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/entity/xml/JAXBXmlProvider.java Tue Jul 6 15:36:47 2010
@@ -146,6 +146,7 @@ public class JAXBXmlProvider extends Abs
try {
if (isJAXBObject(type)) {
JAXBContext context = getContext(type, genericType, mediaType);
+ logger.debug("using context {}@{} to get marshaller", context.getClass().getName(), System.identityHashCode(context)); //$NON-NLS-1$
Marshaller marshaller = getJAXBMarshaller(type, context, mediaType);
Object entityToMarshal = getEntityToMarshal(t, type);
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/AcceptEncodingHeaderDelegate.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/AcceptEncodingHeaderDelegate.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/AcceptEncodingHeaderDelegate.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/AcceptEncodingHeaderDelegate.java Tue Jul 6 15:36:47 2010
@@ -45,25 +45,25 @@ public class AcceptEncodingHeaderDelegat
List<AcceptEncoding.ValuedEncoding> vEncodings = parseAcceptEncoding(value);
for (AcceptEncoding.ValuedEncoding qEncoding : vEncodings) {
- logger.debug("Processing {} with qValue {}", qEncoding.encoding, qEncoding.qValue);
+ logger.debug("Processing {} with qValue {}", qEncoding.encoding, qEncoding.qValue); //$NON-NLS-1$
if (anyAllowed) {
- logger.debug("anyAllowed is true");
+ logger.debug("anyAllowed is true"); //$NON-NLS-1$
if (qEncoding.qValue == 0 && !qEncoding.isWildcard()) {
- logger.debug("qValue is 0 and qEncoding is not a wildcard so {} is banned",
+ logger.debug("qValue is 0 and qEncoding is not a wildcard so {} is banned", //$NON-NLS-1$
qEncoding.encoding);
banned.add(qEncoding.encoding);
}
} else {
- logger.debug("anyAllowed is still false");
+ logger.debug("anyAllowed is still false"); //$NON-NLS-1$
if (qEncoding.qValue == 0) {
- logger.debug("qValue is 0 so breaking out of loop");
+ logger.debug("qValue is 0 so breaking out of loop"); //$NON-NLS-1$
break; // gone through all acceptable languages
}
if (qEncoding.isWildcard()) {
- logger.debug("qEncoding is a wildcard so everything afterwards is allowable");
+ logger.debug("qEncoding is a wildcard so everything afterwards is allowable"); //$NON-NLS-1$
anyAllowed = true;
} else {
- logger.debug("qEncoding is not a wildcard so adding to acceptable list");
+ logger.debug("qEncoding is not a wildcard so adding to acceptable list"); //$NON-NLS-1$
acceptable.add(qEncoding.encoding);
}
}
@@ -72,16 +72,16 @@ public class AcceptEncodingHeaderDelegat
}
private List<AcceptEncoding.ValuedEncoding> parseAcceptEncoding(String acceptableEncodingValue) {
- logger.debug("parseAcceptEncoding({}) entry", acceptableEncodingValue);
+ logger.debug("parseAcceptEncoding({}) entry", acceptableEncodingValue); //$NON-NLS-1$
List<AcceptEncoding.ValuedEncoding> qEncodings =
new LinkedList<AcceptEncoding.ValuedEncoding>();
if (acceptableEncodingValue == null) {
- logger.debug("parseAcceptEncoding() exit - return empty list");
+ logger.debug("parseAcceptEncoding() exit - return empty list"); //$NON-NLS-1$
return qEncodings;
}
for (String encodingRange : acceptableEncodingValue.split(",")) { //$NON-NLS-1$
- logger.debug("Parsing encodingRange as {}", encodingRange);
+ logger.debug("Parsing encodingRange as {}", encodingRange); //$NON-NLS-1$
int semicolonIndex = encodingRange.indexOf(';');
double qValue;
String encodingSpec;
@@ -101,22 +101,22 @@ public class AcceptEncodingHeaderDelegat
qValue = 1.0d;
}
}
- logger.debug("encodingSpec before trim is {}", encodingSpec);
- logger.debug("qValue is {}", qValue);
+ logger.debug("encodingSpec before trim is {}", encodingSpec); //$NON-NLS-1$
+ logger.debug("qValue is {}", qValue); //$NON-NLS-1$
encodingSpec = encodingSpec.trim();
if (encodingSpec.length() == 0) {
// ignore empty encoding specifications
- logger.debug("ignoring empty encodingSpec");
+ logger.debug("ignoring empty encodingSpec"); //$NON-NLS-1$
continue;
} else if (encodingSpec.equals("*")) { //$NON-NLS-1$
- logger.debug("Wildcard spec so adding as wildcard");
+ logger.debug("Wildcard spec so adding as wildcard"); //$NON-NLS-1$
qEncodings.add(new AcceptEncoding.ValuedEncoding(qValue, null));
} else {
qEncodings.add(new AcceptEncoding.ValuedEncoding(qValue, encodingSpec));
}
}
Collections.sort(qEncodings, Collections.reverseOrder());
- logger.debug("parseAcceptEncoding exit() returning {}", qEncodings);
+ logger.debug("parseAcceptEncoding exit() returning {}", qEncodings); //$NON-NLS-1$
return qEncodings;
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CacheControlHeaderDelegate.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CacheControlHeaderDelegate.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CacheControlHeaderDelegate.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CacheControlHeaderDelegate.java Tue Jul 6 15:36:47 2010
@@ -26,25 +26,27 @@ import java.util.Map.Entry;
import javax.ws.rs.core.CacheControl;
import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+import org.apache.wink.common.internal.i18n.Messages;
+
public class CacheControlHeaderDelegate implements HeaderDelegate<CacheControl> {
- private static final String S_MAXAGE = "s-maxage";
- private static final String MAX_AGE = "max-age";
- private static final String PROXY_REVALIDATE = "proxy-revalidate";
- private static final String MUST_REVALIDATE = "must-revalidate";
- private static final String NO_TRANSFORM = "no-transform";
- private static final String NO_STORE = "no-store";
- private static final String NO_CACHE = "no-cache";
- private static final String PRIVATE = "private";
+ private static final String S_MAXAGE = "s-maxage"; //$NON-NLS-1$
+ private static final String MAX_AGE = "max-age"; //$NON-NLS-1$
+ private static final String PROXY_REVALIDATE = "proxy-revalidate"; //$NON-NLS-1$
+ private static final String MUST_REVALIDATE = "must-revalidate"; //$NON-NLS-1$
+ private static final String NO_TRANSFORM = "no-transform"; //$NON-NLS-1$
+ private static final String NO_STORE = "no-store"; //$NON-NLS-1$
+ private static final String NO_CACHE = "no-cache"; //$NON-NLS-1$
+ private static final String PRIVATE = "private"; //$NON-NLS-1$
public CacheControl fromString(String value) throws IllegalArgumentException {
throw new UnsupportedOperationException(
- "JAX-RS CacheControl type is designed to support only cache-response-directives");
+ Messages.getMessage("jaxrsCacheControlTypeSupport")); //$NON-NLS-1$
}
public String toString(CacheControl header) {
if (header == null)
- throw new IllegalArgumentException("CacheControl header is null");
+ throw new IllegalArgumentException(Messages.getMessage("headerIsNull", "CacheControl")); //$NON-NLS-1$ //$NON-NLS-2$
StringBuffer cacheControlHeader = new StringBuffer();
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/CookieHeaderDelegate.java Tue Jul 6 15:36:47 2010
@@ -25,39 +25,41 @@ import java.util.regex.Pattern;
import javax.ws.rs.core.Cookie;
import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+import org.apache.wink.common.internal.i18n.Messages;
+
public class CookieHeaderDelegate implements HeaderDelegate<Cookie> {
- private static Pattern whitespace = Pattern.compile("\\s");
- private static final String VERSION = "$Version";
- private static final String DOMAIN = "$Domain";
- private static final String PATH = "$Path";
+ private static Pattern whitespace = Pattern.compile("\\s"); //$NON-NLS-1$
+ private static final String VERSION = "$Version"; //$NON-NLS-1$
+ private static final String DOMAIN = "$Domain"; //$NON-NLS-1$
+ private static final String PATH = "$Path"; //$NON-NLS-1$
public Cookie fromString(String cookie) throws IllegalArgumentException {
if (cookie == null) {
- throw new IllegalArgumentException("Cookie header is null");
+ throw new IllegalArgumentException(Messages.getMessage("headerIsNull", "Cookie")); //$NON-NLS-1$ //$NON-NLS-2$
}
- String tokens[] = cookie.split("[;,]");
+ String tokens[] = cookie.split("[;,]"); //$NON-NLS-1$
if (tokens.length <= 0) {
- throw new IllegalArgumentException("Invalid Cookie " + cookie);
+ throw new IllegalArgumentException(Messages.getMessage("invalidCookie", cookie)); //$NON-NLS-1$
}
ModifiableCookie firstCookie = null;
int cookieNum = 0;
boolean versionSet = false;
for (String token : tokens) {
- String[] subTokens = token.trim().split("=", 2);
+ String[] subTokens = token.trim().split("=", 2); //$NON-NLS-1$
String name = subTokens.length > 0 ? subTokens[0] : null;
String value = subTokens.length > 1 ? subTokens[1] : null;
- if (value != null && value.startsWith("\"")
- && value.endsWith("\"")
+ if (value != null && value.startsWith("\"") //$NON-NLS-1$
+ && value.endsWith("\"") //$NON-NLS-1$
&& value.length() > 1) {
value = value.substring(1, value.length() - 1);
}
- if (!name.startsWith("$")) {
+ if (!name.startsWith("$")) { //$NON-NLS-1$
cookieNum++;
if (cookieNum > 1) {
// Return only first Cookie
@@ -74,37 +76,37 @@ public class CookieHeaderDelegate implem
} else {
if (versionSet) {
throw new IllegalArgumentException(
- "Cookie cannot contain additional $Version: " + cookie);
+ Messages.getMessage("cookieCannotContainAddlVers", cookie)); //$NON-NLS-1$
}
}
versionSet = true;
firstCookie.version = Integer.parseInt(value);
} else if (name.startsWith(PATH) && cookie != null) {
if (firstCookie == null) {
- throw new IllegalArgumentException("Cookie must start with $Version: " + cookie);
+ throw new IllegalArgumentException(Messages.getMessage("cookieMustStartWithVersion", cookie)); //$NON-NLS-1$
}
firstCookie.path = value;
} else if (name.startsWith(DOMAIN) && cookie != null) {
if (firstCookie == null) {
- throw new IllegalArgumentException("Cookie must start with $Version: " + cookie);
+ throw new IllegalArgumentException(Messages.getMessage("cookieMustStartWithVersion", cookie)); //$NON-NLS-1$
}
firstCookie.domain = value;
}
}
if (cookieNum == 0) {
- throw new IllegalArgumentException("Cookie doesn't contain NAME+VALUE: " + cookie);
+ throw new IllegalArgumentException(Messages.getMessage("cookieDoesNotContainNAMEVALUE", cookie)); //$NON-NLS-1$
}
if (firstCookie != null) {
return validateAndBuildCookie(firstCookie, cookie);
} else {
- throw new IllegalArgumentException("Failed to parse Cookie " + cookie);
+ throw new IllegalArgumentException(Messages.getMessage("failedToParseCookie", cookie)); //$NON-NLS-1$
}
}
private Cookie validateAndBuildCookie(ModifiableCookie firstCookie, String cookie) {
if (firstCookie.name == null || firstCookie.value == null) {
- throw new IllegalArgumentException("Failed to parse Cookie " + cookie);
+ throw new IllegalArgumentException(Messages.getMessage("failedToParseCookie", cookie)); //$NON-NLS-1$
}
return new Cookie(firstCookie.name, firstCookie.value, firstCookie.path,
firstCookie.domain, firstCookie.version);
@@ -113,21 +115,21 @@ public class CookieHeaderDelegate implem
public String toString(Cookie cookie) {
if (cookie == null) {
- throw new IllegalArgumentException("Cookie header is null");
+ throw new IllegalArgumentException(Messages.getMessage("headerIsNull", "Cookie")); //$NON-NLS-1$ //$NON-NLS-2$
}
StringBuilder cookieHeader = new StringBuilder();
- cookieHeader.append(VERSION + "=").append(cookie.getVersion()).append(';');
+ cookieHeader.append(VERSION + "=").append(cookie.getVersion()).append(';'); //$NON-NLS-1$
cookieHeader.append(cookie.getName()).append('=');
appendValue(cookieHeader, cookie.getValue());
if (cookie.getDomain() != null) {
- cookieHeader.append(";" + DOMAIN + "=");
+ cookieHeader.append(";" + DOMAIN + "="); //$NON-NLS-1$ //$NON-NLS-2$
appendValue(cookieHeader, cookie.getDomain());
}
if (cookie.getPath() != null) {
- cookieHeader.append(";" + PATH + "=");
+ cookieHeader.append(";" + PATH + "="); //$NON-NLS-1$ //$NON-NLS-2$
appendValue(cookieHeader, cookie.getPath());
}
return cookieHeader.toString();
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/DateHeaderDelegate.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/DateHeaderDelegate.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/DateHeaderDelegate.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/DateHeaderDelegate.java Tue Jul 6 15:36:47 2010
@@ -23,6 +23,7 @@ import java.util.Date;
import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+import org.apache.wink.common.internal.i18n.Messages;
import org.apache.wink.common.internal.utils.HttpDateParser;
/**
@@ -33,7 +34,7 @@ public class DateHeaderDelegate implemen
public Date fromString(String date) throws IllegalArgumentException {
if (date == null) {
- throw new IllegalArgumentException("Date is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "date")); //$NON-NLS-1$ //$NON-NLS-2$
}
return HttpDateParser.parseHttpDate(date);
@@ -45,7 +46,7 @@ public class DateHeaderDelegate implemen
public String toString(Date date) {
if (date == null) {
- throw new IllegalArgumentException("Date is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "date")); //$NON-NLS-1$ //$NON-NLS-2$
}
return HttpDateParser.toHttpDate(date);
}
Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/EntityTagHeaderDelegate.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/EntityTagHeaderDelegate.java?rev=960918&r1=960917&r2=960918&view=diff
==============================================================================
--- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/EntityTagHeaderDelegate.java (original)
+++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/internal/providers/header/EntityTagHeaderDelegate.java Tue Jul 6 15:36:47 2010
@@ -22,13 +22,15 @@ package org.apache.wink.common.internal.
import javax.ws.rs.core.EntityTag;
import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+import org.apache.wink.common.internal.i18n.Messages;
+
public class EntityTagHeaderDelegate implements HeaderDelegate<EntityTag> {
- private static String WEAK = "W/";
+ private static String WEAK = "W/"; //$NON-NLS-1$
public EntityTag fromString(String eTag) throws IllegalArgumentException {
if (eTag == null) {
- throw new IllegalArgumentException("Entity Tag is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "eTag")); //$NON-NLS-1$ //$NON-NLS-2$
}
// Remove leading and trailing white spaces
@@ -41,11 +43,11 @@ public class EntityTagHeaderDelegate imp
}
// Check that e-tag is quoted-string
- if (!eTag.startsWith("\"") || !eTag.endsWith("\"")) {
- if ("*".equals(eTag)) {
- return new EntityTag("*");
+ if (!eTag.startsWith("\"") || !eTag.endsWith("\"")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if ("*".equals(eTag)) { //$NON-NLS-1$
+ return new EntityTag("*"); //$NON-NLS-1$
}
- throw new IllegalArgumentException("Entity Tag " + eTag + " is not quoted properly");
+ throw new IllegalArgumentException(Messages.getMessage("entityTagNotQuoted", eTag)); //$NON-NLS-1$
}
// Remove quotes
@@ -85,12 +87,12 @@ public class EntityTagHeaderDelegate imp
public String toString(EntityTag eTag) {
if (eTag == null) {
- throw new IllegalArgumentException("Entity Tag is null");
+ throw new IllegalArgumentException(Messages.getMessage("variableIsNull", "eTag")); //$NON-NLS-1$ //$NON-NLS-2$
}
StringBuilder builder = new StringBuilder();
if (eTag.isWeak()) {
- builder.append("W/");
+ builder.append("W/"); //$NON-NLS-1$
}
builder.append('"');
String value = eTag.getValue();