changeset 7:bc57f2660b0f

implementation of web service
author Jorge Urzua <jurzua@mpiwg-berlin.mpg.de>
date Fri, 12 Apr 2013 17:48:42 +0200
parents 7d231e4e86e5
children 9ce7979fd037
files pom.xml src/main/java/de/mpiwg/indexmeta/AnnotateIndexMeta.java src/main/java/de/mpiwg/indexmeta/services/DataProvider.java src/main/java/de/mpiwg/indexmeta/services/PersistentService.java src/main/java/de/mpiwg/indexmeta/web/beans/AbstractBean.java src/main/java/de/mpiwg/indexmeta/web/beans/ApplicationBean.java src/main/java/de/mpiwg/indexmeta/web/beans/SessionBean.java src/main/java/de/mpiwg/indexmeta/web/servlet/AbstractServlet.java src/main/java/de/mpiwg/indexmeta/web/servlet/JSONInterface.java src/main/java/de/mpiwg/indexmeta/web/servlet/methods/AbstractServletMethod.java src/main/java/de/mpiwg/indexmeta/web/servlet/methods/JSONGetCtxFromDB.java src/main/java/de/mpiwg/indexmeta/web/utils/JSONUtils.java src/main/java/log4j.properties src/main/webapp/META-INF/MANIFEST.MF src/main/webapp/WEB-INF/.faces-config.xml.jsfdia src/main/webapp/WEB-INF/faces-config.xml src/main/webapp/WEB-INF/web.xml src/main/webapp/pages/home.xhtml src/main/webapp/pages/index.jsp src/main/webapp/template/template.xhtml
diffstat 20 files changed, 802 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pom.xml	Fri Apr 12 14:28:32 2013 +0200
+++ b/pom.xml	Fri Apr 12 17:48:42 2013 +0200
@@ -43,6 +43,15 @@
 	</build>
 
 	<dependencies>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>3.0.1</version>
+            <scope>provided</scope>
+        </dependency>           
+        
+
 	    <!-- compat -->	
 		<dependency>
 		    <groupId>org.icefaces</groupId>
@@ -54,13 +63,21 @@
 	        		<groupId>javax.servlet.jsp</groupId>
 	        	</exclusion>
 	        </exclusions>
+		</dependency>
+		
 
-		</dependency>
 		<dependency>
 		  <groupId>org.glassfish</groupId>
 		  <artifactId>javax.faces</artifactId>
 		  <version>2.1.6</version>
 		</dependency>			
+		
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20090211</version>
+        </dependency>	
+		
 		<!--  
 		<dependency>
 		    <groupId>javax.el</groupId>
