DominikSuess commented on a change in pull request #32:
URL: 
https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/32#discussion_r520572507



##########
File path: 
src/main/java/org/apache/sling/feature/cpconverter/handlers/XmlConfigurationEntryHandler.java
##########
@@ -65,13 +74,77 @@ protected void onJcrRootElement(String uri, String 
localName, String qName, Attr
 
                     if (attributeValue != null && !attributeValue.isEmpty()) {
                         DocViewProperty property = 
DocViewProperty.parse(attributeQName, attributeValue);
-
+                        Object value = property.values;
+                        List<String> strValues = 
Arrays.asList(property.values);
+                        switch (property.type) {
+                            case PropertyType.DATE:
+                                // Date was never properly supported as osgi 
configs don't support dates so converting to millis 
+                                // Scenario should just be theoretical
+                                attributeQName += ":Long";
+                                value = Lists.transform(strValues, new 
Function<String, Long>() {
+                                   public Long apply(String s) {
+                                      Long res = null;
+                                      if (s != null) {
+                                           Calendar cal = ISO8601.parse(s);
+                                           if (cal != null) {
+                                               res = cal.getTimeInMillis();
+                                           }
+                                      } 
+                                      return res;
+                                   }
+                                }).toArray();
+                                break;
+                            case PropertyType.DOUBLE:
+                                attributeQName += ":Double";
+                                value = Lists.transform(strValues, new 
Function<String, Double>() {
+                                   public Double apply(String s) {
+                                      Double res = null;
+                                      try {
+                                          res = Double.parseDouble(s);
+                                      } catch ( NumberFormatException ex ){
+                                          // ignore as nonexisting

Review comment:
       @rombert ok - in theory they shouldn't exist but yes you are right if 
somebody crafted  a broken vault package that may happen - I can make this 
throw an exception.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to