myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject [myfaces-tobago] branch master updated: TOBAGO-1782: Clean up * Exception Handling * etc.
Date Thu, 30 Nov 2017 14:24:16 GMT
This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 8dc1837  TOBAGO-1782: Clean up * Exception Handling * etc.
8dc1837 is described below

commit 8dc1837905af69747b8b3d24322f46ff71bc8f21
Author: Udo Schnurpfeil <lofwyr@apache.org>
AuthorDate: Thu Nov 30 15:21:53 2017 +0100

    TOBAGO-1782: Clean up
    * Exception Handling
    * etc.
---
 .../tobago/facelets/TabChangeListenerHandler.java  |   2 +-
 .../apache/myfaces/tobago/util/MessageUtils.java   |   1 +
 .../tobago/example/data/CantorInterval.java        |   3 +-
 .../myfaces/tobago/example/data/SolarObject.java   |   8 +-
 .../tobago/example/demo/EventController.java       |   2 +-
 .../tobago/example/test/DirectoryBrowser.java      | 108 -----------------
 .../myfaces/tobago/example/test/PageItem.java      |  91 --------------
 .../tobago/example/test/TestPageFilter.java        | 132 ---------------------
 8 files changed, 9 insertions(+), 338 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeListenerHandler.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeListenerHandler.java
