Personal tools
You are here: Home GRIA Documentation Documentation 5.2 Tutorials Java Interface Tutorial Service Provider Management Java Interface

Service Provider Management Java Interface

A Java tutorial for the Trade Account and SLA Service
Tutorials on how to use the GRIA Client Interface API
Page 3 of 15.

Opening a Trade Account

In order to use some services a Trade Account is required. First we create a proxy to the RemoteTradeAccountService

EndpointReferenceType tradeAccountServiceEPR = 
	ConversationID.getEPR("http://.../gria-service-provider-mgt/services/TradeAccountService");
RemoteTradeAccountService tradeAccountService = 
	(RemoteTradeAccountService) repository.getOrCreateObject(RemoteTradeAccountService.class,tradeAccountServiceEPR);

Then we can request a TradeAccountConversation using the openAccount method

TradeAccountConversation tradeAccount 
	= tradeAccountService.openAccount(Name","1234","email@mycompany.com",
		new AddressType(),"1234-1234-1234","TradeAccount1");

Creating an SLA

In order to use some services an SLA is required. First we create a proxy to the RemoteSLAService

EndpointReferenceType slaServiceEPR = ConversationID.getEPR("http://.../gria-service-provider-mgt/services/SLAService");
RemoteSLAService slaService = (RemoteSLAService) repository.getOrCreateObject(RemoteSLAService.class,slaServiceEPR);

Then we get a list of resources on the SLA Service. This list will include SLATemplate's and any SLA's  we have access to. We can identify sla templates by getting the type of the resource in the metadata using ConversationID.getResourceType

EndpointReferenceType[] eprs = slaService.getResources();
EndpointReferenceType slaTemplateEPR = null;
for(EndpointReferenceType epr : eprs){
    String resourceType = ConversationID.getResourceType(epr);
     if (resourceType.equals("http://www.it-innovation.soton.ac.uk/grid/resource/sla-template")){
          slaTemplateEPR = epr;
          break;
     }
}

If we find a valid SLATemplate and agree to its terms we can then propose an SLA:

SLATemplateConversation slaTemplateConversation = repository.getOrCreateObject(SLATemplateConversation.class,slaTemplateEPR);
SLATemplate slaTemplate = slaTemplateConversation.getSLATemplate();
SLAProposal slaProposal = new SLAProposal();
slaProposal.setSlaTemplate(slaTemplate);
slaProposal.setStartTime(new GregorianCalendar());
EndpointReferenceType epr = slaService.createSLA(slaProposal, "Name");