Author: ktlili
Date: Tue Jan 22 11:54:09 2008
New Revision: 19561

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19561&repname=
=3Djahia
Log:
- [GWT] add basic widget + Abstract GWT service

Added:
    branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/widgets/AdvancedTable.java
    branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/widgets/EngineDialogBox.java
    branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/widgets/SimplePagination.java
    branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/server/AbstractJahiaGWTServiceImpl.java
Modified:
    branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/JahiaService.java
    branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/util/DOMUtil.java
    branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/server/JahiaServiceImpl.java

Modified: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gw=
t/base/client/JahiaService.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-INCLUD=
E-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base/client/JahiaService.java=
&rev=3D19561&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/JahiaService.java (original)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/JahiaService.java Tue Jan 22 11:54:09 2008
@@ -21,6 +21,26 @@
  * To change this template use File | Settings | File Templates.
  */
 public interface JahiaService extends RemoteService {
+    /**
+     * Utility/Convinience class.
+     * Use JahiaService.App.getInstance() to access static instance of MyS=
erviceAsync
+     */
+    public static class App {
+        private static JahiaServiceAsync ourInstance =3D null;
+
+
+        public static synchronized JahiaServiceAsync getInstance() {
+            if (ourInstance =3D=3D null) {
+                String relativeServiceEntryPoint =3D JahiaGWTParameters.ge=
tServiceEntryPoint()+"base/";
+                String serviceEntryPoint =3D URL.getAbsolutleURL(relativeS=
erviceEntryPoint);
+                ourInstance =3D (JahiaServiceAsync) GWT.create(JahiaServic=
e.class);
+                ((ServiceDefTarget) ourInstance).setServiceEntryPoint(serv=
iceEntryPoint);
+            }
+
+            return ourInstance;
+        }
+
+    }
 =

     public JahiaGWTContainerList loadContainerList(JahiaGWTPage page, Stri=
ng containerListName);
 =

@@ -60,7 +80,7 @@
 =

     public void saveUserProperties(JahiaGWTPage page, List properties);
 =

-    public Map loadPageUserProperties(JahiaGWTPage page,String propType);
+    public Map loadPageUserProperties(JahiaGWTPage page, String propType);
 =

     public GWTJahiaPageWrapper[] getSubPagesForCurrentUser(int pid, String=
 mode, GWTJahiaPageWrapper parentPage);
 =

@@ -69,25 +89,4 @@
     public String drawPortletInstanceOutput(JahiaGWTPage page, String entr=
yPointIDStr);
 =

 =

-    /**
-     * Utility/Convinience class.
-     * Use JahiaService.App.getInstance() to access static instance of MyS=
erviceAsync
-     */
-    public static class App {
-        private static JahiaServiceAsync ourInstance =3D null;
-
-
-        public static synchronized JahiaServiceAsync getInstance() {
-            if (ourInstance =3D=3D null) {
-                String relativeServiceEntryPoint =3D JahiaGWTParameters.ge=
tServiceEntryPoint();
-                String serviceEntryPoint =3D URL.getAbsolutleURL(relativeS=
erviceEntryPoint);
-                ourInstance =3D (JahiaServiceAsync) GWT.create(JahiaServic=
e.class);
-                ((ServiceDefTarget) ourInstance).setServiceEntryPoint(serv=
iceEntryPoint);
-            }
-
-            return ourInstance;
-        }
-
-    }
-
 }