index 814c870..0c43a32 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeListenerHandler.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/TabChangeListenerHandler.java
@@ -74,7 +74,7 @@ public class TabChangeListenerHandler extends TagHandler {
           try {
             listener = (TabChangeListener) listenerType.newInstance();
           } catch (final Exception e) {
-            throw new TagAttributeException(tag, type, e.getCause());
+            throw new TagAttributeException(tag, type, e);
           }
           if (valueExpression != null) {
             valueExpression.setValue(faceletContext, listener);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageUtils.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageUtils.java
index a4fec60..de5e24d 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageUtils.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageUtils.java
@@ -107,6 +107,7 @@ public final class MessageUtils {
     try {
       return bundle == null ? null : bundle.getString(key);
     } catch (final MissingResourceException e) {
+      // ignore
       return null;
     }
   }
diff --git a/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/CantorInterval.java
b/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/CantorInterval.java
index 251692c..fc97c44 100644
--- a/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/CantorInterval.java
+++ b/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/CantorInterval.java
@@ -21,6 +21,7 @@ package org.apache.myfaces.tobago.example.data;
 
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.TreeNode;
+import java.io.Serializable;
 import java.math.BigInteger;
 import java.util.Enumeration;
 
@@ -90,7 +91,7 @@ public class CantorInterval extends DefaultMutableTreeNode {
     return getLabel();
   }
 
-  public static final class Fraction {
+  public static final class Fraction implements Serializable {
 
     private final BigInteger numerator;
     private final BigInteger denominator;
diff --git a/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java
b/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java
index 97ef140..9e16655 100644
--- a/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java
+++ b/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/SolarObject.java
@@ -248,11 +248,11 @@ public class SolarObject implements Serializable {
   }
 
 
-  public static final SolarObject SUN = new SolarObject("Sun", "-", "-", 0, 0.0, 0.0, 0.0,
"-", null);
-  public static final SolarObject EARTH = new SolarObject("Earth", "III", "Sun", 149600,
365.26, 0.00, 0.02, "-", null);
-  public static final SolarObject MOON = new SolarObject("Moon", "I", "Earth", 384, 27.32,
5.14, 0.05, "-", null);
+  private static final SolarObject SUN = new SolarObject("Sun", "-", "-", 0, 0.0, 0.0, 0.0,
"-", null);
+  private static final SolarObject EARTH = new SolarObject("Earth", "III", "Sun", 149600,
365.26, 0.00, 0.02, "-", null);
+  private static final SolarObject MOON = new SolarObject("Moon", "I", "Earth", 384, 27.32,
5.14, 0.05, "-", null);
 
-  public static final SolarObject[] DATA = {
+  private static final SolarObject[] DATA = {
       SUN,
       new SolarObject("Mercury", "I", "Sun", 57910, 87.97, 7.00, 0.21, "-", null),
       new SolarObject("Venus", "II", "Sun", 108200, 224.70, 3.39, 0.01, "-", null),
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/EventController.java
b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/EventController.java
index 3d31995..bc275a8 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/EventController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/EventController.java
@@ -236,7 +236,7 @@ public class EventController implements Serializable {
     return planets;
   }
 
-  public class EventsOnComponent {
+  public class EventsOnComponent implements Serializable {
     private final String tagName;
     private final Collection<String> eventNames = new TreeSet<>();
 
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/DirectoryBrowser.java
b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/DirectoryBrowser.java
deleted file mode 100644
index e402ec1..0000000
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/DirectoryBrowser.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.myfaces.tobago.example.test;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-public class DirectoryBrowser implements Serializable {
-
-  private static final Logger LOG = LoggerFactory.getLogger(DirectoryBrowser.class);
-
-  private PageItem tree;
-  private PageItem current;
-
-  public DirectoryBrowser() {
-    tree = new PageItem("/", false, false);
-    final ServletContext servletContext
-        = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
-
-    locateResourcesInWar(tree, servletContext);
-    current = tree;
-  }
-
-  private void locateResourcesInWar(final PageItem node, final ServletContext servletContext)
{
-
-    String path = node.getName();
-
-    // fix for jetty6
-    if (path.endsWith("/") && path.length() > 1) {
-      path = path.substring(0, path.length() - 1);
-    }
-    final Set<String> resourcePaths = servletContext.getResourcePaths(path);
-    if (resourcePaths == null || resourcePaths.isEmpty()) {
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Skipping empty resource path: path='" + path + "'");
-      }
-      return;
-    }
-
-    final List<PageItem> list = new ArrayList<>();
-
-    for (final String childPath : resourcePaths) {
-      if (childPath.endsWith("/")) {
-        // ignore, because weblogic puts the path directory itself in the Set
-        if (!childPath.equals(path)) {
-          if (TestPageFilter.isValid(childPath)) {
-            if (LOG.isDebugEnabled()) {
-              LOG.debug("childPath dir " + childPath);
-            }
-            list.add(new PageItem(childPath, TestPageFilter.isDisabled(childPath), TestPageFilter.isTodo(childPath)));
-          }
-        }
-      } else {
-        if (TestPageFilter.isValid(childPath)) {
-          LOG.info("add resc " + childPath);
-          list.add(new PageItem(childPath, TestPageFilter.isDisabled(childPath), TestPageFilter.isTodo(childPath)));
-        }
-      }
-    }
-
-    Collections.sort(list);
-
-    for (final PageItem pageItem : list) {
-      node.add(pageItem);
-
-      if (pageItem.isFolder()) {
-        locateResourcesInWar(pageItem, servletContext);
-      }
-    }
-  }
-
-  public PageItem getTree() {
-    return tree;
-  }
-
-  public PageItem getCurrent() {
-    return current;
-  }
-
-  public void setCurrent(final PageItem current) {
-    this.current = current;
-  }
-}
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/PageItem.java
b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/PageItem.java
deleted file mode 100644
index 2c6a067..0000000
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/PageItem.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.myfaces.tobago.example.test;
-
-import org.apache.myfaces.tobago.context.Markup;
-import org.apache.myfaces.tobago.util.VariableResolverUtils;
-
-import javax.faces.context.FacesContext;
-import javax.swing.tree.DefaultMutableTreeNode;
-
-
-public class PageItem extends DefaultMutableTreeNode implements Comparable {
-
-  private String name;
-  private String label;
-  private boolean folder;
-  private boolean disabled;
-  private boolean todo;
-
-  public PageItem(final String name, final boolean disabled, final boolean todo) {
-    this.name = name;
-    folder = name.endsWith("/");
-
-    label = name;
-    if (folder && label.length() > 1) {
-      label = label.substring(0, label.length() - 1);
-    }
-    label = label.substring(label.lastIndexOf("/") + 1);
-//    label = label.replaceAll("_", "__");
-    this.disabled = disabled;
-    this.todo = todo;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public String getLabel() {
-    return label;
-  }
-
-  @Override
-  public int compareTo(final Object object) {
-    return label.compareTo(((PageItem) object).label);
-  }
-
-  public boolean isFolder() {
-    return folder;
-  }
-
-  public boolean isDisabled() {
-    return disabled;
-  }
-
-  public Markup getMarkup() {
-    if (todo) {
-      return Markup.valueOf("todo");
-    } else {
-      return null;
-    }
-  }
-
-  public String navigate() {
-    final DirectoryBrowser browser =
-        (DirectoryBrowser) VariableResolverUtils.resolveVariable(FacesContext.getCurrentInstance(),
"browser");
-    browser.setCurrent(this);
-    return null; // here it works, but return null is usually not a good idea.
-  }
-
-  @Override
-  public String toString() {
-    return name;
-  }
-}
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/TestPageFilter.java
b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/TestPageFilter.java
deleted file mode 100644
index 133d217..0000000
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/test/TestPageFilter.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.myfaces.tobago.example.test;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-public class TestPageFilter {
-
-  public static final List<String> ALLOWED = Arrays.asList(
-      ".*\\/",
-      ".*\\.xhtml",
-      ".*\\.html"
-  );
-
-  public static final Set<String> HIDDEN = new HashSet<>(Arrays.asList(
-      "/META-INF/.*",
-      "/WEB-INF/.*",
-      "/script/.*",
-      "/style/.*",
-      "/org/.*",
-      "/src/.*",
-      ".*/\\.svn/.*",
-      ".*\\.selenium\\.html",
-      "/javax\\.faces/.*",
-      "/oam\\.custom\\..*",
-      "/org\\.apache\\.myfaces/.*",
-      "/org\\.apache\\.myfaces\\.custom/.*"
-  ));
-
-  /**
-   * Internal pages and pages that are impossible to run.
-   */
-  public static final Set<String> DISABLED = new HashSet<>(Arrays.asList(
-      ".*-fragment\\.xhtml", // intern
-
-      "/index.html", // intern
-      "/navigation.*", // intern
-
-      "/404.*", // meta test
-      "/500.*", // meta test
-
-      "/meta-test/meta-1.*", // meta test
-      "/meta-test/meta-3.*\\.xhtml", // meta test
-      "/meta-test/meta-4.*", // meta test
-      "/meta-test/meta-5.*", // meta test
-
-      "/test/button/plain.html", // intern
-      "/test/button/plain_de.html" // intern
-  ));
-
-  /**
-   * Switched off temporary.
-   */
-  private static final Set<String> TODO = new HashSet<>(Arrays.asList(
-      "/test/gridLayout/scrolling-2-levels.*", // todo: ?
-      "/test/gridLayout/scrolling-tab.*", // todo: measurement problem with firefox?
-      "/test/treeListbox/*", // todo
-      "/test/label/label-tx.xhtml" // todo see TOBAGO-993
-  ));
-
-  public static boolean isValid(final String name) {
-
-    // 1st all has to start with a '/' slash
-
-    if (!name.startsWith("/")) {
-      return false;
-    }
-
-    // 2nd the positive check
-
-    boolean matches = false;
-    for (final String allowed : ALLOWED) {
-      if (name.matches(allowed)) {
-        matches = true;
-      }
-    }
-    if (!matches) {
-      return false;
-    }
-
-    // 3rd the negative check
-
-    for (final String hidden : HIDDEN) {
-      if (name.matches(hidden)) {
-        return false;
-      }
-    }
-
-    return true;
-  }
-
-  public static boolean isDisabled(final String name) {
-    for (final String disabled : DISABLED) {
-      if (name.matches(disabled)) {
-        return true;
-      }
-    }
-
-    return false;
-  }
-
-  public static boolean isTodo(final String name) {
-    for (final String todo : TODO) {
-      if (name.matches(todo)) {
-        return true;
-      }
-    }
-
-    return false;
-  }
-
-}

-- 
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <commits@myfaces.apache.org>'].

Mime
View raw message