manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1698355 [1/2] - in /manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf: authorities/authorities/amazons3/ connectors/common/amazons3/ crawler/connectors/amazons3/
Date Fri, 28 Aug 2015 15:25:10 GMT
Author: kwright
Date: Fri Aug 28 15:25:09 2015
New Revision: 1698355

URL: http://svn.apache.org/r1698355
Log:
Reformat to meet MCF standards

Modified:
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/AmazonS3Authority.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/AmazonS3Config.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/ResponseException.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/connectors/common/amazons3/S3Artifact.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/connectors/common/amazons3/XThreadBuffer.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/AmazonS3Config.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/AmazonS3Connector.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/AmazonS3DocumentProcessUtility.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/DocumentProcess.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/GenericDocumentProcess.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/Messages.java
    manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/ResponseException.java

Modified: manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/AmazonS3Authority.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/AmazonS3Authority.java?rev=1698355&r1=1698354&r2=1698355&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/AmazonS3Authority.java (original)
+++ manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/AmazonS3Authority.java Fri Aug 28 15:25:09 2015
@@ -57,537 +57,537 @@ import com.amazonaws.services.s3.model.O
  *
  */
 public class AmazonS3Authority extends org.apache.manifoldcf.authorities.authorities.BaseAuthorityConnector {
-	private static final String TAB_NAME = "TabName";
+  private static final String TAB_NAME = "TabName";
 
-	protected long lastSessionFetch = -1L;
+  protected long lastSessionFetch = -1L;
 
-	protected static final long timeToRelease = 300000L;
+  protected static final long timeToRelease = 300000L;
 
-	protected AmazonS3 amazonS3;
+  protected AmazonS3 amazonS3;
 
-	protected boolean connected = false;
-
-	protected String amazons3ProxyHost = null;
-
-	protected String amazons3ProxyPort = null;
-
-	protected String amazons3ProxyDomain = null;
-
-	protected String amazons3ProxyUserName = null;
-
-	protected String amazons3ProxyPassword = null;
-
-	protected String amazons3AwsAccessKey = null;
-
-	protected String amazons3AwsSecretKey = null;
-
-	public AmazonS3Authority() {
-
-	}
-
-	@Override
-	public void disconnect() throws ManifoldCFException {
-		amazons3AwsAccessKey = null;
-		amazons3AwsSecretKey = null;
-
-		amazons3ProxyHost = null;
-		amazons3ProxyPort = null;
-		amazons3ProxyDomain = null;
-		amazons3ProxyUserName = null;
-		amazons3ProxyPassword = null;
-	}
-
-	@Override
-	public void connect(ConfigParams configParams) {
-		super.connect(configParams);
-		// aws access and secret keys
-		amazons3AwsAccessKey = configParams
-				.getParameter(AmazonS3Config.AWS_ACCESS_KEY);
-		amazons3AwsSecretKey = configParams
-				.getObfuscatedParameter(AmazonS3Config.AWS_SECRET_KEY);
-
-		// proxy values
-		amazons3ProxyHost = configParams
-				.getParameter(AmazonS3Config.AMAZONS3_PROXY_HOST);
-		amazons3ProxyPort = configParams
-				.getParameter(AmazonS3Config.AMAZONS3_PROXY_PORT);
-		amazons3ProxyDomain = configParams
-				.getParameter(AmazonS3Config.AMAZONS3_PROXY_DOMAIN);
-		amazons3ProxyUserName = configParams
-				.getParameter(AmazonS3Config.AMAZONS3_PROXY_USERNAME);
-		amazons3ProxyPassword = configParams
-				.getObfuscatedParameter(AmazonS3Config.AMAZONS3_PROXY_PASSWORD);
-	}
-
-	/**
-	 * Test the connection. Returns a string describing the connection
-	 * integrity.
-	 *
-	 * @return the connection's status as a displayable string.
-	 */
-	@Override
-	public String check() throws ManifoldCFException {
-		// connect with amazons3 client
-		Logging.authorityConnectors.info("Checking connection");
-
-		try {
-			// invokes the check thread
-			CheckThread checkThread = new CheckThread(getClient());
-			checkThread.start();
-			checkThread.join();
-			if (checkThread.getException() != null) {
-				Throwable thr = checkThread.getException();
-				return "Check exception: " + thr.getMessage();
-			}
-			return checkThread.getResult();
-		}
-		catch (InterruptedException ex) {
-			Logging.authorityConnectors.error(
-					"Error while checking connection", ex);
-			throw new ManifoldCFException(ex.getMessage(), ex,
-					ManifoldCFException.INTERRUPTED);
-		}
-
-	}
-
-	/**
-	 * Get the Amazons3 client, relevant access keys should have been posted
-	 * already
-	 * @return
-	 */
-	protected AmazonS3 getClient() {
-		if (amazonS3 == null) {
-			try {
-				BasicAWSCredentials awsCreds = new BasicAWSCredentials(
-						amazons3AwsAccessKey, amazons3AwsSecretKey);
-				amazonS3 = new AmazonS3Client(awsCreds);
-			}
-			catch (Exception e) {
-				Logging.authorityConnectors.error(
-						"Error while amazon s3 connectionr", e);
-
-			}
-		}
-		lastSessionFetch = System.currentTimeMillis();
-		return amazonS3;
-	}
-
-	@Override
-	public boolean isConnected() {
-		return amazonS3 != null && amazonS3.getS3AccountOwner() != null;
-	}
-
-	@Override
-	public void poll() throws ManifoldCFException {
-		if (lastSessionFetch == -1L) {
-			return;
-		}
-
-		long currentTime = System.currentTimeMillis();
-		if (currentTime >= lastSessionFetch + timeToRelease) {
-			amazonS3 = null;
-			lastSessionFetch = -1L;
-		}
-	}
-
-	private void fillInServerConfigurationMap(Map<String, Object> out,
-			IPasswordMapperActivity mapper, ConfigParams parameters) {
-
-		String amazons3AccessKey = parameters
-				.getParameter(AmazonS3Config.AWS_ACCESS_KEY);
-		String amazons3SecretKey = parameters
-				.getParameter(AmazonS3Config.AWS_SECRET_KEY);
-
-		// default values
-		if (amazons3AccessKey == null)
-			amazons3AccessKey = AmazonS3Config.AMAZONS3_AWS_ACCESS_KEY_DEFAULT;
-		if (amazons3SecretKey == null)
-			amazons3SecretKey = AmazonS3Config.AMAZONS3_AWS_SECRET_KEY_DEFAULT;
-		else
-			amazons3SecretKey = mapper.mapPasswordToKey(amazons3SecretKey);
-
-		// fill the map
-		out.put("AMAZONS3_AWS_ACCESS_KEY", amazons3AccessKey);
-		out.put("AMAZONS3_AWS_SECRET_KEY", amazons3SecretKey);
-	}
-
-	private void fillInProxyConfigurationMap(Map<String, Object> out,
-			IPasswordMapperActivity mapper, ConfigParams parameters) {
-		String amazons3ProxyHost = parameters
-				.getParameter(AmazonS3Config.AMAZONS3_PROXY_HOST);
-		String amazons3ProxyPort = parameters
-				.getParameter(AmazonS3Config.AMAZONS3_PROXY_PORT);
-		String amazons3ProxyDomain = parameters
-				.getParameter(AmazonS3Config.AMAZONS3_PROXY_DOMAIN);
-		String amazons3ProxyUserName = parameters
-				.getParameter(AmazonS3Config.AMAZONS3_PROXY_USERNAME);
-		String amazons3ProxyPassword = parameters
-				.getObfuscatedParameter(AmazonS3Config.AMAZONS3_PROXY_PASSWORD);
-
-		if (amazons3ProxyHost == null)
-			amazons3ProxyHost = AmazonS3Config.AMAZONS3_PROXY_HOST_DEFAULT;
-		if (amazons3ProxyPort == null)
-			amazons3ProxyPort = AmazonS3Config.AMAZONS3_PROXY_PORT_DEFAULT;
-		if (amazons3ProxyDomain == null)
-			amazons3ProxyDomain = AmazonS3Config.AMAZONS3_PROXY_DOMAIN_DEFAULT;
-		if (amazons3ProxyUserName == null)
-			amazons3ProxyUserName = AmazonS3Config.AMAZONS3_PROXY_USERNAME_DEFAULT;
-		if (amazons3ProxyPassword == null)
-			amazons3ProxyPassword = AmazonS3Config.AMAZONS3_PROXY_PASSWORD_DEFAULT;
-		else
-			amazons3ProxyPassword = mapper
-					.mapPasswordToKey(amazons3ProxyPassword);
-
-		// fill the map
-		out.put("AMAZONS3_PROXY_HOST", amazons3ProxyHost);
-		out.put("AMAZONS3_PROXY_PORT", amazons3ProxyPort);
-		out.put("AMAZONS3_PROXY_DOMAIN", amazons3ProxyDomain);
-		out.put("AMAZONS3_PROXY_USERNAME", amazons3ProxyUserName);
-		out.put("AMAZONS3_PROXY_PWD", amazons3ProxyPassword);
-	}
-
-	/**
-	 * View configuration. This method is called in the body section of the
-	 * connector's view configuration page. Its purpose is to present the
-	 * connection information to the user. The coder can presume that the HTML
-	 * that is output from this configuration will be within appropriate <html>
-	 * and <body> tags.
-	 * 
-	 * */
-	public void viewConfiguration(IThreadContext threadContext,
-			IHTTPOutput out, Locale locale, ConfigParams parameters)
-			throws ManifoldCFException, IOException {
-		Map<String, Object> paramMap = new HashMap<String, Object>();
-
-		// Fill in map from each tab
-		fillInServerConfigurationMap(paramMap, out, parameters);
-		fillInProxyConfigurationMap(paramMap, out, parameters);
-
-		Messages.outputResourceWithVelocity(out, locale, AmazonS3Config.VIEW_CONFIG_FORWARD, paramMap);
-	}
-
-	/**
-	 * Output the configuration header section. This method is called in the
-	 * head section of the connector's configuration page. Its purpose is to add
-	 * the required tabs to the list, and to output any javascript methods that
-	 * might be needed by the configuration editing HTML.
-	 * */
-	@Override
-	public void outputConfigurationHeader(IThreadContext threadContext,
-			IHTTPOutput out, Locale locale, ConfigParams parameters,
-			List<String> tabsArray) throws ManifoldCFException, IOException {
-		// Add the Server tab
-		tabsArray.add(Messages.getString(locale,
-				AmazonS3Config.AMAZONS3_SERVER_TAB_PROPERTY));
-		// Add the Proxy tab
-		tabsArray.add(Messages.getString(locale,
-				AmazonS3Config.AMAZONS3_PROXY_TAB_PROPERTY));
-		// Map the parameters
-		Map<String, Object> paramMap = new HashMap<String, Object>();
-
-		// Fill in the parameters from each tab
-		fillInServerConfigurationMap(paramMap, out, parameters);
-		fillInProxyConfigurationMap(paramMap, out, parameters);
-
-		// Output the Javascript - only one Velocity template for all tabs
-		Messages.outputResourceWithVelocity(out, locale,
-				AmazonS3Config.EDIT_CONFIG_HEADER_FORWARD, paramMap);
-	}
-
-	@Override
-	public void outputConfigurationBody(IThreadContext threadContext,
-			IHTTPOutput out, Locale locale, ConfigParams parameters,
-			String tabName) throws ManifoldCFException, IOException {
-
-		// Call the Velocity templates for each tab
-		Map<String, Object> paramMap = new HashMap<String, Object>();
-		// Set the tab name
-		paramMap.put(TAB_NAME, tabName);
-
-		// Fill in the parameters
-		fillInServerConfigurationMap(paramMap, out, parameters);
-		fillInProxyConfigurationMap(paramMap, out, parameters);
-
-		// Server tab
-		Messages.outputResourceWithVelocity(out, locale,
-				AmazonS3Config.EDIT_CONFIG_FORWARD_SERVER, paramMap);
-		// Proxy tab
-		Messages.outputResourceWithVelocity(out, locale,
-				AmazonS3Config.EDIT_CONFIG_FORWARD_PROXY, paramMap);
-
-	}
-
-	/**
-	 * Process a configuration post. This method is called at the start of the
-	 * connector's configuration page, whenever there is a possibility that form
-	 * data for a connection has been posted. Its purpose is to gather form
-	 * information and modify the configuration parameters accordingly. The name
-	 * of the posted form is "editconnection".
-	 * */
-	@Override
-	public String processConfigurationPost(IThreadContext threadContext,
-			IPostParameters variableContext, Locale locale,
-			ConfigParams parameters) throws ManifoldCFException {
-		// server tab
-		String awsAccessKey = variableContext.getParameter("aws_access_key");
-
-		if (awsAccessKey != null) {
-			parameters
-					.setParameter(AmazonS3Config.AWS_ACCESS_KEY, awsAccessKey);
-		}
-		String awsSecretKey = variableContext.getParameter("aws_secret_key");
-		if (awsSecretKey != null) {
-			// set as obfuscated parameter
-			parameters.setObfuscatedParameter(AmazonS3Config.AWS_SECRET_KEY,
-					awsSecretKey);
-		}
-		Logging.authorityConnectors.info("Saved values for aws keys");
-
-		int i = 0;
-		while (i < parameters.getChildCount()) {
-			ConfigNode cn = parameters.getChild(i);
-			if (cn.getType().equals(AmazonS3Config.AWS_ACCESS_KEY)
-					|| cn.getType().equals(AmazonS3Config.AWS_SECRET_KEY))
-				parameters.removeChild(i);
-			else
-				i++;
-		}
-
-		// proxy tab
-		String amazons3ProxyHost = variableContext
-				.getParameter("amazons3_proxy_host");
-		if (amazons3ProxyHost != null) {
-			parameters.setParameter(AmazonS3Config.AMAZONS3_PROXY_HOST,
-					amazons3ProxyHost);
-		}
-		String amazons3ProxyPort = variableContext
-				.getParameter("amazons3_proxy_port");
-		if (amazons3ProxyPort != null) {
-			parameters.setParameter(AmazonS3Config.AMAZONS3_PROXY_PORT,
-					amazons3ProxyPort);
-		}
-		String amazons3ProxyDomain = variableContext
-				.getParameter("amazons3_proxy_domain");
-		if (amazons3ProxyDomain != null) {
-			parameters.setParameter(AmazonS3Config.AMAZONS3_PROXY_DOMAIN,
-					amazons3ProxyDomain);
-		}
-		String amazons3ProxyUserName = variableContext
-				.getParameter("amazons3_proxy_username");
-		if (amazons3ProxyUserName != null) {
-			parameters.setParameter(AmazonS3Config.AMAZONS3_PROXY_USERNAME,
-					amazons3ProxyUserName);
-		}
-		String amazons3ProxyPassword = variableContext
-				.getParameter("amazons3_proxy_pwd");
-		if (amazons3ProxyPassword != null) {
-			// set as obfuscated parameter
-			parameters.setObfuscatedParameter(
-					AmazonS3Config.AMAZONS3_PROXY_USERNAME,
-					amazons3ProxyUserName);
-		}
-
-		return null;
-	}
-
-	@Override
-	public AuthorizationResponse getAuthorizationResponse(String userName)
-			throws ManifoldCFException {
-
-		HashMap<String, Set<Grant>> checkUserExists = checkUserExists(userName);
-		if (isUserAvailable(userName, checkUserExists.values())) {
-			return new AuthorizationResponse(new String[] { userName },
-					AuthorizationResponse.RESPONSE_OK);
-		}
-		return RESPONSE_USERNOTFOUND;
-	}
-
-	private boolean isUserAvailable(String userName,
-			Collection<Set<Grant>> collection) {
-		String[] users = getUsers(collection);
-		return Arrays.asList(users).contains(userName);
-	}
-
-	private String[] getUsers(Collection<Set<Grant>> collection) {
-		Set<String> users = new HashSet<String>();// no duplicates
-		for (Collection c : collection) {
-			Set<Grant> c1 = (Set<Grant>) c;
-			for (Grant grant : c1) {
-				if (grant != null && grant.getGrantee() != null) {
-					Grantee grantee = grant.getGrantee();
-
-					if (grantee instanceof CanonicalGrantee) {
-						users.add(((CanonicalGrantee) grantee).getDisplayName());
-					}
-					else {
-						users.add(grantee.getIdentifier());
-					}
-				}
-			}
-		}
-
-		return users.toArray(new String[users.size()]);
-	}
-
-	private HashMap<String, Set<Grant>> checkUserExists(String userName)
-			throws ManifoldCFException {
-		GrantsThread t = new GrantsThread(getClient());
-		try {
-			t.start();
-			t.finishUp();
-			return t.getResult();
-		}
-		catch (InterruptedException e) {
-			t.interrupt();
-			throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
-					ManifoldCFException.INTERRUPTED);
-		}
-		catch (java.net.SocketTimeoutException e) {
-			handleIOException(e);
-		}
-		catch (InterruptedIOException e) {
-			t.interrupt();
-			handleIOException(e);
-		}
-		catch (IOException e) {
-			handleIOException(e);
-		}
-		catch (ResponseException e) {
-			handleResponseException(e);
-		}
-		return null;
-	}
-
-	/**
-	 * Obtain the default access tokens for a given user name.
-	 * @param userName is the user name or identifier.
-	 * @return the default response tokens, presuming that the connect method
-	 * fails.
-	 */
-	@Override
-	public AuthorizationResponse getDefaultAuthorizationResponse(String userName) {
-		return RESPONSE_UNREACHABLE;
-	}
-
-	private static void handleIOException(IOException e)
-			throws ManifoldCFException {
-		if (!(e instanceof java.net.SocketTimeoutException)
-				&& (e instanceof InterruptedIOException)) {
-			throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
-					ManifoldCFException.INTERRUPTED);
-		}
-		Logging.authorityConnectors.warn(
-				"JIRA: IO exception: " + e.getMessage(), e);
-		throw new ManifoldCFException("IO exception: " + e.getMessage(), e);
-	}
-
-	private static void handleResponseException(ResponseException e)
-			throws ManifoldCFException {
-		throw new ManifoldCFException("Response exception: " + e.getMessage(),
-				e);
-	}
-
-	protected static class GrantsThread extends Thread {
-
-		protected Throwable exception = null;
-
-		protected boolean result = false;
-
-		protected AmazonS3 amazonS3 = null;
-
-		private HashMap<String, Set<Grant>> grants;
-
-		public GrantsThread(AmazonS3 amazonS3) {
-			super();
-			this.amazonS3 = amazonS3;
-			setDaemon(true);
-			grants = new HashMap<String, Set<Grant>>();
-		}
-
-		public void finishUp() throws InterruptedException, IOException,
-				ResponseException {
-			join();
-			Throwable thr = exception;
-			if (thr != null) {
-				if (thr instanceof IOException) {
-					throw (IOException) thr;
-				}
-				else if (thr instanceof ResponseException) {
-					throw (ResponseException) thr;
-				}
-				else if (thr instanceof RuntimeException) {
-					throw (RuntimeException) thr;
-				}
-				else {
-					throw (Error) thr;
-				}
-			}
-		}
-
-		@Override
-		public void run() {
-
-			List<Bucket> listBuckets = amazonS3.listBuckets();
-			for (Bucket bucket : listBuckets) {
-				AccessControlList bucketAcl = amazonS3.getBucketAcl(bucket
-						.getName());
-
-				if (bucketAcl != null)
-					grants.put(bucket.getName(), bucketAcl.getGrants());
-			}
-		}
-
-		public HashMap<String, Set<Grant>> getResult() {
-			return grants;
-		}
-
-	}
-
-	protected static class CheckThread extends Thread {
-		protected String result = "Unknown";
-
-		protected AmazonS3 s3 = null;
-
-		protected Throwable exception = null;
-
-		public CheckThread(AmazonS3 s3) {
-			this.s3 = s3;
-		}
-
-		public String getResult() {
-			return result;
-		}
-
-		public Throwable getException() {
-			return exception;
-		}
-
-		@Override
-		public void run() {
-			try {
-				if (s3 != null) {
-					Owner s3AccountOwner = s3.getS3AccountOwner();
-					if (s3AccountOwner != null) {
-						result = StringUtils.isNotEmpty(s3AccountOwner
-								.getDisplayName()) ? "Connection OK"
-								: "Connection Failed";
-					}
-
-				}
-			}
-			catch (AmazonServiceException e) {
-				result = "Connection Failed : " + e.getMessage();
-				exception = e;
-
-				Logging.authorityConnectors.error(e);
-			}
-			catch (AmazonClientException e) {
-				result = "Connection Failed : " + e.getMessage();
-				exception = e;
-
-				Logging.authorityConnectors.error(e);
-			}
-		}
-	}
+  protected boolean connected = false;
+
+  protected String amazons3ProxyHost = null;
+
+  protected String amazons3ProxyPort = null;
+
+  protected String amazons3ProxyDomain = null;
+
+  protected String amazons3ProxyUserName = null;
+
+  protected String amazons3ProxyPassword = null;
+
+  protected String amazons3AwsAccessKey = null;
+
+  protected String amazons3AwsSecretKey = null;
+
+  public AmazonS3Authority() {
+
+  }
+
+  @Override
+  public void disconnect() throws ManifoldCFException {
+    amazons3AwsAccessKey = null;
+    amazons3AwsSecretKey = null;
+
+    amazons3ProxyHost = null;
+    amazons3ProxyPort = null;
+    amazons3ProxyDomain = null;
+    amazons3ProxyUserName = null;
+    amazons3ProxyPassword = null;
+  }
+
+  @Override
+  public void connect(ConfigParams configParams) {
+    super.connect(configParams);
+    // aws access and secret keys
+    amazons3AwsAccessKey = configParams
+        .getParameter(AmazonS3Config.AWS_ACCESS_KEY);
+    amazons3AwsSecretKey = configParams
+        .getObfuscatedParameter(AmazonS3Config.AWS_SECRET_KEY);
+
+    // proxy values
+    amazons3ProxyHost = configParams
+        .getParameter(AmazonS3Config.AMAZONS3_PROXY_HOST);
+    amazons3ProxyPort = configParams
+        .getParameter(AmazonS3Config.AMAZONS3_PROXY_PORT);
+    amazons3ProxyDomain = configParams
+        .getParameter(AmazonS3Config.AMAZONS3_PROXY_DOMAIN);
+    amazons3ProxyUserName = configParams
+        .getParameter(AmazonS3Config.AMAZONS3_PROXY_USERNAME);
+    amazons3ProxyPassword = configParams
+        .getObfuscatedParameter(AmazonS3Config.AMAZONS3_PROXY_PASSWORD);
+  }
+
+  /**
+   * Test the connection. Returns a string describing the connection
+   * integrity.
+   *
+   * @return the connection's status as a displayable string.
+   */
+  @Override
+  public String check() throws ManifoldCFException {
+    // connect with amazons3 client
+    Logging.authorityConnectors.info("Checking connection");
+
+    try {
+      // invokes the check thread
+      CheckThread checkThread = new CheckThread(getClient());
+      checkThread.start();
+      checkThread.join();
+      if (checkThread.getException() != null) {
+        Throwable thr = checkThread.getException();
+        return "Check exception: " + thr.getMessage();
+      }
+      return checkThread.getResult();
+    }
+    catch (InterruptedException ex) {
+      Logging.authorityConnectors.error(
+          "Error while checking connection", ex);
+      throw new ManifoldCFException(ex.getMessage(), ex,
+          ManifoldCFException.INTERRUPTED);
+    }
+
+  }
+
+  /**
+   * Get the Amazons3 client, relevant access keys should have been posted
+   * already
+   * @return
+   */
+  protected AmazonS3 getClient() {
+    if (amazonS3 == null) {
+      try {
+        BasicAWSCredentials awsCreds = new BasicAWSCredentials(
+            amazons3AwsAccessKey, amazons3AwsSecretKey);
+        amazonS3 = new AmazonS3Client(awsCreds);
+      }
+      catch (Exception e) {
+        Logging.authorityConnectors.error(
+            "Error while amazon s3 connectionr", e);
+
+      }
+    }
+    lastSessionFetch = System.currentTimeMillis();
+    return amazonS3;
+  }
+
+  @Override
+  public boolean isConnected() {
+    return amazonS3 != null && amazonS3.getS3AccountOwner() != null;
+  }
+
+  @Override
+  public void poll() throws ManifoldCFException {
+    if (lastSessionFetch == -1L) {
+      return;
+    }
+
+    long currentTime = System.currentTimeMillis();
+    if (currentTime >= lastSessionFetch + timeToRelease) {
+      amazonS3 = null;
+      lastSessionFetch = -1L;
+    }
+  }
+
+  private void fillInServerConfigurationMap(Map<String, Object> out,
+      IPasswordMapperActivity mapper, ConfigParams parameters) {
+
+    String amazons3AccessKey = parameters
+        .getParameter(AmazonS3Config.AWS_ACCESS_KEY);
+    String amazons3SecretKey = parameters
+        .getParameter(AmazonS3Config.AWS_SECRET_KEY);
+
+    // default values
+    if (amazons3AccessKey == null)
+      amazons3AccessKey = AmazonS3Config.AMAZONS3_AWS_ACCESS_KEY_DEFAULT;
+    if (amazons3SecretKey == null)
+      amazons3SecretKey = AmazonS3Config.AMAZONS3_AWS_SECRET_KEY_DEFAULT;
+    else
+      amazons3SecretKey = mapper.mapPasswordToKey(amazons3SecretKey);
+
+    // fill the map
+    out.put("AMAZONS3_AWS_ACCESS_KEY", amazons3AccessKey);
+    out.put("AMAZONS3_AWS_SECRET_KEY", amazons3SecretKey);
+  }
+
+  private void fillInProxyConfigurationMap(Map<String, Object> out,
+      IPasswordMapperActivity mapper, ConfigParams parameters) {
+    String amazons3ProxyHost = parameters
+        .getParameter(AmazonS3Config.AMAZONS3_PROXY_HOST);
+    String amazons3ProxyPort = parameters
+        .getParameter(AmazonS3Config.AMAZONS3_PROXY_PORT);
+    String amazons3ProxyDomain = parameters
+        .getParameter(AmazonS3Config.AMAZONS3_PROXY_DOMAIN);
+    String amazons3ProxyUserName = parameters
+        .getParameter(AmazonS3Config.AMAZONS3_PROXY_USERNAME);
+    String amazons3ProxyPassword = parameters
+        .getObfuscatedParameter(AmazonS3Config.AMAZONS3_PROXY_PASSWORD);
+
+    if (amazons3ProxyHost == null)
+      amazons3ProxyHost = AmazonS3Config.AMAZONS3_PROXY_HOST_DEFAULT;
+    if (amazons3ProxyPort == null)
+      amazons3ProxyPort = AmazonS3Config.AMAZONS3_PROXY_PORT_DEFAULT;
+    if (amazons3ProxyDomain == null)
+      amazons3ProxyDomain = AmazonS3Config.AMAZONS3_PROXY_DOMAIN_DEFAULT;
+    if (amazons3ProxyUserName == null)
+      amazons3ProxyUserName = AmazonS3Config.AMAZONS3_PROXY_USERNAME_DEFAULT;
+    if (amazons3ProxyPassword == null)
+      amazons3ProxyPassword = AmazonS3Config.AMAZONS3_PROXY_PASSWORD_DEFAULT;
+    else
+      amazons3ProxyPassword = mapper
+          .mapPasswordToKey(amazons3ProxyPassword);
+
+    // fill the map
+    out.put("AMAZONS3_PROXY_HOST", amazons3ProxyHost);
+    out.put("AMAZONS3_PROXY_PORT", amazons3ProxyPort);
+    out.put("AMAZONS3_PROXY_DOMAIN", amazons3ProxyDomain);
+    out.put("AMAZONS3_PROXY_USERNAME", amazons3ProxyUserName);
+    out.put("AMAZONS3_PROXY_PWD", amazons3ProxyPassword);
+  }
+
+  /**
+   * View configuration. This method is called in the body section of the
+   * connector's view configuration page. Its purpose is to present the
+   * connection information to the user. The coder can presume that the HTML
+   * that is output from this configuration will be within appropriate <html>
+   * and <body> tags.
+   * 
+   * */
+  public void viewConfiguration(IThreadContext threadContext,
+      IHTTPOutput out, Locale locale, ConfigParams parameters)
+      throws ManifoldCFException, IOException {
+    Map<String, Object> paramMap = new HashMap<String, Object>();
+
+    // Fill in map from each tab
+    fillInServerConfigurationMap(paramMap, out, parameters);
+    fillInProxyConfigurationMap(paramMap, out, parameters);
+
+    Messages.outputResourceWithVelocity(out, locale, AmazonS3Config.VIEW_CONFIG_FORWARD, paramMap);
+  }
+
+  /**
+   * Output the configuration header section. This method is called in the
+   * head section of the connector's configuration page. Its purpose is to add
+   * the required tabs to the list, and to output any javascript methods that
+   * might be needed by the configuration editing HTML.
+   * */
+  @Override
+  public void outputConfigurationHeader(IThreadContext threadContext,
+      IHTTPOutput out, Locale locale, ConfigParams parameters,
+      List<String> tabsArray) throws ManifoldCFException, IOException {
+    // Add the Server tab
+    tabsArray.add(Messages.getString(locale,
+        AmazonS3Config.AMAZONS3_SERVER_TAB_PROPERTY));
+    // Add the Proxy tab
+    tabsArray.add(Messages.getString(locale,
+        AmazonS3Config.AMAZONS3_PROXY_TAB_PROPERTY));
+    // Map the parameters
+    Map<String, Object> paramMap = new HashMap<String, Object>();
+
+    // Fill in the parameters from each tab
+    fillInServerConfigurationMap(paramMap, out, parameters);
+    fillInProxyConfigurationMap(paramMap, out, parameters);
+
+    // Output the Javascript - only one Velocity template for all tabs
+    Messages.outputResourceWithVelocity(out, locale,
+        AmazonS3Config.EDIT_CONFIG_HEADER_FORWARD, paramMap);
+  }
+
+  @Override
+  public void outputConfigurationBody(IThreadContext threadContext,
+      IHTTPOutput out, Locale locale, ConfigParams parameters,
+      String tabName) throws ManifoldCFException, IOException {
+
+    // Call the Velocity templates for each tab
+    Map<String, Object> paramMap = new HashMap<String, Object>();
+    // Set the tab name
+    paramMap.put(TAB_NAME, tabName);
+
+    // Fill in the parameters
+    fillInServerConfigurationMap(paramMap, out, parameters);
+    fillInProxyConfigurationMap(paramMap, out, parameters);
+
+    // Server tab
+    Messages.outputResourceWithVelocity(out, locale,
+        AmazonS3Config.EDIT_CONFIG_FORWARD_SERVER, paramMap);
+    // Proxy tab
+    Messages.outputResourceWithVelocity(out, locale,
+        AmazonS3Config.EDIT_CONFIG_FORWARD_PROXY, paramMap);
+
+  }
+
+  /**
+   * Process a configuration post. This method is called at the start of the
+   * connector's configuration page, whenever there is a possibility that form
+   * data for a connection has been posted. Its purpose is to gather form
+   * information and modify the configuration parameters accordingly. The name
+   * of the posted form is "editconnection".
+   * */
+  @Override
+  public String processConfigurationPost(IThreadContext threadContext,
+      IPostParameters variableContext, Locale locale,
+      ConfigParams parameters) throws ManifoldCFException {
+    // server tab
+    String awsAccessKey = variableContext.getParameter("aws_access_key");
+
+    if (awsAccessKey != null) {
+      parameters
+          .setParameter(AmazonS3Config.AWS_ACCESS_KEY, awsAccessKey);
+    }
+    String awsSecretKey = variableContext.getParameter("aws_secret_key");
+    if (awsSecretKey != null) {
+      // set as obfuscated parameter
+      parameters.setObfuscatedParameter(AmazonS3Config.AWS_SECRET_KEY,
+          awsSecretKey);
+    }
+    Logging.authorityConnectors.info("Saved values for aws keys");
+
+    int i = 0;
+    while (i < parameters.getChildCount()) {
+      ConfigNode cn = parameters.getChild(i);
+      if (cn.getType().equals(AmazonS3Config.AWS_ACCESS_KEY)
+          || cn.getType().equals(AmazonS3Config.AWS_SECRET_KEY))
+        parameters.removeChild(i);
+      else
+        i++;
+    }
+
+    // proxy tab
+    String amazons3ProxyHost = variableContext
+        .getParameter("amazons3_proxy_host");
+    if (amazons3ProxyHost != null) {
+      parameters.setParameter(AmazonS3Config.AMAZONS3_PROXY_HOST,
+          amazons3ProxyHost);
+    }
+    String amazons3ProxyPort = variableContext
+        .getParameter("amazons3_proxy_port");
+    if (amazons3ProxyPort != null) {
+      parameters.setParameter(AmazonS3Config.AMAZONS3_PROXY_PORT,
+          amazons3ProxyPort);
+    }
+    String amazons3ProxyDomain = variableContext
+        .getParameter("amazons3_proxy_domain");
+    if (amazons3ProxyDomain != null) {
+      parameters.setParameter(AmazonS3Config.AMAZONS3_PROXY_DOMAIN,
+          amazons3ProxyDomain);
+    }
+    String amazons3ProxyUserName = variableContext
+        .getParameter("amazons3_proxy_username");
+    if (amazons3ProxyUserName != null) {
+      parameters.setParameter(AmazonS3Config.AMAZONS3_PROXY_USERNAME,
+          amazons3ProxyUserName);
+    }
+    String amazons3ProxyPassword = variableContext
+        .getParameter("amazons3_proxy_pwd");
+    if (amazons3ProxyPassword != null) {
+      // set as obfuscated parameter
+      parameters.setObfuscatedParameter(
+          AmazonS3Config.AMAZONS3_PROXY_USERNAME,
+          amazons3ProxyUserName);
+    }
+
+    return null;
+  }
+
+  @Override
+  public AuthorizationResponse getAuthorizationResponse(String userName)
+      throws ManifoldCFException {
+
+    HashMap<String, Set<Grant>> checkUserExists = checkUserExists(userName);
+    if (isUserAvailable(userName, checkUserExists.values())) {
+      return new AuthorizationResponse(new String[] { userName },
+          AuthorizationResponse.RESPONSE_OK);
+    }
+    return RESPONSE_USERNOTFOUND;
+  }
+
+  private boolean isUserAvailable(String userName,
+      Collection<Set<Grant>> collection) {
+    String[] users = getUsers(collection);
+    return Arrays.asList(users).contains(userName);
+  }
+
+  private String[] getUsers(Collection<Set<Grant>> collection) {
+    Set<String> users = new HashSet<String>();// no duplicates
+    for (Collection c : collection) {
+      Set<Grant> c1 = (Set<Grant>) c;
+      for (Grant grant : c1) {
+        if (grant != null && grant.getGrantee() != null) {
+          Grantee grantee = grant.getGrantee();
+
+          if (grantee instanceof CanonicalGrantee) {
+            users.add(((CanonicalGrantee) grantee).getDisplayName());
+          }
+          else {
+            users.add(grantee.getIdentifier());
+          }
+        }
+      }
+    }
+
+    return users.toArray(new String[users.size()]);
+  }
+
+  private HashMap<String, Set<Grant>> checkUserExists(String userName)
+      throws ManifoldCFException {
+    GrantsThread t = new GrantsThread(getClient());
+    try {
+      t.start();
+      t.finishUp();
+      return t.getResult();
+    }
+    catch (InterruptedException e) {
+      t.interrupt();
+      throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
+          ManifoldCFException.INTERRUPTED);
+    }
+    catch (java.net.SocketTimeoutException e) {
+      handleIOException(e);
+    }
+    catch (InterruptedIOException e) {
+      t.interrupt();
+      handleIOException(e);
+    }
+    catch (IOException e) {
+      handleIOException(e);
+    }
+    catch (ResponseException e) {
+      handleResponseException(e);
+    }
+    return null;
+  }
+
+  /**
+   * Obtain the default access tokens for a given user name.
+   * @param userName is the user name or identifier.
+   * @return the default response tokens, presuming that the connect method
+   * fails.
+   */
+  @Override
+  public AuthorizationResponse getDefaultAuthorizationResponse(String userName) {
+    return RESPONSE_UNREACHABLE;
+  }
+
+  private static void handleIOException(IOException e)
+      throws ManifoldCFException {
+    if (!(e instanceof java.net.SocketTimeoutException)
+        && (e instanceof InterruptedIOException)) {
+      throw new ManifoldCFException("Interrupted: " + e.getMessage(), e,
+          ManifoldCFException.INTERRUPTED);
+    }
+    Logging.authorityConnectors.warn(
+        "JIRA: IO exception: " + e.getMessage(), e);
+    throw new ManifoldCFException("IO exception: " + e.getMessage(), e);
+  }
+
+  private static void handleResponseException(ResponseException e)
+      throws ManifoldCFException {
+    throw new ManifoldCFException("Response exception: " + e.getMessage(),
+        e);
+  }
+
+  protected static class GrantsThread extends Thread {
+
+    protected Throwable exception = null;
+
+    protected boolean result = false;
+
+    protected AmazonS3 amazonS3 = null;
+
+    private HashMap<String, Set<Grant>> grants;
+
+    public GrantsThread(AmazonS3 amazonS3) {
+      super();
+      this.amazonS3 = amazonS3;
+      setDaemon(true);
+      grants = new HashMap<String, Set<Grant>>();
+    }
+
+    public void finishUp() throws InterruptedException, IOException,
+        ResponseException {
+      join();
+      Throwable thr = exception;
+      if (thr != null) {
+        if (thr instanceof IOException) {
+          throw (IOException) thr;
+        }
+        else if (thr instanceof ResponseException) {
+          throw (ResponseException) thr;
+        }
+        else if (thr instanceof RuntimeException) {
+          throw (RuntimeException) thr;
+        }
+        else {
+          throw (Error) thr;
+        }
+      }
+    }
+
+    @Override
+    public void run() {
+
+      List<Bucket> listBuckets = amazonS3.listBuckets();
+      for (Bucket bucket : listBuckets) {
+        AccessControlList bucketAcl = amazonS3.getBucketAcl(bucket
+            .getName());
+
+        if (bucketAcl != null)
+          grants.put(bucket.getName(), bucketAcl.getGrants());
+      }
+    }
+
+    public HashMap<String, Set<Grant>> getResult() {
+      return grants;
+    }
+
+  }
+
+  protected static class CheckThread extends Thread {
+    protected String result = "Unknown";
+
+    protected AmazonS3 s3 = null;
+
+    protected Throwable exception = null;
+
+    public CheckThread(AmazonS3 s3) {
+      this.s3 = s3;
+    }
+
+    public String getResult() {
+      return result;
+    }
+
+    public Throwable getException() {
+      return exception;
+    }
+
+    @Override
+    public void run() {
+      try {
+        if (s3 != null) {
+          Owner s3AccountOwner = s3.getS3AccountOwner();
+          if (s3AccountOwner != null) {
+            result = StringUtils.isNotEmpty(s3AccountOwner
+                .getDisplayName()) ? "Connection OK"
+                : "Connection Failed";
+          }
+
+        }
+      }
+      catch (AmazonServiceException e) {
+        result = "Connection Failed : " + e.getMessage();
+        exception = e;
+
+        Logging.authorityConnectors.error(e);
+      }
+      catch (AmazonClientException e) {
+        result = "Connection Failed : " + e.getMessage();
+        exception = e;
+
+        Logging.authorityConnectors.error(e);
+      }
+    }
+  }
 
 }

