manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1222799 - in /incubator/lcf/branches/CONNECTORS-335/connectors: activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cm...
Date Fri, 23 Dec 2011 19:03:51 GMT
Author: kwright
Date: Fri Dec 23 19:03:50 2011
New Revision: 1222799

URL: http://svn.apache.org/viewvc?rev=1222799&view=rev
Log:
Use the localization parameter for the activedirectory and CMIS connectors.

Added:
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration_en_US.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration_en_US.js
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration.js
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration_ja_JP.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration_ja.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration_ja_JP.js
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration_ja.js
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification_en_US.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification_en_US.js
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification.js
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification_ja_JP.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification_ja.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification_ja_JP.js
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification_ja.js
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/hiddenConfiguration_en_US.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/hiddenConfiguration.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/hiddenConfiguration_ja_JP.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/hiddenConfiguration.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/hiddenSpecification_en_US.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/hiddenSpecification.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/hiddenSpecification_ja_JP.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/hiddenSpecification.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewConfiguration_en_US.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewConfiguration.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewConfiguration_ja_JP.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewConfiguration_ja.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewSpecification_en_US.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewSpecification.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewSpecification_ja_JP.html
      - copied unchanged from r1222517, incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewSpecification_ja.html
Removed:
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration.js
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration_ja.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editConfiguration_ja.js
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification.js
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification_ja.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/editSpecification_ja.js
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/hiddenConfiguration.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/hiddenSpecification.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewConfiguration.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewConfiguration_ja.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewSpecification.html
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/cmis/viewSpecification_ja.html
Modified:
    incubator/lcf/branches/CONNECTORS-335/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
    incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java

Modified: incubator/lcf/branches/CONNECTORS-335/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-335/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java?rev=1222799&r1=1222798&r2=1222799&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-335/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
(original)
+++ incubator/lcf/branches/CONNECTORS-335/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
Fri Dec 23 19:03:50 2011
@@ -339,11 +339,11 @@ public class ActiveDirectoryAuthority ex
   *@param tabsArray is an array of tab names.  Add to this array any tab names that are specific
to the connector.
   */
   @Override