Modified: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gw=
t/base/client/util/DOMUtil.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-INCLUD=
E-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base/client/util/DOMUtil.java=
&rev=3D19561&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/util/DOMUtil.java (original)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/util/DOMUtil.java Tue Jan 22 11:54:09 2008
@@ -29,7 +29,7 @@
             // set title
             Element currentChild =3D DOM.getFirstChild(wrapperEle);
             while (currentChild !=3D null) {
-                // convert to widget element
+                // convert to ui element
                 WidgetElement we =3D new WidgetElement(currentChild);
 =

                 // get title

Added: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/b=
ase/client/widgets/AdvancedTable.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base/client/widgets/Ad=
vancedTable.java&rev=3D19561&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/widgets/AdvancedTable.java (added)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/widgets/AdvancedTable.java Tue Jan 22 11:54:09 2008
@@ -0,0 +1,77 @@
+package org.jahia.ajax.gwt.base.client.widgets;
+
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * User: jahia
+ * Date: 11 janv. 2008
+ * Time: 09:29:20
+ */
+public abstract class AdvancedTable extends FlexTable {
+    public abstract void mouseEntersRow(Widget sender, int row);
+
+    public abstract void mouseLeavesRow(Widget sender, int row);
+
+    public AdvancedTable() {
+        super();
+        sinkEvents(Event.ONMOUSEOVER);
+        sinkEvents(Event.ONMOUSEOUT);
+    }
+
+    public void onBrowserEvent(Event event) {
+        switch (DOM.eventGetType(event)) {
+            case Event.ONMOUSEOVER: {
+                // Find out which cell was entered.
+                Element td =3D getMouseEventTargetCell(event);
+                if (td =3D=3D null) return;
+                Element tr =3D DOM.getParent(td);
+                Element body =3D DOM.getParent(tr);
+                int row =3D DOM.getChildIndex(body, tr);
+                // Fire the event
+                mouseEntersRow(this, row);
+                break;
+            }
+            case Event.ONMOUSEOUT: {
+                // Find out which cell was exited.
+                Element td =3D getMouseEventTargetCell(event);
+                if (td =3D=3D null) return;
+                Element tr =3D DOM.getParent(td);
+                Element body =3D DOM.getParent(tr);
+                int row =3D DOM.getChildIndex(body, tr);
+                // Fire the event.
+                mouseLeavesRow(this, row);
+                break;
+            }
+        }
+        super.onBrowserEvent(event);
+    }
+
+    /**
+     * Method originally copied from HTMLTable superclass where it was
+     * defined private
+     * Now implemented differently to only return target cell if it's
+     * part of 'this' table
+     */
+    private Element getMouseEventTargetCell(Event event) {
+        Element td =3D DOM.eventGetTarget(event);
+        //locate enclosing td element
+        while (!DOM.getAttribute(td, "tagName").equalsIgnoreCase("td")) {
+            // If we run out of elements, or run into the table itself,the=
n give up.
+            if ((td =3D=3D null) || DOM.compare(td, getElement()))
+                return null;
+            td =3D DOM.getParent(td);
+        }
+        //test if the td is actually from this table
+        Element tr =3D DOM.getParent(td);
+        Element body =3D DOM.getParent(tr);
+        if (DOM.compare(body, this.getBodyElement())) {
+            return td;
+        }
+        //Didn't find appropriate cell
+        return null;
+    }
+}

Added: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/b=
ase/client/widgets/EngineDialogBox.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base/client/widgets/En=
gineDialogBox.java&rev=3D19561&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/widgets/EngineDialogBox.java (added)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/widgets/EngineDialogBox.java Tue Jan 22 11:54:09 2008
@@ -0,0 +1,102 @@
+package org.jahia.ajax.gwt.base.client.widgets;
+
+import com.google.gwt.user.client.ui.*;
+
+/**
+ * User: jahia
+ * Date: 16 janv. 2008
+ * Time: 14:08:43
+ */
+public class EngineDialogBox extends DialogBox {
+    private VerticalPanel mainPanel =3D new VerticalPanel();
+    private Panel enginePane =3D new HorizontalPanel();
+    private String engineTitle =3D "";
+    private Widget engineIcon =3D new Label();
+
+    public EngineDialogBox(String engineTitle) {
+        this.engineTitle =3D engineTitle;
+    }
+
+    private void close() {
+        hide();
+    }
+
+    protected void createEngineUI() {
+        addStyleName("gwt-enginedialogbox");
+        // user panel
+        HorizontalPanel userPanel =3D new HorizontalPanel();
+        Label userLabel =3D new Label("Utilisateur:guest");
+        userLabel.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
+        userPanel.add(userLabel);
+        userPanel.addStyleName("gwt-enginecomponent");
+        userPanel.addStyleName("gwt-engineuserheader");
+        mainPanel.add(userPanel);
+
+        // wrapper pane
+        VerticalPanel wrapperPane =3D new VerticalPanel();
+        wrapperPane.setSpacing(5);
+        wrapperPane.addStyleName("gwt-enginecomponent");
+        mainPanel.add(wrapperPane);
+
+        // engine title panel
+        HorizontalPanel engineTitlePanel =3D new HorizontalPanel();
+        if (engineIcon !=3D null) {
+            engineTitlePanel.add(engineIcon);
+            engineTitlePanel.setCellWidth(engineIcon, "50px");
+        }
+        Label engineTitleLabel =3D new HTML("<h3>" + engineTitle + "</h3>"=
);
+        engineTitleLabel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT=
);
+        engineTitlePanel.setCellVerticalAlignment(engineTitleLabel, Vertic=
alPanel.ALIGN_BOTTOM);
+        engineTitlePanel.add(engineTitleLabel);
+        engineTitlePanel.addStyleName("gwt-enginecomponent");
+        engineTitlePanel.addStyleName("gwt-enginetitleheader");
+        wrapperPane.add(engineTitlePanel);
+
+        // button pane
+        HorizontalPanel buttonsPane =3D new HorizontalPanel();
+        buttonsPane.addStyleName("gwt-enginecomponent");
+        buttonsPane.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);
+        Button closeButton =3D new Button("Close");
+        closeButton.addClickListener(new ClickListener() {
+            public void onClick(Widget widget) {
+                close();
+            }
+        });
+        buttonsPane.add(closeButton);
+        wrapperPane.add(buttonsPane);
+
+        // engine pane
+        enginePane.addStyleName("gwt-enginecomponent");
+        enginePane.addStyleName("gwt-enginemaincomponent");
+        wrapperPane.add(new ScrollPanel(enginePane));
+
+        // Copyrigth Panel
+        HorizontalPanel copyrightPanel =3D new HorizontalPanel();
+        Label jahiaLabel =3D new HTML("&nbsp;");
+        jahiaLabel.addStyleName("gwt-copyright");
+        Label copyrightLabel =3D new HTML("=C2=A9 Copyright 2002-2007 Jahi=
a Ltd - Tous droits r=C3=A9serv=C3=A9s.");
+        copyrightPanel.add(jahiaLabel);
+        copyrightPanel.add(copyrightLabel);
+        copyrightPanel.setCellVerticalAlignment(copyrightLabel, VerticalPa=
nel.ALIGN_BOTTOM);
+        copyrightPanel.addStyleName("gwt-enginecomponent");
+        copyrightPanel.addStyleName("gwt-engineversionfooter");
+        wrapperPane.add(copyrightPanel);
+
+        // build
+        HorizontalPanel backgroundPane =3D new HorizontalPanel();
+        backgroundPane.addStyleName("jahia-gwt-mainpane");
+        mainPanel.addStyleName("jahia-gwt-mainpane");
+        mainPanel.setSpacing(1);
+        backgroundPane.setSpacing(5);
+        backgroundPane.add(mainPanel);
+        setWidget(backgroundPane);
+    }
+
+    public void setEnginePane(Panel enginePane) {
+        this.enginePane =3D enginePane;
+    }
+
+    public void setEngineIcon(Widget engineIcon) {
+        this.engineIcon =3D engineIcon;
+    }
+}