--- a/src/main/java/de/mpiwg/indexmeta/AnnotateIndexMeta.java	Fri Apr 12 14:28:32 2013 +0200
+++ b/src/main/java/de/mpiwg/indexmeta/AnnotateIndexMeta.java	Fri Apr 12 17:48:42 2013 +0200
@@ -62,7 +62,8 @@
                 NodeList nodeList = doc.getElementsByTagName(contextElement);
                 for(int i=0; i < nodeList.getLength(); i++){
                     Node iter2 = nodeList.item(i);
-                    String currentNodeValue = iter2.getTextContent();
+                    String currentNodeValue = null;
+                    //String currentNodeValue = iter2.getTextContent();
                     NamedNodeMap attr = iter2.getAttributes();
                     // make a new attribute
                     if (attr.getNamedItem("context-id") == null){
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/indexmeta/services/DataProvider.java	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,54 @@
+package de.mpiwg.indexmeta.services;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import de.mpiwg.indexmeta.bo.Contextualization;
+
+public class DataProvider {
+
+	protected static Logger logger = Logger.getLogger(DataProvider.class);
+	
+	public DataProvider(){
+		logger.info("Starting DataProvider *********");
+	}
+	
+	private PersistentService ps = new PersistentService();
+	
+	public List<Contextualization> getCtxByIndexMetaId(String indexMetaId){
+		//QuadKey(indexMetaId, type, remoteId, id)
+		return ps.getCtxMap().getValuesByFirstKey(indexMetaId);
+	}
+	
+	public List<Contextualization> getCtxByType(String type){
+		//QuadKey(indexMetaId, type, remoteId, id)
+		return ps.getCtxMap().getValuesBySecondKey(type);
+	}
+	
+	public List<Contextualization> getCtxByRemoteId(String remoteId){
+		//QuadKey(indexMetaId, type, remoteId, id)
+		return ps.getCtxMap().getValuesByThirdKey(remoteId);
+	}
+	
+	public List<Contextualization> getCtx(String indexMetaId, String elementId){
+		List<Contextualization> rs = new ArrayList<Contextualization>();
+		
+		for(Contextualization ctx : ps.getCtxMap().getValuesByFirstKey(indexMetaId)){
+			if(ctx.getElementId().equals(elementId)){
+				rs.add(ctx);
+			}
+		}
+		return rs;
+	}
+	
+	public Contextualization getCtx(Long id){
+		return ps.getCtxMap().getValuesByOwnKey(id);
+	}
+	
+	public void saveCtx(Contextualization ctx){
+		ps.saveCtx(ctx);
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/indexmeta/services/PersistentService.java	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,71 @@
+package de.mpiwg.indexmeta.services;
+
+import java.util.List;
+
+import javax.persistence.Query;
+
+import de.mpiwg.indexmeta.bo.Contextualization;
+import de.mpiwg.indexmeta.utils.QuadMap;
+
+public class PersistentService {
+
+	private QuadMap<Contextualization> ctxMap = null;
+    private javax.persistence.EntityManagerFactory emf;
+    private javax.persistence.EntityManager em;
+    private String PERSISTENCE_UNIT_NAME = "uno";
+
+
+	public QuadMap<Contextualization> getCtxMap() {
+		if(ctxMap == null){
+			this.loadCtxMap();
+		}
+		return ctxMap;
+	}
+	
+	public void saveCtx(Contextualization ctx){
+		System.out.println("Saving= " + ctx.toString());
+		
+		initEntityManager();
+		em.getTransaction().begin();
+		
+		em.persist(ctx);
+		ctxMap.put(ctx.getKey(), ctx);
+		
+		em.getTransaction().commit();
+		closeEntityManager();
+		
+		System.out.println("Saved= " + ctx.toString());
+	}
+	
+	
+	private void loadCtxMap(){
+		ctxMap = new QuadMap<Contextualization>();
+		
+		initEntityManager();
+		em.getTransaction().begin();
+
+		Query q = em.createQuery("from Contextualization");
+		List<Contextualization> list =  q.getResultList();
+				
+		for(Contextualization ctx : list){
+			ctxMap.put(ctx.getKey(), ctx);
+		}
+	        
+		em.getTransaction().commit();
+		closeEntityManager();
+	}
+	
+	
+    private void initEntityManager() {
+        emf = javax.persistence.Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
+        em = emf.createEntityManager();
+    }
+
+    private void closeEntityManager() {
+        em.close();
+        emf.close();
+    }
+	
+	
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/indexmeta/web/beans/AbstractBean.java	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,69 @@
+package de.mpiwg.indexmeta.web.beans;
+
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.apache.commons.lang.StringUtils;
+
+public abstract class AbstractBean {
+	
+	public static String BEAN_APP = "appBean";
+	public static String BEAN_SESSION = "sessionBean";
+	
+	private String requestContextPath = null;
+	
+	public AbstractBean(){
+	}
+	
+	public String getContextPath(){
+		FacesContext fc = FacesContext.getCurrentInstance();
+		ExternalContext ec = fc.getExternalContext();
+		return ec.getRequestContextPath();
+	}
+	
+	public String getRequestContextPath(){
+		if(StringUtils.isEmpty(requestContextPath)){
+			String root = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
+			String[] s = root.split(";");	
+			requestContextPath = s[0];
+		}
+		return requestContextPath;
+	}
+	
+	public ApplicationBean getAppBean(){
+		ApplicationBean appBean = 
+			((ApplicationBean)FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get(BEAN_APP));
+		
+		if(appBean == null){
+			appBean = new ApplicationBean();
+			FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().put(BEAN_APP, appBean);
+		}
+		
+		return appBean; 
+	}
+	
+	protected SessionBean getSession(){
+		SessionBean session = 
+			((SessionBean)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(BEAN_SESSION));
+		
+		if(session == null){
+			session = new SessionBean();
+			FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(BEAN_SESSION, session);
+		}
+		
+		return session;
+	}
+	
+	protected Object getRequestBean(String name){
+		return FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(name);
+	}
+	
+	protected void addMsg(String msg){
+		getSession().addMsg(msg);
+	}
+	
+	protected void addError(String error){
+		getSession().addError(error);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/indexmeta/web/beans/ApplicationBean.java	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,47 @@
+package de.mpiwg.indexmeta.web.beans;
+
+import java.lang.management.ManagementFactory;
+
+import org.apache.log4j.Logger;
+
+import de.mpiwg.indexmeta.services.DataProvider;
+
+public class ApplicationBean {
+	
+	protected static Logger logger = Logger.getLogger(ApplicationBean.class);
+
+	DataProvider dp = new DataProvider();
+	
+	public ApplicationBean(){
+		logger.info("Starting ApplicationBean *********");
+		
+		logger.info(ManagementFactory.getRuntimeMXBean().getName());
+		
+		try{
+			int mb = 1024*1024;
+			 
+	        //Getting the runtime reference from system
+	        Runtime runtime = Runtime.getRuntime();
+	 
+	        logger.info("##### Heap utilization statistics [MB] #####");
+	 
+	        //Print used memory
+	        logger.info("Used Memory:"
+	            + (runtime.totalMemory() - runtime.freeMemory()) / mb);
+	 
+	        //Print free memory
+	        logger.info("Free Memory:"
+	            + runtime.freeMemory() / mb);
+	 
+	        //Print total available memory
+	        logger.info("Total Memory:" + runtime.totalMemory() / mb);
+	 
+	        //Print Maximum available memory
+	        logger.info("Max Memory:" + runtime.maxMemory() / mb + "\n");
+	        
+		}catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/indexmeta/web/beans/SessionBean.java	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,5 @@
+package de.mpiwg.indexmeta.web.beans;
+
+public class SessionBean extends AbstractBean {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/indexmeta/web/servlet/AbstractServlet.java	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,46 @@
+package de.mpiwg.indexmeta.web.servlet;
+
+import javax.faces.FactoryFinder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import de.mpiwg.indexmeta.web.beans.AbstractBean;
+import de.mpiwg.indexmeta.web.beans.ApplicationBean;
+
+
+public class AbstractServlet extends HttpServlet {
+	private static final long serialVersionUID = 1L;
+	
+	public static String METHOD = "mt";
+	public static String getCtxFromDB = "getCtxFromDB";
+	
+	public ApplicationBean getAppBean(HttpServletRequest request, HttpServletResponse response) {
+		ApplicationBean appBean = (ApplicationBean)getApplicationBean(request, response, AbstractBean.BEAN_APP);
+		
+		
+		if(appBean == null){
+			appBean = new ApplicationBean();
+			getFacesContext(request, response).getCurrentInstance().getExternalContext().getApplicationMap().put(AbstractBean.BEAN_APP, appBean);			
+		}
+		return appBean; 
+	}
+	
+	public Object getApplicationBean(HttpServletRequest request, HttpServletResponse response, String bean) {
+		return getFacesContext(request, response).getExternalContext().getApplicationMap().get(bean);
+	}
+
+	
+	public FacesContext getFacesContext(HttpServletRequest request, HttpServletResponse response) { 
+		ServletContext servletContext = ((HttpServletRequest)request).getSession().getServletContext(); 
+		FacesContextFactory contextFactory = (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY); 
+		LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY); 
+		Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE); 
+		return contextFactory.getFacesContext(servletContext, request, response, lifecycle);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/indexmeta/web/servlet/JSONInterface.java	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,100 @@
+package de.mpiwg.indexmeta.web.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.json.JSONObject;
+
+import de.mpiwg.indexmeta.web.servlet.methods.JSONGetCtxFromDB;
+
+public class JSONInterface extends AbstractServlet implements Servlet{
+	private static final long serialVersionUID = 1L;
+	
+	private static Logger logger = Logger.getLogger(JSONInterface.class);
+
+	private HttpServletRequest request;
+	private HttpServletResponse response;
+	
+	private void initialize(HttpServletRequest request, HttpServletResponse response){
+
+		this.request = request;
+		this.response = response;
+		this.response.setContentType("application/json; charset=UTF-8");
+
+		try {
+			System.out.println(request.getCharacterEncoding());
+			request.setCharacterEncoding("UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+		} 
+	}
+	
+	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+		this.doIt(request, response);
+	}
+	
+	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+		this.doIt(request, response);
+	}
+	
+	public void doIt(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+		long start = System.currentTimeMillis();
+		this.initialize(request, response);
+
+		String method = request.getParameter(METHOD);
+		
+		logger.info("Starting " + paramsToString(request.getParameterMap()));
+		
+		
+		if(StringUtils.isNotEmpty(method)){
+			try{
+				
+				if(method.equals(getCtxFromDB)){
+					JSONGetCtxFromDB.execute(null, request, response);
+				}else if(method.equals("")){
+					
+				}
+				
+			}catch (Exception e) {
+				logger.error(e.getMessage(), e);
+				PrintWriter out = response.getWriter();
+				out.print(e.getMessage());
+				response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+			}
+		}else{
+			response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter method can not be null.");
+		}
+		
+		long end = System.currentTimeMillis();
+		logger.info("Finish [time=" + (end-start) + "] " + paramsToString(request.getParameterMap()));
+	}
+	
+	private String paramsToString(Map<String, String[]> paramMap){
+		StringBuilder sb = new StringBuilder();
+		
+		for(Entry<String, String[]> entry : paramMap.entrySet()){
+			sb.append(entry.getKey() + "=[");
+			int count = 0;
+			for(String value : entry.getValue()){
+				if(count > 0){
+					sb.append(", ");
+				}
+				sb.append(value);
+				count++;
+			}
+			sb.append("] ");
+		}
+		
+		return sb.toString();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/indexmeta/web/servlet/methods/AbstractServletMethod.java	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,111 @@
+package de.mpiwg.indexmeta.web.servlet.methods;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang.StringUtils;
+
+import de.mpiwg.indexmeta.bo.Contextualization;
+
+public abstract class AbstractServletMethod {
+	
+	public static String p_indexMetaId = "indexMetaId";
+	public static String p_type = "type";
+	public static String p_remoteId = "remoteId";
+	public static String p_elementId = "elementId";
+	
+	protected static String RUNTIME = "runtime";
+	
+	public static Long getLong(HttpServletRequest request, String name){
+		Long value = null;
+		try{
+			String s = request.getParameter(name);
+			value = new Long(s);
+		}catch (Exception e) {
+		}
+		return value;
+	}
+	
+	public static String getString(HttpServletRequest request, String name){
+		String value = null;
+		try{
+			value = request.getParameter(name);
+		}catch (Exception e) {
+		}
+		return value;
+	}
+	
+	public static Boolean getBoolean(HttpServletRequest request, String name){
+		Boolean value = null;
+		try{
+			String s = request.getParameter(name);
+			value = new Boolean(s);
+		}catch (Exception e) {
+		}
+		return value;
+	}
+	
+	public static Integer getInteger(HttpServletRequest request, String name){
+		Integer value = null;
+		try{
+			String s = request.getParameter(name);
+			value = new Integer(s);
+		}catch (Exception e) {
+		}
+		return value;
+	}
+	
+	protected static List<Contextualization> filterByType(List<Contextualization> list, String type){
+		if(StringUtils.isEmpty(type)){
+			return list;
+		}
+		List<Contextualization> rs = new ArrayList<Contextualization>();		
+		for(Contextualization ctx : list){
+			if(type.equals(ctx.getType())){
+				rs.add(ctx);
+			}
+		}		
+		return rs;
+	}
+	
+	protected static List<Contextualization> filterByElementId(List<Contextualization> list, String elementId){
+		if(StringUtils.isEmpty(elementId)){
+			return list;
+		}
+		List<Contextualization> rs = new ArrayList<Contextualization>();		
+		for(Contextualization ctx : list){
+			if(elementId.equals(elementId)){
+				rs.add(ctx);
+			}
+		}		
+		return rs;
+	}
+	
+	protected static List<Contextualization> filterByRemoteId(List<Contextualization> list, String remoteId){
+		if(StringUtils.isEmpty(remoteId)){
+			return list;
+		}
+		List<Contextualization> rs = new ArrayList<Contextualization>();		
+		for(Contextualization ctx : list){
+			if(remoteId.equals(ctx.getRemoteId())){
+				rs.add(ctx);
+			}
+		}		
+		return rs;
+	}
+	
+	public static List<Long> getLongList(HttpServletRequest request, String name){
+		List<Long> list = new ArrayList<Long>();
+		String s = request.getParameter(name);
+		String[] array = s.split("[|]");
+		for(String sID : array){
+			try{
+				Long id = new Long(sID);
+				list.add(id);
+			}catch (Exception e) {}
+		}
+		return list;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/indexmeta/web/servlet/methods/JSONGetCtxFromDB.java	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,71 @@
+package de.mpiwg.indexmeta.web.servlet.methods;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import de.mpiwg.indexmeta.bo.Contextualization;
+import de.mpiwg.indexmeta.services.DataProvider;
+import de.mpiwg.indexmeta.web.utils.JSONUtils;
+
+public class JSONGetCtxFromDB extends AbstractServletMethod {
+
+	public static void execute(DataProvider dp,
+			HttpServletRequest request, HttpServletResponse response)
+			throws ServletException, IOException, JSONException {
+		
+		JSONObject json = new JSONObject();
+
+		long startExecution = System.currentTimeMillis();
+
+		String indexMetaId = getString(request, p_indexMetaId);
+		String type = getString(request, p_type);
+		String elementId = getString(request, p_elementId);
+		String remoteId = getString(request, p_remoteId);
+
+		List<Contextualization> rs = null;
+
+		if (StringUtils.isNotEmpty(indexMetaId)) {
+
+			rs = dp.getCtxByIndexMetaId(indexMetaId);
+			rs = filterByType(rs, type);
+			rs = filterByElementId(rs, elementId);
+			rs = filterByRemoteId(rs, remoteId);
+
+		} else if (StringUtils.isNotEmpty(type)) {
+
+			rs = dp.getCtxByType(type);
+			rs = filterByElementId(rs, elementId);
+			rs = filterByRemoteId(rs, remoteId);
+
+		} else {
+			response.sendError(HttpServletResponse.SC_BAD_REQUEST,
+					"Parameters 'indexMetaId' and 'type' are null. "
+							+ "At least one of them must be not null.");
+			return;
+		}
+
+		JSONArray rsArray = new JSONArray();
+		for (Contextualization ctx : rs) {
+			rsArray.put(JSONUtils.ctx2JSON(ctx));
+		}
+
+		json.put("rs", rsArray);
+		json.put(RUNTIME, (System.currentTimeMillis() - startExecution));
+		
+		PrintWriter out = response.getWriter();
+		out.print(json.toString());	
+
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/mpiwg/indexmeta/web/utils/JSONUtils.java	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,26 @@
+package de.mpiwg.indexmeta.web.utils;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import de.mpiwg.indexmeta.bo.Contextualization;
+
+public class JSONUtils {
+
+	public static JSONObject ctx2JSON(Contextualization ctx) throws JSONException{
+		JSONObject json = new JSONObject();
+		
+		json.put("comment", ctx.getComment());
+		json.put("content", ctx.getContent());
+		json.put("elementId", ctx.getElementId());
+		json.put("id", ctx.getId());
+		json.put("indexMetaId", ctx.getIndexMetaId());
+		json.put("remoteId", ctx.getRemoteId());
+		json.put("state", ctx.getState());
+		json.put("type", ctx.getType());
+		json.put("xpath", ctx.getXpath());
+		
+		return json;
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/log4j.properties	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,13 @@
+### direct log messages to stdout ###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+### direct messages to file hibernate.log ###
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.File=${catalina.home}/logs/indexMetaContextualizer.log
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+log4j.rootLogger=INFO, stdout
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/META-INF/MANIFEST.MF	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PROCESS model-entity="JSFProcess"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/WEB-INF/faces-config.xml	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<faces-config
+    xmlns="http://java.sun.com/xml/ns/javaee"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+    version="2.0">
+    
+    <managed-bean>
+        <managed-bean-name>sessionBean</managed-bean-name>
+        <managed-bean-class>de.mpiwg.indexmeta.web.beans.SessionBean</managed-bean-class>
+        <managed-bean-scope>session</managed-bean-scope>
+    </managed-bean>
+    <managed-bean>
+        <managed-bean-name>appBean</managed-bean-name>
+        <managed-bean-class>de.mpiwg.indexmeta.web.beans.ApplicationBean</managed-bean-class>
+        <managed-bean-scope>application</managed-bean-scope>
+    </managed-bean>
+
+</faces-config>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/WEB-INF/web.xml	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+	id="WebApp_ID" version="3.0">
+
+	<display-name>IndexMetaContextualizer</display-name>
+
+	<welcome-file-list>
+		<welcome-file>pages/index.jsp</welcome-file>
+		<!-- 
+		<welcome-file>index.html</welcome-file>
+		<welcome-file>index.htm</welcome-file>
+		<welcome-file>index.jsp</welcome-file>
+		<welcome-file>default.html</welcome-file>
+		<welcome-file>default.htm</welcome-file>
+		<welcome-file>default.jsp</welcome-file>
+		 -->
+	</welcome-file-list>
+	
+    <servlet>
+        <servlet-name>ws</servlet-name>
+        <servlet-class>de.mpiwg.indexmeta.web.servlet.JSONInterface</servlet-class>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>ws</servlet-name>
+        <url-pattern>/ws</url-pattern>
+    </servlet-mapping> 	
+	
+	
+	<servlet>
+		<servlet-name>Faces Servlet</servlet-name>
+		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+	<servlet-mapping>
+		<servlet-name>Faces Servlet</servlet-name>
+		<url-pattern>*.xhtml</url-pattern>
+		<!-- <url-pattern>/faces/*</url-pattern> <url-pattern>/icefaces/*</url-pattern> -->
+	</servlet-mapping>
+	<context-param>
+		<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
+		<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+		<param-value>server</param-value>
+	</context-param>
+	<context-param>
+		<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
+		<param-value>resources.application</param-value>
+	</context-param>
+	<listener>
+		<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
+	</listener>
+	<context-param>
+		<param-name>javax.faces.PROJECT_STAGE</param-name>
+		<param-value>Development</param-value>
+	</context-param>
+	<context-param>
+		<param-name>org.icefaces.mandatoryResourceConfiguration</param-name>
+		<param-value></param-value>
+	</context-param>
+	<context-param>
+		<param-name>org.icefaces.ace.theme</param-name>
+		<param-value>sam</param-value>
+	</context-param>
+	<context-param>
+		<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
+		<param-value>true</param-value>
+	</context-param>
+	<context-param>
+		<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
+		<param-value>false</param-value>
+	</context-param>
+	<context-param>
+		<description>Google Maps API key is required if gMap component is used. Sign up for an API key from http://code.google.com/apis/maps/signup.html</description>
+		<param-name>com.icesoft.faces.gmapKey</param-name>
+		<param-value>ABQIAAAADlu0ZiSTam64EKaCQr9eTRTOTuQNzJNXRlYRLknj4cQ89tFfpxTEqxQnVWL4k55OPICgF5_SOZE06A</param-value>
+	</context-param>
+	 
+	<servlet>
+		<servlet-name>Resource Servlet</servlet-name>
+		<servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+	
+	<servlet-mapping>
+		<servlet-name>Resource Servlet</servlet-name>
+		<url-pattern>/xmlhttp/*</url-pattern>
+	</servlet-mapping>
+</web-app>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/pages/home.xhtml	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,16 @@
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:f="http://java.sun.com/jsf/core"
+    xmlns:c="http://java.sun.com/jsp/jstl/core"
+    xmlns:ace="http://www.icefaces.org/icefaces/components"
+    xmlns:ice="http://www.icesoft.com/icefaces/component"
+    xmlns:icecore="http://www.icefaces.org/icefaces/core"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    template="../template/template.xhtml">
+
+    <ui:define name="content">
+        <f:view>
+            <ice:outputLabel value="Home"/>
+        </f:view>
+    </ui:define>
+</ui:composition>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/pages/index.jsp	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,6 @@
+<html>
+    <head/>
+    <body>
+        <jsp:forward page="/pages/home.xhtml" />
+    </body>
+</html>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/webapp/template/template.xhtml	Fri Apr 12 17:48:42 2013 +0200
@@ -0,0 +1,33 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:f="http://java.sun.com/jsf/core"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:icecore="http://www.icefaces.org/icefaces/core"
+    xmlns:ace="http://www.icefaces.org/icefaces/components"
+    xmlns:ice="http://www.icesoft.com/icefaces/component">
+
+<h:head>
+    <title>IndexMetaContextualizer</title>
+    <ice:outputStyle href="/resources/icefaces/rime/rime.css" />
+    <ice:outputStyle href="/resources/style.css" />
+              
+</h:head>
+<h:body>
+
+            <ice:outputConnectionStatus />
+            
+            <div id="canvas"></div>
+            
+            <div id="page">
+                <div id="page-bgtop">
+                    <div id="page-bgbtm">
+                        <ui:insert name="content" />
+                    </div>
+                </div>
+            </div>          
+</h:body>
+</html>
+
+