JBoss Portal SVN: r10699 - modules/common/tags.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-04-23 03:15:22 -0400 (Wed, 23 Apr 2008)
New Revision: 10699
Added:
modules/common/tags/JBP_COMMON_1_2_0/
Log:
Tagging common 1.2.0
Copied: modules/common/tags/JBP_COMMON_1_2_0 (from rev 10698, modules/common/trunk)
16 years
JBoss Portal SVN: r10698 - in modules/presentation/trunk: ajax/src/main/config/war/WEB-INF and 5 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-04-23 02:13:10 -0400 (Wed, 23 Apr 2008)
New Revision: 10698
Added:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/Constants.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxNavigationalStateContext.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxUINode.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxViewPortContext.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/PageViewPortScope.java
modules/presentation/trunk/ajax/src/test/java/org/jboss/portal/presentation/test/portal/PresentationServerImpl.java
Modified:
modules/presentation/trunk/ajax/
modules/presentation/trunk/ajax/build.xml
modules/presentation/trunk/ajax/pom.xml
modules/presentation/trunk/ajax/src/main/config/war/WEB-INF/jboss-beans.xml
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java
Log:
New Ajax User Agent Integration
Property changes on: modules/presentation/trunk/ajax
___________________________________________________________________
Name: svn:ignore
- target
+ target
.gwt-cache
Modified: modules/presentation/trunk/ajax/build.xml
===================================================================
--- modules/presentation/trunk/ajax/build.xml 2008-04-23 06:05:47 UTC (rev 10697)
+++ modules/presentation/trunk/ajax/build.xml 2008-04-23 06:13:10 UTC (rev 10698)
@@ -68,15 +68,19 @@
<lib file="${dependency.jboss-dependency.jar}"/>
<lib file="${dependency.jboss-common-core.jar}"/>
<lib file="${dependency.jboss.portal.common.mc.jar}"/>
+ <lib file="${dependency.jboss.portal.common.common.jar}"/>
+ <lib file="${dependency.jboss.portal.common.portal.jar}"/>
+ <lib file="${dependency.jboss.portal.web.jar}"/>
+ <lib file="${dependency.jboss.portal.portlet-jsr168api.jar}"/>
+ <lib file="${dependency.jboss.portal.portlet-portal.jar}"/>
<lib file="${dependency.gwt-user.jar}"/>
<lib file="${dependency.presentation.presentation.jar}"/>
- <lib file="${dependency.presentation.classic.jar}"/>
<lib file="${dependency.presentation.ajax.jar}"/>
<lib file="${basedir}/target/presentation-mockportal-plugin.jar"/>
</war>
</target>
- <target name="install" description="Generate all target output and deploy it to a locally setup app server" depends="package">
+ <target name="install" description="Generate all target output and deploy it to a locally setup app server">
<copy file="${basedir}/target/presentation.war" todir="${jboss.home}/server/${portal.deploy.dir}/deploy" overwrite="true"/>
</target>
<!-- ================================================================== -->
Modified: modules/presentation/trunk/ajax/pom.xml
===================================================================
--- modules/presentation/trunk/ajax/pom.xml 2008-04-23 06:05:47 UTC (rev 10697)
+++ modules/presentation/trunk/ajax/pom.xml 2008-04-23 06:13:10 UTC (rev 10698)
@@ -18,14 +18,8 @@
<artifactId>presentation-presentation</artifactId>
<version>${project.version}</version>
</dependency>
-
+
<dependency>
- <groupId>org.jboss.portal.presentation</groupId>
- <artifactId>presentation-classic</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
<groupId>sun-servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
@@ -133,9 +127,8 @@
</dependency>
</dependencies>
- <build>
- <plugins>
-<!--
+ <build>
+ <plugins>
<plugin>
<groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
<artifactId>maven-antrun-extended-plugin</artifactId>
@@ -161,30 +154,32 @@
</dependencies>
<executions>
<execution>
- <id>install</id>
- <phase>install</phase>
+ <id>package</id>
+ <phase>package</phase>
<configuration>
<tasks>
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
- <property name="project.version" value="${project.version}"/>
- <property name="jboss.home" value="${jboss.home}"/>
- <property name="portal.deploy.dir" value="${portal.deploy.dir}"/>
+ <property name="project.version" value="${project.version}"/>
<property name="dependency.gwt-user.jar" value="${maven.dependency.com.google.gwt.gwt-user.jar.path}"/>
<property name="dependency.jboss.portal.common.mc.jar" value="${maven.dependency.org.jboss.portal.common.common-mc.jar.path}"/>
+ <property name="dependency.jboss.portal.common.common.jar" value="${maven.dependency.org.jboss.portal.common.common-common.jar.path}"/>
+ <property name="dependency.jboss.portal.common.portal.jar" value="${maven.dependency.org.jboss.portal.common.common-portal.jar.path}"/>
+ <property name="dependency.jboss.portal.web.jar" value="${maven.dependency.org.jboss.portal.web.web-web.jar.path}"/>
+ <property name="dependency.jboss.portal.portlet-jsr168api.jar" value="${maven.dependency.org.jboss.portal.portlet.portlet-jsr168api.jar.path}"/>
+ <property name="dependency.jboss.portal.portlet-portal.jar" value="${maven.dependency.org.jboss.portal.portlet.portlet-portal.jar.path}"/>
<property name="dependency.jboss-kernel.jar" value="${maven.dependency.org.jboss.microcontainer.jboss-kernel.jar.path}"/>
<property name="dependency.jboss-container.jar" value="${maven.dependency.org.jboss.microcontainer.jboss-container.jar.path}"/>
<property name="dependency.jboss-dependency.jar" value="${maven.dependency.org.jboss.microcontainer.jboss-dependency.jar.path}"/>
<property name="dependency.jboss-common-core.jar" value="${maven.dependency.org.jboss.jboss-common-core.jar.path}"/>
<property name="dependency.presentation.ajax.jar" value="${basedir}/target/presentation-ajax-${project.version}.jar"/>
- <property name="dependency.presentation.presentation.jar" value="${maven.dependency.org.jboss.portal.presentation.presentation-presentation.jar.path}"/>
- <property name="dependency.presentation.classic.jar" value="${maven.dependency.org.jboss.portal.presentation.presentation-classic.jar.path}"/>
+ <property name="dependency.presentation.presentation.jar" value="${maven.dependency.org.jboss.portal.presentation.presentation-presentation.jar.path}"/>
<ant antfile="${basedir}/build.xml">
- <target name="install"/>
+ <target name="package"/>
</ant>
</tasks>
@@ -193,9 +188,29 @@
<goal>run</goal>
</goals>
</execution>
+
+ <!-- Used for deployment to a local application server during Development. Hence commented out -->
+ <!--
+ <execution>
+ <id>install</id>
+ <phase>install</phase>
+ <configuration>
+ <tasks>
+ <property name="jboss.home" value="${jboss.home}"/>
+ <property name="portal.deploy.dir" value="${portal.deploy.dir}"/>
+ <ant antfile="${basedir}/build.xml">
+ <target name="install"/>
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ -->
+
</executions>
- </plugin>
--->
+ </plugin>
</plugins>
</build>
</project>
Modified: modules/presentation/trunk/ajax/src/main/config/war/WEB-INF/jboss-beans.xml
===================================================================
--- modules/presentation/trunk/ajax/src/main/config/war/WEB-INF/jboss-beans.xml 2008-04-23 06:05:47 UTC (rev 10697)
+++ modules/presentation/trunk/ajax/src/main/config/war/WEB-INF/jboss-beans.xml 2008-04-23 06:13:10 UTC (rev 10698)
@@ -31,7 +31,7 @@
</bean>
<bean
name="PresentationServer"
- class="org.jboss.portal.presentation.impl.server.PresentationServerImpl">
+ class="org.jboss.portal.presentation.test.portal.PresentationServerImpl">
<constructor>
<parameter><inject bean="StructuralStateContext"/></parameter>
</constructor>
Modified: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java
===================================================================
--- modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java 2008-04-23 06:05:47 UTC (rev 10697)
+++ modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/AjaxPresentationClient.java 2008-04-23 06:13:10 UTC (rev 10698)
@@ -22,13 +22,15 @@
******************************************************************************/
package org.jboss.portal.presentation.ajax;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
+import org.jboss.portal.portlet.URLFormat;
import org.jboss.portal.presentation.ajax.client.model.AjaxUIPage;
import org.jboss.portal.presentation.ajax.client.model.AjaxUIWindow;
-import org.jboss.portal.presentation.classic.ClassicPresentationClient;
-import org.jboss.portal.presentation.classic.model.ClassicUINode;
-import org.jboss.portal.presentation.classic.model.ClassicViewPortContext;
-import org.jboss.portal.presentation.classic.model.DefaultPageViewPortScope;
-import org.jboss.portal.presentation.classic.model.PageViewPortScope;
+import org.jboss.portal.presentation.ajax.model.AjaxUINode;
+import org.jboss.portal.presentation.ajax.model.AjaxViewPortContext;
+import org.jboss.portal.presentation.ajax.model.PageViewPortScope;
+import org.jboss.portal.presentation.ajax.model.AjaxNavigationalStateContext;
import org.jboss.portal.presentation.impl.model.UIModelImpl;
import org.jboss.portal.presentation.model.UIModel;
import org.jboss.portal.presentation.model.UIObject;
@@ -41,23 +43,39 @@
import org.jboss.portal.presentation.protocol.ProtocolAction;
import org.jboss.portal.presentation.protocol.ProtocolResponse;
import org.jboss.portal.presentation.protocol.ShowUIObjectResponse;
+import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
import org.jboss.portal.presentation.server.PresentationRequest;
import org.jboss.portal.presentation.server.PresentationResponse;
import org.jboss.portal.presentation.server.PresentationServer;
import org.jboss.portal.presentation.server.PresentationServerException;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.presentation.client.PresentationClient;
+import org.jboss.portal.web.ServletContextDispatcher;
import org.jboss.portal.web.WebRequest;
import org.jboss.portal.web.WebResponse;
+import org.jboss.portal.web.impl.DefaultServletContainerFactory;
+import org.jboss.portal.web.ServletContainer;
import java.io.IOException;
+import java.io.Writer;
import java.util.Collection;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
-public class AjaxPresentationClient extends ClassicPresentationClient
-{
+public class AjaxPresentationClient implements PresentationClient
+{
+ /** . */
+ protected final WebRequest req;
+
+ /** . */
+ protected final WebResponse resp;
+
+ /** . */
+ protected final PresentationServer server;
+
/**
*
* @param request
@@ -69,59 +87,117 @@
WebResponse response,
PresentationServer server)
{
- super(request, response, server);
+ this.req = request;
+ this.resp = response;
+ this.server = server;
}
- //---------------------------------------------------------------------------------------------------------------------------------------------------------
+ //---PresentationClient implementation------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
*/
- public void process() throws IOException, PresentationServerException
+ public ServletContextDispatcher getDispatcher()
{
- ProtocolAction action = (ProtocolAction)req.getAttribute("serverAction");
+ ServletContainer container = DefaultServletContainerFactory.getInstance().getServletContainer();
+ return new ServletContextDispatcher(
+ req,
+ resp,
+ container);
+ }
- PresentationResponse presentationResp = null;
-
- if (action != null)
+ /**
+ *
+ */
+ public NavigationalStateContext getNavigationalStateContext()
+ {
+ NavigationalStateContext ajaxNavigationalStateContext = (NavigationalStateContext)this.req.getSession().getAttribute(Constants.navigationalStateContext);
+
+ if(ajaxNavigationalStateContext == null)
{
- PresentationRequest request = new PresentationRequest(action);
-
- presentationResp = server.process(this, request);
+ ajaxNavigationalStateContext = new AjaxNavigationalStateContext();
+ this.req.getSession().setAttribute(Constants.navigationalStateContext, ajaxNavigationalStateContext);
}
+
+ return ajaxNavigationalStateContext;
+ }
- if (presentationResp != null)
+ /**
+ *
+ */
+ public String renderURL(ProtocolAction action, URLFormat format) throws IllegalArgumentException
+ {
+ return null;
+ }
+
+ /**
+ *
+ */
+ public void renderURL(Writer writer, ProtocolAction action, URLFormat format) throws IOException
+ {
+ }
+
+ /**
+ *
+ */
+ public void process() throws IOException, PresentationServerException
+ {
+ try
{
- ProtocolResponse protocolResp = presentationResp.getProtocolResponse();
-
- //
- if (protocolResp instanceof ShowUIObjectResponse)
+ ProtocolAction action = (ProtocolAction)req.getAttribute(Constants.serverAction);
+ PresentationResponse presentationResp = null;
+
+ if (action != null)
{
- ShowUIObjectResponse showObjectResp = (ShowUIObjectResponse)protocolResp;
- PageViewPortScope scope = new PageViewPortScope(showObjectResp.getTargetId());
- renderDocument(scope, showObjectResp.getTargetId());
+ PresentationRequest request = new PresentationRequest(action);
+
+ presentationResp = server.process(this, request);
}
+
+ if (presentationResp != null)
+ {
+ ProtocolResponse protocolResp = presentationResp.getProtocolResponse();
+
+ if(action instanceof ViewUIObjectAction)
+ {
+ req.setAttribute(Constants.forceRender, Boolean.TRUE);
+ }
+
+ //
+ if (protocolResp instanceof ShowUIObjectResponse)
+ {
+ ShowUIObjectResponse showObjectResp = (ShowUIObjectResponse)protocolResp;
+ PageViewPortScope scope = new PageViewPortScope(showObjectResp.getTargetId());
+ prepareRPCResponse(scope, showObjectResp.getTargetId());
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Not handled: " + protocolResp);
+ }
+ }
else
{
- throw new UnsupportedOperationException("Not handled: " + protocolResp);
+ //Show the default Portal Page
+ StructuralStateContext ssc = server.getStructuralStateContext();
+ PageViewPortScope scope = new PageViewPortScope(ssc.getRootId());
+ req.setAttribute(Constants.forceRender, Boolean.TRUE);
+ prepareRPCResponse(scope, ssc.getRootId());
}
}
- else
+ finally
{
- StructuralStateContext ssc = server.getStructuralStateContext();
- DefaultPageViewPortScope scope = new DefaultPageViewPortScope(ssc.getRootId());
- renderDocument(scope, ssc.getRootId());
+ ((AjaxNavigationalStateContext)this.getNavigationalStateContext()).clearStaleState();
}
- }
-
+ }
+ //----------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
* @param scope
* @param nodeId
* @throws IOException
*/
- private void renderDocument(ViewPortScope scope, String nodeId) throws IOException
+ private void prepareRPCResponse(ViewPortScope scope, String nodeId) throws IOException
{
StructuralStateContext ssc = server.getStructuralStateContext();
- ClassicViewPortContext context = new ClassicViewPortContext();
+ AjaxViewPortContext context = new AjaxViewPortContext();
UIModel model = new UIModelImpl(null, ssc);
ViewPort viewPort = model.createViewPort(context, scope);
@@ -129,7 +205,7 @@
viewPort.refresh();
//
- ClassicUINode node = context.getNode(nodeId);
+ AjaxUINode node = context.getNode(nodeId);
//
renderNode(node);
@@ -139,7 +215,7 @@
*
* @param node
*/
- private void renderNode(ClassicUINode node)
+ private void renderNode(AjaxUINode node)
{
UIObject object = node.getObject();
@@ -150,12 +226,12 @@
}
else if (object instanceof UIPage)
{
- AjaxUIPage clientPage = (AjaxUIPage)this.req.getAttribute("uiObject");
+ AjaxUIPage clientPage = (AjaxUIPage)this.req.getAttribute(Constants.uiObject);
if(clientPage == null)
{
clientPage = new AjaxUIPage();
clientPage.setId(object.getId());
- this.req.setAttribute("uiObject", clientPage);
+ this.req.setAttribute(Constants.uiObject, clientPage);
}
if (node.getChildren() != null)
@@ -165,28 +241,37 @@
}
else if (object instanceof UIWindow)
{
- AjaxUIPage clientPage = (AjaxUIPage)this.req.getAttribute("uiObject");
- UIWindow window = (UIWindow)object;
+ AjaxUIPage clientPage = (AjaxUIPage)this.req.getAttribute(Constants.uiObject);
+ AjaxNavigationalStateContext navState = (AjaxNavigationalStateContext)this.getNavigationalStateContext();
try
{
- WindowContent content = server.renderWindow(this, object.getId());
+ AjaxUIWindow clientWindow = new AjaxUIWindow();
- AjaxUIWindow clientWindow = new AjaxUIWindow();
+ if(navState.isStale(object.getId()) || this.req.getAttribute(Constants.forceRender)!=null)
+ {
+ WindowContent content = server.renderWindow(this, object.getId());
+ clientWindow.setContent(content.getMarkup());
+ }
+
clientWindow.setId(object.getId());
clientWindow.setParent(clientPage);
- clientPage.getChildren().add(clientWindow);
+ clientPage.getChildren().add(clientWindow);
- clientWindow.setContent(content.getMarkup());
+ WindowState windowState = (WindowState)this.getNavigationalStateContext().getProperty(object.getId(), Constants.windowState);
+ if(windowState == null)
+ {
+ windowState = WindowState.NORMAL;
+ this.getNavigationalStateContext().setProperty(object.getId(), Constants.windowState, windowState);
+ }
+ clientWindow.setState(windowState.toString().toLowerCase());
- //TODO: remove hardcoding
- clientWindow.setState(AjaxUIWindow.NORMAL);
-
- //TODO: remove hard coding
- clientWindow.setMode(AjaxUIWindow.VIEW);
-
-
- //Restore the Status of the Window
- clientWindow.setStatus(AjaxUIWindow.STATUS_VALID);
+ Mode mode = (Mode)this.getNavigationalStateContext().getProperty(object.getId(), Constants.mode);
+ if(mode == null)
+ {
+ mode = Mode.VIEW;
+ this.getNavigationalStateContext().setProperty(object.getId(), Constants.mode, mode);
+ }
+ clientWindow.setMode(mode.toString().toLowerCase());
}
catch (PresentationServerException e)
{
@@ -199,17 +284,17 @@
*
* @param node
*/
- private void renderChildren(ClassicUINode node)
+ private void renderChildren(AjaxUINode node)
{
- Collection<ClassicUINode> children = node.getChildren();
+ Collection<AjaxUINode> children = node.getChildren();
//
if (children != null)
{
- for (ClassicUINode child : children)
+ for (AjaxUINode child : children)
{
renderNode(child);
}
}
- }
+ }
}
Added: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/Constants.java
===================================================================
--- modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/Constants.java (rev 0)
+++ modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/Constants.java 2008-04-23 06:13:10 UTC (rev 10698)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.ajax;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface Constants
+{
+ public String navigationalStateContext = "navigationalStateContext";
+ public String serverAction = "serverAction";
+ public String uiObject = "uiObject";
+ public String windowState = "windowstate";
+ public String mode = "mode";
+ public String forceRender = "forceRender";
+}
Added: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxNavigationalStateContext.java
===================================================================
--- modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxNavigationalStateContext.java (rev 0)
+++ modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxNavigationalStateContext.java 2008-04-23 06:13:10 UTC (rev 10698)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.ajax.model;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
+import org.jboss.portal.presentation.state.StateChangeVetoException;
+import org.jboss.portal.presentation.state.StateException;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AjaxNavigationalStateContext extends NavigationalStateContextImpl
+{
+ /**
+ *
+ */
+ private List<String> staleObjects = new ArrayList<String>();
+
+ /**
+ *
+ * @param objectId
+ * @return
+ */
+ public boolean isStale(String objectId)
+ {
+ boolean isStale = false;
+
+ if(this.staleObjects.contains(objectId))
+ {
+ isStale = true;
+ }
+
+ return isStale;
+ }
+
+ /**
+ *
+ * @param objectId
+ */
+ public void markAsStale(String objectId)
+ {
+ this.staleObjects.add(objectId);
+ }
+
+ /**
+ *
+ *
+ */
+ public void clearStaleState()
+ {
+ this.staleObjects.clear();
+ }
+ //-----Overriden methods-----------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ public void setProperty(String objectId, String key, Object navigationalState)
+ throws StateChangeVetoException, StateException, IllegalArgumentException
+ {
+ this.markAsStale(objectId);
+
+ if(!key.equals("stale"))
+ {
+ super.setProperty(objectId, key, navigationalState);
+ }
+ }
+}
Added: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxUINode.java
===================================================================
--- modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxUINode.java (rev 0)
+++ modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxUINode.java 2008-04-23 06:13:10 UTC (rev 10698)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.ajax.model;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.jboss.portal.presentation.model.UIObject;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AjaxUINode
+{
+ /** . */
+ private final UIObject object;
+
+ /** . */
+ AjaxUINode parent = null;
+
+ /** . */
+ Map<String, AjaxUINode> children;
+
+ /**
+ *
+ * @param object
+ */
+ public AjaxUINode(UIObject object)
+ {
+ this.object = object;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public AjaxUINode getParent()
+ {
+ return parent;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getId()
+ {
+ return object.getId();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getName()
+ {
+ return object.getName();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public UIObject getObject()
+ {
+ return object;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Collection<AjaxUINode> getChildren()
+ {
+ return children == null ? null : children.values();
+ }
+}
Added: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxViewPortContext.java
===================================================================
--- modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxViewPortContext.java (rev 0)
+++ modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/AjaxViewPortContext.java 2008-04-23 06:13:10 UTC (rev 10698)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.ajax.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.presentation.model.ViewPortContext;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AjaxViewPortContext implements ViewPortContext
+{
+ /**
+ *
+ */
+ final Map<String, AjaxUINode> nodes = new HashMap<String, AjaxUINode>();
+
+ /**
+ *
+ * @param nodeId
+ * @return
+ */
+ public AjaxUINode getNode(String nodeId)
+ {
+ return nodes.get(nodeId);
+ }
+
+ /**
+ *
+ */
+ public UIObject getObject(String objectId)
+ {
+ AjaxUINode node = nodes.get(objectId);
+
+ //
+ if (node == null)
+ {
+ return null;
+ }
+ else
+ {
+ return node.getObject();
+ }
+ }
+
+ /**
+ *
+ */
+ public void addObject(UIObject object)
+ {
+ AjaxUINode node = new AjaxUINode(object);
+
+ //
+ nodes.put(node.getId(), node);
+ }
+
+ /**
+ *
+ */
+ public void updateObject(String objectId)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ public void removeObject(String objectId)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ public void createChildren(String parentId)
+ {
+ nodes.get(parentId).children = new HashMap<String, AjaxUINode>();
+ }
+
+ /**
+ *
+ */
+ public void destroyChildren(String parentId)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ public void addChild(String parentId, String childId)
+ {
+ AjaxUINode parent = nodes.get(parentId);
+ AjaxUINode child = nodes.get(childId);
+
+ //
+ parent.children.put(child.getName(), child);
+ child.parent = parent;
+ }
+
+ /**
+ *
+ */
+ public void removeChild(String parentId, String childId)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/PageViewPortScope.java
===================================================================
--- modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/PageViewPortScope.java (rev 0)
+++ modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/model/PageViewPortScope.java 2008-04-23 06:13:10 UTC (rev 10698)
@@ -0,0 +1,137 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.ajax.model;
+
+import org.jboss.portal.presentation.model.ObjectTraversalType;
+import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.presentation.model.ViewPortScope;
+import org.jboss.portal.presentation.model.ui.UIContext;
+import org.jboss.portal.presentation.model.ui.UIPage;
+import org.jboss.portal.presentation.model.ui.UIWindow;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ *
+ * @version $Revision: 630 $
+ */
+public class PageViewPortScope implements ViewPortScope
+{
+
+ /** . */
+ private static final int NO_PAGE = 0;
+
+ /** . */
+ private static final int PAGE = 1;
+
+ /** . */
+ private static final int PAGE_CHILD = 2;
+
+ /** . */
+ private static final int PAGE_SIBLING = 3;
+
+ /** . */
+ private final String pageId;
+
+ /** . */
+ private int pageStatus;
+
+ public PageViewPortScope(String pageId)
+ {
+ this.pageId = pageId;
+ this.pageStatus = 0;
+ }
+
+ public String getRootId()
+ {
+ return pageId;
+ }
+
+ public ObjectTraversalType enterObject(UIObject object)
+ {
+ if (object instanceof UIPage)
+ {
+ switch (pageStatus)
+ {
+ case NO_PAGE:
+ if (pageId.equals(object.getId()) || "default".equals(object.getName()))
+ {
+ pageStatus = PAGE;
+
+ // We want to traverse the children of the page currently being displayed
+ return ObjectTraversalType.RECURSIVE;
+ }
+ else
+ {
+ pageStatus = PAGE_SIBLING;
+
+ // We want to see the sibbling pages of the page currently being displayed
+ return ObjectTraversalType.SINGLE;
+ }
+ case PAGE:
+ pageStatus = PAGE_CHILD;
+
+ // We want to see the children pages of the page currently being displayed
+ return ObjectTraversalType.SINGLE;
+ case PAGE_CHILD:
+ case PAGE_SIBLING:
+ return ObjectTraversalType.SKIP;
+ default:
+ throw new AssertionError();
+ }
+ }
+ else if (object instanceof UIWindow)
+ {
+ // We don't traverse windows (for now as they are supposed to be leaves)
+ return ObjectTraversalType.SINGLE;
+ }
+ else if (object instanceof UIContext)
+ {
+ return ObjectTraversalType.RECURSIVE;
+ }
+ else
+ {
+ return ObjectTraversalType.SKIP;
+ }
+ }
+
+ public void leaveObject(UIObject object)
+ {
+ if (object instanceof UIPage)
+ {
+ switch (pageStatus)
+ {
+ case NO_PAGE:
+ throw new AssertionError();
+ case PAGE:
+ pageStatus = NO_PAGE;
+ break;
+ case PAGE_SIBLING:
+ pageStatus = NO_PAGE;
+ break;
+ case PAGE_CHILD:
+ pageStatus = PAGE;
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java
===================================================================
--- modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java 2008-04-23 06:05:47 UTC (rev 10697)
+++ modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java 2008-04-23 06:13:10 UTC (rev 10698)
@@ -6,6 +6,7 @@
import org.apache.log4j.Logger;
import org.jboss.portal.common.io.IOTools;
import org.jboss.portal.presentation.ajax.AjaxPresentationClient;
+import org.jboss.portal.presentation.ajax.Constants;
import org.jboss.portal.presentation.ajax.client.model.AjaxUIObject;
import org.jboss.portal.presentation.ajax.client.protocol.AjaxShowUIObjectResponse;
import org.jboss.portal.presentation.ajax.client.protocol.ClientResponse;
@@ -99,18 +100,18 @@
HttpServletRequest request = this.getThreadLocalRequest();
- Object pendingServerAction = request.getSession().getAttribute("serverAction");
+ Object pendingServerAction = request.getSession().getAttribute(Constants.serverAction);
if(pendingServerAction != null)
{
- request.setAttribute("serverAction", pendingServerAction);
- request.getSession().removeAttribute("serverAction");
+ request.setAttribute(Constants.serverAction, pendingServerAction);
+ request.getSession().removeAttribute(Constants.serverAction);
}
//execute the call on the Portal
this.callPortalServer();
//Setup the initial UIContext for the client session
- AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute("uiObject");
+ AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute(Constants.uiObject);
if(uiObject != null)
{
clientResponse = new AjaxShowUIObjectResponse(uiObject);
@@ -146,13 +147,13 @@
GetActivation get = new GetActivation(targetId, null, queryParams);
- request.setAttribute("serverAction", get);
+ request.setAttribute(Constants.serverAction, get);
//execute the call on the Portal
this.callPortalServer();
//Setup the initial UIContext for the client session
- AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute("uiObject");
+ AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute(Constants.uiObject);
if(uiObject != null)
{
clientResponse = new AjaxShowUIObjectResponse(uiObject);
@@ -200,13 +201,13 @@
PostActivation post = new PostActivation(targetId, null, queryParams, null);
- request.setAttribute("serverAction", post);
+ request.setAttribute(Constants.serverAction, post);
//execute the call on the Portal
this.callPortalServer();
//Setup the initial UIContext for the client session
- AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute("uiObject");
+ AjaxUIObject uiObject = (AjaxUIObject)request.getAttribute(Constants.uiObject);
if(uiObject != null)
{
clientResponse = new AjaxShowUIObjectResponse(uiObject);
@@ -275,9 +276,6 @@
{
HttpServletRequest req = this.getThreadLocalRequest();
HttpServletResponse resp = this.getThreadLocalResponse();
-
-// WebRequest webReq = new WebRequest(req);
-// WebResponse webResp = new WebResponse(resp);
AjaxPresentationClient client = new AjaxPresentationClient(new AjaxRequest(req), new AjaxResponse(resp), this.server);
client.process();
Added: modules/presentation/trunk/ajax/src/test/java/org/jboss/portal/presentation/test/portal/PresentationServerImpl.java
===================================================================
--- modules/presentation/trunk/ajax/src/test/java/org/jboss/portal/presentation/test/portal/PresentationServerImpl.java (rev 0)
+++ modules/presentation/trunk/ajax/src/test/java/org/jboss/portal/presentation/test/portal/PresentationServerImpl.java 2008-04-23 06:13:10 UTC (rev 10698)
@@ -0,0 +1,177 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.test.portal;
+
+import java.util.Map;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.presentation.client.PresentationClient;
+import org.jboss.portal.presentation.impl.state.structural.StructuralNode;
+import org.jboss.portal.presentation.impl.state.structural.StructuralStateContextImpl;
+import org.jboss.portal.presentation.impl.state.structural.WindowNode;
+import org.jboss.portal.presentation.model.content.WindowContent;
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.protocol.ErrorResponse;
+import org.jboss.portal.presentation.protocol.ProtocolAction;
+import org.jboss.portal.presentation.protocol.ShowUIObjectResponse;
+import org.jboss.portal.presentation.protocol.UIObjectAction;
+import org.jboss.portal.presentation.protocol.ViewUIObjectAction;
+import org.jboss.portal.presentation.protocol.LinkActivation;
+import org.jboss.portal.presentation.protocol.PostActivation;
+import org.jboss.portal.presentation.server.PresentationRequest;
+import org.jboss.portal.presentation.server.PresentationResponse;
+import org.jboss.portal.presentation.server.PresentationServer;
+import org.jboss.portal.presentation.server.PresentationServerException;
+import org.jboss.portal.presentation.state.structural.StructuralStateContext;
+import org.jboss.portal.web.Body;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PresentationServerImpl implements PresentationServer
+{
+
+ /** . */
+ private StructuralStateContextImpl structuralStateContext;
+
+ public PresentationServerImpl(StructuralStateContextImpl structuralStateContext)
+ {
+ this.structuralStateContext = structuralStateContext;
+ }
+
+ public StructuralStateContext getStructuralStateContext()
+ {
+ return structuralStateContext;
+ }
+
+ public String render(ProtocolAction action) throws IllegalArgumentException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ */
+ public WindowContent renderWindow(PresentationClient client, String windowId) throws PresentationServerException
+ {
+ StructuralNode node = structuralStateContext.getNode(windowId);
+
+ //
+ if (node instanceof WindowNode)
+ {
+ WindowNode window = (WindowNode)node;
+ return new WindowContent(0, "Window " + window.getName(), window.getContent());
+ }
+ else
+ {
+ throw new PresentationServerException("No such window " + windowId);
+ }
+ }
+
+ /**
+ *
+ */
+ public PresentationResponse process(PresentationClient client, PresentationRequest request) throws PresentationServerException
+ {
+ ProtocolAction action = request.getProtocolAction();
+
+ if (action instanceof UIObjectAction)
+ {
+ UIObjectAction objectAction = (UIObjectAction)action;
+
+ //
+ String targetId = objectAction.getTargetId();
+
+ //
+ StructuralNode targetNode = structuralStateContext.getNode(targetId);
+
+ //
+ if (targetNode == null)
+ {
+ return new PresentationResponse(new ErrorResponse(404));
+ }
+
+ //
+ if (objectAction instanceof ViewUIObjectAction)
+ {
+ return new PresentationResponse(new ShowUIObjectResponse(targetId));
+ }
+ else if(action instanceof LinkActivation)
+ {
+ return this.processLinkActivation(client, targetNode, (LinkActivation)action);
+ }
+ }
+
+ //
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ *
+ * @param activation
+ * @return
+ */
+ private PresentationResponse processLinkActivation(PresentationClient client, StructuralNode targetNode, LinkActivation activation)
+ {
+ PresentationResponse response = null;
+ NavigationalStateContext navState = client.getNavigationalStateContext();
+
+ //Get form parameters if any
+ Map formParameters = null;
+ if (activation instanceof PostActivation)
+ {
+ PostActivation post = (PostActivation)activation;
+ Body body = post.getBody();
+ if (body instanceof Body.Form)
+ {
+ formParameters = ((Body.Form)body).getParameters();
+ }
+ }
+
+ WindowState windowState = activation.getWindowState();
+ Mode windowMode = activation.getWindowMode();
+
+ //Perform processing of this request through to the PortletContainer
+ //Just Stub code...just mark all children on this page as stale for re-rendering
+ for(StructuralNode window: targetNode.getParent().getChildren())
+ {
+ //TODO: need to finalize proper way to designate staleness of a window
+ //This matters to the ajax client, and not really to the classic client
+ //since classic client does a full refresh regardless
+ //Probably one way to signify staleness of window content requiring a rendering
+ //in a client agnostic manner....Still not sure about this one
+ navState.setProperty(window.getId(), "stale", Boolean.TRUE);
+ }
+
+ //Success so update the corresponding UI objects
+ navState.setProperty(targetNode.getId(), "windowstate", windowState);
+ navState.setProperty(targetNode.getId(), "mode", windowMode);
+
+ //Select the proper response
+ response = new PresentationResponse(new ShowUIObjectResponse(targetNode.getParent().getId()));
+
+ return response;
+ }
+}
Modified: modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java
===================================================================
--- modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java 2008-04-23 06:05:47 UTC (rev 10697)
+++ modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/LinkActivation.java 2008-04-23 06:13:10 UTC (rev 10698)
@@ -24,6 +24,9 @@
import java.util.Map;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
* @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
@@ -77,4 +80,54 @@
{
return queryParameters;
}
+
+ /**
+ *
+ * @return
+ */
+ public WindowState getWindowState()
+ {
+ WindowState windowState = null;
+
+ if(this.queryParameters != null)
+ {
+ String[] windowStateValue = this.queryParameters.get("windowstate");
+ if(windowStateValue != null)
+ {
+ windowState = WindowState.create(windowStateValue[0]);
+ }
+ }
+
+ if(windowState == null)
+ {
+ windowState = windowState.NORMAL;
+ }
+
+ return windowState;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Mode getWindowMode()
+ {
+ Mode mode = null;
+
+ if(this.queryParameters != null)
+ {
+ String[] modeValue = this.queryParameters.get("mode");
+ if(modeValue != null)
+ {
+ mode = Mode.create(modeValue[0]);
+ }
+ }
+
+ if(mode == null)
+ {
+ mode = Mode.VIEW;
+ }
+
+ return mode;
+ }
}
16 years
JBoss Portal SVN: r10697 - in branches/JBoss_Portal_Branch_2_7: core-admin/src/main/org/jboss/portal/core/admin/ui/actions and 1 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-04-23 02:05:47 -0400 (Wed, 23 Apr 2008)
New Revision: 10697
Added:
branches/JBoss_Portal_Branch_2_7/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
Log:
JBPORTAL-1999: Adding properties through the admin portlet on Oracle fails
Store "" as __EMPTY_STRING__ for Oracle compatibility.
It could probably be improved to only do it for Oracle databases
Modified: branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2008-04-23 06:00:25 UTC (rev 10696)
+++ branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2008-04-23 06:05:47 UTC (rev 10697)
@@ -121,7 +121,7 @@
type="string"
column="NAME"/>
<element
- type="string"
+ type="org.jboss.portal.jems.hibernate.OracleStringUserType"
column="jbp_VALUE"
not-null="false"/>
</map>
Modified: branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2008-04-23 06:00:25 UTC (rev 10696)
+++ branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2008-04-23 06:05:47 UTC (rev 10697)
@@ -118,7 +118,7 @@
String value = getPropertyValue().trim();
if (value == null)
{
- value = " ";
+ value = "";
}
pomgr.getSelectedObject().setDeclaredProperty(propertyName, value);
}
Copied: branches/JBoss_Portal_Branch_2_7/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java (from rev 10696, branches/JBoss_Portal_Branch_2_6/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java)
===================================================================
--- branches/JBoss_Portal_Branch_2_7/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java 2008-04-23 06:05:47 UTC (rev 10697)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.OracleDialect;
+import org.hibernate.usertype.UserType;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class OracleStringUserType implements UserType
+{
+
+ private static final int[] SQL_TYPES = {Types.VARCHAR};
+
+ private static final String EMPTY_STRING = "__EMPTY_STRING__";
+
+ public Object assemble(Serializable arg0, Object arg1) throws HibernateException
+ {
+ return arg0;
+ }
+
+ public Object deepCopy(Object value) throws HibernateException
+ {
+ return value;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException
+ {
+ return (Serializable)value;
+ }
+
+ public boolean equals(Object arg0, Object arg1) throws HibernateException
+ {
+ if (arg0 == arg1)
+ {
+ return true;
+ }
+ if ((arg0 == null) || (arg1 == null))
+ {
+ return false;
+ }
+ return arg0.equals(arg1);
+ }
+
+ public int hashCode(Object arg0) throws HibernateException
+ {
+ return arg0.hashCode();
+ }
+
+ public boolean isMutable()
+ {
+ return false;
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException
+ {
+ String dbValue = (String) Hibernate.STRING.nullSafeGet(rs, names[0]);
+
+ if (dbValue == null)
+ {
+ return null;
+ }
+ else if (dbValue.equals(EMPTY_STRING))
+ {
+ return "";
+ }
+ else
+ {
+ return dbValue;
+ }
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException
+ {
+ if (value.equals(""))
+ {
+ Hibernate.STRING.nullSafeSet(st, EMPTY_STRING, index);
+ }
+ else
+ {
+ Hibernate.STRING.nullSafeSet(st, value, index);
+ }
+ }
+
+ public Object replace(Object arg0, Object arg1, Object arg2) throws HibernateException
+ {
+ return arg0;
+ }
+
+ public Class returnedClass()
+ {
+ return String.class;
+ }
+
+ public int[] sqlTypes()
+ {
+ return SQL_TYPES;
+ }
+
+}
+
16 years
JBoss Portal SVN: r10696 - in branches/JBoss_Portal_Branch_2_6: core-admin/src/main/org/jboss/portal/core/admin/ui/actions and 1 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-04-23 02:00:25 -0400 (Wed, 23 Apr 2008)
New Revision: 10696
Added:
branches/JBoss_Portal_Branch_2_6/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
Log:
JBPORTAL-1999: Adding properties through the admin portlet on Oracle fails
Store "" as __EMPTY_STRING__ for Oracle compatibility.
It could probably be improved to only do it for Oracle databases
Modified: branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2008-04-23 00:47:17 UTC (rev 10695)
+++ branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2008-04-23 06:00:25 UTC (rev 10696)
@@ -121,7 +121,7 @@
type="string"
column="NAME"/>
<element
- type="string"
+ type="org.jboss.portal.jems.hibernate.OracleStringUserType"
column="jbp_VALUE"
not-null="false"/>
</map>
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2008-04-23 00:47:17 UTC (rev 10695)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2008-04-23 06:00:25 UTC (rev 10696)
@@ -118,7 +118,7 @@
String value = getPropertyValue();
if (value == null)
{
- value = " ";
+ value = "";
}
pomgr.getSelectedObject().setDeclaredProperty(propertyName, value);
}
Added: branches/JBoss_Portal_Branch_2_6/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/jems/src/main/org/jboss/portal/jems/hibernate/OracleStringUserType.java 2008-04-23 06:00:25 UTC (rev 10696)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.jems.hibernate;
+
+import java.io.Serializable;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.hibernate.Hibernate;
+import org.hibernate.HibernateException;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.Oracle9Dialect;
+import org.hibernate.dialect.OracleDialect;
+import org.hibernate.usertype.UserType;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class OracleStringUserType implements UserType
+{
+
+ private static final int[] SQL_TYPES = {Types.VARCHAR};
+
+ private static final String EMPTY_STRING = "__EMPTY_STRING__";
+
+ public Object assemble(Serializable arg0, Object arg1) throws HibernateException
+ {
+ return arg0;
+ }
+
+ public Object deepCopy(Object value) throws HibernateException
+ {
+ return value;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException
+ {
+ return (Serializable)value;
+ }
+
+ public boolean equals(Object arg0, Object arg1) throws HibernateException
+ {
+ if (arg0 == arg1)
+ {
+ return true;
+ }
+ if ((arg0 == null) || (arg1 == null))
+ {
+ return false;
+ }
+ return arg0.equals(arg1);
+ }
+
+ public int hashCode(Object arg0) throws HibernateException
+ {
+ return arg0.hashCode();
+ }
+
+ public boolean isMutable()
+ {
+ return false;
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException
+ {
+ String dbValue = (String) Hibernate.STRING.nullSafeGet(rs, names[0]);
+
+ if (dbValue == null)
+ {
+ return null;
+ }
+ else if (dbValue.equals(EMPTY_STRING))
+ {
+ return "";
+ }
+ else
+ {
+ return dbValue;
+ }
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException
+ {
+ if (value.equals(""))
+ {
+ Hibernate.STRING.nullSafeSet(st, EMPTY_STRING, index);
+ }
+ else
+ {
+ Hibernate.STRING.nullSafeSet(st, value, index);
+ }
+ }
+
+ public Object replace(Object arg0, Object arg1, Object arg2) throws HibernateException
+ {
+ return arg0;
+ }
+
+ public Class returnedClass()
+ {
+ return String.class;
+ }
+
+ public int[] sqlTypes()
+ {
+ return SQL_TYPES;
+ }
+
+}
+
16 years
JBoss Portal SVN: r10695 - docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: mmcallis
Date: 2008-04-22 20:47:17 -0400 (Tue, 22 Apr 2008)
New Revision: 10695
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/xmldescriptors.xml
Log:
<sigh> minor case correction "Management Portlet" (
now Management portlet)
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/xmldescriptors.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/xmldescriptors.xml 2008-04-23 00:33:42 UTC (rev 10694)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/xmldescriptors.xml 2008-04-23 00:47:17 UTC (rev 10695)
@@ -1747,7 +1747,7 @@
</screen>
</para>
<para>
- A depoloyment is composed of a <computeroutput><deployments></computeroutput> element, which is a container for <computeroutput><deployment></computeroutput> elements. In the previous example, a page is defined, the portlet is placed as a window on a page, and an instance of the portlet is created. The Mangement Portlet (bundled with JBoss Portal) can modify portal instances, page position, and so on.
+ A depoloyment is composed of a <computeroutput><deployments></computeroutput> element, which is a container for <computeroutput><deployment></computeroutput> elements. In the previous example, a page is defined, the portlet is placed as a window on a page, and an instance of the portlet is created. The Mangement portlet (bundled with JBoss Portal) can modify portal instances, page position, and so on.
</para>
<para>
The following list describes elements in a <filename>*-object.xml</filename> file:
16 years
JBoss Portal SVN: r10694 - docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules.
by portal-commits@lists.jboss.org
Author: mmcallis
Date: 2008-04-22 20:33:42 -0400 (Tue, 22 Apr 2008)
New Revision: 10694
Modified:
docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/ldap.xml
Log:
19.2.1. Connection Pooling
- minor correction as per Boles?\197?\130aw request
Modified: docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/ldap.xml
===================================================================
--- docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/ldap.xml 2008-04-22 20:41:53 UTC (rev 10693)
+++ docs/branches/JBoss_Portal_Branch_2_6/referenceGuide/en/modules/ldap.xml 2008-04-23 00:33:42 UTC (rev 10694)
@@ -154,7 +154,7 @@
</config>
</datasource>]]></programlisting>
<para>
- Remember, as it is described in the <ulink url="http://java.sun.com/products/jndi/tutorial/ldap/connect/config.html">JNDI documentation</ulink>, these options are system values, not environment properties, and affect all connection pooling requests in the Java runtime.
+ Remember, as it is described in the <ulink url="http://java.sun.com/products/jndi/tutorial/ldap/connect/config.html">JNDI documentation</ulink>, these options are system properties, not environment properties, and as such, they affect all connection pooling requests in the Java runtime.
</para>
</sect2>
16 years
JBoss Portal SVN: r10692 - in branches/JBoss_Portal_Branch_2_7/core-identity/src: main/org/jboss/portal/core/identity/services/impl and 9 other directories.
by portal-commits@lists.jboss.org
Author: emuckenhuber
Date: 2008-04-22 11:01:55 -0400 (Tue, 22 Apr 2008)
New Revision: 10692
Modified:
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityConstants.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailService.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityUserManagementService.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityCommandFactoryService.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityMailServiceImpl.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityUserManagementServiceImpl.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfiguration.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationService.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/UIComponentConfiguration.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/RegistrationService.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/UserContainer.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/CreateUserAction.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/RegistrationServiceImpl.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/SendValidationMailAction.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/UpdateEmailAction.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/ValidateEmailServiceImpl.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/CreateUserAction.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/EditProfileAction.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/LostPasswordAction.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/RoleManagementBean.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/UserAdministrationBean.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/ConfigurationBean.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityRoleBean.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityUserBean.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/MetaDataServiceBean.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/components/StaticValues.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CurrentPasswordValidator.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/EmailValidator.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/PasswordValidator.java
branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-war/WEB-INF/portlet.xml
Log:
JBPORTAL-1974 for 2.7 branch, generics and cleanup
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityConstants.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityConstants.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityConstants.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -61,6 +61,7 @@
/** Registration and validation status */
public static final String REGISTRATION_REGISTERED = "registered";
public static final String REGISTRATION_PENDING = "registration_pending";
+ public static final String REGISTRATION_FAILED = "registration_failed";
public static final String VALIDATION_FAILED = "validation_failed";
public static final String VALIDATION_VALIDATED = "validated";
public static final String VALIDATION_ERROR = "validation_error";
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailService.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailService.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityMailService.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -52,6 +52,7 @@
* @param email to
* @param subject
* @param email body
+ * @throws IllegalArgumentException
*/
public void send(String emailFrom, String emailTo, String subject, String emailText);
}
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityUserManagementService.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityUserManagementService.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/IdentityUserManagementService.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -25,17 +25,41 @@
import java.util.List;
import java.util.Map;
+import org.jboss.portal.identity.IdentityException;
+
/**
+ * The IdentityUserManagementService interface
+ *
* @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
public interface IdentityUserManagementService
{
- boolean createUser(String username, String password, Map profileMap, List roles);
+ /**
+ * @param username the user name
+ * @param password the users password
+ * @param profileMap the users profile map
+ * @param roles the users roles
+ * @throws IdentityException
+ * @throws IllegalArgumentException
+ */
+ void createUser(String username, String password, Map<String, Object> profileMap, List<String> roles) throws IdentityException;
- public String getCurrentEmail(String username);
+ /**
+ * @param username the user name
+ * @return the users email address
+ * @throws IdentityException
+ * @throws IllegalArgumentException if the user name is null
+ */
+ String getCurrentEmail(String username) throws IdentityException;
- public boolean updateEmail(String username, String email);
+ /**
+ * @param username the user name
+ * @param email the users new email address
+ * @throws IdentityException
+ * @throws IllegalArgumentException
+ */
+ void updateEmail(String username, String email) throws IdentityException;
}
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityCommandFactoryService.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityCommandFactoryService.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityCommandFactoryService.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -75,10 +75,10 @@
String hash = aRequest[1];
try
{
- // Validating email
- String status = validateEmailService.validateEmail(bpmId, hash);
- // Passing status to portlet render parameters
- operation = status;
+ // Validating email
+ String status = validateEmailService.validateEmail(bpmId, hash);
+ // Passing status to portlet render parameters
+ operation = status;
}
catch(CoreIdentityConfigurationException e)
{
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityMailServiceImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityMailServiceImpl.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityMailServiceImpl.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -70,6 +70,9 @@
/** The core-identity configuration service. */
private IdentityUIConfigurationService identityUIConfigurationService;
+
+ /** The Bundle prefix for an unknown action. */
+ public static final String UNKOWN_ACTION_PREFIX = "IDENTITY_MAIL_SUBJECT_CUSTOM_";
/** The logger */
private static final Logger log = Logger.getLogger(IdentityMailServiceImpl.class);
@@ -84,7 +87,7 @@
{
super.startService();
- IdentityUIConfiguration cf =this.identityUIConfigurationService.getConfiguration();
+ IdentityUIConfiguration cf = this.identityUIConfigurationService.getConfiguration();
// Set mail attributes
this.setEmailDomain(cf.getEmailDomain());
this.setEmailFrom(cf.getEmailFrom());
@@ -193,9 +196,14 @@
}
else
{
- subject = bundle.getString(templateLocation);
+ // In the case it's an unknown action we try to load a custom subject from the Bundle
+ // where the templateLocation is the path to the folder containing the email templates
+ // IDENTITY_MAIL_SUBJECT_CUSTOM_templateLocation
+ subject = bundle.getString(UNKOWN_ACTION_PREFIX + templateLocation);
+
+ // No null subject allowed
if(subject == null)
- throw new IllegalArgumentException("unknown template.");
+ throw new IllegalArgumentException("No custom mail subject found (Unknown Template). ");
}
// Generating message
@@ -209,6 +217,13 @@
public void send(String emailFrom, String emailTo, String subject, String emailText)
{
+ if(emailFrom == null)
+ throw new IllegalArgumentException("email-from may not be null.");
+ if(emailTo == null)
+ throw new IllegalArgumentException("email-to may not be null.");
+ if(subject == null)
+ throw new IllegalArgumentException("email-subject may not be null.");
+
this.getMailModule().send(emailFrom, emailTo, subject, emailText);
}
@@ -232,6 +247,7 @@
InputStream in = config.openStream();
Template tpl = new Template("emailTemplate", new InputStreamReader(in), new Configuration());
StringWriter out = new StringWriter();
+ // Process
tpl.process(mailData, out);
IOTools.safeClose(out);
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityUserManagementServiceImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityUserManagementServiceImpl.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/impl/IdentityUserManagementServiceImpl.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -24,13 +24,13 @@
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.jboss.portal.core.identity.services.IdentityConstants;
import org.jboss.portal.core.identity.services.IdentityUserManagementService;
+import org.jboss.portal.core.identity.services.metadata.CoreIdentityConfigurationException;
import org.jboss.portal.core.identity.services.metadata.IdentityUIConfigurationService;
import org.jboss.portal.identity.IdentityContext;
import org.jboss.portal.identity.IdentityException;
@@ -61,12 +61,12 @@
/** The identity membership module */
private MembershipModule membershipModule;
-
+
/** The identity service controller */
private IdentityServiceController identityServiceController;
-
+
/** The core-identity configuration service */
- private IdentityUIConfigurationService identityUIConfigurationService;
+ private IdentityUIConfigurationService identityUIConfigurationService;
/** The JNDI binding */
private JNDI.Binding jndiBinding;
@@ -77,19 +77,23 @@
public void startService() throws Exception
{
super.startService();
-
+
try
{
// Loading required modules
- userModule = (UserModule) identityServiceController.getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
- roleModule = (RoleModule) identityServiceController.getIdentityContext().getObject(IdentityContext.TYPE_ROLE_MODULE);
- userProfileModule = (UserProfileModule) identityServiceController.getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
- membershipModule = (MembershipModule) identityServiceController.getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+ userModule = (UserModule) identityServiceController.getIdentityContext().getObject(
+ IdentityContext.TYPE_USER_MODULE);
+ roleModule = (RoleModule) identityServiceController.getIdentityContext().getObject(
+ IdentityContext.TYPE_ROLE_MODULE);
+ userProfileModule = (UserProfileModule) identityServiceController.getIdentityContext().getObject(
+ IdentityContext.TYPE_USER_PROFILE_MODULE);
+ membershipModule = (MembershipModule) identityServiceController.getIdentityContext().getObject(
+ IdentityContext.TYPE_MEMBERSHIP_MODULE);
}
- catch(IdentityException e)
+ catch (IdentityException e)
{
super.stopService();
- throw new RuntimeException(e);
+ throw new CoreIdentityConfigurationException(e);
}
if (this.jndiName != null)
@@ -180,87 +184,74 @@
this.identityUIConfigurationService = identityUIConfigurationService;
}
- public boolean createUser(String username, String password, Map profileMap, List roles)
+ public void createUser(String username, String password, Map<String, Object> profileMap, List<String> roles) throws IdentityException
{
- try
- {
- User user = this.getUserModule().createUser(username, password);
- Set roleSet = this.checkRoles(roles);
- // Enable the user
- profileMap.put(User.INFO_USER_ENABLED, Boolean.TRUE);
+ if (username == null)
+ throw new IllegalArgumentException("Username may not be null.");
+ if (password == null)
+ throw new IllegalArgumentException("Password may not be null.");
+ if (profileMap == null)
+ throw new IllegalArgumentException("profileMap may not be null.");
- Iterator i = profileMap.keySet().iterator();
- while (i.hasNext())
- {
- String key = (String) i.next();
- Object value = profileMap.get(key);
- this.getUserProfileModule().setProperty(user, key, value);
- }
+
+ User user = this.getUserModule().createUser(username, password);
+ Set<Role> roleSet = this.checkRoles(roles);
- this.getMembershipModule().assignRoles(user, roleSet);
- return true;
- }
- catch (Exception e)
+ // Enable the user
+ profileMap.put(User.INFO_USER_ENABLED, Boolean.TRUE);
+
+ for(String key : profileMap.keySet())
{
- log.error("Error when creating user", e);
+ Object value = profileMap.get(key);
+ this.getUserProfileModule().setProperty(user, key, value);
}
- return false;
+ this.getMembershipModule().assignRoles(user, roleSet);
}
- public String getCurrentEmail(String username)
+ public String getCurrentEmail(String username) throws IdentityException
{
- try
- {
- User user = this.getUserModule().findUserByUserName(username);
- return (String) this.getUserProfileModule().getProperty(user, User.INFO_USER_EMAIL_REAL);
- }
- catch (Exception e)
- {
- log.error("failed to retrieve current email address", e);
- }
- return null;
+ if(username == null)
+ throw new IllegalArgumentException("username may not be null.");
+
+ User user = this.getUserModule().findUserByUserName(username);
+ return (String) this.getUserProfileModule().getProperty(user, User.INFO_USER_EMAIL_REAL);
}
- public boolean updateEmail(String username, String email)
+ public void updateEmail(String username, String email) throws IdentityException
{
- try
- {
- User user = this.getUserModule().findUserByUserName(username);
- this.getUserProfileModule().setProperty(user, User.INFO_USER_EMAIL_REAL, email);
- return true;
- }
- catch (Exception e)
- {
- log.error("failed to update email", e);
- }
- return false;
+ if(username == null)
+ throw new IllegalArgumentException("username may not be null.");
+ if(email == null)
+ throw new IllegalArgumentException("email may not be null.");
+
+ User user = this.getUserModule().findUserByUserName(username);
+ this.getUserProfileModule().setProperty(user, User.INFO_USER_EMAIL_REAL, email);
}
- private Set checkRoles(List roles) throws IllegalArgumentException, IdentityException
+ private Set<Role> checkRoles(List<String> roles) throws IllegalArgumentException, IdentityException
{
- Set roleSet = new HashSet();
+
+ Set<Role> roleSet = new HashSet<Role>();
// Set default roles if required
- if (roles == null || (roles != null && roles.size() == 0 ))
+ if (roles == null || (roles != null && roles.size() == 0))
{
roles = this.identityUIConfigurationService.getConfiguration().getDefaultRoles();
}
// If roles are still not available
- if (roles == null || (roles != null && roles.size() == 0 ))
+ if (roles == null || (roles != null && roles.size() == 0))
{
- roles = new ArrayList();
+ roles = new ArrayList<String>();
roles.add(IdentityConstants.DEFAULT_ROLE);
log.error("no default roles spezified - please check your configuration");
}
-
+
if (roles != null && roles.size() > 0)
{ // Checking existing roles
- Iterator i = roles.iterator();
- while (i.hasNext())
+ for(String roleName : roles)
{
- String roleName = (String) i.next();
Role role = this.getRoleModule().findRoleByName(roleName);
if (role == null)
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfiguration.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfiguration.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfiguration.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -49,13 +49,13 @@
private String emailFrom;
/** List of default roles */
- private List defaultRoles;
+ private List<String> defaultRoles;
/** Characters used for generating a random password */
private String passwordGenerationCharacters;
/** Map of available UI-Components */
- private Map uiComponents;
+ private Map<String, UIComponentConfiguration> uiComponents;
public String getSubscriptionMode()
{
@@ -107,12 +107,12 @@
this.emailFrom = emailFrom;
}
- public List getDefaultRoles()
+ public List<String> getDefaultRoles()
{
return defaultRoles;
}
- public void setDefaultRoles(List defaultRoles)
+ public void setDefaultRoles(List<String> defaultRoles)
{
this.defaultRoles = defaultRoles;
}
@@ -127,12 +127,12 @@
this.passwordGenerationCharacters = passwordGenerationCharacters;
}
- public Map getUiComponents()
+ public Map<String, UIComponentConfiguration> getUiComponents()
{
return uiComponents;
}
- public void setUiComponents(Map uiComponents)
+ public void setUiComponents(Map<String, UIComponentConfiguration> uiComponents)
{
this.uiComponents = uiComponents;
}
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationService.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationService.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationService.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.core.identity.services.metadata;
-import javax.naming.NamingException;
-
import org.jboss.portal.workflow.service.WorkflowService;
/**
@@ -33,29 +31,40 @@
public interface IdentityUIConfigurationService
{
- /**
- *
- * Core-Identity configuration
- *
+ /**
* @return IdentityUIConfiguration
*/
IdentityUIConfiguration getConfiguration();
/**
- *
- * jBPM Workflow Service
- *
- * @return WorkflowService
- * @throws NamingException
+ * @return the workflow service
+ * @throws CoreIdentityConfigurationException
*/
WorkflowService getWorkflowService() throws CoreIdentityConfigurationException;
+ /**
+ * @param the workflow service
+ */
void setWorkflowService(WorkflowService workflowService);
+ /**
+ * @return true if the configuration is valid
+ * @throws CoreIdentityConfigurationException
+ */
boolean isValidConfiguration() throws CoreIdentityConfigurationException;
+ /**
+ * start the workflow service
+ *
+ * @throws Exception
+ */
void startWorkflow() throws Exception;
+ /**
+ * stop the workflow service
+ *
+ * @throws Exception
+ */
void stopWorkflow() throws Exception;
}
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/IdentityUIConfigurationServiceImpl.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -245,7 +245,7 @@
}
catch(Exception e)
{
- throw new CoreIdentityConfigurationException("I don't like your subscription mode [" + processName + "] ! Please make sure that the file and the process name match - also check the syntax.", e);
+ throw new CoreIdentityConfigurationException("Invalid subscription mode [" + processName + "] ! Please make sure that the file and the process name match - also check the syntax.", e);
}
finally
{
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/UIComponentConfiguration.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/UIComponentConfiguration.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/metadata/UIComponentConfiguration.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -44,7 +44,7 @@
private String name;
/** List of validators */
- private List validators;
+ private List<String> validators;
/** The converter */
private String converter;
@@ -56,7 +56,7 @@
private boolean readOnly;
/** Property values */
- private Map values;
+ private Map<String, String> values;
/** Reference for predefined values */
private String predefinedMapValues;
@@ -91,12 +91,12 @@
return (String) validators.get(0);
}
- public List getValidators()
+ public List<String> getValidators()
{
return validators;
}
- public void setValidators(List validators)
+ public void setValidators(List<String> validators)
{
this.validators = validators;
}
@@ -133,12 +133,12 @@
this.converter = converter;
}
- public Map getValues()
+ public Map<String, String> getValues()
{
return values;
}
- public void setValues(Map values)
+ public void setValues(Map<String, String> values)
{
this.values = values;
}
@@ -168,4 +168,14 @@
// Returns the Class of the Property
return Thread.currentThread().getContextClassLoader().loadClass(this.propertyInfo.getType());
}
+
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append(getClass().getSimpleName());
+ builder.append('@').append(Integer.toHexString(System.identityHashCode(this)));
+ builder.append("{ name = ").append(name).append(',');
+ builder.append(" reference = ").append(propertyRef).append('}');
+ return builder.toString();
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/RegistrationService.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/RegistrationService.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/RegistrationService.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -38,16 +38,17 @@
/**
* Start the registration process for a new user
*
- * @param portalURL
- * @param username
- * @param password
- * @param profileMap
- * @param roles
- * @param locale
- * @param adminFlag
- * @return
+ * @param portalURL the portal url, used for sending the validation email
+ * @param username the user name
+ * @param password the users password
+ * @param profileMap the users profile map
+ * @param roles the users roles
+ * @param locale the users locale
+ * @param adminFlag if this service uses the admin approval workflow
+ * @throws CoreIdentityConfigurationException
+ * @return a status string
*/
- String registerUser(String portalURL, String username, String password, Map profileMap, List roles, Locale locale, boolean adminFlag) throws CoreIdentityConfigurationException;
+ String registerUser(String url, String username, String password, Map<String, Object> profileMap, List<String> roles, Locale locale, boolean adminFlag) throws CoreIdentityConfigurationException;
/**
* Approve or reject a registration
@@ -64,7 +65,7 @@
* @param nodeName
* @return
*/
- List getPendingUsers(String nodeName) throws CoreIdentityConfigurationException;
+ List<UserContainer> getPendingUsers(String nodeName) throws CoreIdentityConfigurationException;
/**
* Check for a existing username in the jBPM context
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/UserContainer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/UserContainer.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/UserContainer.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -47,10 +47,10 @@
private String password;
/** The profile Map */
- private Map profileMap;
+ private Map<String, Object> profileMap;
/** The assigned roles */
- private List roles;
+ private List<String> roles;
/** Is selected */
private boolean selected = false;
@@ -63,7 +63,7 @@
this.username = user.getUserName();
}
- public UserContainer(String username, String password, Map profileMap, List roles)
+ public UserContainer(String username, String password, Map<String, Object> profileMap, List<String> roles)
{
this.username = username;
this.password = password;
@@ -101,22 +101,22 @@
this.processId = processId;
}
- public Map getProfileMap()
+ public Map<String, Object> getProfileMap()
{
return profileMap;
}
- public void setProfileMap(Map profileMap)
+ public void setProfileMap(Map<String, Object> profileMap)
{
this.profileMap = profileMap;
}
- public List getRoles()
+ public List<String> getRoles()
{
return roles;
}
- public void setRoles(List roles)
+ public void setRoles(List<String> roles)
{
this.roles = roles;
}
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/CreateUserAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/CreateUserAction.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/CreateUserAction.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -35,6 +35,7 @@
* @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
+@SuppressWarnings("serial")
public class CreateUserAction implements ActionHandler
{
@@ -42,21 +43,15 @@
private IdentityUserManagementService identityManagementService;
/** The logger */
- private static Logger log = Logger.getLogger(CreateUserAction.class);
+ private final static Logger log = Logger.getLogger(CreateUserAction.class);
public void execute(ExecutionContext ectx) throws Exception
{
- try
- {
- // Getting user information
- UserContainer uc = (UserContainer) ectx.getContextInstance().getVariable(IdentityConstants.VARIABLE_USER);
- // Creating user
- this.getIdentityManagementService().createUser(uc.getUsername(), uc.getPassword(), uc.getProfileMap(), uc.getRoles());
- }
- catch (ClassCastException e)
- {
- log.error("error while creating user", e);
- }
+ // Getting user information
+ UserContainer uc = (UserContainer) ectx.getContextInstance().getVariable(IdentityConstants.VARIABLE_USER);
+
+ // Creating user
+ this.getIdentityManagementService().createUser(uc.getUsername(), uc.getPassword(), uc.getProfileMap(), uc.getRoles());
}
private IdentityUserManagementService getIdentityManagementService()
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/RegistrationServiceImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/RegistrationServiceImpl.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/RegistrationServiceImpl.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -37,6 +37,7 @@
import org.jboss.portal.core.identity.services.metadata.IdentityUIConfigurationService;
import org.jboss.portal.core.identity.services.workflow.RegistrationService;
import org.jboss.portal.core.identity.services.workflow.UserContainer;
+import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.User;
import org.jboss.portal.jems.as.JNDI;
import org.jboss.portal.jems.as.system.AbstractJBossService;
@@ -150,7 +151,7 @@
this.identityUserManagementService = identityManagementService;
}
- public String registerUser(String url, String username, String password, Map profileMap, List roles, Locale locale, boolean adminFlag)
+ public String registerUser(String url, String username, String password, Map<String, Object> profileMap, List<String> roles, Locale locale, boolean adminFlag)
throws CoreIdentityConfigurationException
{
@@ -160,8 +161,15 @@
|| IdentityConstants.SUBSCRIPTION_MODE_AUTOMATIC.equals(adminSubscriptionMode))
{
// Admin - automatic subscription
- this.getIdentityUserManagementService().createUser(username, password, profileMap, roles);
- return IdentityConstants.REGISTRATION_REGISTERED;
+ try
+ {
+ this.getIdentityUserManagementService().createUser(username, password, profileMap, roles);
+ return IdentityConstants.REGISTRATION_REGISTERED;
+ }
+ catch(IdentityException e)
+ {
+ throw new CoreIdentityConfigurationException("registration failed", e);
+ }
}
else
{
@@ -176,8 +184,15 @@
if (subscriptionMode == null || IdentityConstants.SUBSCRIPTION_MODE_AUTOMATIC.equals(subscriptionMode))
{
// User - automatic subscription
- this.getIdentityUserManagementService().createUser(username, password, profileMap, roles);
- return IdentityConstants.REGISTRATION_REGISTERED;
+ try
+ {
+ this.getIdentityUserManagementService().createUser(username, password, profileMap, roles);
+ return IdentityConstants.REGISTRATION_REGISTERED;
+ }
+ catch(IdentityException e)
+ {
+ throw new CoreIdentityConfigurationException("registration failed", e);
+ }
}
else
{
@@ -303,9 +318,9 @@
return count;
}
- public List getPendingUsers(String nodeName) throws CoreIdentityConfigurationException
+ public List<UserContainer> getPendingUsers(String nodeName) throws CoreIdentityConfigurationException
{
- List queue = new ArrayList();
+ List<UserContainer> queue = new ArrayList<UserContainer>();
JbpmContext jbpmContext = null;
try
{
@@ -332,9 +347,9 @@
return queue;
}
- private List getPendingUser(List processInstances, String nodeName)
+ private List<UserContainer> getPendingUser(List processInstances, String nodeName)
{
- List queue = new ArrayList();
+ List<UserContainer> queue = new ArrayList<UserContainer>();
if (processInstances != null)
{
Iterator i = processInstances.iterator();
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/SendValidationMailAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/SendValidationMailAction.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/SendValidationMailAction.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -33,7 +33,6 @@
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.core.identity.services.IdentityConstants;
import org.jboss.portal.core.identity.services.IdentityMailService;
-import org.jboss.portal.core.identity.services.IdentityUserManagementService;
import org.jboss.portal.core.identity.services.workflow.UserContainer;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
@@ -42,21 +41,20 @@
* @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
+@SuppressWarnings("serial")
public class SendValidationMailAction implements ActionHandler
{
- /** . */
- private IdentityUserManagementService identityManagementService;
- /** . */
+ /** The identity mail service. */
private IdentityMailService identityMailService;
- /** . */
+ /** The logger. */
private static Logger log = Logger.getLogger(SendValidationMailAction.class);
public void execute(ExecutionContext ectx) throws Exception
{
HashMap emailMap = new HashMap();
- String hash = this.hashGen();
+ String hash = generateRandomHash();
String action = (String) ectx.getContextInstance().getVariable(IdentityConstants.ACTION);
String email = (String) ectx.getContextInstance().getVariable(IdentityConstants.VARIABLE_EMAIL);
@@ -67,45 +65,38 @@
locale = new Locale(IdentityConstants.DEFAULT_LOCALE);
}
- try
- {
- UserContainer uc = (UserContainer) ectx.getContextInstance().getVariable(IdentityConstants.VARIABLE_USER);
+ UserContainer uc = (UserContainer) ectx.getContextInstance().getVariable(IdentityConstants.VARIABLE_USER);
- // Register new user
- if (IdentityConstants.ACTION_REGISTER_USER.equals(action))
- {
- emailMap.put(IdentityConstants.EMAIL_TO, email);
- emailMap.put("username", uc.getUsername());
- emailMap.put("password", uc.getPassword());
- }
- // Change email request (send an email to the NEW email address)
- else if (IdentityConstants.ACTION_CHANGE_EMAIL.equals(action))
- {
- emailMap.put(IdentityConstants.EMAIL_TO, email);
- }
- else
- {
- throw new RuntimeException("no actuin defined for SendValidationMail: " + action);
- }
-
- ectx.getContextInstance().setVariable(IdentityConstants.VALIDATION_HASH, hash);
-
- // Generating the validation URL
- String portalURL = (String) ectx.getContextInstance().getVariable(IdentityConstants.PORTAL_URL);
- String activationLink = portalURL + "/" + IdentityConstants.VALIDATE_EMAIL + "/"
- + ectx.getProcessInstance().getId() + "/" + hash;
- emailMap.put("activationLink", activationLink);
-
- this.getIdentityMailService().sendMail(action, emailMap, locale);
+ // Register new user
+ if (IdentityConstants.ACTION_REGISTER_USER.equals(action))
+ {
+ emailMap.put(IdentityConstants.EMAIL_TO, email);
+ emailMap.put("username", uc.getUsername());
+ emailMap.put("password", uc.getPassword());
}
- catch (ClassCastException e)
+ // Change email request (send an email to the NEW email address)
+ else if (IdentityConstants.ACTION_CHANGE_EMAIL.equals(action))
{
- log.error("error while sending validation mail", e);
+ emailMap.put(IdentityConstants.EMAIL_TO, email);
}
+ else
+ {
+ throw new RuntimeException("no actuin defined for SendValidationMail: " + action);
+ }
+
+ ectx.getContextInstance().setVariable(IdentityConstants.VALIDATION_HASH, hash);
+
+ // Generating the validation URL
+ String portalURL = (String) ectx.getContextInstance().getVariable(IdentityConstants.PORTAL_URL);
+ String activationLink = portalURL + "/" + IdentityConstants.VALIDATE_EMAIL + "/"
+ + ectx.getProcessInstance().getId() + "/" + hash;
+ emailMap.put("activationLink", activationLink);
+
+ this.getIdentityMailService().sendMail(action, emailMap, locale);
}
// generating a random hash
- private String hashGen()
+ private static String generateRandomHash()
{
try
{
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/UpdateEmailAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/UpdateEmailAction.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/UpdateEmailAction.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -35,13 +35,14 @@
* @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
* @version $Revision$
*/
+@SuppressWarnings("serial")
public class UpdateEmailAction implements ActionHandler
{
- /** . */
+ /** The identity management service. */
private IdentityUserManagementService identityManagementService;
- /** . */
+ /** The logger. */
private static Logger log = Logger.getLogger(CreateUserAction.class);
public void execute(ExecutionContext ectx) throws Exception
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/ValidateEmailServiceImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/ValidateEmailServiceImpl.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/services/workflow/impl/ValidateEmailServiceImpl.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -32,6 +32,7 @@
import org.jboss.portal.core.identity.services.metadata.IdentityUIConfigurationService;
import org.jboss.portal.core.identity.services.workflow.UserContainer;
import org.jboss.portal.core.identity.services.workflow.ValidateEmailService;
+import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.User;
import org.jboss.portal.jems.as.JNDI;
import org.jboss.portal.jems.as.system.AbstractJBossService;
@@ -47,7 +48,6 @@
public class ValidateEmailServiceImpl extends AbstractJBossService implements ValidateEmailService
{
-
/** The e-mail validation process name */
private String processName = IdentityConstants.jbp_identity_validate_email_process_name;
@@ -139,8 +139,15 @@
{
if (! this.identityUIConfigurationService.getConfiguration().enableWorkflow())
{
- this.getIdentityUserManagementService().updateEmail(user.getUserName(), email);
- return IdentityConstants.REGISTRATION_REGISTERED;
+ try
+ {
+ this.getIdentityUserManagementService().updateEmail(user.getUserName(), email);
+ return IdentityConstants.REGISTRATION_REGISTERED;
+ }
+ catch(IdentityException e)
+ {
+ throw new CoreIdentityConfigurationException("udating the email address failed.", e);
+ }
}
else
{
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/CreateUserAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/CreateUserAction.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/CreateUserAction.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -188,24 +188,23 @@
}
catch(CoreIdentityConfigurationException e)
{
+ registrationStatus = IdentityConstants.REGISTRATION_FAILED;
log.error("", e);
- FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(bundle.getString("IDENTITY_VALIDATION_ERROR_REGISTRATION")));
}
}
- /*
- * Cleaning up
- */
+
+ // cleaning up the user
this.uiUser = new IdentityUIUser();
- if (registrationStatus.equals(IdentityConstants.REGISTRATION_PENDING) && !adminSubscription.equals("admin"))
+ if (IdentityConstants.REGISTRATION_PENDING.equals(registrationStatus) && !adminSubscription.equals("admin"))
{
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(bundle.getString("IDENTITY_REGISTER_PENDING_TITLE")));
}
- else if (registrationStatus.equals(IdentityConstants.REGISTRATION_REGISTERED) && !adminSubscription.equals("admin"))
+ else if (IdentityConstants.REGISTRATION_REGISTERED.equals(registrationStatus) && !adminSubscription.equals("admin"))
{
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(bundle.getString("IDENTITY_REGISTER_SUCCESS_TITLE")));
}
- else if (adminSubscription.equals("admin"))
+ else if (adminSubscription.equals("admin") && ! IdentityConstants.REGISTRATION_FAILED.equals(registrationStatus))
{
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(bundle.getString("IDENTITY_MANAGEMENT_CREATE_USER_CREATED")));
}
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/EditProfileAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/EditProfileAction.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/EditProfileAction.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -36,21 +36,16 @@
import org.jboss.logging.Logger;
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
-import org.jboss.portal.common.p3p.P3PConstants;
import org.jboss.portal.common.text.FastURLDecoder;
import org.jboss.portal.core.aspects.server.UserInterceptor;
import org.jboss.portal.core.identity.services.IdentityConstants;
import org.jboss.portal.core.identity.services.workflow.ValidateEmailService;
import org.jboss.portal.core.identity.ui.IdentityUIUser;
import org.jboss.portal.core.identity.ui.common.IdentityUserBean;
-import org.jboss.portal.faces.el.PropertyValue;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.User;
import org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor;
-import org.jboss.portal.portlet.impl.jsr168.api.PortletContextImpl;
-import org.jboss.portal.portlet.impl.jsr168.api.PortletRequestImpl;
import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portlet.JBossActionRequest;
@@ -275,7 +270,7 @@
this.identityUserBean.updatePassword(this.currentUser, this.password);
ctx.addMessage("status", new FacesMessage(bundle.getString("IDENTITY_EDIT_CHANGE_PASSWOR_STATUS")));
}
- catch (Exception e)
+ catch (IdentityException e)
{
log.error("error while updating password", e);
ctx.addMessage("status", new FacesMessage(bundle.getString("IDENTITY_EDIT_CHANGE_PASSWORD_ERROR")));
@@ -333,6 +328,11 @@
return "status";
}
+ /**
+ * Reset the window state (MAXIMIZED, NORMAL), which is for editing profile
+ *
+ * @param ctx the faces context
+ */
private void resetWindowState(FacesContext ctx)
{
if ( windowState != null)
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/LostPasswordAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/LostPasswordAction.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/actions/LostPasswordAction.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -48,25 +48,25 @@
*/
public class LostPasswordAction
{
- /** . */
+ /** The user name. */
private String username;
- /** . */
+ /** The users email address. */
private String email;
- /** . */
+ /** Characters used for generating the password. */
private String passwordCharacters;
- /** . */
+ /** The identity user bean. */
private IdentityUserBean identityUserBean;
- /** . */
+ /** The identity mail service. */
private IdentityMailService identityMailService;
- /** . */
+ /** The logger. */
private static final Logger log = Logger.getLogger(LostPasswordAction.class);
- /** . */
+ /** The decoder. */
private static final FastURLDecoder decoder = FastURLDecoder.getUTF8Instance();
public String getUsername()
@@ -160,7 +160,7 @@
IdentityUIUser uiUser = new IdentityUIUser(user.getUserName());
- Map mailMap = new HashMap();
+ Map<String, String> mailMap = new HashMap<String, String>();
mailMap.put(IdentityConstants.EMAIL_TO, (String) uiUser.getAttribute().getValue("email").getObject());
mailMap.put("username", user.getUserName());
mailMap.put("password", newPassword);
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/RoleManagementBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/RoleManagementBean.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/RoleManagementBean.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
@@ -50,31 +49,31 @@
*/
public class RoleManagementBean
{
- /** . */
+ /** The current role. */
private String currentRole;
- /** . */
+ /** The uiRole */
private UIRole uiRole;
- /** . */
+ /** The initial page. */
private int page = 1;
- /** . */
+ /** The initial result limit. */
private String limit = "10";
- /** . */
+ /** The filtered user name. */
private String userNameFilter = new String();
- /** . */
+ /** The related role list. */
private ListDataModel roleList;
- /** . */
+ /** The identity role bean. */
private IdentityRoleBean identityRoleBean;
- /** The logger */
+ /** The logger. */
private static final Logger log = Logger.getLogger(RoleManagementBean.class);
- /** The decoder */
+ /** The decoder. */
private static final FastURLDecoder decoder = FastURLDecoder.getUTF8Instance();
public IdentityRoleBean getIdentityRoleBean()
@@ -129,21 +128,21 @@
public ListDataModel getRoleList()
{
- List list = new ArrayList();
- Set set = new HashSet();
+ List<UIRole> list = new ArrayList<UIRole>();
+ Set<Role> set = new HashSet<Role>();
try
{
set = identityRoleBean.getRoleModule().findRoles();
}
catch (IdentityException e)
{
- log.error("", e);
+ log.error("Error while performing roleModule.findRoles.", e);
}
- Iterator i = set.iterator();
- while (i.hasNext())
+
+ for(Role role : set)
{
- UIRole role = new UIRole((Role) i.next());
- list.add(role);
+ UIRole uiRole = new UIRole(role);
+ list.add(uiRole);
}
this.roleList = new ListDataModel(list);
return this.roleList;
@@ -172,9 +171,13 @@
public ListDataModel getRoleMembers()
{
- Set members = new HashSet();
- List roleMembers = new ArrayList();
+ Set<User> members = new HashSet<User>();
+ List<IdentityUIUser> roleMembers = new ArrayList<IdentityUIUser>();
FacesContext ctx = FacesContext.getCurrentInstance();
+
+ if(this.currentRole == null || this.currentRole.length() < 1)
+ return new ListDataModel(roleMembers);
+
try
{
int intLimit = Integer.valueOf(limit).intValue();
@@ -188,20 +191,14 @@
ResourceBundle bundle = ResourceBundle.getBundle("conf.bundles.Identity", ctx.getViewRoot().getLocale());
ctx.addMessage("status", new FacesMessage(bundle.getString("IDENTITY_MANAGEMENT_ERROR_ACTION_ROLE")));
}
- Iterator i = members.iterator();
- while (i.hasNext())
+
+ if(members != null)
{
- User user = (User) i.next();
- try
+ for(User user : members)
{
- roleMembers.add(new IdentityUIUser(user.getUserName()));
+ IdentityUIUser uiUser = new IdentityUIUser(user.getUserName());
+ roleMembers.add(uiUser);
}
- catch (Exception e)
- {
- log.error("", e);
- ResourceBundle bundle = ResourceBundle.getBundle("conf.bundles.Identity", ctx.getViewRoot().getLocale());
- ctx.addMessage("status", new FacesMessage(bundle.getString("IDENTITY_MANAGEMENT_ERROR_ACTION_USER")));
- }
}
return new ListDataModel(roleMembers);
}
@@ -216,8 +213,8 @@
{
try
{
- this.uiRole = identityRoleBean.getUIRole(this.currentRole);
- return "deleteRole";
+ this.uiRole = identityRoleBean.getUIRole(this.currentRole);
+ return "deleteRole";
}
catch (Exception e)
{
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/UserAdministrationBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/UserAdministrationBean.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/admin/UserAdministrationBean.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
@@ -53,61 +52,61 @@
public class UserAdministrationBean
{
- /** . */
+ /** The current user. */
private String currentUser;
- /** . */
+ /** A list of users. */
private ListDataModel userList;
- /** . */
+ /** The page. */
private int page = 1;
- /** . */
+ /** The result limit. */
private String limit = "10";
- /** . */
+ /** The user count. */
private int userCount = 0;
- /** . */
- private List roles = new ArrayList();
+ /** The roles */
+ private List<String> roles = new ArrayList<String>();
- /** . */
+ /** The node which should be displayed. */
private String displayNode = IdentityConstants.JBPM_NODE_APPROVAL;
- /** . */
+ /** The subscription mode. */
private String subscriptionMode;
- /** . */
+ /** The admin subscription mode. */
private String adminSubscriptionMode;
- /** . */
- private List pendingUsers = null;
+ /** The pending users. */
+ private List<UserContainer> pendingUsers = null;
- /** . */
- private List pendingActionList = null;
+ /** The pending list selected for approval or reject. */
+ private List<UserContainer> pendingActionList = null;
- /** . */
+ /** The pending user action. */
private String pendingUserAction = null;
- /** . */
+ /** The uiUser. */
private IdentityUIUser uiUser;
- /** . */
+ /** The search string */
private String searchString = "";
- /** . */
+ /** The identity user bean. */
private IdentityUserBean identityUserBean;
- /** . */
+ /** The idenetity role bean. */
private IdentityRoleBean identityRoleBean;
- /** . */
+ /** The registration service. */
private RegistrationService registrationService;
- /** . */
+ /** The logger. */
private static final Logger log = Logger.getLogger(UserAdministrationBean.class);
- /** The decoder */
+ /** The decoder. */
private static final FastURLDecoder decoder = FastURLDecoder.getUTF8Instance();
public UserAdministrationBean()
@@ -154,12 +153,12 @@
this.limit = limit;
}
- public List getRoles()
+ public List<String> getRoles()
{
return roles;
}
- public void setRoles(List roles)
+ public void setRoles(List<String> roles)
{
this.roles = roles;
}
@@ -204,7 +203,7 @@
return pendingUserAction;
}
- public List getPendingActionList()
+ public List<UserContainer> getPendingActionList()
{
return pendingActionList;
}
@@ -263,10 +262,9 @@
String action = (String) params.get("enableAction");
this.currentUser = params.get("currentUser") != null ? decoder.encode((String) params.get("currentUser")) : null;
- // TODO - do something better than .equals("admin")
- if (this.currentUser != null && action != null && ! this.currentUser.equals("admin"))
+ if (this.currentUser != null && action != null)
{
- HashMap profileMap = new HashMap();
+ Map<String, Object> profileMap = new HashMap<String, Object>();
User user;
try
@@ -293,6 +291,7 @@
}
// Updating search
ctx.addMessage("status", new FacesMessage("user enabled"));
+ // Update userList
return this.searchUsers();
}
return "searchUsers";
@@ -329,7 +328,7 @@
return userCount;
}
- public List getPendingUsers()
+ public List<UserContainer> getPendingUsers()
{
try
{
@@ -349,6 +348,7 @@
ExternalContext ectx = ctx.getExternalContext();
Map params = ectx.getRequestParameterMap();
this.currentUser = params.get("currentUser") != null ? decoder.encode((String) params.get("currentUser")) : null;
+
if (this.currentUser != null)
{
this.uiUser = new IdentityUIUser(this.currentUser);
@@ -365,6 +365,7 @@
User user = identityUserBean.findUserByUserName(this.uiUser.getUsername());
identityUserBean.getUserModule().removeUser(user.getId());
FacesContext.getCurrentInstance().addMessage("status", new FacesMessage(bundle.getString("IDENTITY_MANAGEMENT_USER_DELETED")));
+ // Update the userList
this.searchUsers();
return "userAdmin";
}
@@ -426,10 +427,9 @@
public String approveList()
{
this.pendingUserAction = "approve";
- this.pendingActionList = new ArrayList();
- for(Iterator i = pendingUsers.iterator(); i.hasNext(); )
+ this.pendingActionList = new ArrayList<UserContainer>();
+ for(UserContainer user : pendingUsers)
{
- UserContainer user = (UserContainer) i.next();
if ( user.isSelected() )
{
this.pendingActionList.add(user);
@@ -445,10 +445,9 @@
public String rejectList()
{
this.pendingUserAction = "reject";
- this.pendingActionList = new ArrayList();
- for(Iterator i = pendingUsers.iterator(); i.hasNext(); )
+ this.pendingActionList = new ArrayList<UserContainer>();
+ for(UserContainer user : pendingUsers)
{
- UserContainer user = (UserContainer) i.next();
if ( user.isSelected() )
{
this.pendingActionList.add(user);
@@ -465,9 +464,8 @@
{
try
{
- for(Iterator i = pendingActionList.iterator(); i.hasNext(); )
+ for(UserContainer user : pendingActionList)
{
- UserContainer user = (UserContainer) i.next();
if (this.pendingUserAction.equals("approve"))
{
this.registrationService.approve(user.getProcessId(), true);
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/ConfigurationBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/ConfigurationBean.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/ConfigurationBean.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -61,14 +61,16 @@
public boolean isValidConfiguration()
{
+ if(this.identityUIConfigurationService == null)
+ {
+ log.error("IdentityUIConfigurationService not found.");
+ return false;
+ }
+
try
{
this.identityUIConfigurationService.isValidConfiguration();
}
- catch(NullPointerException e)
- {
- return false;
- }
catch(CoreIdentityConfigurationException e)
{
log.error("", e);
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityRoleBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityRoleBean.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityRoleBean.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -70,22 +69,20 @@
this.membershipModule = membershipModule;
}
- public void assignRoles(User user, List roles) throws IllegalArgumentException, IdentityException
+ public void assignRoles(User user, List<String> roles) throws IllegalArgumentException, IdentityException
{
- Set roleSet = this.checkRoles(roles);
+ Set<Role> roleSet = this.checkRoles(roles);
this.membershipModule.assignRoles(user, roleSet);
}
- private Set checkRoles(List roles) throws IllegalArgumentException, IdentityException
+ private Set<Role> checkRoles(List<String> roles) throws IllegalArgumentException, IdentityException
{
- Set roleSet = new HashSet();
+ Set<Role> roleSet = new HashSet<Role>();
if (roles != null && roles.size() > 0)
{ // Checking existing roles
- Iterator i = roles.iterator();
- while (i.hasNext())
+ for(String roleName : roles)
{
- String roleName = (String) i.next();
Role role = roleModule.findRoleByName(roleName);
if (role == null)
@@ -108,10 +105,10 @@
cRole.setDisplayName(roleDisplayName);
}
- public void updateRoles(User user, List roles) throws IllegalArgumentException, NoSuchUserException,
+ public void updateRoles(User user, List<String> roles) throws IllegalArgumentException, NoSuchUserException,
IdentityException
{
- Set roleSet = this.checkRoles(roles);
+ Set<Role> roleSet = this.checkRoles(roles);
this.membershipModule.assignRoles(user, roleSet);
}
@@ -124,10 +121,10 @@
return uiRole;
}
- public List getRoleSelectItems()
+ public List<SelectItem> getRoleSelectItems()
{
- List list = new ArrayList();
- Set set = new HashSet();
+ List<SelectItem> list = new ArrayList<SelectItem>();
+ Set<Role> set = new HashSet<Role>();
try
{
set = roleModule.findRoles();
@@ -137,23 +134,22 @@
// FIXME
e.printStackTrace();
}
- Iterator i = set.iterator();
- while (i.hasNext())
+
+ for(Role role : set)
{
- Role role = (Role) i.next();
list.add(new SelectItem(role.getName(), role.getDisplayName()));
}
return list;
}
- public List getUserRoles(User user) throws IllegalArgumentException, NoSuchUserException, IdentityException
+ public List<String> getUserRoles(User user) throws IllegalArgumentException, NoSuchUserException, IdentityException
{
- List list = new ArrayList();
- Set roleSet = this.membershipModule.getRoles(user);
- Iterator i = roleSet.iterator();
- while (i.hasNext())
+ List<String> list = new ArrayList<String>();
+ Set<Role> roleSet = this.membershipModule.getRoles(user);
+
+ for(Role role : roleSet)
{
- list.add(((Role) i.next()).getName());
+ list.add(role.getName());
}
return list;
}
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityUserBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityUserBean.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/IdentityUserBean.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
@@ -92,20 +91,18 @@
this.metaDataService = metaDataService;
}
- /*
- * converts the dynamic attribute Map to a map concerning the identity service - UserProfileModule
+ /**
+ * converts the dynamic attribute Map to a map for the identity service - UserProfileModule
*/
- public Map getProfileMap(Map attributeMap)
+ public Map<String, Object> getProfileMap(Map<String, Object> attributeMap)
{
- Map profileMap = new HashMap();
- Set attributeSet = attributeMap.keySet();
- Iterator i = attributeSet.iterator();
+ Map<String, Object> profileMap = new HashMap<String, Object>();
- while(i.hasNext())
+ for(String key : attributeMap.keySet())
{
- String key = (String) i.next();
Object value = attributeMap.get(key);
UIComponentConfiguration uiComponent = (UIComponentConfiguration) this.metaDataService.getValue(key).getObject();
+
if ( uiComponent != null)
{
profileMap.put(uiComponent.getPropertyRef(), value);
@@ -114,14 +111,12 @@
return profileMap;
}
- public void updateProfile(User user, Map attributeMap)
+ public void updateProfile(User user, Map<String, Object> attributeMap)
{
- Map profileMap = this.getProfileMap(attributeMap);
- Iterator i = profileMap.keySet().iterator();
+ Map<String, Object> profileMap = this.getProfileMap(attributeMap);
- while(i.hasNext())
+ for(String key : profileMap.keySet())
{
- String key = (String) i.next();
Object value = profileMap.get(key);
try
{
@@ -140,20 +135,18 @@
return userModule.findUserByUserName(username);
}
- public List findUsersFilteredByUserName(String filter, int offset, int limit)
+ public List<IdentityUIUser> findUsersFilteredByUserName(String filter, int offset, int limit)
throws IllegalArgumentException, IdentityException
{
- Set users = new HashSet();
- List list = new ArrayList();
+ Set<User> users = new HashSet<User>();
+ List<IdentityUIUser> list = new ArrayList<IdentityUIUser>();
users = userModule.findUsersFilteredByUserName(filter, offset, limit);
- Iterator i = users.iterator();
-
- while (i.hasNext())
+ for(User user : users)
{
- User u = (User) i.next();
- list.add(new IdentityUIUser(u.getUserName()));
+ IdentityUIUser uiUser =new IdentityUIUser(user.getUserName());
+ list.add(uiUser);
}
return list;
}
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/MetaDataServiceBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/MetaDataServiceBean.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/common/MetaDataServiceBean.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -41,7 +41,7 @@
public class MetaDataServiceBean implements DynamicBean
{
/** The map */
- Map map = null;
+ Map<String, UIComponentConfiguration> map = null;
public MetaDataServiceBean()
{
@@ -58,7 +58,7 @@
public PropertyValue getValue(Object propertyName) throws IllegalArgumentException
{
- UIComponentConfiguration uiComponent = (UIComponentConfiguration) map.get((String) propertyName);
+ UIComponentConfiguration uiComponent = map.get((String) propertyName);
return uiComponent != null ? new PropertyValue(uiComponent) : null;
}
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/components/StaticValues.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/components/StaticValues.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/faces/components/StaticValues.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -50,9 +50,9 @@
*
* @return List <SelectItem>
*/
- public static List getTimezone()
+ public static List<SelectItem> getTimezone()
{
- List list = new ArrayList();
+ List<SelectItem> list = new ArrayList<SelectItem>();
for (int i = 0; i < UserPortletConstants.TIME_ZONE_OFFSETS.length; i++)
{
if (UserPortletConstants.TIME_ZONE_OFFSETS[i] != null)
@@ -69,14 +69,14 @@
* @param FacesContext
* @return List <SelectItem>
*/
- public static List getTheme(FacesContext ctx)
+ public static List<SelectItem> getTheme(FacesContext ctx)
{
- List list = new ArrayList();
+ List<SelectItem> list = new ArrayList<SelectItem>();
PortletContext pctx = (PortletContext) ctx.getExternalContext().getContext();
ThemeService themeService = (ThemeService) pctx.getAttribute("ThemeService");
- for (Iterator i = themeService.getThemes().iterator(); i.hasNext();)
+ for (Iterator<PortalTheme> i = themeService.getThemes().iterator(); i.hasNext();)
{
- PortalTheme theme = (PortalTheme)i.next();
+ PortalTheme theme = i.next();
ThemeInfo info = theme.getThemeInfo();
list.add(new SelectItem(info.getRegistrationId().toString(), info.getAppId() + "." + info.getName()));
}
@@ -89,28 +89,28 @@
* @param FacesContext
* @return List <SelectItem>
*/
- public static List getLocale(FacesContext ctx)
+ public static List<SelectItem> getLocale(FacesContext ctx)
{
- List list = new ArrayList();
+ List<SelectItem> list = new ArrayList<SelectItem>();
Locale currentLocale = ctx.getViewRoot().getLocale();
- ArrayList locales = new ArrayList(LocaleManager.getLocales());
+ ArrayList<Locale> locales = new ArrayList<Locale>(LocaleManager.getLocales());
Collections.sort(locales, new LocaleComparator());
- for (Iterator i = locales.iterator(); i.hasNext();)
+ for (Iterator<Locale> i = locales.iterator(); i.hasNext();)
{
- Locale locale = (Locale)i.next();
+ Locale locale = i.next();
list.add(new SelectItem(locale.toString(), locale.getDisplayName(currentLocale)));
}
return list;
}
- private static class LocaleComparator implements Comparator
+ private static class LocaleComparator implements Comparator<Locale>
{
- public int compare(Object arg0, Object arg1)
+ public int compare(Locale arg0, Locale arg1)
{
- Locale locale1 = (Locale)arg0;
- Locale locale2 = (Locale)arg1;
+ Locale locale1 = arg0;
+ Locale locale2 = arg1;
int compare = locale1.getDisplayLanguage().compareTo(locale2.getDisplayLanguage());
if (compare == 0)
{
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CurrentPasswordValidator.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CurrentPasswordValidator.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/CurrentPasswordValidator.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -41,26 +41,20 @@
public class CurrentPasswordValidator implements Validator
{
- /** . */
+ /** The user module. */
private UserModule userModule;
- /** . */
- private String currentUser;
-
- /** . */
- private User user;
-
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
{
ResourceBundle bundle = ResourceBundle.getBundle("conf.bundles.Identity", context.getViewRoot().getLocale());
PortletContext portletContext = (PortletContext) context.getExternalContext().getContext();
userModule = (UserModule) portletContext.getAttribute("UserModule");
- this.currentUser = context.getExternalContext().getRemoteUser();
+ String currentUser = context.getExternalContext().getRemoteUser();
-
+ User user;
try
{
- user = userModule.findUserByUserName(this.currentUser);
+ user = userModule.findUserByUserName(currentUser);
}
catch (Exception e)
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/EmailValidator.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/EmailValidator.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/EmailValidator.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -36,7 +36,7 @@
*/
public class EmailValidator implements Validator
{
- /** . */
+ /** The email validation string. */
private static final String EMAIL_VALIDATION = "^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*(a)[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$";
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/PasswordValidator.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/PasswordValidator.java 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/main/org/jboss/portal/core/identity/ui/validators/PasswordValidator.java 2008-04-22 15:01:55 UTC (rev 10692)
@@ -49,7 +49,6 @@
{
throw new ValidatorException(new FacesMessage(bundle.getString("IDENTITY_VALIDATION_ERROR_PASSWORD_DOESNT_MATCH")));
}
-
}
else
{
Modified: branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-war/WEB-INF/portlet.xml 2008-04-22 06:44:16 UTC (rev 10691)
+++ branches/JBoss_Portal_Branch_2_7/core-identity/src/resources/portal-identity-war/WEB-INF/portlet.xml 2008-04-22 15:01:55 UTC (rev 10692)
@@ -38,6 +38,7 @@
<filter-mapping>
<filter-name>JBoss Portlet Filter</filter-name>
<portlet-name>IdentityUserPortlet</portlet-name>
+ <portlet-name>IdentityAdminPortlet</portlet-name>
</filter-mapping>
16 years
JBoss Portal SVN: r10691 - branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-04-22 02:44:16 -0400 (Tue, 22 Apr 2008)
New Revision: 10691
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
Log:
JBPORTAL-1999: Adding properties through the admin portlet on Oracle fails
Oups
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2008-04-22 06:00:13 UTC (rev 10690)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2008-04-22 06:44:16 UTC (rev 10691)
@@ -115,7 +115,7 @@
//
if (propertyName.length() > 0)
{
- String value = getPropertyValue().trim();
+ String value = getPropertyValue();
if (value == null)
{
value = " ";
16 years
JBoss Portal SVN: r10690 - modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-04-22 02:00:13 -0400 (Tue, 22 Apr 2008)
New Revision: 10690
Modified:
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
Log:
- Added more test cases for border conditions and error checking.
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2008-04-22 05:39:57 UTC (rev 10689)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2008-04-22 06:00:13 UTC (rev 10690)
@@ -68,10 +68,56 @@
CharBuffer buffer = new CharBuffer();
buffer.append("abcdef".toCharArray(), 1, 5);
assertEquals("bcdef", buffer.asString());
+
buffer.append("pqrstu".toCharArray(), 3, 3);
assertEquals("stu", buffer.asString());
+
+ buffer.append("abc".toCharArray(), 0, 0);
+ assertEquals("", buffer.asString());
+
+ buffer.append("abc".toCharArray(), 3, 0);
+ assertEquals("", buffer.asString());
+
+ buffer.append("abc".toCharArray(), 2, 1);
+ assertEquals("c", buffer.asString());
}
+ public void testAppendCharArrayRobustness()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+
+ try
+ {
+ buffer.append("abc".toCharArray(), 3, 1);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+
+ try
+ {
+ buffer.append("abc".toCharArray(), -1, 1);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+
+ try
+ {
+ buffer.append("abc".toCharArray(), 0, 4);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+
+ }
+
public void testReset()
{
CharBuffer buffer = new CharBuffer(0);
16 years
JBoss Portal SVN: r10689 - in modules/common/trunk/common/src: main/java/org/jboss/portal/common/text and 2 other directories.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2008-04-22 01:39:57 -0400 (Tue, 22 Apr 2008)
New Revision: 10689
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java
Log:
- Fixed CharBuffer.appendNoCheck method which was incorrect for case where offset was not 0.
- Refactored CharEncoder hierachy:
+ Simplified AbstractCharEncoder.
+ Added String encode(String) method on CharEncoder.
+ FastURLDecoder and FastURLEncoder now extends AbstractCharEncoder.
+ JBPORTAL-1970: Improved exception messages by using ParameterValidation where possible.
- Added ParameterValidation.throwIllegalArgExceptionIfRangeInvalid to check range.
- Added test cases.
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java 2008-04-21 23:09:28 UTC (rev 10688)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java 2008-04-22 05:39:57 UTC (rev 10689)
@@ -23,10 +23,10 @@
package org.jboss.portal.common.io;
import org.jboss.portal.common.text.CharWriter;
-import org.jboss.portal.common.io.UndeclaredIOException;
+import org.jboss.portal.common.util.ParameterValidation;
-import java.io.Writer;
import java.io.IOException;
+import java.io.Writer;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -39,15 +39,12 @@
private final Writer writer;
/**
- * @param writer the target writer
+ * @param writer the target writer
* @throws IllegalArgumentException if the writer is null
*/
public WriterCharWriter(Writer writer) throws IllegalArgumentException
{
- if (writer == null)
- {
- throw new IllegalArgumentException("No null writer accepted");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(writer, "Writer");
this.writer = writer;
}
@@ -66,22 +63,8 @@
public CharWriter append(char[] chars, int off, int len) throws UndeclaredIOException
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (off < 0)
- {
- throw new IllegalArgumentException();
- }
- if (len < 0)
- {
- throw new IllegalArgumentException();
- }
- if (off + len > chars.length)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfRangeInvalid(chars, off, len);
+
try
{
writer.write(chars, off, len);
@@ -95,10 +78,7 @@
public CharWriter append(char[] chars) throws UndeclaredIOException
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(chars, "char[]");
try
{
writer.write(chars, 0, chars.length);
@@ -112,10 +92,7 @@
public CharWriter append(CharSequence s) throws UndeclaredIOException
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(s, "CharSequence");
try
{
if (s instanceof String)
@@ -124,7 +101,7 @@
}
else
{
- for (int i = 0;i < s.length();i++)
+ for (int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
writer.write(c);
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java 2008-04-21 23:09:28 UTC (rev 10688)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java 2008-04-22 05:39:57 UTC (rev 10689)
@@ -22,6 +22,12 @@
******************************************************************************/
package org.jboss.portal.common.text;
+import org.jboss.portal.common.io.WriterCharWriter;
+import org.jboss.portal.common.util.ParameterValidation;
+
+import java.io.StringWriter;
+import java.io.Writer;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -31,88 +37,56 @@
public void encode(char[] chars, int off, int len, CharWriter writer) throws EncodingException
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
- if (off < 0)
- {
- throw new IllegalArgumentException();
- }
- if (off + len > chars.length)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfRangeInvalid(chars, off, len);
+ ParameterValidation.throwIllegalArgExceptionIfNull(writer, "CharWriter");
+
//
safeEncode(chars, off, len, writer);
}
public void encode(char[] chars, CharWriter writer) throws EncodingException
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- safeEncode(chars, writer);
+ ParameterValidation.throwIllegalArgExceptionIfNull(chars, "char[]");
+ encode(chars, 0, chars.length, writer);
}
public void encode(CharSequence s, CharWriter writer) throws EncodingException
{
- if (s == null)
+ ParameterValidation.throwIllegalArgExceptionIfNull(s, "CharSequence");
+
+ //
+ if (s instanceof String)
{
- throw new IllegalArgumentException();
+ char[] chars = ((String)s).toCharArray();
+ encode(chars, 0, chars.length, writer);
}
- if (writer == null)
+ else
{
- throw new IllegalArgumentException();
+ char[] chars = new char[s.length()];
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ chars[i] = c;
+ }
+ encode(chars, 0, chars.length, writer);
}
-
- //
- safeEncode(s, writer);
}
public void encode(char c, CharWriter writer) throws EncodingException
{
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- safeEncode(c, writer);
+ encode(new char[]{c}, writer);
}
- protected void safeEncode(char[] chars, int off, int len, CharWriter writer) throws EncodingException
+ public String encode(String string) throws IllegalArgumentException
{
- for (int i = off;i < len;i++)
- {
- safeEncode(chars[i], writer);
- }
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(string, "String");
- protected void safeEncode(char[] chars, CharWriter writer) throws EncodingException
- {
- safeEncode(chars, 0, chars.length, writer);
+ Writer sw = new StringWriter();
+ CharWriter charWriter = new WriterCharWriter(sw);
+ safeEncode(string.toCharArray(), 0, string.length(), charWriter);
+ return sw.toString();
}
- protected void safeEncode(CharSequence s, CharWriter writer) throws EncodingException
- {
- for (int i = 0;i < s.length();i++)
- {
- safeEncode(s.charAt(i), writer);
- }
- }
-
- protected abstract void safeEncode(char c, CharWriter writer) throws EncodingException;
+ protected abstract void safeEncode(char[] chars, int off, int len, CharWriter writer) throws EncodingException;
}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java 2008-04-21 23:09:28 UTC (rev 10688)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java 2008-04-22 05:39:57 UTC (rev 10689)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.common.text;
+import org.jboss.portal.common.util.ParameterValidation;
+
/**
* A simple char buffer that implements the <code>CharWriter</code> interface
*
@@ -38,7 +40,6 @@
protected int length;
/**
- *
* @param size the initial size
* @throws IllegalArgumentException if the initial size is not a positive value.
*/
@@ -46,7 +47,7 @@
{
if (size < 0)
{
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Size must be positive!");
}
this.buffer = new char[size];
this.length = 0;
@@ -60,42 +61,22 @@
public CharBuffer append(String s, CharEncoder encoder)
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (encoder == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(s, "String");
+ ParameterValidation.throwIllegalArgExceptionIfNull(encoder, "CharEncoder");
encoder.encode(s, this);
return this;
}
public CharWriter append(CharSequence s)
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(s, "CharSequence");
appendNoCheck(s);
return this;
}
public CharWriter append(char[] chars, int off, int len)
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (off < 0)
- {
- throw new IllegalArgumentException();
- }
- if (off + len > chars.length)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfRangeInvalid(chars, off, len);
//
appendNoCheck(chars, off, len);
@@ -118,10 +99,7 @@
public CharWriter append(char[] chars)
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(chars, "char[]");
//
appendNoCheck(chars, 0, chars.length);
@@ -159,7 +137,7 @@
{
if (length < 0)
{
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Length must be positive!");
}
//
@@ -184,7 +162,8 @@
ensureCapacity(length + len);
if (len < 10)
{
- while (off < len)
+ int toCopy = off + len;
+ while (off < toCopy)
{
buffer[length++] = chars[off++];
}
@@ -208,7 +187,7 @@
}
else
{
- for (int i = 0;i < s.length();i++)
+ for (int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
buffer[length++] = c;
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java 2008-04-21 23:09:28 UTC (rev 10688)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java 2008-04-22 05:39:57 UTC (rev 10689)
@@ -31,40 +31,43 @@
public interface CharEncoder
{
/**
- *
- * @param c the char to encode
+ * @param c the char to encode
* @param writer the writer to use
* @throws IllegalArgumentException if any argument is null
- * @throws EncodingException an encoding exception
+ * @throws EncodingException an encoding exception
*/
void encode(char c, CharWriter writer) throws IllegalArgumentException, EncodingException;
/**
- *
- * @param chars the chars to encode
- * @param off the offset in the char array
- * @param len the lenght of chars to encode
+ * @param chars the chars to encode
+ * @param off the offset in the char array
+ * @param len the lenght of chars to encode
* @param writer the writer to use
* @throws IllegalArgumentException if any argument is null or if the bounds not valid in the provided array
- * @throws EncodingException an encoding exception
+ * @throws EncodingException an encoding exception
*/
void encode(char[] chars, int off, int len, CharWriter writer) throws IllegalArgumentException, EncodingException;
/**
- *
- * @param chars the chars to encode
+ * @param chars the chars to encode
* @param writer the writer to use
* @throws IllegalArgumentException if any argument is null
- * @throws EncodingException an encoding exception
+ * @throws EncodingException an encoding exception
*/
void encode(char[] chars, CharWriter writer) throws IllegalArgumentException, EncodingException;
/**
- *
- * @param s the sequence to encode
+ * @param s the sequence to encode
* @param writer the writer to use
* @throws IllegalArgumentException if any argument is null
- * @throws EncodingException an encoding exception
+ * @throws EncodingException an encoding exception
*/
void encode(CharSequence s, CharWriter writer) throws IllegalArgumentException, EncodingException;
+
+ /**
+ * @param string the String to encode
+ * @return the encoded String
+ * @throws IllegalArgumentException if the specified String is <code>null</code>
+ */
+ String encode(String string) throws IllegalArgumentException;
}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java 2008-04-21 23:09:28 UTC (rev 10688)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java 2008-04-22 05:39:57 UTC (rev 10689)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.common.text;
+import org.jboss.portal.common.util.ParameterValidation;
+
/**
* This encoder performs lookup for converting a char to its HTML entity representation.
*
@@ -31,8 +33,10 @@
public class EntityEncoder extends AbstractCharEncoder
{
- protected void safeEncode(char c, CharWriter writer) throws EncodingException
+ public void encode(char c, CharWriter writer) throws EncodingException
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(writer, "CharWriter");
+
String s = charToEntity[c];
//
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java 2008-04-21 23:09:28 UTC (rev 10688)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java 2008-04-22 05:39:57 UTC (rev 10689)
@@ -22,16 +22,11 @@
******************************************************************************/
package org.jboss.portal.common.text;
-import java.io.StringWriter;
-import java.io.Writer;
-
-import org.jboss.portal.common.io.WriterCharWriter;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class FastURLDecoder implements CharEncoder
+public class FastURLDecoder extends AbstractCharEncoder
{
/** . */
@@ -165,98 +160,9 @@
}
}
- public void encode(char c, CharWriter writer)
- {
- encode(new char[]{c}, writer);
- }
- public void encode(char[] chars, int off, int len, CharWriter writer)
+ protected void safeEncode(char[] chars, int i, int length, CharWriter tmp)
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (off < 0)
- {
- throw new IllegalArgumentException();
- }
- if (len < 0)
- {
- throw new IllegalArgumentException();
- }
- if (off + len > chars.length)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- encodeNoCheck(chars, off, len, writer);
- }
-
- public void encode(char[] chars, CharWriter writer)
- {
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- encodeNoCheck(chars, 0, chars.length, writer);
- }
-
- public void encode(CharSequence s, CharWriter writer)
- {
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- if (s instanceof String)
- {
- char[] chars = ((String)s).toCharArray();
- encodeNoCheck(chars, 0, chars.length, writer);
- }
- else
- {
- char[] chars = new char[s.length()];
- for (int i = 0; i < s.length(); i++)
- {
- char c = s.charAt(i);
- chars[i] = c;
- }
- encodeNoCheck(chars, 0, chars.length, writer);
- }
- }
-
- /**
- * @param s
- * @return
- * @throws IllegalArgumentException
- * @since 1.1
- */
- public String encode(String s) throws IllegalArgumentException
- {
- Writer sw = new StringWriter();
- CharWriter charWriter = new WriterCharWriter(sw);
- encodeNoCheck(s.toCharArray(), 0, s.length(), charWriter);
- return sw.toString();
- }
-
- private void encodeNoCheck(char[] chars, int i, int length, CharWriter tmp)
- {
while (i < length)
{
char c = chars[i++];
@@ -326,7 +232,7 @@
case ERROR:
if (strict)
{
- throw new MalformedInputException("Cannot decode char " + c);
+ throw new MalformedInputException("Cannot decode char '" + c + "'");
}
else
{
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java 2008-04-21 23:09:28 UTC (rev 10688)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java 2008-04-22 05:39:57 UTC (rev 10689)
@@ -23,6 +23,7 @@
package org.jboss.portal.common.text;
import org.jboss.portal.common.io.UndeclaredIOException;
+import org.jboss.portal.common.util.ParameterValidation;
import java.io.IOException;
import java.io.Writer;
@@ -33,7 +34,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 7228 $
*/
-public class FastURLEncoder implements CharEncoder
+public class FastURLEncoder extends AbstractCharEncoder
{
/** . */
@@ -106,151 +107,46 @@
}
}
- public void encode(CharSequence s, CharWriter out) throws IllegalArgumentException
+ public void encode(char c, CharWriter writer)
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (out == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(writer, "CharWriter");
//
- for (int i = 0; i < s.length(); i++)
- {
- char c = s.charAt(i);
- char[] z = table[c];
- if (z == null)
- {
- throw new MalformedInputException("Wrong");
- }
- out.append(z);
- }
+ char[] z = getEncoding(c);
+ writer.append(z);
}
- public void encode(char c, CharWriter writer)
+ private char[] getEncoding(char c)
{
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
char[] z = table[c];
if (z == null)
{
- throw new MalformedInputException("Wrong");
+ throw new MalformedInputException("Couldn't find appropriate encoding for '" + c + "'");
}
- writer.append(z);
+ return z;
}
- public void encode(char[] chars, int off, int len, CharWriter writer)
+ protected void safeEncode(char[] chars, int off, int len, CharWriter writer)
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (off < 0)
- {
- throw new IllegalArgumentException();
- }
- if (len < 0)
- {
- throw new IllegalArgumentException();
- }
- if (off + len > chars.length)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- encodeNoCheck(chars, off, len, writer);
- }
-
- public void encode(char[] chars, CharWriter writer)
- {
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- encodeNoCheck(chars, 0, chars.length, writer);
- }
-
- private void encodeNoCheck(char[] chars, int off, int len, CharWriter writer)
- {
for (int i = off; i < len; i++)
{
char c = chars[i];
- char[] z = table[c];
- if (z == null)
- {
- throw new IllegalArgumentException("Wrong");
- }
+ char[] z = getEncoding(c);
writer.append(z);
}
}
- public String encode(String s) throws IllegalArgumentException
- {
- StringBuffer tmp = new StringBuffer();
- encode(s, tmp);
- return tmp.toString();
- }
-
- public void encode(String s, StringBuffer out) throws IllegalArgumentException
- {
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (out == null)
- {
- throw new IllegalArgumentException();
- }
- for (int i = 0; i < s.length(); i++)
- {
- char c = s.charAt(i);
- char[] z = table[c];
- if (z == null)
- {
- throw new MalformedInputException("Cannot encode char=" + (int)c);
- }
- out.append(z);
- }
- }
-
public void encode(String s, Writer out) throws IllegalArgumentException, UndeclaredIOException
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (out == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(s, "String");
+ ParameterValidation.throwIllegalArgExceptionIfNull(out, "Writer");
+
try
{
for (int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
- char[] z = table[c];
- if (z == null)
- {
- throw new MalformedInputException("Wrong");
- }
+ char[] z = getEncoding(c);
out.write(z);
}
}
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2008-04-21 23:09:28 UTC (rev 10688)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2008-04-22 05:39:57 UTC (rev 10689)
@@ -37,6 +37,24 @@
}
}
+ public static void throwIllegalArgExceptionIfRangeInvalid(char[] chars, int offset, int length)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(chars, "characters");
+
+ if (offset < 0)
+ {
+ throw new IllegalArgumentException("Offset must be positive!");
+ }
+ if (length < 0)
+ {
+ throw new IllegalArgumentException("Length must be positive!");
+ }
+ if (offset + length > chars.length)
+ {
+ throw new IllegalArgumentException("Specified character range is outside of the given char[]!");
+ }
+ }
+
/** @since 2.6 */
public static boolean isNullOrEmpty(String valueToCheck)
{
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2008-04-21 23:09:28 UTC (rev 10688)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2008-04-22 05:39:57 UTC (rev 10689)
@@ -63,6 +63,15 @@
assertEquals("abc", buffer.asString());
}
+ public void testCharArrayAppendWithOffset()
+ {
+ CharBuffer buffer = new CharBuffer();
+ buffer.append("abcdef".toCharArray(), 1, 5);
+ assertEquals("bcdef", buffer.asString());
+ buffer.append("pqrstu".toCharArray(), 3, 3);
+ assertEquals("stu", buffer.asString());
+ }
+
public void testReset()
{
CharBuffer buffer = new CharBuffer(0);
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java 2008-04-21 23:09:28 UTC (rev 10688)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java 2008-04-22 05:39:57 UTC (rev 10689)
@@ -23,8 +23,8 @@
package org.jboss.portal.test.common.text;
import junit.framework.TestCase;
+import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.EntityEncoder;
-import org.jboss.portal.common.text.CharBuffer;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -42,6 +42,13 @@
assertEquals("c", buffer.asString(true));
}
+ public void testChars()
+ {
+ CharBuffer buffer = new CharBuffer();
+ EntityEncoder.FULL.encode("&bar".toCharArray(), buffer);
+ assertEquals("&bar", buffer.asString(true));
+ }
+
public void testString()
{
test("&", "&");
16 years