Added: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/b=
ase/client/widgets/SimplePagination.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base/client/widgets/Si=
mplePagination.java&rev=3D19561&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/widgets/SimplePagination.java (added)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/client/widgets/SimplePagination.java Tue Jan 22 11:54:09 2008
@@ -0,0 +1,121 @@
+package org.jahia.ajax.gwt.base.client.widgets;
+
+import com.google.gwt.user.client.ui.*;
+
+/**
+ * User: jahia
+ * Date: 11 janv. 2008
+ * Time: 15:05:24
+ */
+public abstract class SimplePagination extends Composite {
+    private HTML goToFirstPageLabel =3D new HTML("&nbsp;");
+    private HTML goToPreviousPage =3D new HTML("&nbsp;");
+    private HTML pagesLabel =3D new HTML(" pages ");
+    private HTML goToNextPage =3D new HTML("&nbsp;");
+    private HTML goToLastPage =3D new HTML("&nbsp;");
+    private TextBox currentPageTextBox =3D new TextBox();
+    private int pagesNumber =3D 0;
+    private int currentPageIndex;
+
+    public SimplePagination() {
+        init();
+    }
+
+    public SimplePagination(int pagesNumber) {
+        this.pagesNumber =3D pagesNumber;
+        init();
+
+    }
+
+    private void init() {
+        /*  << < page 3 of 21 > >> */
+        HorizontalPanel mainPanel =3D new HorizontalPanel();
+        goToFirstPageLabel.setStyleName("jahia-gwt-simplepagination-firstp=
age");
+        goToFirstPageLabel.addClickListener(new ClickListener() {
+            public void onClick(Widget widget) {
+
+                onFirstPageClick();
+            }
+        });
+        mainPanel.add(goToFirstPageLabel);
+
+        mainPanel.add(goToPreviousPage);
+        goToPreviousPage.setStyleName("jahia-gwt-simplepagination-previous=
page");
+        goToPreviousPage.setWidth("15px");
+        goToPreviousPage.addClickListener(new ClickListener() {
+            public void onClick(Widget widget) {
+                onPreviousPageClick();
+            }
+        });
+
+        mainPanel.add(pagesLabel);
+
+        mainPanel.add(currentPageTextBox);
+        currentPageTextBox.setVisibleLength(3);
+
+        Label totalPagesLabel =3D new Label(" of " + pagesNumber);
+        mainPanel.add(totalPagesLabel);
+
+        mainPanel.add(goToNextPage);
+        goToNextPage.setStyleName("jahia-gwt-simplepagination-nextpage");
+        goToNextPage.addClickListener(new ClickListener() {
+            public void onClick(Widget widget) {
+                onNextPageClick();
+            }
+        });
+
+        mainPanel.add(goToLastPage);
+        goToLastPage.setStyleName("jahia-gwt-simplepagination-lastpage");
+        goToLastPage.addClickListener(new ClickListener() {
+            public void onClick(Widget widget) {
+                onLastPageClick();
+            }
+        });
+
+        initWidget(mainPanel);
+    }
+
+    public int getPagesNumber() {
+        return pagesNumber;
+    }
+
+    public void setPagesNumber(int pagesNumber) {
+        this.pagesNumber =3D pagesNumber;
+    }
+
+    public int getCurrentPageIndex() {
+        return currentPageIndex;
+    }
+
+    public void onFirstPageClick() {
+        currentPageIndex =3D 0;
+        currentPageTextBox.setText(String.valueOf(currentPageIndex + 1));
+        updateUI();
+    }
+
+    public void onPreviousPageClick() {
+        if (currentPageIndex > 0) {
+            currentPageIndex--;
+            currentPageTextBox.setText(String.valueOf(currentPageIndex + 1=
));
+            updateUI();
+        }
+    }
+
+    public void onNextPageClick() {
+        if (currentPageIndex < (pagesNumber - 1)) {
+            currentPageIndex++;
+            currentPageTextBox.setText(String.valueOf(currentPageIndex + 1=
));
+            updateUI();
+        }
+    }
+
+    public void onLastPageClick() {
+        currentPageIndex =3D pagesNumber - 1;
+        currentPageTextBox.setText(String.valueOf(currentPageIndex + 1));
+        updateUI();
+    }
+
+    public abstract void updateUI();
+
+
+}

Added: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/b=
ase/server/AbstractJahiaGWTServiceImpl.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base/server/AbstractJa=
hiaGWTServiceImpl.java&rev=3D19561&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/server/AbstractJahiaGWTServiceImpl.java (added)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/server/AbstractJahiaGWTServiceImpl.java Tue Jan 22 11:54:09 2008
@@ -0,0 +1,160 @@
+package org.jahia.ajax.gwt.base.server;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+import org.apache.log4j.Logger;
+import org.jahia.data.JahiaData;
+import org.jahia.hibernate.manager.SpringContextSingleton;
+import org.jahia.params.ParamBean;
+import org.jahia.params.ProcessingContext;
+import org.jahia.params.ProcessingContextFactory;
+import org.jahia.services.usermanager.JahiaUser;
+import org.springframework.beans.factory.BeanFactory;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: jahia
+ * Date: 10 janv. 2008
+ * Time: 11:45:21
+ * To change this template use File | Settings | File Templates.
+ */
+public class AbstractJahiaGWTServiceImpl extends RemoteServiceServlet {
+    private static final Logger logger =3D Logger.getLogger(AbstractJahiaG=
WTServiceImpl.class);
+    private static final String ORG_JAHIA_PARAMS_PARAM_BEAN =3D "org.jahia=
.params.ParamBean";
+    private static final String ORG_JAHIA_DATA_JAHIA_DATA =3D "org.jahia.d=
ata.JahiaData";
+
+    protected ParamBean getParamBeanRequestAttr() {
+        final HttpServletRequest request =3D getThreadLocalRequest();
+        ParamBean jParams =3D (ParamBean) request.getAttribute(ORG_JAHIA_P=
ARAMS_PARAM_BEAN);
+        if (jParams =3D=3D null) {
+            logger.debug("ParamBean is not set.");
+        }
+        return jParams;
+    }
+
+    protected JahiaData getJahiaDataRequestAttr() {
+        final HttpServletRequest request =3D getThreadLocalRequest();
+        JahiaData jData =3D (JahiaData) request.getAttribute(ORG_JAHIA_DAT=
A_JAHIA_DATA);
+        if (jData =3D=3D null) {
+            logger.debug("ParamBean is not set.");
+        }
+        return jData;
+    }
+
+    protected String createExtraParam(String mode, int pid) {
+        String urlParams =3D "?params=3D/" + ProcessingContext.OPERATION_M=
ODE_PARAMETER + "/" + mode + "/" + ProcessingContext.PAGE_ID_PARAMETER + "/=
" + pid;
+        return urlParams;
+    }
+
+    protected String getRemoteUser() {
+        //retrieve user
+        JahiaUser jUser =3D getRemoteJahiaUser();
+        if (jUser !=3D null) {
+            return jUser.getName();
+        }
+        return null;
+    }
+
+    protected JahiaUser getRemoteJahiaUser() {
+        // get session
+        final HttpServletRequest request =3D getThreadLocalRequest();
+        final HttpSession session =3D request.getSession();
+
+        //retrieve user
+        return (JahiaUser) session.getAttribute(ProcessingContext.SESSION_=
USER);
+
+    }
+
+    protected JahiaData retrieveJahiaData(int pid, String mode) {
+        final HttpServletRequest request =3D getThreadLocalRequest();
+        JahiaData jData =3D (JahiaData) request.getAttribute(ORG_JAHIA_DAT=
A_JAHIA_DATA);
+        if (jData =3D=3D null) {
+            ProcessingContext jParams =3D retrieveParamBean(pid, mode);
+
+            // put jdata
+            try {
+                jData =3D new JahiaData(jParams, true);
+                request.setAttribute(ORG_JAHIA_DATA_JAHIA_DATA, jData);
+            } catch (Exception e) {
+                logger.error(e, e);
+            }
+        }
+        return jData;
+    }
+
+    protected ParamBean retrieveParamBean(int pid, String mode) {
+        final HttpServletRequest request =3D getThreadLocalRequest();
+        ParamBean jParams =3D getParamBeanRequestAttr();
+        if (jParams =3D=3D null) {
+            logger.debug("Init processing context");
+            // build processiong context and jParam
+            final HttpServletResponse response =3D getThreadLocalResponse(=
);
+            final ServletContext context =3D getServletContext();
+            final BeanFactory bf =3D SpringContextSingleton.getInstance().=
getContext();
+            final ProcessingContextFactory pcf =3D (ProcessingContextFacto=
ry) bf.getBean(ProcessingContextFactory.class.getName());
+            try {
+                // build jParam
+                String urlParams =3D createExtraParam(mode, pid);
+                jParams =3D pcf.getContext(request, response, context, url=
Params);
+                request.setAttribute(ORG_JAHIA_PARAMS_PARAM_BEAN, jParams);
+                return jParams;
+            } catch (Exception e) {
+                logger.error(e, e);
+            }
+        } else {
+            logger.debug("Processing context found in request");
+        }
+        logger.debug("jParam: " + jParams);
+        return jParams;
+
+    }
+
+    protected Locale getLocale() {
+        Locale locale =3D (Locale) getThreadLocalRequest().getSession().ge=
tAttribute(ParamBean.SESSION_LOCALE);
+        return locale;
+    }
+
+    /**
+     * internal method to render bundle resources
+     *
+     * @param label the keylabel
+     * @param l     the locale
+     * @return a string empty if resource is non existent
+     */
+    protected String getRessource(String label, Locale l) {
+        try {
+            return ResourceBundle.getBundle("JahiaEnginesResources", l).ge=
tString(label);
+        } catch (Exception e) {
+            try {
+                return ResourceBundle.getBundle("JahiaMessageResources", l=
).getString(label);
+            } catch (Exception e1) {
+                return "";
+            }
+        }
+    }
+
+    /**
+     * internal method to render bundle resources
+     *
+     * @param label the keylabel
+     * @return a string empty if resource is non existent
+     */
+    protected String getLocaleRessource(String label) {
+        Locale l =3D getLocale();
+        try {
+            return ResourceBundle.getBundle("JahiaEnginesResources", l).ge=
tString(label);
+        } catch (Exception e) {
+            try {
+                return ResourceBundle.getBundle("JahiaMessageResources", l=
).getString(label);
+            } catch (Exception e1) {
+                return "";
+            }
+        }
+    }
+}

Modified: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gw=
t/base/server/JahiaServiceImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-INCLUD=
E-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base/server/JahiaServiceImpl.=
java&rev=3D19561&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/server/JahiaServiceImpl.java (original)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/ajax/gwt/base=
/server/JahiaServiceImpl.java Tue Jan 22 11:54:09 2008
@@ -22,7 +22,6 @@
 import org.jahia.services.pagesusers.JahiaPageUserPropService;
 import org.jahia.services.pagesusers.PageUserProperty;
 import org.jahia.registries.ServicesRegistry;
-import org.jahia.resourcebundle.ResourceBundleMarker;
 import org.jahia.content.ContentPageKey;
 import org.jahia.exceptions.JahiaException;
 import org.springframework.beans.factory.BeanFactory;
@@ -42,15 +41,11 @@
  * User: ktlili
  * Date: 5 juil. 2007
  * Time: 14:04:49
- * To change this template use File | Settings | File Templates.
  */
-public class JahiaServiceImpl extends RemoteServiceServlet implements Jahi=
aService {
+public class JahiaServiceImpl extends AbstractJahiaGWTServiceImpl implemen=
ts JahiaService {
     private static final ServicesRegistry servicesRegistry =3D ServicesReg=
istry.getInstance();
 =

     private static final Logger logger =3D Logger.getLogger(JahiaServiceIm=
pl.class);
-    private static final String ORG_JAHIA_PARAMS_PARAM_BEAN =3D "org.jahia=
.params.ParamBean";
-    private static final String ORG_JAHIA_DATA_JAHIA_DATA =3D "org.jahia.d=
ata.JahiaData";
-
 =

     public JahiaGWTContainerList loadContainerList(JahiaGWTPage page, Stri=
ng containerListName) {
         logger.debug("start: " + page);
@@ -428,49 +423,6 @@
         return servicesRegistry.getJahiaPageUserPropService();
     }
 =

-    private JahiaData retrieveJahiaData(int pid, String mode) {
-        final HttpServletRequest request =3D getThreadLocalRequest();
-        JahiaData jData =3D (JahiaData) request.getAttribute(ORG_JAHIA_DAT=
A_JAHIA_DATA);
-        if (jData =3D=3D null) {
-            ProcessingContext jParams =3D retrieveParamBean(pid, mode);
-
-            // put jdata
-            try {
-                jData =3D new JahiaData(jParams, true);
-                request.setAttribute(ORG_JAHIA_DATA_JAHIA_DATA, jData);
-            } catch (Exception e) {
-                logger.error(e, e);
-            }
-        }
-        return jData;
-    }
-
-    private ParamBean retrieveParamBean(int pid, String mode) {
-        final HttpServletRequest request =3D getThreadLocalRequest();
-        ParamBean jParams =3D getParamBeanRequestAttr();
-        if (jParams =3D=3D null) {
-            logger.debug("Init processing context");
-            // build processiong context and jParam
-            final HttpServletResponse response =3D getThreadLocalResponse(=
);
-            final ServletContext context =3D getServletContext();
-            final BeanFactory bf =3D SpringContextSingleton.getInstance().=
getContext();
-            final ProcessingContextFactory pcf =3D (ProcessingContextFacto=
ry) bf.getBean(ProcessingContextFactory.class.getName());
-            try {
-                // build jParam
-                String urlParams =3D createExtraParam(mode, pid);
-                jParams =3D pcf.getContext(request, response, context, url=
Params);
-                request.setAttribute(ORG_JAHIA_PARAMS_PARAM_BEAN, jParams);
-                return jParams;
-            } catch (Exception e) {
-                logger.error(e, e);
-            }
-        } else {
-            logger.debug("Processing context found in request");
-        }
-        logger.debug("jParam: " + jParams);
-        return jParams;
-
-    }
 =

     public void saveUserProperties(JahiaGWTPage page, List properties) {
         logger.debug("begin save user properties");
@@ -528,54 +480,54 @@
     /**
      * Get the subpages for a given jahia page, considering the current us=
er and the mode.
      *
-     * @param pid the pid of the current paqe (to create processing contex=
t)
-     * @param mode the current mode (to create processing context)
+     * @param pid        the pid of the current paqe (to create processing=
 context)
+     * @param mode       the current mode (to create processing context)
      * @param parentPage the parent page as a GWT-specific bean (page wrap=
per)
      * @return an array of pages (page wrapper) containing all visible sub=
pages
      */
     public GWTJahiaPageWrapper[] getSubPagesForCurrentUser(int pid, String=
 mode, GWTJahiaPageWrapper parentPage) {
-        ProcessingContext jParams =3D retrieveParamBean(pid, mode) ;
+        ProcessingContext jParams =3D retrieveParamBean(pid, mode);
         if (parentPage =3D=3D null) { // this is the home page case
-            JahiaPage jPage =3D jParams.getSite().getHomePage() ;
-            parentPage =3D new GWTJahiaPageWrapper() ;
-            parentPage.setTitle(jPage.getTitle()) ;
-            parentPage.setPid(jPage.getID()) ;
+            JahiaPage jPage =3D jParams.getSite().getHomePage();
+            parentPage =3D new GWTJahiaPageWrapper();
+            parentPage.setTitle(jPage.getTitle());
+            parentPage.setPid(jPage.getID());
         }
 =

-        ArrayList<GWTJahiaPageWrapper> children =3D new ArrayList<GWTJahia=
PageWrapper>() ;
+        ArrayList<GWTJahiaPageWrapper> children =3D new ArrayList<GWTJahia=
PageWrapper>();
         try {
-            Vector<JahiaPage> childs =3D servicesRegistry.getJahiaPageServ=
ice().getPageChilds(parentPage.getPid(), PageLoadFlags.ALL, jParams.getUser=
()) ;
+            Vector<JahiaPage> childs =3D servicesRegistry.getJahiaPageServ=
ice().getPageChilds(parentPage.getPid(), PageLoadFlags.ALL, jParams.getUser=
());
 =

             // sort children
-            for (JahiaPage page: childs) {
-                if (page.hasActiveEntries() || (!page.hasActiveEntries() &=
& page.checkWriteAccess(jParams.getUser())) ) {
-                    GWTJahiaPageWrapper wPage =3D new GWTJahiaPageWrapper(=
) ;
+            for (JahiaPage page : childs) {
+                if (page.hasActiveEntries() || (!page.hasActiveEntries() &=
& page.checkWriteAccess(jParams.getUser()))) {
+                    GWTJahiaPageWrapper wPage =3D new GWTJahiaPageWrapper(=
);
                     wPage.setTitle(page.getTitle());
                     wPage.setPid(page.getID());
                     wPage.setLink(page.getURL(jParams));
                     wPage.setHasChildren(servicesRegistry.getJahiaPageServ=
ice().pageHasChildren(page.getID(), PageLoadFlags.ALL, jParams.getUser()));
-                    children.add(wPage) ;
+                    children.add(wPage);
                 }
             }
-            =

+
         } catch (JahiaException e) {
             logger.error("could not find children for page " + pid, e);
         }
-        return children.toArray(new GWTJahiaPageWrapper[0]) ;
+        return children.toArray(new GWTJahiaPageWrapper[0]);
     }
 =

     /**
      * Retrieve the home page for the current site in order to get the sit=
emap entry point.
      *
-     * @param pid the pid of the current page (to create processing contex=
t)
+     * @param pid  the pid of the current page (to create processing conte=
xt)
      * @param mode the current mode (to create processing context)
-     * @param rec choose whether the sitemap should be retrieved in one ca=
ll or not
+     * @param rec  choose whether the sitemap should be retrieved in one c=
all or not
      * @return the home page as a GWT specific bean (page wrapper) contain=
ing all subpages if specified (arg "rec")
      */
     public GWTJahiaPageWrapper getHomePageForCurrentUser(int pid, String m=
ode, boolean rec) {
         ProcessingContext jParams =3D retrieveParamBean(pid, mode);
-        GWTJahiaPageWrapper page =3D new GWTJahiaPageWrapper() ;
-        JahiaPage home =3D jParams.getSite().getHomePage() ;
+        GWTJahiaPageWrapper page =3D new GWTJahiaPageWrapper();
+        JahiaPage home =3D jParams.getSite().getHomePage();
         page.setPid(home.getID());
         page.setTitle(home.getTitle());
         try {
@@ -588,7 +540,7 @@
             page.setHasChildren(true);
             logger.error("could not retrieve home page", e);
         }
-        return page ;
+        return page;
     }
 =

     /**
@@ -600,14 +552,14 @@
      */
     private GWTJahiaPageWrapper[] getSubPagesForCurrentUserRec(int parentI=
d, ProcessingContext jParams) {
 =

-        ArrayList<GWTJahiaPageWrapper> children =3D new ArrayList<GWTJahia=
PageWrapper>() ;
+        ArrayList<GWTJahiaPageWrapper> children =3D new ArrayList<GWTJahia=
PageWrapper>();
         try {
-            Vector<JahiaPage> childs =3D servicesRegistry.getJahiaPageServ=
ice().getPageChilds(parentId, PageLoadFlags.ALL, jParams.getUser()) ;
+            Vector<JahiaPage> childs =3D servicesRegistry.getJahiaPageServ=
ice().getPageChilds(parentId, PageLoadFlags.ALL, jParams.getUser());
 =

             // sort children
-            for (JahiaPage page: childs) {
-                if (page.hasActiveEntries() || (!page.hasActiveEntries() &=
& page.checkWriteAccess(jParams.getUser())) ) {
-                    GWTJahiaPageWrapper wPage =3D new GWTJahiaPageWrapper(=
) ;
+            for (JahiaPage page : childs) {
+                if (page.hasActiveEntries() || (!page.hasActiveEntries() &=
& page.checkWriteAccess(jParams.getUser()))) {
+                    GWTJahiaPageWrapper wPage =3D new GWTJahiaPageWrapper(=
);
                     wPage.setTitle(page.getTitle());
                     wPage.setPid(page.getID());
                     wPage.setLink(page.getURL(jParams));
@@ -615,14 +567,14 @@
                     if (wPage.hasChildren()) {
                         wPage.setSubpages(getSubPagesForCurrentUserRec(wPa=
ge.getPid(), jParams));
                     }
-                    children.add(wPage) ;
+                    children.add(wPage);
                 }
             }
 =

         } catch (JahiaException e) {
             logger.error("could not find children for page " + parentId, e=
);
         }
-        return children.toArray(new GWTJahiaPageWrapper[0]) ;
+        return children.toArray(new GWTJahiaPageWrapper[0]);
     }
 =

     public String getHTML(String jspPath) {
@@ -632,24 +584,23 @@
             BufferedHttpResponseWrapper httpResponseWrapper =3D new Buffer=
edHttpResponseWrapper(getThreadLocalResponse());
             RequestDispatcher requestDispatcher =3D getServletContext().ge=
tRequestDispatcher(jspPath);
             requestDispatcher.include(getThreadLocalRequest(), httpRespons=
eWrapper);
-            output =3D  httpResponseWrapper.getOutput();
+            output =3D httpResponseWrapper.getOutput();
             logger.debug(output);
         } catch (ServletException e) {
             e.printStackTrace();
         } catch (IOException e) {
-            e.printStackTrace(); =

-        }finally{
+            e.printStackTrace();
+        } finally {
             return output;
         }
     }
 =

     public String drawPortletInstanceOutput(JahiaGWTPage page, String entr=
yPointIDStr) {
         try {
-             System.err.println("call drawPortletInstanceOutput") ;
             int fieldId =3D -1;
-            ParamBean jParams =3D retrieveParamBean(page.getPid(),page.get=
Mode());
-            String result =3D  servicesRegistry.getApplicationsDispatchSer=
vice().getAppOutput(fieldId,entryPointIDStr,jParams);
-            System.err.println("result is: \n"+result);
+            ParamBean jParams =3D retrieveParamBean(page.getPid(), page.ge=
tMode());
+            String result =3D servicesRegistry.getApplicationsDispatchServ=
ice().getAppOutput(fieldId, entryPointIDStr, jParams);
+            System.err.println("result is: \n" + result);
             return result;
         } catch (JahiaException e) {
             e.printStackTrace();
@@ -657,48 +608,6 @@
         return "";
     }
 =

-    private ParamBean getParamBeanRequestAttr() {
-        final HttpServletRequest request =3D getThreadLocalRequest();
-        ParamBean jParams =3D (ParamBean) request.getAttribute(ORG_JAHIA_P=
ARAMS_PARAM_BEAN);
-        if (jParams =3D=3D null) {
-            logger.debug("ParamBean is not set.");
-        }
-        return jParams;
-    }
-
-    private JahiaData getJahiaDataRequestAttr() {
-        final HttpServletRequest request =3D getThreadLocalRequest();
-        JahiaData jData =3D (JahiaData) request.getAttribute(ORG_JAHIA_DAT=
A_JAHIA_DATA);
-        if (jData =3D=3D null) {
-            logger.debug("ParamBean is not set.");
-        }
-        return jData;
-    }
-
-    private String createExtraParam(String mode, int pid) {
-        String urlParams =3D "?params=3D/" + ProcessingContext.OPERATION_M=
ODE_PARAMETER + "/" + mode + "/" + ProcessingContext.PAGE_ID_PARAMETER + "/=
" + pid;
-        return urlParams;
-    }
-
-    private String getRemoteUser() {
-        //retrieve user
-        JahiaUser jUser =3D getRemoteJahiaUser();
-        if (jUser !=3D null) {
-            return jUser.getName();
-        }
-        return null;
-    }
-
-    private JahiaUser getRemoteJahiaUser() {
-        // get session
-        final HttpServletRequest request =3D getThreadLocalRequest();
-        final HttpSession session =3D request.getSession();
-
-        //retrieve user
-        return (JahiaUser) session.getAttribute(ProcessingContext.SESSION_=
USER);
-
-    }
-
 =

     private void testEnumerateSessionAttr() {
         // get session

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to