Developing and Implementing an SC Service Connector
This section examines an example of code for the SC Service Connector
Import the main SCF and portal packages required for the connector. For more information on these packages, refer to the Javadoc.
import com.sap.ip.collaboration.core.api.scf.client.SCSessionManagerFactory; import com.sap.ip.collaboration.core.api.scf.exception.SCFException; import com.sap.ip.collaboration.core.api.scf.service.ProviderSession; import com.sap.ip.collaboration.core.api.scf.service.UserInfo; import com.sap.ip.collaboration.core.api.util.text.TextBundle; import com.sap.ip.collaboration.sync.api.scf.service.AbstractSCServiceConnector; import com.sap.tc.logging.Location; import com.sapportals.portal.prt.component.IPortalComponentRequest; import com.sapportals.portal.prt.component.IPortalComponentResponse; import com.sapportals.portal.prt.component.IPortalComponentURI; import com.sapportals.portal.prt.logger.Level; import com.sapportals.portal.prt.session.IUserContext;
|
Each SCServiceConnector must extend AbstractScServiceConnector. This class extends the AbstractPortalComponent, which enables it to communicate with Synchronous Collaboration Service providers using HTTP protocol
public class NewServiceConnector extends AbstractSCServiceConnector { public void setupSCSession(ProviderSession providerSession, UserInfo userInfo, IPortalComponentRequest request) throws SCFException{ } public void updateSCSession(String provideSessionId, ProviderSession providerSession, UserInfo userInfo, IPortalComponentRequest request) throws SCFException{ } public void cancelSCSession(String providerSessionId, UserInfo userInfo, IPortalComponentRequest request) throws SCFException{ } public void addUserToSCSession(ProviderSession providerSession, UserInfo userInfo, IPortalComponentRequest request) throws SCFException{ }
} |
Each of above four methods of AbstractSCServiceConnector needs to be implemented by the new SC Service Connector.
This method is called by SCF when the client calls corresponding method in SCF. If this method call is successful, SCF returns session id to the client. The connector can use this method to check resources, permissions, authentications or setup a session in the service provider etc. Hosts of information can be retrieved from input objects by the connector. Implementation of this method can be left blank if connector does not want to make any check before start of the session.
public void setupSCSession(ProviderSession providerSession, UserInfo userInfo, IPortalComponentRequest request) throws SCFException { //getting info about the session String hosts = providerSession.getHosts (); String participants= providerSession.getParticipants (); Date startTime = providerSession.getStartTime(); String username = userInfo.getUserName(); String password = userInfo.getPassword(); String actionUrl = getProviderServerUrl() + username +password; request.getServletResponse(true).sendRedirect(actionUrl); } |
This method is called when the client needs to update meeting parameters. The implementation may be left blank if the connector does not need to do any processing for update of the session.
This method is called when the client needs to cancel the meeting/session. The implementation may be left blank if the connector does not need to do any processing to cancel the session at service provider end.
This method adds the user to the session. This method is used either for starting the session as a host or joining to the session as a participant. SCF calls this method when a user is needed to be added to the ongoing session. The connector in turn could call the provider and pass required information to the service provider.
public void addUserToSCSession(ProviderSession providerSession, UserInfo userInfo, IPortalComponentRequest request) throws SCFException{ //getting the id of the session which was provider by the service provider. String sessionId = providerSession.getSCSessionId(); String serviceTypeId = providerSession.getSCServiceTypeId();
//getting service provider user mapping info. Please refer to section Error! Reference source not found. String username = userInfo.getUserName(); String password = userInfo.getPassword(); String providerUrl = getProviderServerUrl(); String actionUrl = providerUrl+ username +password +sessionId; request.getServletResponse(true).sendRedirect(actionUrl); } |
The following code statements get the information about the user necessary for the connector to authenticate the user with its Service Provider. This information may not be used by the Service Providers who has Single Sign on enabled and does not require additional user information.
String username = userInfo.getUserName(); String password = usrInfo.getPassword(); |