package com.atg.openssp.common.cache.broker;

import com.atg.openssp.common.configuration.ContextCache;
import com.atg.openssp.common.configuration.ContextProperties;
import com.atg.openssp.common.exception.EmptyHostException;

import restful.client.JsonDataProviderConnector;
import restful.context.PathBuilder;
import restful.exception.RestException;

/**
 * Generic Broker to connect to a remote webservice.
 * 
 * @author André Schmer
 *
 */
public abstract class AbstractDataBroker<T> extends DataBrokerObserver {

	protected T connect(final Class<T> clazz) throws RestException, EmptyHostException {
		return new JsonDataProviderConnector<>(clazz).connectDataProvider(getRestfulContext());
	}

	protected PathBuilder getDefaulPathBuilder() {
		final PathBuilder pathBuilder = new PathBuilder();
		pathBuilder.setMaster_pw(ContextCache.instance.get(ContextProperties.MASTER_PW));
		pathBuilder.setMaster_user(ContextCache.instance.get(ContextProperties.MASTER_USER));
		pathBuilder.setServer(ContextCache.instance.get(ContextProperties.DATA_PROVIDER_URL));
		return pathBuilder;
	}
}

@@ -37,19 +37,17 @@
 .broker;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -96,17 +96,16 @@
 xtCache;
-%0D
 %0Aimport 
@@ -159,17 +159,16 @@
 perties;
-%0D
 %0Aimport 
@@ -219,19 +219,17 @@
 ception;
-%0D%0A%0D
+%0A
 %0Aimport 
@@ -269,17 +269,16 @@
 nnector;
-%0D
 %0Aimport 
@@ -305,17 +305,16 @@
 Builder;
-%0D
 %0Aimport 
@@ -349,16 +349,13 @@
 ion;
-%0D%0A%0D
+%0A
 %0A/**
-%0D
 %0A * 
@@ -407,14 +407,12 @@
 ice.
-%0D
 %0A * 
-%0D
 %0A * 
@@ -435,18 +435,15 @@
 hmer
-%0D
 %0A *
-%0D
 %0A */
-%0D
 %0Apub
@@ -511,19 +511,17 @@
 server %7B
-%0D%0A%0D
+%0A
 %0A%09protec
@@ -598,17 +598,16 @@
 eption %7B
-%0D
 %0A%09%09retur
@@ -692,15 +692,12 @@
 ());
-%0D
 %0A%09%7D
-%0D%0A%0D
+%0A
 %0A%09pr
@@ -740,17 +740,16 @@
 lder() %7B
-%0D
 %0A%09%09final
@@ -793,17 +793,16 @@
 ilder();
-%0D
 %0A%09%09pathB
@@ -877,17 +877,16 @@
 ER_PW));
-%0D
 %0A%09%09pathB
@@ -965,17 +965,16 @@
 _USER));
-%0D
 %0A%09%09pathB
@@ -1054,17 +1054,16 @@
 R_URL));
-%0D
 %0A%09%09retur
@@ -1080,13 +1080,210 @@
 der;
-%0D
 %0A%09%7D
-%0D%0A%7D%0D
+%0A%0A%09/**%0A%09 * @return the context of the restful service to connect with %7Bsee PathBuilder%7D.%0A%09 * @throws EmptyHostException%0A%09 */%0A%09public abstract PathBuilder getRestfulContext() throws EmptyHostException;%0A%7D
 %0A

Move getRestfulContext() from superclass to this.