-  public void outputConfigurationHeader(IThreadContext threadContext, IHTTPOutput out, ConfigParams
parameters, List<String> tabsArray)
+  public void outputConfigurationHeader(IThreadContext threadContext, IHTTPOutput out, Locale
locale, ConfigParams parameters, List<String> tabsArray)
     throws ManifoldCFException, IOException
   {
-    tabsArray.add(Messages.getString("ActiveDirectoryAuthority.DomainController"));
-    tabsArray.add(Messages.getString("ActiveDirectoryAuthority.Cache"));
+    tabsArray.add(Messages.getString(locale,"ActiveDirectoryAuthority.DomainController"));
+    tabsArray.add(Messages.getString(locale,"ActiveDirectoryAuthority.Cache"));
     
     out.print(
 "<script type=\"text/javascript\">\n"+
@@ -422,7 +422,7 @@ public class ActiveDirectoryAuthority ex
   *@param tabName is the current tab name.
   */
   @Override
-  public void outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out, ConfigParams
parameters, String tabName)
+  public void outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out, Locale
locale, ConfigParams parameters, String tabName)
     throws ManifoldCFException, IOException
   {
     String domainControllerName = parameters.getParameter(org.apache.manifoldcf.authorities.authorities.activedirectory.ActiveDirectoryConfig.PARAM_DOMAINCONTROLLER);
@@ -448,7 +448,7 @@ public class ActiveDirectoryAuthority ex
       cacheLRUsize = "1000";    
     
     // The "Domain Controller" tab
-    if (tabName.equals(Messages.getString("ActiveDirectoryAuthority.DomainController")))
+    if (tabName.equals(Messages.getString(locale,"ActiveDirectoryAuthority.DomainController")))
     {
       out.print(
 "<table class=\"displaytable\">\n"+
@@ -492,7 +492,7 @@ public class ActiveDirectoryAuthority ex
       );
     }
     // The "Cache" tab
-    if (tabName.equals(Messages.getString("ActiveDirectoryAuthority.Cache")))
+    if (tabName.equals(Messages.getString(locale,"ActiveDirectoryAuthority.Cache")))
     {
       out.print(
 "<table class=\"displaytable\">\n"+
@@ -528,7 +528,7 @@ public class ActiveDirectoryAuthority ex
   *@return null if all is well, or a string error message if there is an error that should
prevent saving of the connection (and cause a redirection to an error page).
   */
   @Override
-  public String processConfigurationPost(IThreadContext threadContext, IPostParameters variableContext,
ConfigParams parameters)
+  public String processConfigurationPost(IThreadContext threadContext, IPostParameters variableContext,
Locale locale, ConfigParams parameters)
     throws ManifoldCFException
   {
     String domainControllerName = variableContext.getParameter("domaincontrollername");
@@ -564,13 +564,13 @@ public class ActiveDirectoryAuthority ex
   *@param parameters are the configuration parameters, as they currently exist, for this
connection being configured.
   */
   @Override
-  public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out, ConfigParams
parameters)
+  public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out, Locale locale,
ConfigParams parameters)
     throws ManifoldCFException, IOException
   {
     out.print(
 "<table class=\"displaytable\">\n"+
 "  <tr>\n"+
-"    <td class=\"description\" colspan=\"1\"><nobr>" + Messages.getString("ActiveDirectoryAuthority.Parameters")
+ "</nobr></td>\n"+
+"    <td class=\"description\" colspan=\"1\"><nobr>" + Messages.getString(locale,"ActiveDirectoryAuthority.Parameters")
+ "</nobr></td>\n"+
 "    <td class=\"value\" colspan=\"3\">\n"
     );
     Iterator iter = parameters.listParameters();

Modified: incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java?rev=1222799&r1=1222798&r2=1222799&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
(original)
+++ incubator/lcf/branches/CONNECTORS-335/connectors/cmis/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/cmis/CmisRepositoryConnector.java
Fri Dec 23 19:03:50 2011
@@ -32,6 +32,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Locale;
 
 import org.apache.chemistry.opencmis.client.api.CmisObject;
 import org.apache.chemistry.opencmis.client.api.Document;
@@ -73,7 +74,6 @@ import org.apache.manifoldcf.crawler.sys
 public class CmisRepositoryConnector extends BaseRepositoryConnector {
 
   private static final String JOB_STARTPOINT_NODE_TYPE = "startpoint";
-  private static final String TAB_LABEL_CMIS_QUERY = Messages.getString("CmisRepositoryConnector.CMISQuery");
 
   protected final static String ACTIVITY_READ = "read document";
   protected static final String RELATIONSHIP_CHILD = "child";
@@ -688,9 +688,17 @@ public class CmisRepositoryConnector ext
    * @param out
    * @throws ManifoldCFException
    */
-  private void outputResource(String resName, IHTTPOutput out,
-      ConfigParams params) throws ManifoldCFException {
-    InputStream is = getClass().getResourceAsStream(resName);
+  private static void outputResource(String resName, IHTTPOutput out,
+      Locale locale, ConfigParams params) throws ManifoldCFException {
+    String localResourceName = localizeResourceName(resName,locale);
+    InputStream is = CmisRepositoryConnector.class.getResourceAsStream(localResourceName);
+    if (is == null)
+    {
+      Logging.misc.error("No resource named '"+resName+"' found for locale '"+locale.toString()+"'");
+      is = CmisRepositoryConnector.class.getResourceAsStream(localizeResourceName(resName,Locale.US));
+      if (is == null)
+        throw new ManifoldCFException("No resource named '"+resName+"' found for US locale!");
+    }
     BufferedReader br = null;
     try {
       br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
@@ -734,6 +742,14 @@ public class CmisRepositoryConnector ext
     }
   }
   
+  private static String localizeResourceName(String resourceName, Locale locale)
+  {
+    int dotIndex = resourceName.lastIndexOf(".");
+    if (dotIndex == -1)
+      return resourceName + "_" + locale.toString();
+    return resourceName.substring(0,dotIndex) + "_" + locale.toString() + resourceName.substring(dotIndex);
+  }
+  
   /**
    * View configuration. This method is called in the body section of the
    * connector's view configuration page. Its purpose is to present the
@@ -751,12 +767,12 @@ public class CmisRepositoryConnector ext
    */
   @Override
   public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out,
-      ConfigParams parameters) throws ManifoldCFException, IOException {
+      Locale locale, ConfigParams parameters) throws ManifoldCFException, IOException {
     String repositoryId = parameters.getParameter(CmisConfig.REPOSITORY_ID_PARAM);
     if(StringUtils.isEmpty(repositoryId))
       repositoryId = StringUtils.EMPTY;
     parameters.setParameter(CmisConfig.REPOSITORY_ID_PARAM, repositoryId);
-    outputResource(VIEW_CONFIG_FORWARD, out, parameters);
+    outputResource(VIEW_CONFIG_FORWARD, out, locale, parameters);
   }
 
   /**
@@ -779,15 +795,15 @@ public class CmisRepositoryConnector ext
    */
   @Override
   public void outputConfigurationHeader(IThreadContext threadContext,
-      IHTTPOutput out, ConfigParams parameters, List<String> tabsArray)
+      IHTTPOutput out, Locale locale, ConfigParams parameters, List<String> tabsArray)
       throws ManifoldCFException, IOException {
     tabsArray.add(CMIS_SERVER_TAB_NAME);
-    outputResource(EDIT_CONFIG_HEADER_FORWARD, out, parameters);
+    outputResource(EDIT_CONFIG_HEADER_FORWARD, out, locale, parameters);
   }
 
   @Override
   public void outputConfigurationBody(IThreadContext threadContext,
-      IHTTPOutput out, ConfigParams parameters, String tabName)
+      IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
       throws ManifoldCFException, IOException {
     
     if(CMIS_SERVER_TAB_NAME.equals(tabName)){
@@ -826,9 +842,9 @@ public class CmisRepositoryConnector ext
       parameters.setParameter(CmisConfig.PATH_PARAM, path);
       parameters.setParameter(CmisConfig.REPOSITORY_ID_PARAM, repositoryId);
       parameters.setParameter(CmisConfig.BINDING_PARAM, binding);
-      outputResource(EDIT_CONFIG_FORWARD, out, parameters);
+      outputResource(EDIT_CONFIG_FORWARD, out, locale, parameters);
     } else {
-      outputResource(HIDDEN_CONFIG_FORWARD, out, parameters);
+      outputResource(HIDDEN_CONFIG_FORWARD, out, locale, parameters);
     }
   }
 
@@ -911,7 +927,7 @@ public class CmisRepositoryConnector ext
    *          is the current document specification for this job.
    */
   @Override
-  public void viewSpecification(IHTTPOutput out, DocumentSpecification ds)
+  public void viewSpecification(IHTTPOutput out, Locale locale, DocumentSpecification ds)
       throws ManifoldCFException, IOException {
     int i = 0;
     boolean seenAny = false;
@@ -927,7 +943,7 @@ public class CmisRepositoryConnector ext
       }
       i++;
     }
-    outputResource(VIEW_SPEC_FORWARD, out, specificationParams);
+    outputResource(VIEW_SPEC_FORWARD, out, locale, specificationParams);
   }
 
   /**
@@ -995,7 +1011,7 @@ public class CmisRepositoryConnector ext
    */
   @Override
   public void outputSpecificationBody(IHTTPOutput out,
-      DocumentSpecification ds, String tabName) throws ManifoldCFException,
+      Locale locale, DocumentSpecification ds, String tabName) throws ManifoldCFException,
       IOException {
     String cmisQuery = StringUtils.EMPTY;
     int i = 0;
@@ -1007,13 +1023,13 @@ public class CmisRepositoryConnector ext
       }
       i++;
     }
