package com.celements.web.service;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.Requirement;
import org.xwiki.context.Execution;
import org.xwiki.script.service.ScriptService;

import com.celements.sajson.Builder;
import com.xpn.xwiki.XWikiContext;

@Component("mobileLogging")
public class MobileLoggingScriptService implements ScriptService {

  private static Log LOGGER = LogFactory.getFactory().getInstance(
      MobileLoggingScriptService.class);

  @Requirement
  Execution execution;

  private XWikiContext getContext() {
    return (XWikiContext)execution.getContext().getProperty("xwikicontext");
  }

  public String dimensionAndAgentLog() {
    LOGGER.info("dimensionAndAgentLog: mobileDim ["
        + getContext().getRequest().getParameter("mobileDim") + "], userAgent ["
        + getContext().getRequest().getParameter("userAgent")
        + "], isOrientationLandscape [" + getContext().getRequest().getParameter(
            "isOrientationLandscape") + "]");
    Builder jsonBuilder = new Builder();
    jsonBuilder.openDictionary();
    jsonBuilder.addStringProperty("message", "OK");
    jsonBuilder.closeDictionary();
    return jsonBuilder.getJSON();
  }

}

@@ -772,24 +772,121 @@
 gentLog() %7B%0A
+    return dimensionAndAgentLog(%22%22);%0A  %7D%0A%0A  public String dimensionAndAgentLog(String message) %7B%0A
     LOGGER.i
@@ -1189,16 +1189,43 @@
 cape%22) +
+ %22%5D, message %5B%22 + message +
  %22%5D%22);%0A 

extend dimensionAndAgentLog with message parameter