manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From piergior...@apache.org
Subject svn commit: r1542298 [3/3] - in /manifoldcf/branches/CONNECTORS-553/connectors/email/connector/src/main: java/org/apache/manifoldcf/crawler/connectors/email/ resources/org/apache/manifoldcf/crawler/connectors/email/
Date Fri, 15 Nov 2013 15:46:53 GMT
Modified: manifoldcf/branches/CONNECTORS-553/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/Messages.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-553/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/Messages.java?rev=1542298&r1=1542297&r2=1542298&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-553/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/Messages.java
(original)
+++ manifoldcf/branches/CONNECTORS-553/connectors/email/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/email/Messages.java
Fri Nov 15 15:46:52 2013
@@ -1,141 +1,147 @@
 /* $Id$ */
 
 /**
-* 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.
-*/
+ * 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.manifoldcf.crawler.connectors.email;
 
+import org.apache.manifoldcf.core.interfaces.IHTTPOutput;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.ui.util.Encoder;
+
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
-import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
-import org.apache.manifoldcf.core.interfaces.IHTTPOutput;
 
-public class Messages extends org.apache.manifoldcf.ui.i18n.Messages
-{
-  public static final String DEFAULT_BUNDLE_NAME="org.apache.manifoldcf.crawler.connectors.email.common";
-  public static final String DEFAULT_PATH_NAME="org.apache.manifoldcf.crawler.connectors.email";
-  
-  /** Constructor - do no instantiate
-  */
-  protected Messages()
-  {
-  }
-  
-  public static String getString(Locale locale, String messageKey)
-  {
-    return getString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
-  }
-
-  public static String getAttributeString(Locale locale, String messageKey)
-  {
-    return getAttributeString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
-  }
-
-  public static String getBodyString(Locale locale, String messageKey)
-  {
-    return getBodyString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
-  }
-
-  public static String getAttributeJavascriptString(Locale locale, String messageKey)
-  {
-    return getAttributeJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
-  }
-
-  public static String getBodyJavascriptString(Locale locale, String messageKey)
-  {
-    return getBodyJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
-  }
-
-  public static String getString(Locale locale, String messageKey, Object[] args)
-  {
-    return getString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
-  }
-
-  public static String getAttributeString(Locale locale, String messageKey, Object[] args)
-  {
-    return getAttributeString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
-  }
-  
-  public static String getBodyString(Locale locale, String messageKey, Object[] args)
-  {
-    return getBodyString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
-  }
-
-  public static String getAttributeJavascriptString(Locale locale, String messageKey, Object[]
args)
-  {
-    return getAttributeJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
-  }
-
-  public static String getBodyJavascriptString(Locale locale, String messageKey, Object[]
args)
-  {
-    return getBodyJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
-  }
-
-  // More general methods which allow bundlenames and class loaders to be specified.
-  
-  public static String getString(String bundleName, Locale locale, String messageKey, Object[]
args)
-  {
-    return getString(Messages.class, bundleName, locale, messageKey, args);
-  }
-
-  public static String getAttributeString(String bundleName, Locale locale, String messageKey,
Object[] args)
-  {
-    return getAttributeString(Messages.class, bundleName, locale, messageKey, args);
-  }
-
-  public static String getBodyString(String bundleName, Locale locale, String messageKey,
Object[] args)
-  {
-    return getBodyString(Messages.class, bundleName, locale, messageKey, args);
-  }
-  
-  public static String getAttributeJavascriptString(String bundleName, Locale locale, String
messageKey, Object[] args)
-  {
-    return getAttributeJavascriptString(Messages.class, bundleName, locale, messageKey, args);
-  }
-
-  public static String getBodyJavascriptString(String bundleName, Locale locale, String messageKey,
Object[] args)
-  {
-    return getBodyJavascriptString(Messages.class, bundleName, locale, messageKey, args);
-  }
-
-  // Resource output
-  
-  public static void outputResource(IHTTPOutput output, Locale locale, String resourceKey,
-    Map<String,String> substitutionParameters, boolean mapToUpperCase)
-    throws ManifoldCFException
-  {
-    outputResource(output,Messages.class,DEFAULT_PATH_NAME,locale,resourceKey,
-      substitutionParameters,mapToUpperCase);
-  }
-  
-  public static void outputResourceWithVelocity(IHTTPOutput output, Locale locale, String
resourceKey,
-    Map<String,String> substitutionParameters, boolean mapToUpperCase)
-    throws ManifoldCFException
-  {
-    outputResourceWithVelocity(output,Messages.class,DEFAULT_BUNDLE_NAME,DEFAULT_PATH_NAME,locale,resourceKey,
-      substitutionParameters,mapToUpperCase);
-  }
-
-  public static void outputResourceWithVelocity(IHTTPOutput output, Locale locale, String
resourceKey,
-    Map<String,Object> contextObjects)
-    throws ManifoldCFException
-  {
-    outputResourceWithVelocity(output,Messages.class,DEFAULT_BUNDLE_NAME,DEFAULT_PATH_NAME,locale,resourceKey,
-      contextObjects);
-  }
-  
+public class Messages extends org.apache.manifoldcf.ui.i18n.Messages {
+    public static final String DEFAULT_BUNDLE_NAME = "org.apache.manifoldcf.crawler.connectors.email.common";
+    public static final String DEFAULT_PATH_NAME = "org.apache.manifoldcf.crawler.connectors.email";
+
+    /**
+     * Constructor - do no instantiate
+     */
+    protected Messages() {
+    }
+
+    public static String getString(Locale locale, String messageKey) {
+        return getString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getAttributeString(Locale locale, String messageKey) {
+        return getAttributeString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getBodyString(Locale locale, String messageKey) {
+        return getBodyString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getAttributeJavascriptString(Locale locale, String messageKey) {
+        return getAttributeJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getBodyJavascriptString(Locale locale, String messageKey) {
+        return getBodyJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getString(Locale locale, String messageKey, Object[] args) {
+        return getString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getAttributeString(Locale locale, String messageKey, Object[] args)
{
+        return getAttributeString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getBodyString(Locale locale, String messageKey, Object[] args) {
+        return getBodyString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getAttributeJavascriptString(Locale locale, String messageKey, Object[]
args) {
+        return getAttributeJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getBodyJavascriptString(Locale locale, String messageKey, Object[]
args) {
+        return getBodyJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    // More general methods which allow bundlenames and class loaders to be specified.
+
+    public static String getString(String bundleName, Locale locale, String messageKey, Object[]
args) {
+        return getString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getAttributeString(String bundleName, Locale locale, String messageKey,
Object[] args) {
+        return getAttributeString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getBodyString(String bundleName, Locale locale, String messageKey,
Object[] args) {
+        return getBodyString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getAttributeJavascriptString(String bundleName, Locale locale, String
messageKey, Object[] args) {
+        return getAttributeJavascriptString(Messages.class, bundleName, locale, messageKey,
args);
+    }
+
+    public static String getBodyJavascriptString(String bundleName, Locale locale, String
messageKey, Object[] args) {
+        return getBodyJavascriptString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    // Resource output
+
+    public static void outputResource(IHTTPOutput output, Locale locale, String resourceKey,
+                                      Map<String, String> substitutionParameters, boolean
mapToUpperCase)
+            throws ManifoldCFException {
+        outputResource(output, Messages.class, DEFAULT_PATH_NAME, locale, resourceKey,
+                substitutionParameters, mapToUpperCase);
+    }
+
+    public static void outputResourceWithVelocity(IHTTPOutput output, Locale locale, String
resourceKey,
+                                                  Map<String, String> substitutionParameters,
boolean mapToUpperCase)
+            throws ManifoldCFException {
+        outputResourceWithVelocity(output, Messages.class, DEFAULT_BUNDLE_NAME, DEFAULT_PATH_NAME,
locale, resourceKey,
+                substitutionParameters, mapToUpperCase);
+    }
+
+    public static void outputResourceWithVelocity(IHTTPOutput output, Locale locale, String
resourceKey,
+                                                  Map<String, Object> contextObjects)
+            throws ManifoldCFException {
+        Map<String, Object> tmpContextObjects = null;
+        if (contextObjects != null) {
+            tmpContextObjects = new HashMap<String, Object>();
+            Iterator<String> i = contextObjects.keySet().iterator();
+            while (i.hasNext()) {
+                String key = i.next();
+                Object value = contextObjects.get(key);
+
+                key = key.toUpperCase();
+
+                if (value instanceof String) {
+                    tmpContextObjects.put(key, value);
+                    tmpContextObjects.put(key + "_A", Encoder.attributeEscape((String) value));
+                    tmpContextObjects.put(key + "_B", Encoder.bodyEscape((String) value));
+                    tmpContextObjects.put(key + "_AJ", Encoder.attributeJavascriptEscape((String)
value));
+                    tmpContextObjects.put(key + "_BJ", Encoder.bodyJavascriptEscape((String)
value));
+                } else {
+                    tmpContextObjects.put(key, value);
+                }
+            }
+        }
+        outputResourceWithVelocity(output, Messages.class, DEFAULT_BUNDLE_NAME, DEFAULT_PATH_NAME,
locale, resourceKey,
+                tmpContextObjects);
+    }
+
 }
 



Mime
View raw message