-    
+
     ConfigParams params = new ConfigParams();
     params.setParameter(CmisConfig.CMIS_QUERY_PARAM, cmisQuery);
-    if (tabName.equals(TAB_LABEL_CMIS_QUERY)) {
-      outputResource(EDIT_SPEC_FORWARD, out, params);
+    if (tabName.equals(Messages.getString(locale,"CmisRepositoryConnector.CMISQuery"))) {
+      outputResource(EDIT_SPEC_FORWARD, out, locale, params);
     } else {
-      outputResource(HIDDEN_SPEC_FORWARD, out, params);
+      outputResource(HIDDEN_SPEC_FORWARD, out, locale, params);
     }
   }
 
@@ -1033,10 +1049,10 @@ public class CmisRepositoryConnector ext
    */
   @Override
   public void outputSpecificationHeader(IHTTPOutput out,
-      DocumentSpecification ds, List<String> tabsArray)
+      Locale locale, DocumentSpecification ds, List<String> tabsArray)
       throws ManifoldCFException, IOException {
-    tabsArray.add(TAB_LABEL_CMIS_QUERY);
-    outputResource(EDIT_SPEC_HEADER_FORWARD, out, params);
+    tabsArray.add(Messages.getString(locale,"CmisRepositoryConnector.CMISQuery"));
+    outputResource(EDIT_SPEC_HEADER_FORWARD, out, locale, params);
   }
 
   /** Process a set of documents.



Mime
View raw message