com.sage.orion.sdata.servlet.accpac.hosting
Class SDSFactory

java.lang.Object
  extended by com.sage.orion.sdata.servlet.accpac.hosting.SDSFactory

public class SDSFactory
extends java.lang.Object

An SDSFactory is a factory for Accpac SharedDataSet objects. It is required to support hosting, where the host server may handle multiple shared data sets.

Be aware that this class contains some code that is quite specific to the way AccpacOnline manages hosting.


Constructor Summary
SDSFactory(javax.servlet.ServletContext context)
          creates an instance of the SDSFactory
 
Method Summary
 java.lang.String getHostCompanyID(javax.servlet.http.HttpServletRequest request)
          gets the host company ID corresponding to this request.
 com.sage.accpac.sm.SharedDataSet getNonHostedSharedDataSet()
          gets the SharedDataSet for a non-hosted situation
 com.sage.accpac.sm.SharedDataSet getSharedDataSet(javax.servlet.http.HttpServletRequest request)
          gets a SharedDataSet that is compatible with the given request.
 java.lang.Iterable<com.sage.accpac.sm.SharedDataSet> getSharedDataSets()
          gets an iterable collection of all the shared data sets that the factory controls
 boolean hostingIsEnabled()
          returns true if and only if hosting is enabled on this factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SDSFactory

public SDSFactory(@NonNull
                  javax.servlet.ServletContext context)
creates an instance of the SDSFactory

Parameters:
context - the ServletContext for which the factory is defined.
Method Detail

getSharedDataSet

@NonNull
public com.sage.accpac.sm.SharedDataSet getSharedDataSet(@NonNull
                                                                 javax.servlet.http.HttpServletRequest request)
gets a SharedDataSet that is compatible with the given request.

In non-hosted situations there is only one shared data directory and so this will return either a new SharedDataSet or else a new reference to a shared object of the class.

In hosted environments different users use different shared data directories and this method will ensure that the user identified by the request has a shared data directory and will return a SharedDataSet against that directory. (Again it may be a second reference to a shared copy)

Parameters:
request - the request being handled. If the system is in hosting mode (with multiple shared data directories) then the request must include an authorization header containing a Basic mode authorization. The system will use the user name from that header to decide upon the correct shared data directory to use.
Returns:
a SharedDataSet that is compatible with the request, or null if there is none.
Throws:
java.lang.IllegalArgumentException - if the request is not in the correct form. The message will indicate in what way the request is unsuitable.

getNonHostedSharedDataSet

@NonNull
public com.sage.accpac.sm.SharedDataSet getNonHostedSharedDataSet()
gets the SharedDataSet for a non-hosted situation

In non-hosted situations there is only one shared data directory and so this will return either a new SharedDataSet or else a new reference to a shared object of the class.

This method should not be called from a hosted environment. Calling this from a hosted environment will result in an IllegalStateException being thrown.

Returns:
a SharedDataSet that is compatible with the request, or null if there is none.
Throws:
java.lang.IllegalStateException - if called in a hosted situation

hostingIsEnabled

public boolean hostingIsEnabled()
returns true if and only if hosting is enabled on this factory

Returns:
true if and only if hosting is enabled

getSharedDataSets

public java.lang.Iterable<com.sage.accpac.sm.SharedDataSet> getSharedDataSets()
gets an iterable collection of all the shared data sets that the factory controls

Returns:
a non-null iterable collection of shared data sets

getHostCompanyID

public java.lang.String getHostCompanyID(javax.servlet.http.HttpServletRequest request)
gets the host company ID corresponding to this request.

If hosting is not enabled a blank string will be returned.

This is equivalent to

 hostingIsEnabled() ? ((HostedSharedDataSet)getSharedDataSet(request)).getHostCompanyID() : "";
 

Parameters:
request - the request being handled. If the system is in hosting mode (with multiple shared data directories) then the request must include an authorization header containing a Basic mode authorization. The system will use the user name from that header to decide upon the correct shared data directory to use.
Returns:
a non-null string containing either a blank string (if hosting is not enabled) or a non-blank string (if hosting is enabled)


Copyright © 2011 Sage Software, Inc. All rights reserved.