You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by hs...@apache.org on 2011/11/17 18:26:15 UTC

svn commit: r1203288 - in /shindig/trunk: UPGRADING java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/ExternalServices.java java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java

Author: hsaputra
Date: Thu Nov 17 17:26:15 2011
New Revision: 1203288

URL: http://svn.apache.org/viewvc?rev=1203288&view=rev
Log:
Update the UPGRADING file for Paul Lindner checkins upgrade to commons-lang3.

Added:
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/ExternalServices.java
Modified:
    shindig/trunk/UPGRADING
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java

Modified: shindig/trunk/UPGRADING
URL: http://svn.apache.org/viewvc/shindig/trunk/UPGRADING?rev=1203288&r1=1203287&r2=1203288&view=diff
==============================================================================
--- shindig/trunk/UPGRADING (original)
+++ shindig/trunk/UPGRADING Thu Nov 17 17:26:15 2011
@@ -7,8 +7,8 @@ FROM 2.0.x TO 3.0.x
 * guice 2.0->3.0
 * nekohtml 1.9.14->1.9.15
 * htmlunit 2.8->2.9 
-
 * closure-compiler r1459
+* commons-lang to commons-lang3 3.1
 
 FROM 1.0.x TO 2.0.x
 ===================

Added: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/ExternalServices.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/ExternalServices.java?rev=1203288&view=auto
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/ExternalServices.java (added)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/ExternalServices.java Thu Nov 17 17:26:15 2011
@@ -0,0 +1,98 @@
+/*
+ * 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.shindig.gadgets.spec;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.shindig.common.xml.XmlUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.util.Map;
+
+/**
+ * Represents the ExternalServices tag in the gadget spec.
+ *
+ * It includes the child ServiceTag and its text element.
+ *
+ * @since 3.0.0
+ */
+public class ExternalServices {
+  // The name to be used in the "alias" request parameters.
+  private static final String ATTR_ALIAS = "alias";
+
+  private Map<String, ServiceTag> serviceTags;
+
+  public ExternalServices(Element element) {
+    Map<String, ServiceTag> serviceTagsBuilder = Maps.newLinkedHashMap();
+    parseServiceTags(element, serviceTagsBuilder);
+
+    serviceTags = ImmutableMap.copyOf(serviceTagsBuilder);
+  }
+
+  public Map<String, ServiceTag> getServiceTags() {
+    return serviceTags;
+  }
+
+  private void parseServiceTags(Element element, Map<String, ServiceTag> serviceTagsBuilder) {
+    NodeList children = element.getChildNodes();
+    for (int i = 0, j = children.getLength(); i < j; ++i) {
+      Node child = children.item(i);
+      String tagName = child.getNodeName();
+      if (!(child instanceof Element)) continue;
+
+      // only process ServiceTag child tags
+      if(ServiceTag.SERVICE_TAG.equals(tagName)) {
+        String alias = XmlUtil.getAttribute(child, ATTR_ALIAS, "");
+        String tag = child.getTextContent();
+        tag = (tag != null) ? tag.trim() : "";
+        ServiceTag serviceTag = new ServiceTag(alias, tag);
+        serviceTagsBuilder.put(alias, serviceTag);
+      }
+    }
+  }
+
+  /**
+   * Represent the ServiceTag tag in the gadget spec.
+   *
+   * @since 3.0.0
+   */
+  public static class ServiceTag {
+    public static final String SERVICE_TAG = "ServiceTag";
+
+    private final String alias;
+    private final String tag;
+
+    public ServiceTag(String alias, String tag) {
+      this.alias = alias;
+      this.tag = tag;
+    }
+
+    public String getAlias() {
+      return alias;
+    }
+
+    public String getTag() {
+      return tag;
+    }
+  }
+}

Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java?rev=1203288&r1=1203287&r2=1203288&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java (original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/GadgetSpec.java Thu Nov 17 17:26:15 2011
@@ -107,6 +107,13 @@ public class GadgetSpec {
           viewElements.add(element);
         }
       }
+      if("ExternalServices".equals(name)) {
+        // There could be only one ExternalServices tag
+        if(externalServices != null) {
+          throw new SpecParserException("Only can have one ExternalServices is allowed.");
+        }
+        externalServices = new ExternalServices(element);
+      }
     }
 
     if (modulePrefs == null) {
@@ -203,6 +210,14 @@ public class GadgetSpec {
   }
 
   /**
+   * ExternalServices
+   */
+  protected ExternalServices externalServices;
+  public ExternalServices getExternalServices() {
+    return externalServices;
+  }
+
+  /**
    * Retrieves a single view by name.
    *
    * @param name The name of the view you want to see