public String request(String request) {
		
		Response response = new Response(Status.failed, null, null);
		
		Gson gson = GsonFactory.getGsonInstance();
		JsonParser parser = new JsonParser();
		
		IHandler handler = null;
		
		try {
			
			JsonElement root = parser.parse(request);
			
			if(root.isJsonObject()) {
				JsonObject rootobj = root.getAsJsonObject();
				JsonElement action = rootobj.get(ACTION_TOKEN);
				JsonElement data = rootobj.get(DATA_TOKEN);
				
				if(action == null) {
					throw new Exception(NO_ACTION);
				}
				
				RequestType type = gson.fromJson(action, RequestType.class);				
				handler = HandlerFactory.findHandler(type);
				response = handler.handle(data);
				
			}
	
		} catch (JsonParseException e) {
			response = new Response(Status.jsonError, e.getMessage(), null);
			Log.getLogger().fine("json parse error: " + e.getMessage());
		} catch (Exception e) {
			response = new Response(Status.failed, e.getMessage(), null);
			Log.getLogger().fine("error: " + e.getMessage());
		}
		
		
		String response_str = "";
		try {
			response_str = gson.toJson(response);
		} catch (Exception e) {
			response_str = "{\"status\":\"" +Status.jsonError +"\",\"message\":\""+ e + ": "+e.getMessage()+"\"}";
			Log.getLogger().fine("json serializaion error: " + e.getMessage());
		}
		
		if(Configuration.LogRequests) {
			try {
				File f,r;
				int i = 0;
				while(true) {
					f = new File(Configuration.LogRequestPath + "/" + handler.getClass().getSimpleName() + "_" +i);
					r = new File(Configuration.LogRequestPath + "/" + handler.getClass().getSimpleName() + "_" +i + "_response");
					if(!f.exists()) {
						BufferedWriter bw = new BufferedWriter(new FileWriter(f));
						bw.write(request);
						bw.close();
						
						bw = new BufferedWriter(new FileWriter(r));
						bw.write(response_str);
						bw.close();
						break;
					} else {
						i++;
					}
				}
			} catch (IOException e) {
				
			}
		}

		return response_str;		
	}