Modified: manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/AmazonS3Config.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/AmazonS3Config.java?rev=1698355&r1=1698354&r2=1698355&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/AmazonS3Config.java (original)
+++ manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/AmazonS3Config.java Fri Aug 28 15:25:09 2015
@@ -16,93 +16,91 @@
  */
 package org.apache.manifoldcf.authorities.authorities.amazons3;
 
-import org.apache.manifoldcf.crawler.connectors.BaseRepositoryConnector;
-
 /**
  * @author Kuhajeyan
  *
  */
 public class AmazonS3Config {
-	public static final String AWS_ACCESS_KEY = "aws_access_key";
+  public static final String AWS_ACCESS_KEY = "aws_access_key";
 
-	public static final String AWS_SECRET_KEY = "aws_secret_key";
+  public static final String AWS_SECRET_KEY = "aws_secret_key";
 
-	public static final String AMAZONS3_HOST = "amazons3_host";
+  public static final String AMAZONS3_HOST = "amazons3_host";
 
-	public static final String AMAZONS3_PORT = "amazons3_port";
+  public static final String AMAZONS3_PORT = "amazons3_port";
 
-	public static final String AMAZONS3_PROTOCOL = "amazons3_protocol";
+  public static final String AMAZONS3_PROTOCOL = "amazons3_protocol";
 
-	public static final String AMAZONS3_PROXY_HOST = "amazons3_proxy_host";
+  public static final String AMAZONS3_PROXY_HOST = "amazons3_proxy_host";
 
-	public static final String AMAZONS3_PROXY_PORT = "amazons3_proxy_port";
+  public static final String AMAZONS3_PROXY_PORT = "amazons3_proxy_port";
 
-	public static final String AMAZONS3_PROXY_DOMAIN = "amazons3_proxy_domain";
+  public static final String AMAZONS3_PROXY_DOMAIN = "amazons3_proxy_domain";
 
-	public static final String AMAZONS3_PROXY_USERNAME = "amazons3_proxy_username";
+  public static final String AMAZONS3_PROXY_USERNAME = "amazons3_proxy_username";
 
-	public static final String AMAZONS3_PROXY_PASSWORD = "amazons3_proxy_password";
+  public static final String AMAZONS3_PROXY_PASSWORD = "amazons3_proxy_password";
 
-	public static final String AMAZONS3_HOST_DEFAULT = "";
+  public static final String AMAZONS3_HOST_DEFAULT = "";
 
-	public static final String AMAZONS3_PORT_DEFAULT = "";
+  public static final String AMAZONS3_PORT_DEFAULT = "";
 
-	public static final String AMAZONS3_PROTOCOL_DEFAULT = "http";
+  public static final String AMAZONS3_PROTOCOL_DEFAULT = "http";
 
-	public static final String AMAZONS3_AWS_ACCESS_KEY_DEFAULT = "";
+  public static final String AMAZONS3_AWS_ACCESS_KEY_DEFAULT = "";
 
-	public static final String AMAZONS3_AWS_SECRET_KEY_DEFAULT = "";
+  public static final String AMAZONS3_AWS_SECRET_KEY_DEFAULT = "";
 
-	public static final String AMAZONS3_PROXY_HOST_DEFAULT = "";
+  public static final String AMAZONS3_PROXY_HOST_DEFAULT = "";
 
-	public static final String AMAZONS3_PROXY_PORT_DEFAULT = "";
+  public static final String AMAZONS3_PROXY_PORT_DEFAULT = "";
 
-	public static final String AMAZONS3_PROXY_DOMAIN_DEFAULT = "";
+  public static final String AMAZONS3_PROXY_DOMAIN_DEFAULT = "";
 
-	public static final String AMAZONS3_PROXY_USERNAME_DEFAULT = "";
+  public static final String AMAZONS3_PROXY_USERNAME_DEFAULT = "";
 
-	public static final String AMAZONS3_PROXY_PASSWORD_DEFAULT = "";
+  public static final String AMAZONS3_PROXY_PASSWORD_DEFAULT = "";
 
-	public static final String AMAZONS3_BUCKETS_DEFAULT = "";
+  public static final String AMAZONS3_BUCKETS_DEFAULT = "";
 
-	// Configuration tabs
-	public static final String AMAZONS3_SERVER_TAB_PROPERTY = "Amazons3AuthorityConnector.Server";
+  // Configuration tabs
+  public static final String AMAZONS3_SERVER_TAB_PROPERTY = "Amazons3AuthorityConnector.Server";
 
-	public static final String AMAZONS3_PROXY_TAB_PROPERTY = "Amazons3AuthorityConnector.Proxy";
+  public static final String AMAZONS3_PROXY_TAB_PROPERTY = "Amazons3AuthorityConnector.Proxy";
 
-	// Specification tabs
-	public static final String AMAZONS3_BUCKETS_TAB_PROPERTY = "Amazons3AuthorityConnector.Amazons3Buckets";
+  // Specification tabs
+  public static final String AMAZONS3_BUCKETS_TAB_PROPERTY = "Amazons3AuthorityConnector.Amazons3Buckets";
 
-	public static final String AMAZONS3_SECURITY_TAB_PROPERTY = "Amazons3AuthorityConnector.Amazons3Security";
+  public static final String AMAZONS3_SECURITY_TAB_PROPERTY = "Amazons3AuthorityConnector.Amazons3Security";
 
-	// Template names for configuration
-	/**
-	 * Forward to the javascript to check the configuration parameters
-	 */
-	public static final String EDIT_CONFIG_HEADER_FORWARD = "editConfiguration_amazons3.js";
+  // Template names for configuration
+  /**
+   * Forward to the javascript to check the configuration parameters
+   */
+  public static final String EDIT_CONFIG_HEADER_FORWARD = "editConfiguration_amazons3.js";
 
-	public static final String EDIT_CONFIG_FORWARD_SERVER = "editConfiguration_amazons3_server.html";
+  public static final String EDIT_CONFIG_FORWARD_SERVER = "editConfiguration_amazons3_server.html";
 
-	public static final String EDIT_CONFIG_FORWARD_PROXY = "editConfiguration_amazons3_proxy.html";
+  public static final String EDIT_CONFIG_FORWARD_PROXY = "editConfiguration_amazons3_proxy.html";
 
-	public static final String VIEW_CONFIG_FORWARD = "viewConfiguration_amazons3.html";
+  public static final String VIEW_CONFIG_FORWARD = "viewConfiguration_amazons3.html";
 
-	
-	
-	
-	
-	
-	//////
-	public static final int CHARACTER_LIMIT = 1000000;
+  
+  
+  
+  
+  
+  //////
+  public static final int CHARACTER_LIMIT = 1000000;
 
-	public static final String DOCUMENT_URI_FORMAT = "%s.s3.amazonaws.com/%s";
+  public static final String DOCUMENT_URI_FORMAT = "%s.s3.amazonaws.com/%s";
 
-	
+  
 
-	/** Deny access token for default authority */
-	public final static String defaultAuthorityDenyToken = BaseRepositoryConnector.GLOBAL_DENY_TOKEN;
+  /** Deny access token for default authority */
+  public final static String defaultAuthorityDenyToken = BaseRepositoryConnector.GLOBAL_DENY_TOKEN;
 
-	public static final String JOB_STARTPOINT_NODE_TYPE = "startpoint";
+  public static final String JOB_STARTPOINT_NODE_TYPE = "startpoint";
 
-	public static final String JOB_BUCKETS_ATTRIBUTE = "s3buckets";
+  public static final String JOB_BUCKETS_ATTRIBUTE = "s3buckets";
 }

Modified: manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/ResponseException.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/ResponseException.java?rev=1698355&r1=1698354&r2=1698355&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/ResponseException.java (original)
+++ manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/amazons3/ResponseException.java Fri Aug 28 15:25:09 2015
@@ -22,11 +22,11 @@ package org.apache.manifoldcf.authoritie
  */
 public class ResponseException extends Exception {
 
-	public ResponseException(String msg) {
-		super(msg);
-	}
+  public ResponseException(String msg) {
+    super(msg);
+  }
 
-	public ResponseException(String msg, Throwable cause) {
-		super(msg, cause);
-	}
+  public ResponseException(String msg, Throwable cause) {
+    super(msg, cause);
+  }
 }

Modified: manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/connectors/common/amazons3/S3Artifact.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/connectors/common/amazons3/S3Artifact.java?rev=1698355&r1=1698354&r2=1698355&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/connectors/common/amazons3/S3Artifact.java (original)
+++ manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/connectors/common/amazons3/S3Artifact.java Fri Aug 28 15:25:09 2015
@@ -23,58 +23,58 @@ package org.apache.manifoldcf.connectors
  */
 public class S3Artifact {
 
-	private String bucketName;
+  private String bucketName;
 
-	private String key;
+  private String key;
 
-	public S3Artifact() {
+  public S3Artifact() {
 
-	}
+  }
 
-	public S3Artifact(String bucketName, String key) {
-
-		this.bucketName = bucketName;
-		this.key = key;
-	}
-
-	public String getBucketName() {
-		return bucketName;
-	}
-
-	public void setBucketName(String bucketName) {
-		this.bucketName = bucketName;
-	}
-
-	public String getKey() {
-		return key;
-	}
-
-	public void setKey(String key) {
-		this.key = key;
-	}
-	
-	@Override
-	public boolean equals(Object obj) {
-		if(obj == null)
-			return false;
-		
-		if(!(obj instanceof S3Artifact))
-			return false;
-		
-		if(obj == this){
-			return true;
-		}
-		
-		S3Artifact newObj = (S3Artifact)obj;
-		if(newObj.getBucketName() == this.getBucketName() && newObj.getKey() == this.getKey())
-			return true;
-		
-		return false;
-	}
-	
-	@Override
-	public int hashCode() {		
-		return this.getBucketName().hashCode() + this.getKey().hashCode() + 345;
-	}
+  public S3Artifact(String bucketName, String key) {
+
+    this.bucketName = bucketName;
+    this.key = key;
+  }
+
+  public String getBucketName() {
+    return bucketName;
+  }
+
+  public void setBucketName(String bucketName) {
+    this.bucketName = bucketName;
+  }
+
+  public String getKey() {
+    return key;
+  }
+
+  public void setKey(String key) {
+    this.key = key;
+  }
+  
+  @Override
+  public boolean equals(Object obj) {
+    if(obj == null)
+      return false;
+    
+    if(!(obj instanceof S3Artifact))
+      return false;
+    
+    if(obj == this){
+      return true;
+    }
+    
+    S3Artifact newObj = (S3Artifact)obj;
+    if(newObj.getBucketName() == this.getBucketName() && newObj.getKey() == this.getKey())
+      return true;
+    
+    return false;
+  }
+  
+  @Override
+  public int hashCode() {    
+    return this.getBucketName().hashCode() + this.getKey().hashCode() + 345;
+  }
 
 }

Modified: manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/connectors/common/amazons3/XThreadBuffer.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/connectors/common/amazons3/XThreadBuffer.java?rev=1698355&r1=1698354&r2=1698355&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/connectors/common/amazons3/XThreadBuffer.java (original)
+++ manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/connectors/common/amazons3/XThreadBuffer.java Fri Aug 28 15:25:09 2015
@@ -29,60 +29,60 @@ import org.apache.manifoldcf.crawler.sys
  * @param <T>
  */
 public class XThreadBuffer<T> {
-	protected static int MAX_SIZE = 1024;
+  protected static int MAX_SIZE = 1024;
 
-	protected List<T> buffer = Collections.synchronizedList(new ArrayList<T>(
-			MAX_SIZE));
+  protected List<T> buffer = Collections.synchronizedList(new ArrayList<T>(
+      MAX_SIZE));
 
-	protected boolean complete = false;
+  protected boolean complete = false;
 
-	protected boolean abandoned = false;
+  protected boolean abandoned = false;
 
-	/** Constructor */
-	public XThreadBuffer() {
-	}
-
-	public synchronized void add(T t) throws InterruptedException {
-		while (buffer.size() == MAX_SIZE && !abandoned)
-			wait();
-		if (abandoned)
-			return;
-		buffer.add(t);
-		// Notify threads that are waiting on there being stuff in the queue
-		notifyAll();
-	}
-
-	public synchronized void abandon() {
-		abandoned = true;
-		// Notify waiting threads
-		notifyAll();
-	}
-
-	public synchronized T fetch() throws InterruptedException {
-
-		while (buffer.size() == 0 && !complete) 
-		{
-			if (Logging.connectors != null) {
-				Logging.connectors.info("thread will be put to wait");
-			}
-			wait();
-		}
-
-		if (buffer.size() == 0)
-			return null;
-		boolean isBufferFull = (buffer.size() == MAX_SIZE);
-		T rval = buffer.remove(buffer.size() - 1);
-		// Notify those threads waiting on buffer being not completely full to
-		// wake
-		if (isBufferFull)
-			notifyAll();
-		return rval;
-	}
-
-	public synchronized void signalDone() {
-		complete = true;
-		// Notify threads that are waiting for stuff to appear, because it won't
-		notifyAll();
-	}
+  /** Constructor */
+  public XThreadBuffer() {
+  }
+
+  public synchronized void add(T t) throws InterruptedException {
+    while (buffer.size() == MAX_SIZE && !abandoned)
+      wait();
+    if (abandoned)
+      return;
+    buffer.add(t);
+    // Notify threads that are waiting on there being stuff in the queue
+    notifyAll();
+  }
+
+  public synchronized void abandon() {
+    abandoned = true;
+    // Notify waiting threads
+    notifyAll();
+  }
+
+  public synchronized T fetch() throws InterruptedException {
+
+    while (buffer.size() == 0 && !complete) 
+    {
+      if (Logging.connectors != null) {
+        Logging.connectors.info("thread will be put to wait");
+      }
+      wait();
+    }
+
+    if (buffer.size() == 0)
+      return null;
+    boolean isBufferFull = (buffer.size() == MAX_SIZE);
+    T rval = buffer.remove(buffer.size() - 1);
+    // Notify those threads waiting on buffer being not completely full to
+    // wake
+    if (isBufferFull)
+      notifyAll();
+    return rval;
+  }
+
+  public synchronized void signalDone() {
+    complete = true;
+    // Notify threads that are waiting for stuff to appear, because it won't
+    notifyAll();
+  }
 
 }

Modified: manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/AmazonS3Config.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/AmazonS3Config.java?rev=1698355&r1=1698354&r2=1698355&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/AmazonS3Config.java (original)
+++ manifoldcf/branches/CONNECTORS-1233/connectors/amazons3/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/amazons3/AmazonS3Config.java Fri Aug 28 15:25:09 2015
@@ -21,100 +21,100 @@ package org.apache.manifoldcf.crawler.co
  *
  */
 public class AmazonS3Config {
-	public static final String AWS_ACCESS_KEY = "aws_access_key";
+  public static final String AWS_ACCESS_KEY = "aws_access_key";
 
-	public static final String AWS_SECRET_KEY = "aws_secret_key";
+  public static final String AWS_SECRET_KEY = "aws_secret_key";
 
-	public static final String AMAZONS3_HOST = "amazons3_host";
+  public static final String AMAZONS3_HOST = "amazons3_host";
 
-	public static final String AMAZONS3_PORT = "amazons3_port";
+  public static final String AMAZONS3_PORT = "amazons3_port";
 
-	public static final String AMAZONS3_PROTOCOL = "amazons3_protocol";
+  public static final String AMAZONS3_PROTOCOL = "amazons3_protocol";
 
-	public static final String AMAZONS3_PROXY_HOST = "amazons3_proxy_host";
+  public static final String AMAZONS3_PROXY_HOST = "amazons3_proxy_host";
 
-	public static final String AMAZONS3_PROXY_PORT = "amazons3_proxy_port";
+  public static final String AMAZONS3_PROXY_PORT = "amazons3_proxy_port";
 
-	public static final String AMAZONS3_PROXY_DOMAIN = "amazons3_proxy_domain";
+  public static final String AMAZONS3_PROXY_DOMAIN = "amazons3_proxy_domain";
 
-	public static final String AMAZONS3_PROXY_USERNAME = "amazons3_proxy_username";
+  public static final String AMAZONS3_PROXY_USERNAME = "amazons3_proxy_username";
 
-	public static final String AMAZONS3_PROXY_PASSWORD = "amazons3_proxy_password";
+  public static final String AMAZONS3_PROXY_PASSWORD = "amazons3_proxy_password";
 
-	public static final String AMAZONS3_HOST_DEFAULT = "";
+  public static final String AMAZONS3_HOST_DEFAULT = "";
 
-	public static final String AMAZONS3_PORT_DEFAULT = "";
+  public static final String AMAZONS3_PORT_DEFAULT = "";
 
-	public static final String AMAZONS3_PROTOCOL_DEFAULT = "http";
+  public static final String AMAZONS3_PROTOCOL_DEFAULT = "http";
 
-	public static final String AMAZONS3_AWS_ACCESS_KEY_DEFAULT = "";
+  public static final String AMAZONS3_AWS_ACCESS_KEY_DEFAULT = "";
 
-	public static final String AMAZONS3_AWS_SECRET_KEY_DEFAULT = "";
+  public static final String AMAZONS3_AWS_SECRET_KEY_DEFAULT = "";
 
-	public static final String AMAZONS3_PROXY_HOST_DEFAULT = "";
+  public static final String AMAZONS3_PROXY_HOST_DEFAULT = "";
 
-	public static final String AMAZONS3_PROXY_PORT_DEFAULT = "";
+  public static final String AMAZONS3_PROXY_PORT_DEFAULT = "";
 
-	public static final String AMAZONS3_PROXY_DOMAIN_DEFAULT = "";
+  public static final String AMAZONS3_PROXY_DOMAIN_DEFAULT = "";
 
-	public static final String AMAZONS3_PROXY_USERNAME_DEFAULT = "";
+  public static final String AMAZONS3_PROXY_USERNAME_DEFAULT = "";
 
-	public static final String AMAZONS3_PROXY_PASSWORD_DEFAULT = "";
+  public static final String AMAZONS3_PROXY_PASSWORD_DEFAULT = "";
 
-	public static final String AMAZONS3_BUCKETS_DEFAULT = "";
+  public static final String AMAZONS3_BUCKETS_DEFAULT = "";
 
-	// Configuration tabs
-	public static final String AMAZONS3_SERVER_TAB_PROPERTY = "Amazons3RepositoryConnector.Server";
+  // Configuration tabs
+  public static final String AMAZONS3_SERVER_TAB_PROPERTY = "Amazons3RepositoryConnector.Server";
 
-	public static final String AMAZONS3_PROXY_TAB_PROPERTY = "Amazons3RepositoryConnector.Proxy";
+  public static final String AMAZONS3_PROXY_TAB_PROPERTY = "Amazons3RepositoryConnector.Proxy";
 
-	// Specification tabs
-	public static final String AMAZONS3_BUCKETS_TAB_PROPERTY = "Amazons3RepositoryConnector.Amazons3Buckets";
+  // Specification tabs
+  public static final String AMAZONS3_BUCKETS_TAB_PROPERTY = "Amazons3RepositoryConnector.Amazons3Buckets";
 
-	public static final String AMAZONS3_SECURITY_TAB_PROPERTY = "Amazons3RepositoryConnector.Amazons3Security";
+  public static final String AMAZONS3_SECURITY_TAB_PROPERTY = "Amazons3RepositoryConnector.Amazons3Security";
 
-	// Template names for configuration
-	/**
-	 * Forward to the javascript to check the configuration parameters
-	 */
-	public static final String EDIT_CONFIG_HEADER_FORWARD = "editConfiguration_amazons3.js";
+  // Template names for configuration
+  /**
+   * Forward to the javascript to check the configuration parameters
+   */
+  public static final String EDIT_CONFIG_HEADER_FORWARD = "editConfiguration_amazons3.js";
 
-	public static final String EDIT_CONFIG_FORWARD_SERVER = "editConfiguration_amazons3_server.html";
+  public static final String EDIT_CONFIG_FORWARD_SERVER = "editConfiguration_amazons3_server.html";
 
-	public static final String EDIT_CONFIG_FORWARD_PROXY = "editConfiguration_amazons3_proxy.html";
+  public static final String EDIT_CONFIG_FORWARD_PROXY = "editConfiguration_amazons3_proxy.html";
 
-	public static final String EDIT_SPEC_HEADER_FORWARD = "editSpecification_amazons3.js";
+  public static final String EDIT_SPEC_HEADER_FORWARD = "editSpecification_amazons3.js";
 
-	public static final String EDIT_SPEC_FORWARD_BUCKETS = "editSpecification_buckets.html";
+  public static final String EDIT_SPEC_FORWARD_BUCKETS = "editSpecification_buckets.html";
 
-	public static final String VIEW_CONFIG_FORWARD = "viewConfiguration_amazons3.html";
+  public static final String VIEW_CONFIG_FORWARD = "viewConfiguration_amazons3.html";
 
-	public static final String VIEW_SPEC_FORWARD = "viewSpecification_amazons3.html";
-	
-	//job
-	protected static final String RELATIONSHIP_RELATED = "related";
+  public static final String VIEW_SPEC_FORWARD = "viewSpecification_amazons3.html";
+  
+  //job
+  protected static final String RELATIONSHIP_RELATED = "related";
 
-	
+  
 
-	public static final String JOB_ACCESS_NODE_TYPE = "access";
+  public static final String JOB_ACCESS_NODE_TYPE = "access";
 
-	public static final String JOB_TOKEN_ATTRIBUTE = "token";
-	
-	
-	
-	
-	//////
-	public static final int CHARACTER_LIMIT = 1000000;
-	public static final String DOCUMENT_URI_FORMAT = "%s.s3.amazonaws.com/%s";
-	public static final String BUCKET_SPLITTER = ",";
-	public static final String STD_SEPARATOR_BUCKET_AND_KEY = BUCKET_SPLITTER;
+  public static final String JOB_TOKEN_ATTRIBUTE = "token";
+  
+  
+  
+  
+  //////
+  public static final int CHARACTER_LIMIT = 1000000;
+  public static final String DOCUMENT_URI_FORMAT = "%s.s3.amazonaws.com/%s";
+  public static final String BUCKET_SPLITTER = ",";
+  public static final String STD_SEPARATOR_BUCKET_AND_KEY = BUCKET_SPLITTER;
 
-	
+  
 
-	/** Deny access token for default authority */
-	public final static String defaultAuthorityDenyToken = BaseRepositoryConnector.GLOBAL_DENY_TOKEN;
+  /** Deny access token for default authority */
+  public final static String defaultAuthorityDenyToken = BaseRepositoryConnector.GLOBAL_DENY_TOKEN;
 
-	public static final String JOB_STARTPOINT_NODE_TYPE = "startpoint";
+  public static final String JOB_STARTPOINT_NODE_TYPE = "startpoint";
 
-	public static final String JOB_BUCKETS_ATTRIBUTE = "s3buckets";
+  public static final String JOB_BUCKETS_ATTRIBUTE = "s3buckets";
 }



Mime
View raw message