dpillot 2005/12/12 17:14:55 CET
Modified files:
core/src/java/org/jahia/ajax/monitors PDisplayAction.java
core/src/java/org/jahia/ajax AjaxAction.java
Log:
added running info
Revision Changes Path
1.3 +29 -1 jahia/core/src/java/org/jahia/ajax/AjaxAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/ajax/AjaxAction.java.diff?r1=1.2&r2=1.3&f=h
1.4 +13 -16
jahia/core/src/java/org/jahia/ajax/monitors/PDisplayAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/ajax/monitors/PDisplayAction.java.diff?r1=1.3&r2=1.4&f=h
Index: PDisplayAction.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/ajax/monitors/PDisplayAction.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PDisplayAction.java 9 Dec 2005 11:24:55 -0000 1.3
+++ PDisplayAction.java 12 Dec 2005 16:14:54 -0000 1.4
@@ -28,7 +28,7 @@
* (the better approximation we have for now of the "working charge" of
process server).
*
* @author joepi
- * @version $Id: PDisplayAction.java,v 1.3 2005/12/09 11:24:55 dpillot Exp $
+ * @version $Id: PDisplayAction.java,v 1.4 2005/12/12 16:14:54 dpillot Exp $
*/
public class PDisplayAction extends AjaxAction {
@@ -50,41 +50,35 @@
*/
public ActionForward execute(final ActionMapping mapping, final
ActionForm form, final HttpServletRequest request, final HttpServletResponse
response) throws IOException, ServletException {
- boolean isRoot = false;// user have right to access to all server
process
- boolean isSiteAdmin = false;// user have right to access to site
process
List process;//process (jobdetails) list
try {
final JahiaUser currentUser = (JahiaUser)
request.getSession().getAttribute(ParamBean.SESSION_USER);
final JahiaSite site = (JahiaSite)
request.getSession().getAttribute("org.jahia.services.sites.jahiasite");
- if (currentUser == null || site == null || !currentUser.isRoot()
|| !currentUser.isAdminMember(site.getID())) {
+ if (currentUser == null || site == null /*||
!currentUser.isRoot() || !currentUser.isAdminMember(site.getID())*/) {
logger.warn("Unauthorized attempt to use AJAX Struts Action
- Process display");
response.sendError(HttpServletResponse.SC_FORBIDDEN,
"Error: Must be logged in and have 'Admin' access");
return null;
}
-
+ logger.debug("user:"+currentUser.getUsername()+"
(isroot:"+currentUser.isRoot()+")
(isAdmin:"+currentUser.isAdminMember(site.getID())+")");
if (currentUser.isRoot()) {
- isRoot = true;
process = getAllProcess();
} else if (currentUser.isAdminMember(site.getID())) {
- isSiteAdmin = true;
process = getSiteProcessList(site.getSiteKey());
} else {
process = getUserProcessList(currentUser);
}
// concurrent threads running
int threadCount = service.getCurrentlyExecutingJobs().size();
+ StringBuffer buf=new StringBuffer();
+ StringBuffer bufval = new StringBuffer();
+ bufval.append(buildXmlElement("count",""+process.size()));
+ bufval.append(buildXmlElement("running",""+threadCount));
+ buildXmlElement(buf,"response",bufval.toString());
- final List tagnames = new Vector();
- final List tagvals = new Vector();
- tagnames.add("count");
- tagvals.add("" + process.size());
- tagnames.add("running");
- tagvals.add("" + threadCount);
-
- sendResponse(tagnames, tagvals, response);
+ sendResponse(buf.toString(),response);
} catch (Exception e) {
@@ -173,6 +167,9 @@
}
/**
* $Log: PDisplayAction.java,v $
+ * Revision 1.4 2005/12/12 16:14:54 dpillot
+ * added running info
+ *
* Revision 1.3 2005/12/09 11:24:55 dpillot
* added running info
*
Index: AjaxAction.java
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/java/org/jahia/ajax/AjaxAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AjaxAction.java 9 Nov 2005 18:01:11 -0000 1.2
+++ AjaxAction.java 12 Dec 2005 16:14:54 -0000 1.3
@@ -54,6 +54,7 @@
* request processing for AJAX calls. It contains utility methods and 1
abstract method.
*
* @author Xavier Lawrence
+ * @version $Id: AjaxAction.java,v 1.3 2005/12/12 16:14:54 dpillot Exp $
*/
public abstract class AjaxAction extends Action {
@@ -233,7 +234,9 @@
buildXmlElement(buff, tagName, tagValue);
}
- //logger.debug("Response:\n" + buff);
+ sendResponse(buff.toString(),response);
+ /*
+ logger.debug("Response:\n" + buff);
final byte[] bytes = buff.toString().getBytes(CHARSET);
response.setContentType(XML_CONTENT); // mandatory, do not
remove ! (see AJAX spec)
@@ -244,6 +247,27 @@
final OutputStream out = response.getOutputStream();
out.write(bytes);
out.flush();
+ */
+ }
+
+ /**
+ * raw method to send bytes from string
+ * @param resp
+ * @param response
+ * @throws IOException
+ */
+ protected void sendResponse(String resp,HttpServletResponse response)
throws IOException {
+ logger.debug("Response:\n" + resp);
+ byte[] bytes = resp.getBytes(CHARSET);
+
+ response.setContentType(XML_CONTENT); // mandatory, do not
remove ! (see AJAX spec)
+ response.setHeader(CACHE_CONTROL, NO_CACHE); // mandatory, do not
remove ! (see AJAX spec)
+ response.setContentLength(bytes.length);
+ response.setStatus(HttpServletResponse.SC_OK);
+
+ final OutputStream out = response.getOutputStream();
+ out.write(bytes);
+ out.flush();
}
/**
@@ -264,3 +288,10 @@
final HttpServletResponse response)
throws IOException, ServletException;
}
+
+/**
+ * $Log: AjaxAction.java,v $
+ * Revision 1.3 2005/12/12 16:14:54 dpillot
+ * added running info
+ *
+ */
\ No newline at end of file