You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2013/04/16 12:29:55 UTC
svn commit: r1468351 - in /sling/trunk/bundles/servlets/post/src:
main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerAutotypeTest.java
Author: bdelacretaz
Date: Tue Apr 16 10:29:55 2013
New Revision: 1468351
URL: http://svn.apache.org/r1468351
Log:
SLING-2775 - make sure auto properties have jcr: equivalents
Added:
sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerAutotypeTest.java (with props)
Modified:
sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java?rev=1468351&r1=1468350&r2=1468351&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java Tue Apr 16 10:29:55 2013
@@ -87,7 +87,13 @@ public class SlingPropertyValueHandler {
this.referenceParser = referenceParser;
this.changes = changes;
}
-
+
+ /** Return the AutoType for a given property name
+ * @return null if not found
+ * */
+ static AutoType getAutoType(String propertyName) {
+ return AUTO_PROPS.get(propertyName);
+ }
/**
* Set property on given node, with some automatic values when user provides
@@ -124,7 +130,7 @@ public class SlingPropertyValueHandler {
// avoid collision with protected properties
final boolean isNew = (mod.node != null ? mod.node.isNew() : true);
try {
- switch (AUTO_PROPS.get(name)) {
+ switch (getAutoType(name)) {
case CREATED:
if (isNew) {
setCurrentDate(mod, name);
Added: sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerAutotypeTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerAutotypeTest.java?rev=1468351&view=auto
==============================================================================
--- sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerAutotypeTest.java (added)
+++ sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerAutotypeTest.java Tue Apr 16 10:29:55 2013
@@ -0,0 +1,41 @@
+/*
+ * 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.sling.servlets.post.impl.helper;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+/** Verify the AutoType values of property names for which
+ * we automatically set values.
+ */
+public class SlingPropertyValueHandlerAutotypeTest {
+ private void assertAlias(String propertyNameA) {
+ final String propertyNameB = "jcr:" + propertyNameA;
+
+ assertEquals("Expecting same AutotType for " + propertyNameA + " and " + propertyNameB,
+ SlingPropertyValueHandler.getAutoType(propertyNameA),
+ SlingPropertyValueHandler.getAutoType(propertyNameB)
+ );
+ }
+ @Test
+ public void checkPropertyAliases() {
+ assertAlias("created");
+ assertAlias("createdBy");
+ assertAlias("lastModified");
+ assertAlias("lastModifiedBy");
+ }
+}
Propchange: sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerAutotypeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandlerAutotypeTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL