Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

MODE-1789 #674

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants

Execute match() not only when assertions are enabled

MODE-1789
Execute {code}match(){code} not only in debug mode

Please change the exception type to IllegalArgumentException and the message to smth. like: "The expression" + pathExpression + " is not a valid projection expression".

Other than that, the fix is good.

@rhauch rhauch and 1 other commented on an outdated diff Feb 7, 2013

...n/java/org/modeshape/jcr/RepositoryConfiguration.java
- assert expressionMatcher.matches();
-
- workspaceName = expressionMatcher.group(1);
- projectedPath = expressionMatcher.group(2);
- if (projectedPath.endsWith("/") && projectedPath.length() > 1) {
- projectedPath = projectedPath.substring(0, projectedPath.length() - 1);
+ if (expressionMatcher.matches()){
+
+ workspaceName = expressionMatcher.group(1);
+ projectedPath = expressionMatcher.group(2);
+ if (projectedPath.endsWith("/") && projectedPath.length() > 1) {
+ projectedPath = projectedPath.substring(0, projectedPath.length() - 1);
+ }
+ externalPath = expressionMatcher.group(7);
+ }else{
+ throw new IllegalStateException("No match found!");
@rhauch

rhauch Feb 7, 2013

Contributor

Actually, all exception messages need to be internationalized. The steps are pretty straightforward:

  1. Add a new line in the JcrI18n.properties file, following the pattern that the key is some short-form of the actual English message (e.g., "projectionExpressionIsInvalid") and the value is the English message with variables (e.g., {0} and {1}) where values are to be inserted at runtime (e.g., "The projection expression '{0}' does not match the expected format")

  2. Add a new static final field in the JcrI18n.java class that creates an I18n object with the same key used in the file.

  3. Change the line above to use it, much like [other places|https://github.com/ModeShape/modeshape/blob/master/modeshape-jcr/src/main/java/org/modeshape/jcr/RepositoryConfiguration.java#L1177] in the same class:

    throw new IllegalStateException(JcrI18n.projectionExpressionIsInvalid.text(pathExpression));

Would you mind making this changes in your pull-request?

@eshevchenko

eshevchenko Feb 7, 2013

Certainly, I will do it.

MODE-1789
Exception messages was internationalized
Contributor

rhauch commented Feb 7, 2013

Rebased and merged into the 'master' branch and cherry-picked into the '3.1.x' branch.

@rhauch rhauch closed this Feb 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment