com.force.sdk.connector
Class ForceConnectorUtils

java.lang.Object
  extended by com.force.sdk.connector.ForceConnectorUtils

public final class ForceConnectorUtils
extends Object

Shared utilities for Force.com connectors.

Author:
Tim Kral

Method Summary
static String buildForceApiEndpoint(String endpoint)
          Builds a valid Force.com API endpoint.
static Map<ForceConnectionProperty,String> loadConnectorPropsFromName(String connectionName)
          Loads Force.com connection properties from a connection name.
static Map<ForceConnectionProperty,String> loadConnectorPropsFromUrl(String connectionUrl)
          Loads Force.com connection properties from a Force.com connection url
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

buildForceApiEndpoint

public static String buildForceApiEndpoint(String endpoint)
Builds a valid Force.com API endpoint.

This method will pass through fully qualified, versioned Force.com API endpoints. If the endpoint parameter is found not to be a fully qualified Force.com API endpoint, then one will be constructed using the API version bound to the Force.com SDK.

All built endpoints will be forced to use the https:// protocol unless the host is localhost or contains the keyword "internal".

Parameters:
endpoint - a non null, non empty String representation of a Force.com endpoint
Returns:
a fully qualified, versioned Force.com API endpoint

loadConnectorPropsFromName

public static Map<ForceConnectionProperty,String> loadConnectorPropsFromName(String connectionName)
                                                                      throws IOException
Loads Force.com connection properties from a connection name.

A connection name can represent connection properties in several locations (and different formats). Connection properties will be searched for in the following order:

  1. Force.com connection URL in an environment variable of the form FORCE__URL (case insensitive match)
  2. Force.com connection URL in a Java System property of the form force..url (case sensitive match)
  3. Force.com connection URL in a properties file on the classpath of the form .properties (case sensitive match)
  4. key=value connection properties in a properties file on the classpath of the form .properties (case sensitive match)
  5. Force.com connection URL in the CLIForce connection file of the form = (case sensitive match)

Parameters:
connectionName - a name which represents one of the locations above
Returns:
a Map which maps ForceConnectionProperty enum values to connection property values
Throws:
IOException - if an attempt to interact with a classpath properties file or the CLIForce connection file results in a thrown IOException
See Also:
ForceConnectionProperty

loadConnectorPropsFromUrl

public static Map<ForceConnectionProperty,String> loadConnectorPropsFromUrl(String connectionUrl)
Loads Force.com connection properties from a Force.com connection url

A Force.com connection url must start with the force:// protocol followed by a non empty endpoint string. Connection properties are specified with key=value pairs and delimited by a semi-colon (';') after the endpoint. Any connection property keys not recognized (i.e. that are not in the ForceConnectionProperty enum) are ignored.

Parameters:
connectionUrl - a well qualified Force.com connection URL
Returns:
a Map which maps ForceConnectionProperty enum values to connection property values
Throws:
IllegalArgumentException - if connectionUrl is null
IllegalArgumentException - if connectionUrl does not start with force://
IllegalArgumentException - if the endpoint within connectionUrl is empty
IllegalArgumentException - if the endpoint within connectionUrl is not valid
See Also:
ForceConnectionProperty


Copyright © 2011. All Rights Reserved.