package jp.ac.nii.prl.mape.controller.service;

import java.net.URI;

import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import jp.ac.nii.prl.mape.controller.model.MAPEKComponent;

@Service("knowledgeBaseService")
public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {

	/* (non-Javadoc)
	 * @see jp.ac.nii.prl.mape.controller.service.KnowledgeBaseService#put(java.lang.String, java.lang.String)
	 */
	@Override
	public void put(MAPEKComponent kb, String bx, String view) {
		RestTemplate template = new RestTemplate();
		URI location = template.postForLocation(kb.getBaseUrl() + "/bx", view);
		view = template.getForObject(location, String.class);
	}
	
	/* (non-Javadoc)
	 * @see jp.ac.nii.prl.mape.controller.service.KnowledgeBaseService#get(java.lang.String)
	 */
	@Override
	public String get(MAPEKComponent kb, String bx) {
		RestTemplate template = new RestTemplate();
		String view = template.getForObject(kb.getBaseUrl() + "/bx", String.class);
		return view;
	}
}

@@ -623,28 +623,24 @@
 ation(kb.get
-Base
 Url() + %22/bx
@@ -637,19 +637,26 @@
 l() + %22/
+get/%22 + 
 bx
-%22
 , view);
@@ -938,16 +938,66 @@
 late();%0A
+%09%09System.out.println(kb.getUrl() + %22/get/%22 + bx);%0A
 %09%09String
@@ -1032,20 +1032,16 @@
 t(kb.get
-Base
 Url() + 
@@ -1046,11 +1046,18 @@
 + %22/
+get/%22 + 
 bx
-%22
 , St

Fix URLs in KB service calls