JBoss Portal SVN: r5858 - tags
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-12-14 14:40:17 -0500 (Thu, 14 Dec 2006)
New Revision: 5858
Removed:
tags/JBoss_Portal_2_4_1/
Log:
retagging 2.4.1
19 years, 5 months
JBoss Portal SVN: r5857 - in branches/JBoss_Portal_Branch_2_4: portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletinterface portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletrequests server/src/main/org/jboss/portal/server/servlet
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-12-14 14:39:34 -0500 (Thu, 14 Dec 2006)
New Revision: 5857
Modified:
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/PortletInterfaceSequenceBuilder.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletrequests/PortletRequestsSequenceBuilder.java
branches/JBoss_Portal_Branch_2_4/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
Log:
fixed failing portlet container test cases in 2.4 branch
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/PortletInterfaceSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/PortletInterfaceSequenceBuilder.java 2006-12-14 14:51:47 UTC (rev 5856)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletinterface/PortletInterfaceSequenceBuilder.java 2006-12-14 19:39:34 UTC (rev 5857)
@@ -167,6 +167,7 @@
{
Sequence seq = new Sequence();
registry.addSequence("InvokeActionFirst", seq);
+ final Boolean[] actionInvoked= new Boolean[1];
seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
{
@@ -180,7 +181,7 @@
{
protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response)
{
- UTP1.local.set(Boolean.TRUE);
+ actionInvoked[0] = Boolean.TRUE;
return null;
}
});
@@ -189,7 +190,7 @@
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
{
- assertEquals(Boolean.TRUE, (Boolean)UTP1.local.get());
+ assertEquals(Boolean.TRUE, actionInvoked[0]);
return new EndTestResult();
}
});
@@ -205,6 +206,7 @@
{
Sequence seq = new Sequence();
registry.addSequence("InvokeRenderAfterActionURL", seq);
+ final Boolean[] actionInvoked= new Boolean[1];
seq.addAction(0, UTP1.RENDER_JOINPOINT, new PortletRenderTestAction()
{
@@ -239,7 +241,7 @@
protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response)
{
//mark action phase invokation
- UTP2.local.set(Boolean.TRUE);
+ actionInvoked[0] = Boolean.TRUE;
return null;
}
});
@@ -249,7 +251,7 @@
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
{
//assert that render is after Portlet B action
- assertEquals(Boolean.TRUE, (Boolean)UTP2.local.get());
+ assertEquals(Boolean.TRUE, actionInvoked[0]);
return null;
}
});
@@ -259,7 +261,7 @@
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
{
//assert that render is after Portlet B action
- assertEquals(Boolean.TRUE, (Boolean)UTP2.local.get());
+ assertEquals(Boolean.TRUE, actionInvoked[0]);
//and reinvoke itself
return new InvokeGetResult(response.createRenderURL().toString());
}
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletrequests/PortletRequestsSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletrequests/PortletRequestsSequenceBuilder.java 2006-12-14 14:51:47 UTC (rev 5856)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/tck/portletrequests/PortletRequestsSequenceBuilder.java 2006-12-14 19:39:34 UTC (rev 5857)
@@ -149,7 +149,10 @@
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
{
- UTP2.holder = response.createRenderURL();
+ PortletURL url = response.createRenderURL();
+ url.setParameter("portlet2key1", "p2k1value1");
+ url.setParameter("portlet2key2", new String[]{"p2k2value1", "p2k2value2", "p2k2value3"});
+ UTP2.holder = url.toString();
return null;
}
});
@@ -173,9 +176,7 @@
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response)
{
//invoke render url from different portlet to be able to pass some params to it
- PortletURL url = (PortletURL)UTP2.holder;
- url.setParameter("portlet2key1", "p2k1value1");
- url.setParameter("portlet2key2", new String[]{"p2k2value1", "p2k2value2", "p2k2value3"});
+ String url = (String)UTP2.holder;
return new InvokeGetResult(url.toString());
}
});
Modified: branches/JBoss_Portal_Branch_2_4/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2006-12-14 14:51:47 UTC (rev 5856)
+++ branches/JBoss_Portal_Branch_2_4/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java 2006-12-14 19:39:34 UTC (rev 5857)
@@ -424,13 +424,21 @@
public class ServerResponseContextImpl implements ServerResponseContext
{
- private HttpServletRequest req;
- private HttpServletResponse resp;
+ private final HttpServletResponse resp;
+ private final String contextPath;
+ private final String scheme;
+ private final String serverName;
+ private final int serverPort;
+ private final boolean secure;
public ServerResponseContextImpl(HttpServletRequest req, HttpServletResponse resp)
{
- this.req = req;
this.resp = resp;
+ this.contextPath = req.getContextPath();
+ this.scheme = req.getScheme();
+ this.serverName = req.getServerName();
+ this.serverPort = req.getServerPort();
+ this.secure = req.isSecure();
}
public HttpServletResponse getClientResponse()
@@ -440,138 +448,131 @@
public String encodeURL(ServerURL url, URLContext context, URLFormat format)
{
- Buffer buffer = new Buffer(req, resp, context, format);
+ Buffer buffer = new Buffer(context, format);
return buffer.toString(url);
}
- }
- public static class Buffer
- {
+ public class Buffer
+ {
- private HttpServletRequest req;
+ private URLContext context;
+ private URLFormat format;
+ private char[] buffer = new char[256];
+ private int len = 0;
- private HttpServletResponse resp;
+ public Buffer(URLContext context, URLFormat format)
+ {
+ this.context = context;
+ this.format = format;
- private URLContext context;
+ //
+ init();
+ }
- private URLFormat format;
-
- private char[] buffer = new char[256];
-
- private int len = 0;
-
-
- public Buffer(HttpServletRequest req, HttpServletResponse resp, URLContext context, URLFormat format)
- {
- this.req = req;
- this.resp = resp;
- this.context = context;
- this.format = format;
- init();
- }
-
- private void init()
- {
- //
- if (!format.isRelative())
+ private void init()
{
- append(req.getScheme());
- append("://");
- append(req.getServerName());
//
- int port = req.getServerPort();
- if (req.isSecure())
+ if (!format.isRelative())
{
- if (port != 443)
+ append(scheme);
+ append("://");
+ append(serverName);
+
+ //
+ int port = serverPort;
+ if (secure)
{
+ if (port != 443)
+ {
+ append(":");
+ append(Integer.toString(port));
+ }
+ }
+ else if (port != 80)
+ {
append(":");
append(Integer.toString(port));
}
}
- else if (port != 80)
- {
- append(":");
- append(Integer.toString(port));
- }
- }
- // Append the context path
- append(req.getContextPath());
+ // Append the context path
+ append(contextPath);
- // Append the servlet path
- if (context.isAuthenticated())
- {
- if (context.getSecure())
+ // Append the servlet path
+ if (context.isAuthenticated())
{
- append("/authsec");
+ if (context.getSecure())
+ {
+ append("/authsec");
+ }
+ else
+ {
+ append("/auth");
+ }
}
else
{
- append("/auth");
+ if (context.getSecure())
+ {
+ append("/sec");
+ }
+ else
+ {
+ append("");
+ }
}
}
- else
+
+ public String toString(ServerURL url)
{
- if (context.getSecure())
+ // julien : check UTF-8 is ok and should not be dependant on the response charset
+ append(url.getPortalRequestPath());
+
+ //
+ boolean first = true;
+ for (Iterator i = url.getParameters(); i.hasNext();)
{
- append("/sec");
+ ServerURL.Parameter parameter = (ServerURL.Parameter)i.next();
+ String name = parameter.getName();
+ for (Iterator j = parameter.getValues(); j.hasNext();)
+ {
+ String value = (String)j.next();
+ append(first ? "?" : "&");
+ append(URLTools.encodeXWWWFormURL(name));
+ append("=");
+ append(URLTools.encodeXWWWFormURL(value));
+ first = false;
+ }
}
- else
- {
- append("");
- }
- }
- }
- public String toString(ServerURL url)
- {
- // julien : check UTF-8 is ok and should not be dependant on the response charset
- append(url.getPortalRequestPath());
+ //
+ String s = new String(buffer, 0, len);
- //
- boolean first = true;
- for (Iterator i = url.getParameters(); i.hasNext();)
- {
- ServerURL.Parameter parameter = (ServerURL.Parameter)i.next();
- String name = parameter.getName();
- for (Iterator j = parameter.getValues(); j.hasNext();)
+ //
+ if (format.isEncoded())
{
- String value = (String)j.next();
- append(first ? "?" : "&");
- append(URLTools.encodeXWWWFormURL(name));
- append("=");
- append(URLTools.encodeXWWWFormURL(value));
- first = false;
+ s = resp.encodeURL(s);
}
- }
- //
- String s = new String(buffer, 0, len);
-
- //
- if (format.isEncoded())
- {
- s = resp.encodeURL(s);
+ //
+ return s;
}
- //
- return s;
- }
-
- private void append(String arg)
- {
- int arglen = arg.length();
- int buflen = buffer.length;
- while (len + arglen > buflen)
+ private void append(String arg)
{
- char[] tmp = new char[buflen * 2 + 1];
- System.arraycopy(buffer, 0, tmp, 0, len);
- buffer = tmp;
- buflen = tmp.length;
+ int arglen = arg.length();
+ int buflen = buffer.length;
+ while (len + arglen > buflen)
+ {
+ char[] tmp = new char[buflen * 2 + 1];
+ System.arraycopy(buffer, 0, tmp, 0, len);
+ buffer = tmp;
+ buflen = tmp.length;
+ }
+ arg.getChars(0, arglen, buffer, len);
+ len += arglen;
}
- arg.getChars(0, arglen, buffer, len);
- len += arglen;
}
}
19 years, 5 months
JBoss Portal SVN: r5856 - trunk/search/src/main/org/jboss/portal/search/test
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2006-12-14 09:51:47 -0500 (Thu, 14 Dec 2006)
New Revision: 5856
Added:
trunk/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java
Log:
Federated search (test)
Added: trunk/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java 2006-12-14 14:51:24 UTC (rev 5855)
+++ trunk/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java 2006-12-14 14:51:47 UTC (rev 5856)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * 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.search.test;
+
+import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.federation.Info;
+import org.jboss.portal.search.federation.SearchFederated;
+import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.result.Results;
+import org.jboss.portal.search.result.impl.SimpleResult;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class DummySearchFederated implements SearchFederated
+{
+
+ private Info info;
+
+ public DummySearchFederated()
+ {
+ info = new Info();
+ }
+
+ public void create() throws IndexingException
+ {
+ info.setStatus(Info.Status.STARTED);
+ }
+
+ public void destroy() throws IndexingException
+ {
+ info.setStatus(Info.Status.STOPPED);
+ }
+
+ public String getId()
+ {
+ return "DummySearchFederated";
+ }
+
+ public Info getInfo()
+ {
+ return info;
+ }
+
+ public String getMarkup(Results results, int markupLevel)
+ {
+ return null;
+ }
+
+ public Results search(Query query)
+ {
+ Results results = new Results();
+ results.add(new SimpleResult(getId(), "Result 1"));
+ results.add(new SimpleResult(getId(), "Result 2"));
+ results.add(new SimpleResult(getId(), "Result 3"));
+ return results;
+ }
+
+}
19 years, 5 months
JBoss Portal SVN: r5855 - trunk/search/src/main/org/jboss/portal/search/test
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2006-12-14 09:51:24 -0500 (Thu, 14 Dec 2006)
New Revision: 5855
Added:
trunk/search/src/main/org/jboss/portal/search/test/FederationTest.java
Log:
Federated search
Added: trunk/search/src/main/org/jboss/portal/search/test/FederationTest.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/FederationTest.java 2006-12-14 14:49:08 UTC (rev 5854)
+++ trunk/search/src/main/org/jboss/portal/search/test/FederationTest.java 2006-12-14 14:51:24 UTC (rev 5855)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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.search.test;
+
+import org.jboss.portal.search.federation.SearchFederation;
+import org.jboss.portal.search.federation.impl.SearchFederationService;
+import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.query.impl.FieldQueryTerm;
+import org.jboss.portal.search.result.Results;
+import org.jboss.portal.search.result.impl.SimpleResult;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class FederationTest extends TestCase
+{
+ public void test01()
+ {
+ SearchFederation federation = new SearchFederationService();
+ DummySearchFederated federated = new DummySearchFederated();
+ federation.register(federated);
+ federation.reindexAll();
+
+ Query query = new Query();
+ query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
+
+ Results results = federation.search(query);
+
+ assertEquals("Result 1", (((SimpleResult)results.getResult(0)).getValue()));
+ assertEquals("Result 2", (((SimpleResult)results.getResult(1)).getValue()));
+ assertEquals("Result 3", (((SimpleResult)results.getResult(2)).getValue()));
+ }
+}
19 years, 5 months
JBoss Portal SVN: r5854 - in trunk/search/src/main/org/jboss/portal/search: . federation federation/impl result result/impl test
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2006-12-14 09:49:08 -0500 (Thu, 14 Dec 2006)
New Revision: 5854
Added:
trunk/search/src/main/org/jboss/portal/search/result/
trunk/search/src/main/org/jboss/portal/search/result/Result.java
trunk/search/src/main/org/jboss/portal/search/result/Results.java
trunk/search/src/main/org/jboss/portal/search/result/impl/
trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java
trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java
Removed:
trunk/search/src/main/org/jboss/portal/search/Result.java
trunk/search/src/main/org/jboss/portal/search/Results.java
Modified:
trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java
trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java
Log:
Federated search
Deleted: trunk/search/src/main/org/jboss/portal/search/Result.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/Result.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/Result.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * 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.search;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class Result
-{
- private String federatedId;
-
- private Object value;
-
- public Result(String federatedId, Object value)
- {
- this.federatedId = federatedId;
- this.value = value;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public void setValue(Object value)
- {
- this.value = value;
- }
-
- public String getFederatedId()
- {
- return federatedId;
- }
-
-}
Deleted: trunk/search/src/main/org/jboss/portal/search/Results.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/Results.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/Results.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -1,36 +0,0 @@
-/******************************************************************************
- * 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.search;
-
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class Results extends ArrayList
-{
-
- private static final long serialVersionUID = -334471675564695554L;
-
-}
Modified: trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -23,8 +23,8 @@
package org.jboss.portal.search.federation;
import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.Results;
import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.result.Results;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
Modified: trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -24,6 +24,9 @@
import java.util.List;
+import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.result.Results;
+
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
@@ -39,5 +42,7 @@
public List getSearchFederated();
public SearchFederated getSearchFederated(String id);
+
+ public Results search(Query query);
}
Modified: trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -34,6 +34,8 @@
import org.jboss.portal.search.federation.Info;
import org.jboss.portal.search.federation.SearchFederated;
import org.jboss.portal.search.federation.SearchFederation;
+import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.result.Results;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -44,6 +46,11 @@
private Map registry;
+ public SearchFederationService()
+ {
+ registry = new HashMap();
+ }
+
public synchronized void register(SearchFederated searchFederated)
{
if (searchFederated == null)
@@ -127,5 +134,17 @@
{
return (SearchFederated)registry.get(id);
}
+
+ public Results search(Query query)
+ {
+ Results results = new Results();
+ Iterator it = registry.values().iterator();
+ while (it.hasNext())
+ {
+ SearchFederated federated = (SearchFederated)it.next();
+ results.addAll(federated.search(query));
+ }
+ return results;
+ }
}
Added: trunk/search/src/main/org/jboss/portal/search/result/Result.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/result/Result.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/result/Result.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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.search.result;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface Result
+{
+ public float getScore();
+
+ public String getFederatedId();
+}
Copied: trunk/search/src/main/org/jboss/portal/search/result/Results.java (from rev 5853, trunk/search/src/main/org/jboss/portal/search/Results.java)
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/Results.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/result/Results.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * 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.search.result;
+
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class Results extends ArrayList
+{
+
+ private static final long serialVersionUID = -334471675564695554L;
+
+ public Result getResult(int i)
+ {
+ return (Result)get(i);
+ }
+
+}
Added: trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * 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.search.result.impl;
+
+import org.jboss.portal.search.result.Result;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractResult implements Result
+{
+ private String federatedId;
+
+ private float score;
+
+ public AbstractResult(String federatedId)
+ {
+ this.federatedId = federatedId;
+ }
+
+ public String getFederatedId()
+ {
+ return federatedId;
+ }
+
+ public float getScore()
+ {
+ return score;
+ }
+
+ public void setScore(float score)
+ {
+ this.score = score;
+ }
+
+}
Added: trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * 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.search.result.impl;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SimpleResult extends AbstractResult
+{
+
+ private Object value;
+
+ public SimpleResult(String federatedId, Object value)
+ {
+ super(federatedId);
+ setValue(value);
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+
+
+}
Modified: trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -23,9 +23,9 @@
package org.jboss.portal.search.test;
import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.Results;
import org.jboss.portal.search.query.Query;
import org.jboss.portal.search.query.impl.FieldQueryTerm;
+import org.jboss.portal.search.result.Results;
import junit.framework.TestCase;
Modified: trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java 2006-12-14 00:37:26 UTC (rev 5853)
+++ trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java 2006-12-14 14:49:08 UTC (rev 5854)
@@ -34,11 +34,12 @@
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Searcher;
import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.Result;
-import org.jboss.portal.search.Results;
import org.jboss.portal.search.federation.Info;
import org.jboss.portal.search.federation.SearchFederated;
import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.result.Results;
+import org.jboss.portal.search.result.impl.AbstractResult;
+import org.jboss.portal.search.result.impl.SimpleResult;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -115,7 +116,7 @@
Hits hits = searcher.search(luceneQuery);
for (int i=0; i<hits.length(); i++)
{
- result.add(new Result(id, hits.doc(i)));
+ result.add(new SimpleResult(id, hits.doc(i)));
}
}
catch (Exception e)
@@ -133,8 +134,8 @@
Iterator it = results.iterator();
while (it.hasNext())
{
- Result result = (Result) it.next();
- Document document = (Document)result.getValue();
+ AbstractResult result = (AbstractResult) it.next();
+ Document document = (Document)((SimpleResult)result).getValue();
buffer.append("Id:" + document.getField("id").stringValue());
buffer.append(" ");
}
19 years, 5 months
JBoss Portal SVN: r5853 - in trunk: identity identity/src/main/org/jboss/portal/identity2 identity/src/main/org/jboss/portal/identity2/db identity/src/main/org/jboss/portal/identity2/ldap identity/src/main/org/jboss/portal/identity2/service identity/src/main/org/jboss/portal/test/identity/db identity/src/main/org/jboss/portal/test/identity/ldap identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity identity/src/resources/test/config test/src/etc test/src/etc/ldap/ldi
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2006-12-13 19:37:26 -0500 (Wed, 13 Dec 2006)
New Revision: 5853
Added:
trunk/identity/src/main/org/jboss/portal/identity2/DelegatingUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPUserProfileModuleTestCase.java
Modified:
trunk/identity/build.xml
trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java
trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/db/DBTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java
trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/ldap-beans.xml
trunk/identity/src/resources/test/config/db-config.xml
trunk/identity/src/resources/test/config/opends-config.xml
trunk/identity/src/resources/test/config/profile-config.xml
trunk/identity/src/resources/test/config/rhds-config.xml
trunk/identity/src/resources/test/config/standardidentity-config.xml
trunk/test/src/etc/directories.xml
trunk/test/src/etc/ldap/ldif/initial-tests.ldif
trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java
Log:
- DelegatingUserProfileModule connected with DB and LDAP and initial test case
Modified: trunk/identity/build.xml
===================================================================
--- trunk/identity/build.xml 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/build.xml 2006-12-14 00:37:26 UTC (rev 5853)
@@ -334,7 +334,7 @@
<x-test>
- <test todir="${test.reports}" name="org.jboss.portal.test.identity.db_old.DBUserTestCase"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.identity.db.DBIdentityTestCase"/>
</x-test>
<x-classpath>
<pathelement location="${build.lib}/portal-identity-lib.jar"/>
@@ -446,15 +446,14 @@
<x-test>
<!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.db_old.DBUserTestCase"/>-->
- <test todir="${test.reports}" name="org.jboss.portal.test.identity.db.DBIdentityTestCase"/>
+ <!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.db.DBIdentityTestCase"/>-->
<!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.UserProtoTestCase"/>-->
<!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ConfigurationTestCase"/>-->
<!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPSimpleUserModuleTestCase"/>-->
- <!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPSimpleRoleModuleTestCase"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPStaticGroupMembershipModuleTestCase"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPStaticRoleMembershipModuleTestCase"/>-->
-
-
+ <!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPSimpleRoleModuleTestCase"/>-->
+ <!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPStaticGroupMembershipModuleTestCase"/>-->
+ <!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPStaticRoleMembershipModuleTestCase"/>-->
+ <test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPUserProfileModuleTestCase"/>
</x-test>
<x-classpath>
<pathelement location="${build.lib}/portal-identity-lib.jar"/>
Added: trunk/identity/src/main/org/jboss/portal/identity2/DelegatingUserProfileModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/DelegatingUserProfileModuleImpl.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/identity2/DelegatingUserProfileModuleImpl.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -0,0 +1,202 @@
+/*
+* 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.identity2;
+
+import org.jboss.portal.identity2.service.UserProfileModuleService;
+import org.jboss.portal.identity2.info.PropertyInfo;
+import org.jboss.portal.identity2.ldap.LDAPUserImpl;
+import org.jboss.portal.identity2.db.HibernateUserImpl;
+import org.jboss.portal.identity.IdentityException;
+
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class DelegatingUserProfileModuleImpl extends UserProfileModuleService
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(DelegatingUserProfileModuleImpl.class);
+
+ private String ldapModuleJNDIName;
+
+ private String dbModuleJNDIName;
+
+ private UserProfileModule LDAPModule;
+
+ private UserProfileModule dbModule;
+
+ protected void startService() throws Exception
+ {
+ super.startService();
+
+ if(getProfileInfo() == null)
+ {
+ throw new IdentityException("No profile information found. Check the configuration.");
+ }
+
+ }
+
+ public Object getProperty(User user, String propertyName) throws IdentityException, IllegalArgumentException
+ {
+ if (log.isDebugEnabled()) log.debug("getProperty: " + propertyName);
+ try
+ {
+ PropertyInfo property = getProfileInfo().getPropertyInfo(propertyName);
+ if (property == null)
+ {
+ throw new IdentityException("Such property name is not supported");
+ }
+ else if (property.isMappedLDAP() && isLDAPSupported() && user instanceof LDAPUserImpl)
+ {
+ log.debug("Delegating to LDAP module");
+ return getLDAPModule().getProperty(user, propertyName);
+ }
+ else if (property.isMappedDB())
+ {
+ log.debug("Delegating to DB module");
+ return getDBModule().getProperty(user, propertyName);
+ }
+ throw new IdentityException("Cannot process property - incorrect profile or module configuration");
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot resolve property: ", e);
+ }
+ }
+
+ public void setProperty(User user, String name, Object propertyValue) throws IdentityException, IllegalArgumentException
+ {
+ if (log.isDebugEnabled()) log.debug("setProperty: " + name + "/" + propertyValue);
+ try
+ {
+ PropertyInfo property = getProfileInfo().getPropertyInfo(name);
+ if (property == null)
+ {
+ throw new IdentityException("Such property name is not supported");
+ }
+ else if (property.isMappedLDAP() && isLDAPSupported() && user instanceof LDAPUserImpl)
+ {
+ log.debug("Delegating to LDAP module");
+ getLDAPModule().setProperty(user, name, propertyValue);
+ return;
+ }
+ else if (property.isMappedDB())
+ {
+ log.debug("Delegating to DB module");
+ getDBModule().setProperty(user, name, propertyValue);
+ return;
+ }
+ throw new IdentityException("Cannot process property - incorrect profile or module configuration");
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot resolve property: ", e);
+ }
+ }
+
+ public Map getProperties(User user) throws IdentityException, IllegalArgumentException
+ {
+ if (log.isDebugEnabled()) log.debug("getProperties");//: " + name + "/" + propertyValue)
+ try
+ {
+ if (user instanceof LDAPUserImpl && isLDAPSupported())
+ {
+ log.debug("Delegating to LDAP module");
+ return getLDAPModule().getProperties(user);
+ }
+ else if (user instanceof HibernateUserImpl && isDBSupported())
+ {
+ log.debug("Delegating to DB module");
+ return getDBModule().getProperties(user);
+ }
+ throw new IdentityException("Cannot process properties - incorrect profile or module configuration");
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot resolve property: ", e);
+ }
+ }
+
+
+ public String getLdapModuleJNDIName()
+ {
+ return ldapModuleJNDIName;
+ }
+
+ public void setLdapModuleJNDIName(String ldapModuleJNDIName)
+ {
+ this.ldapModuleJNDIName = ldapModuleJNDIName;
+ }
+
+ public String getDbModuleJNDIName()
+ {
+ return dbModuleJNDIName;
+ }
+
+ public void setDbModuleJNDIName(String dbModuleJNDIName)
+ {
+ this.dbModuleJNDIName = dbModuleJNDIName;
+ }
+
+ public boolean isLDAPSupported()
+ {
+ return getLdapModuleJNDIName()!=null;
+ }
+
+ public boolean isDBSupported()
+ {
+ return getDbModuleJNDIName()!=null;
+ }
+
+ protected UserProfileModule getDBModule() throws Exception
+ {
+
+ //TODO: to tired to clean this at the moment
+ if (dbModule == null)
+ {
+ dbModule = (UserProfileModule)new InitialContext().lookup(getDbModuleJNDIName());
+ if (dbModule == null)
+ {
+ throw new IdentityException("Couldn't obtain DB UserProfileModule");
+ }
+ }
+ return dbModule;
+ }
+
+ protected UserProfileModule getLDAPModule() throws Exception
+ {
+ if (LDAPModule == null)
+ {
+ LDAPModule = (UserProfileModule)new InitialContext().lookup(getLdapModuleJNDIName());
+ if (LDAPModule == null)
+ {
+ throw new IdentityException("Couldn't obtain LDAP UserProfileModule");
+ }
+ }
+ return LDAPModule;
+ }
+
+}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -328,6 +328,11 @@
moduleBMD.addProperty(propertyBMD);
}
+ //make the type from name
+ propertyBMD = new AbstractPropertyMetaData("moduleType", module.getType());
+ moduleBMD.addProperty(propertyBMD);
+
+
// Installation
beans.add(moduleBMD);
KernelControllerContext controllerContext = kernel.getController().install(moduleBMD);
Modified: trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -213,7 +213,7 @@
hu = new HibernateUserImpl(user.getUserName());
user.updatePassword(user.getPassword());
session = getCurrentSession();
- session.save(user);
+ session.save(hu);
return hu;
}
catch (HibernateException e)
@@ -235,13 +235,10 @@
*/
public ProfileInfo getProfileInfo() throws IdentityException
{
- ProfileInfo profileInfo = super.getProfileInfo();
- if (profileInfo != null)
+
+
+ if (super.getProfileInfo() == null)
{
- return profileInfo;
- }
- else
- {
//obtain main UserProfileModule
UserProfileModule module = (UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
if (module == this)
@@ -251,9 +248,9 @@
else
{
setProfileInfo(module.getProfileInfo());
- return profileInfo;
}
}
+ return super.getProfileInfo();
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -257,13 +257,10 @@
*/
public ProfileInfo getProfileInfo() throws IdentityException
{
- ProfileInfo profileInfo = super.getProfileInfo();
- if (profileInfo == null)
+
+
+ if (super.getProfileInfo() == null)
{
- return profileInfo;
- }
- else
- {
//obtain main UserProfileModule
UserProfileModule module = (UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
if (module == this)
@@ -273,9 +270,9 @@
else
{
setProfileInfo(module.getProfileInfo());
- return profileInfo;
}
}
+ return super.getProfileInfo();
}
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -49,7 +49,7 @@
private Map initOptions;
- private String moduleType;
+ protected String moduleType;
//restrict instance creation
private IdentityModuleService()
@@ -164,6 +164,11 @@
}
+ public void setModuleType(String moduleType)
+ {
+ this.moduleType = moduleType;
+ }
+
public String getConnectionJNDIName()
{
return connectionJNDIName;
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -25,6 +25,10 @@
import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.ProfileMap;
import org.jboss.portal.identity2.User;
+import org.jboss.portal.identity2.service.UserModuleService;
+import org.jboss.portal.identity2.service.UserProfileModuleService;
+import org.jboss.portal.identity2.service.MembershipModuleService;
+import org.jboss.portal.identity2.service.RoleModuleService;
import org.jboss.portal.identity2.db.HibernateUserImpl;
import org.jboss.portal.identity2.db.HibernateUserModuleImpl;
import org.jboss.portal.identity2.db.HibernateRoleModuleImpl;
@@ -78,10 +82,10 @@
controller.setRegisterMBeans(false);
controller.start();
identityContext = controller.getIdentityContext();
- this.userModule = (HibernateUserModuleImpl)identityContext.getObject(IdentityContext.TYPE_USER_MODULE);
- this.roleModule = (HibernateRoleModuleImpl)identityContext.getObject(IdentityContext.TYPE_ROLE_MODULE);
- this.membershipModule = (HibernateMembershipModuleImpl)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
- this.userProfileModule = (HibernateUserProfileModuleImpl)identityContext.getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
+ this.userModule = (UserModuleService)identityContext.getObject(IdentityContext.TYPE_USER_MODULE);
+ this.roleModule = (RoleModuleService)identityContext.getObject(IdentityContext.TYPE_ROLE_MODULE);
+ this.membershipModule = (MembershipModuleService)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+ this.userProfileModule = (UserProfileModuleService)identityContext.getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
//
utc = new UserTest();
@@ -104,86 +108,86 @@
//
- public void testFindUsersUsingFilter() throws Exception
- {
- utc.testFindUsersUsingFilter();
- }
+// public void testFindUsersUsingFilter() throws Exception
+// {
+// utc.testFindUsersUsingFilter();
+// }
+//
+// public void testFindUser1() throws Exception
+// {
+// utc.testFindUser1();
+// }
+//
+// public void testFindUser2() throws Exception
+// {
+// utc.testFindUser2();
+// }
+//
+// public void testFindUsers() throws Exception
+// {
+// utc.testFindUsers();
+// }
+//
+// public void testCreateUser() throws Exception
+// {
+// utc.testCreateUser();
+// }
+//
+// public void testCreateRole() throws Exception
+// {
+// utc.testCreateRole();
+// }
+//
+// public void testCountUser() throws Exception
+// {
+// utc.testCountUser();
+// }
+//
+// public void testRemoveNonExistingRole() throws Exception
+// {
+// utc.testRemoveNonExistingRole();
+// }
+//
+// public void testRemoveRole() throws Exception
+// {
+// utc.testRemoveRole();
+// }
+//
+// public void testRemoveUser() throws Exception
+// {
+// utc.testRemoveUser();
+// }
+//
+// public void testFindRoles() throws Exception
+// {
+// utc.testFindRoles();
+// }
+//
+// public void testFindRoleMembers() throws Exception
+// {
+// utc.testFindRoleMembers();
+// }
+//
+// public void testDynamicProperty() throws Exception
+// {
+// begin();
+// User user = userModule.createUser("testname", "testpassword");
+// ProfileMap map = ((HibernateUserImpl)user).getProfileMap();
+// assertNull(map.get("foo"));
+// assertFalse(map.isReadOnly("foo"));
+// map.put("foo", "value");
+// assertEquals("value", map.get("foo"));
+// assertFalse(map.isReadOnly("foo"));
+// commit();
+//
+// begin();
+// user = userModule.findUserByUserName("testname");
+// map = ((HibernateUserImpl)user).getProfileMap();
+// assertEquals("value", map.get("foo"));
+// assertFalse(map.isReadOnly("foo"));
+// commit();
+// }
- public void testFindUser1() throws Exception
- {
- utc.testFindUser1();
- }
-
- public void testFindUser2() throws Exception
- {
- utc.testFindUser2();
- }
-
- public void testFindUsers() throws Exception
- {
- utc.testFindUsers();
- }
-
- public void testCreateUser() throws Exception
- {
- utc.testCreateUser();
- }
-
- public void testCreateRole() throws Exception
- {
- utc.testCreateRole();
- }
-
- public void testCountUser() throws Exception
- {
- utc.testCountUser();
- }
-
- public void testRemoveNonExistingRole() throws Exception
- {
- utc.testRemoveNonExistingRole();
- }
-
- public void testRemoveRole() throws Exception
- {
- utc.testRemoveRole();
- }
-
- public void testRemoveUser() throws Exception
- {
- utc.testRemoveUser();
- }
-
- public void testFindRoles() throws Exception
- {
- utc.testFindRoles();
- }
-
- public void testFindRoleMembers() throws Exception
- {
- utc.testFindRoleMembers();
- }
-
- public void testDynamicProperty() throws Exception
- {
- begin();
- User user = userModule.createUser("testname", "testpassword");
- ProfileMap map = ((HibernateUserImpl)user).getProfileMap();
- assertNull(map.get("foo"));
- assertFalse(map.isReadOnly("foo"));
- map.put("foo", "value");
- assertEquals("value", map.get("foo"));
- assertFalse(map.isReadOnly("foo"));
- commit();
-
- begin();
- user = userModule.findUserByUserName("testname");
- map = ((HibernateUserImpl)user).getProfileMap();
- assertEquals("value", map.get("foo"));
- assertFalse(map.isReadOnly("foo"));
- commit();
- }
-
public void testStaticProperty() throws Exception
{
begin();
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/db/DBTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/db/DBTestCase.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/db/DBTestCase.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -28,6 +28,11 @@
import org.jboss.portal.common.test.junit.POJOJUnitTest;
import org.jboss.portal.common.test.junit.JUnitAdapter;
import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.DelegatingUserProfileModuleImpl;
+import org.jboss.portal.identity2.service.UserProfileModuleService;
+import org.jboss.portal.identity2.service.MembershipModuleService;
+import org.jboss.portal.identity2.service.RoleModuleService;
+import org.jboss.portal.identity2.service.UserModuleService;
import org.jboss.portal.identity2.db.HibernateUserModuleImpl;
import org.jboss.portal.identity2.db.HibernateRoleModuleImpl;
import org.jboss.portal.identity2.db.HibernateMembershipModuleImpl;
@@ -98,22 +103,22 @@
/**
* .
*/
- protected HibernateUserModuleImpl userModule;
+ protected UserModuleService userModule;
/**
* .
*/
- protected HibernateRoleModuleImpl roleModule;
+ protected RoleModuleService roleModule;
/**
* .
*/
- protected HibernateMembershipModuleImpl membershipModule;
+ protected MembershipModuleService membershipModule;
/**
* .
*/
- protected HibernateUserProfileModuleImpl userProfileModule;
+ protected UserProfileModuleService userProfileModule;
public DataSourceSupport.Config getDataSourceConfigParameter()
{
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -59,10 +59,9 @@
public void setUp() throws Exception
{
- runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
- runtimeContext.addBean("LDAPTestBean", this);
- runtimeContext.start();
+ super.setUp();
+
/*IdentityContextImpl context = new IdentityContextImpl();
context.start();
identityContext = context;
@@ -93,7 +92,8 @@
suffix = getDirectoryServerConfigParameter().getCleanUpDN();
- super.setUp();
+ populate();
+
}
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -54,10 +54,7 @@
public void setUp() throws Exception
{
- System.out.println("#########################");
- runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
- runtimeContext.addBean("LDAPTestBean", this);
- runtimeContext.start();
+ super.setUp();
//IdentityContextImpl context = new IdentityContextImpl();
//context.start();
@@ -92,7 +89,7 @@
suffix = getDirectoryServerConfigParameter().getCleanUpDN();
- super.setUp();
+ populate();
}
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -73,9 +73,7 @@
public void setUp() throws Exception
{
- runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
- runtimeContext.addBean("LDAPTestBean", this);
- runtimeContext.start();
+ super.setUp();
IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
@@ -87,52 +85,10 @@
roleModule = (RoleModule)identityContext.getObject(IdentityContext.TYPE_ROLE_MODULE);
membershipModule = (MembershipModule)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
- /*IdentityContextImpl context = new IdentityContextImpl();
- context.start();
- identityContext = context;
-
- SimpleConfigurationImpl configuration = new SimpleConfigurationImpl();
- configuration.setIdentityContext(identityContext);
- configuration.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
- configuration.start();
-
- LDAPConnectionContext connection = new LDAPConnectionContext();
- connection.setIdentityContext(identityContext);
- connection.start();
-
- LDAPUserModuleImpl userModule = new LDAPUserModuleImpl();
- userModule.setIdentityContext(identityContext);
-
- //userModule.setContainerDN("ou=People,dc=jboss,dc=org");
- //userModule.setUidAttributeID("uid");
-
- userModule.start();
- this.userModule = userModule;
-
- LDAPRoleModuleImpl roleModule = new LDAPRoleModuleImpl();
- roleModule.setIdentityContext(identityContext);
- //roleModule.setContainerDN("ou=Roles,dc=jboss,dc=org");
- //roleModule.setRidAttributeID("cn");
- roleModule.start();
- this.roleModule = roleModule;
-
- LDAPStaticGroupMembershipModuleImpl membership = new LDAPStaticGroupMembershipModuleImpl();
- membership.setIdentityContext(identityContext);
- //membership.setUidAttributeID("member");
- //membership.setUidAttributeIsDN(true);
- membership.start();
- this.membershipModule = membership;*/
-
- /*mstc = new MembershipStrategyTest();
- mstc.setContext(this);
- mstc.setMembershipModule(membership);
- mstc.setUserModule(userModule);
- mstc.setRoleModule(roleModule);*/
-
suffix = getDirectoryServerConfigParameter().getCleanUpDN();
- super.setUp();
+ populate();
}
//TODO:extend this
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -70,9 +70,7 @@
public void setUp() throws Exception
{
- runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
- runtimeContext.addBean("LDAPTestBean", this);
- runtimeContext.start();
+ super.setUp();
IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
@@ -104,64 +102,11 @@
values.add("memberOf");
configuration.setValues(IdentityConfiguration.GROUP_COMMON,IdentityConfiguration.MEMBERSHIP_ATTRIBUTE_ID, values);
- /*IdentityContextImpl context = new IdentityContextImpl();
- context.start();
- identityContext = context;*/
-
- /*SimpleConfigurationImpl configuration = new SimpleConfigurationImpl();
- configuration.setIdentityContext(identityContext);
- configuration.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
- configuration.start();
-
- //provide small configuration change to use another branch of ldap tree
- Set values = new HashSet();
- values.add("ou=Roles,o=example2,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com");
- configuration.setValues(IdentityConfiguration.GROUP_COMMON,IdentityConfiguration.ROLE_CONTAINER_DN, values);
- values = new HashSet();
- values.add("ou=People,o=example2,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com");
- configuration.setValues(IdentityConfiguration.GROUP_COMMON,IdentityConfiguration.USER_CONTAINER_DN, values);
- values = new HashSet();
- values.add("memberOf");
- configuration.setValues(IdentityConfiguration.GROUP_COMMON,IdentityConfiguration.MEMBERSHIP_ATTRIBUTE_ID, values);
-
- LDAPConnectionContext connection = new LDAPConnectionContext();
- connection.setIdentityContext(identityContext);
- connection.start();
-
- LDAPUserModuleImpl userModule = new LDAPUserModuleImpl();
- userModule.setIdentityContext(identityContext);
-
- //userModule.setContainerDN("ou=People,dc=jboss,dc=org");
- //userModule.setUidAttributeID("uid");
-
- userModule.start();
- this.userModule = userModule;
-
- LDAPRoleModuleImpl roleModule = new LDAPRoleModuleImpl();
- roleModule.setIdentityContext(identityContext);
- //roleModule.setContainerDN("ou=Roles,dc=jboss,dc=org");
- //roleModule.setRidAttributeID("cn");
- roleModule.start();
- this.roleModule = roleModule;
-
- LDAPStaticRoleMembershipModuleImpl membership = new LDAPStaticRoleMembershipModuleImpl();
- membership.setIdentityContext(identityContext);
- //membership.setUidAttributeID("member");
- //membership.setUidAttributeIsDN(true);
- membership.start();
- this.membershipModule = membership;*/
-
- /*mstc = new MembershipStrategyTest();
- mstc.setContext(this);
- mstc.setMembershipModule(membership);
- mstc.setUserModule(userModule);
- mstc.setRoleModule(roleModule);*/
-
suffix = getDirectoryServerConfigParameter().getCleanUpDN();
- super.setUp();
+ populate();
}
//TODO:extend this
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -31,6 +31,8 @@
import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.test.framework.TestRuntimeContext;
import org.jboss.portal.test.framework.embedded.DSConfig;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.embedded.HibernateSupport;
import org.jboss.portal.common.test.junit.JUnitAdapter;
import org.jboss.portal.common.test.junit.POJOJUnitTest;
import org.opends.server.tools.LDAPModify;
@@ -69,9 +71,11 @@
public static TestSuite createTestSuite(Class clazz) throws Exception
{
- URL configsURL = Thread.currentThread().getContextClassLoader().getResource("directories.xml");
+ URL directoriesURL = Thread.currentThread().getContextClassLoader().getResource("directories.xml");
+ URL datasourcesURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
Map parameterMap = new HashMap();
- parameterMap.put("DirectoryServerConfig", DSConfig.fromXML2(configsURL));
+ parameterMap.put("DirectoryServerConfig", DSConfig.fromXML2(directoriesURL));
+ parameterMap.put("DataSourceConfig", DataSourceSupport.Config.fromXML2(datasourcesURL));
POJOJUnitTest abc = new POJOJUnitTest(clazz);
JUnitAdapter adapter = new JUnitAdapter(abc, parameterMap);
TestSuite suite = new TestSuite();
@@ -95,8 +99,11 @@
private DSConfig directoryServerConfigParameter;
+ protected DataSourceSupport.Config dataSourceConfigParameter;
//protected OpenDSService embeddedDSService;
+ protected HibernateSupport hibernate;
+
public String getName()
{
return super.getName() + "," + directoryServerConfigParameter.getName() + "," + directoryServerConfigParameter.getDescription();
@@ -112,20 +119,33 @@
this.directoryServerConfigParameter = directoryServerConfigParameter;
}
+ public DataSourceSupport.Config getDataSourceConfigParameter()
+ {
+ return dataSourceConfigParameter;
+ }
+
+ public void setDataSourceConfigParameter(DataSourceSupport.Config dataSourceConfig)
+ {
+ this.dataSourceConfigParameter = dataSourceConfig;
+ }
+
public void setUp() throws Exception
{
- /*if(directoryServerConfigParameter.isUseEmbedded())
- {
- embeddedDSService = new OpenDSService();
- //embeddedDSService.setRemoveWorkingDir(true);
- embeddedDSService.start();
- //give a chance to come up...
- //Thread.sleep(500);
- }*/
- //runtimeContext.start();
+ hibernate = new HibernateSupport();
+ runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
+ runtimeContext.addBean("LDAPTestBean", this);
- populate();
+ runtimeContext.addBean("DBTestBean", this);
+ runtimeContext.addBean("HibernateSupport", hibernate);
+ runtimeContext.addBean("DataSourceConfig", dataSourceConfigParameter);
+ HibernateSupport.Config config = HibernateSupport.getConfig(dataSourceConfigParameter.getName());
+ runtimeContext.addBean("HibernateConfig", config);
+ runtimeContext.start();
+
+ runtimeContext.start();
+
+ //populate();
}
public void tearDown() throws Exception
@@ -145,14 +165,13 @@
public void begin()
{
-
+ hibernate.openSession();
}
public void commit()
{
-
-
+ assertTrue(hibernate.commitTransaction());
}
protected void populate()
Added: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPUserProfileModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPUserProfileModuleTestCase.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPUserProfileModuleTestCase.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -0,0 +1,109 @@
+/*
+* 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.test.identity.ldap;
+
+import junit.framework.TestSuite;
+import org.jboss.portal.identity2.UserModule;
+import org.jboss.portal.identity2.RoleModule;
+import org.jboss.portal.identity2.MembershipModule;
+import org.jboss.portal.identity2.IdentityServiceControllerImpl;
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.UserProfileModule;
+import org.jboss.portal.identity2.User;
+import org.jboss.portal.identity2.ldap.LDAPRoleImpl;
+import org.jboss.portal.identity2.ldap.LDAPUserImpl;
+
+import java.util.Set;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPUserProfileModuleTestCase extends LDAPTestCase
+{
+
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserProfileModuleTestCase.class);
+
+ public static TestSuite suite() throws Exception
+ {
+ return createTestSuite(LDAPUserProfileModuleTestCase.class);
+ }
+
+ private UserModule userModule;
+
+ private RoleModule roleModule;
+
+ private MembershipModule membershipModule;
+
+ private UserProfileModule userProfileModule;
+
+ private String suffix;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
+ controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
+ controller.setDefaultConfigFile("test/config/standardidentity-config.xml");
+ controller.setRegisterMBeans(false);
+ controller.start();
+ identityContext = controller.getIdentityContext();
+ userModule = (UserModule)identityContext.getObject(IdentityContext.TYPE_USER_MODULE);
+ roleModule = (RoleModule)identityContext.getObject(IdentityContext.TYPE_ROLE_MODULE);
+ membershipModule = (MembershipModule)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+ userProfileModule = (UserProfileModule)identityContext.getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
+
+ suffix = getDirectoryServerConfigParameter().getCleanUpDN();
+
+
+ populate();
+ }
+
+ public void testSetPropertyWithDB() throws Exception
+ {
+ begin();
+ LDAPUserImpl ldapu = (LDAPUserImpl)userModule.findUserById("jduke");
+ assertEquals("email(a)email.com", userProfileModule.getProperty(ldapu, User.INFO_USER_EMAIL_REAL));
+ userProfileModule.setProperty(ldapu, User.INFO_USER_EMAIL_REAL, "toto(a)toto.com");
+ assertEquals("toto(a)toto.com", userProfileModule.getProperty(ldapu, User.INFO_USER_EMAIL_REAL));
+
+// userProfileModule.setProperty(ldapu, User.INFO_USER_SIGNATURE, "sig sig");
+// assertEquals("sig sig", userProfileModule.getProperty(ldapu, User.INFO_USER_SIGNATURE));
+
+ userProfileModule.setProperty(ldapu, User.INFO_USER_IM_SKYPE, "skype me");
+ assertEquals("skype me", userProfileModule.getProperty(ldapu, User.INFO_USER_IM_SKYPE));
+
+ userProfileModule.setProperty(ldapu, User.INFO_USER_OCCUPATION, "krawiec");
+ assertEquals("krawiec", userProfileModule.getProperty(ldapu, User.INFO_USER_OCCUPATION));
+ commit();
+ }
+
+
+
+
+
+}
Modified: trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/ldap-beans.xml
===================================================================
--- trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/ldap-beans.xml 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/resources/portal-identity-test-jar/org/jboss/portal/test/identity/ldap-beans.xml 2006-12-14 00:37:26 UTC (rev 5853)
@@ -27,21 +27,23 @@
xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
xmlns="urn:jboss:bean-deployer">
- <bean name="JNDISupport" class="org.jboss.portal.test.framework.embedded.JNDISupport">
- </bean>
-
<bean name="DataSourceConfig" class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
- <!--<constructor factoryMethod="getBean">
+ <constructor factoryMethod="getBean">
<factory bean="BeanFactory"/>
<parameter>DataSourceConfig</parameter>
- </constructor>-->
- <property name="name">dummy</property>
- <property name="connectionURL">jdbc:mysql://localhost:3306/portal_test</property>
- <property name="driverClass">org.gjt.mm.mysql.Driver</property>
- <property name="userName">root</property>
- <!--<property name="password"></property>-->
+ </constructor>
</bean>
+ <bean name="HibernateConfig" class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>HibernateConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="JNDISupport" class="org.jboss.portal.test.framework.embedded.JNDISupport">
+ </bean>
+
<bean name="TransactionManagerSupport" class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
</bean>
@@ -55,24 +57,20 @@
<property name="config"><inject bean="DataSourceConfig"/></property>
</bean>
- <!--<bean name="HibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
- <property name="jNDIName">java:/TestSessionFactory</property>
- <property name="mappings">
- <list elementClass="java.lang.String">
- <value>domain-single.hbm.xml</value>
- </list>
- </property>
- </bean>-->
-
- <!--<bean name="HibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <bean name="HibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>HibernateSupport</parameter>
+ </constructor>
<property name="config"><inject bean="HibernateConfig"/></property>
- <property name="jNDIName">java:/SessionFactory</property>
+ <property name="jNDIName">java:/portal/IdentitySessionFactory</property>
<property name="mappings">
<list elementClass="java.lang.String">
- <value>domain-single.hbm.xml</value>
+ <value>domain-identity.hbm.xml</value>
+ <!--<value>domain-single.hbm.xml</value>-->
</list>
</property>
- </bean>-->
+ </bean>
<bean name="LDAPTestBean" class="org.jboss.portal.test.identity.ldap.LDAPUserTestCase">
Modified: trunk/identity/src/resources/test/config/db-config.xml
===================================================================
--- trunk/identity/src/resources/test/config/db-config.xml 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/resources/test/config/db-config.xml 2006-12-14 00:37:26 UTC (rev 5853)
@@ -51,7 +51,7 @@
</module>
<module>
<type>UserProfile</type>
- <implementation>DB</implementation>
+ <implementation>PORTAL</implementation>
<config>
<option>
<name>profileConfigFile</name>
@@ -60,5 +60,10 @@
</config>
</module>
+ <module>
+ <type>DBDelegateUserProfile</type>
+ <implementation>DB</implementation>
+ <config/>
+ </module>
</modules>
</identity-configuration>
\ No newline at end of file
Modified: trunk/identity/src/resources/test/config/opends-config.xml
===================================================================
--- trunk/identity/src/resources/test/config/opends-config.xml 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/resources/test/config/opends-config.xml 2006-12-14 00:37:26 UTC (rev 5853)
@@ -62,8 +62,28 @@
<implementation>LDAP</implementation>
<config/>
</module>
+
<module>
<type>UserProfile</type>
+ <implementation>PORTAL</implementation>
+ <config>
+ <option>
+ <name>profileConfigFile</name>
+ <value>test/config/profile-config.xml</value>
+ </option>
+ <option>
+ <name>ldapModuleJNDIName</name>
+ <value>java:/portal/LDAPUserProfileModule</value>
+ </option>
+ </config>
+ </module>
+ <module>
+ <type>DBDelegateUserProfile</type>
+ <implementation>DB</implementation>
+ <config/>
+ </module>
+ <module>
+ <type>LDAPDelegateUserProfile</type>
<implementation>LDAP</implementation>
<config/>
</module>
Modified: trunk/identity/src/resources/test/config/profile-config.xml
===================================================================
--- trunk/identity/src/resources/test/config/profile-config.xml 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/resources/test/config/profile-config.xml 2006-12-14 00:37:26 UTC (rev 5853)
@@ -63,6 +63,9 @@
<type>column</type>
<value>jbp_realemail</value>
</database>
+ <ldap>
+ <value>mail</value>
+ </ldap>
</mapping>
</property>
<property>
Modified: trunk/identity/src/resources/test/config/rhds-config.xml
===================================================================
--- trunk/identity/src/resources/test/config/rhds-config.xml 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/resources/test/config/rhds-config.xml 2006-12-14 00:37:26 UTC (rev 5853)
@@ -64,6 +64,25 @@
</module>
<module>
<type>UserProfile</type>
+ <implementation>PORTAL</implementation>
+ <config>
+ <option>
+ <name>profileConfigFile</name>
+ <value>test/config/profile-config.xml</value>
+ </option>
+ <option>
+ <name>ldapModuleJNDIName</name>
+ <value>java:/portal/LDAPUserProfileModule</value>
+ </option>
+ </config>
+ </module>
+ <module>
+ <type>DBDelegateUserProfile</type>
+ <implementation>DB</implementation>
+ <config/>
+ </module>
+ <module>
+ <type>LDAPDelegateUserProfile</type>
<implementation>LDAP</implementation>
<config/>
</module>
Modified: trunk/identity/src/resources/test/config/standardidentity-config.xml
===================================================================
--- trunk/identity/src/resources/test/config/standardidentity-config.xml 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/identity/src/resources/test/config/standardidentity-config.xml 2006-12-14 00:37:26 UTC (rev 5853)
@@ -55,7 +55,7 @@
</option>
</config>
</datasource>
- <datasource>
+ <!--<datasource>
<name>DB</name>
<service-name>portal:service=Hibernate</service-name>
<class>org.jboss.portal.identity2.experimental.db.IdentitySessionFactoryBinder</class>
@@ -68,10 +68,10 @@
<name>configLocation</name>
<value>hibernate-single.cfg.xml</value>
</option>
- <!--<option>
+ --><!--<option>
<name>setupLocation</name>
<value>conf/hibernate/user/setup.txt</value>
- </option>-->
+ </option>--><!--
<option>
<name>jNDIName</name>
<value>java:/portal/UserSessionFactory</value>
@@ -93,18 +93,41 @@
<value><![CDATA[<property name="@name@" column="@column@" type="java.lang.String" update="true" insert="true" unique="false"/>]]></value>
</option>
</config>
- </datasource>
+ </datasource>-->
</datasources>
<modules>
+
<module>
<!--type used to correctly map in IdentityContext registry-->
+ <type>UserProfile</type>
+ <implementation>PORTAL</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=UserProfile</service-name>
+ <class>org.jboss.portal.identity2.DelegatingUserProfileModuleImpl</class>
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/UserProfileModule</value>
+ </option>
+ <option>
+ <name>dbModuleJNDIName</name>
+ <value>java:/portal/DBUserProfileModule</value>
+ </option>
+ </config>
+ </module>
+
+
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
<type>User</type>
<implementation>DB</implementation>
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=User</service-name>
<class>org.jboss.portal.identity2.db.HibernateUserModuleImpl</class>
- <jndi-name>java:/portal/UserModule</jndi-name>
<!--set of options that are passed to a class constructor-->
<config>
@@ -127,7 +150,6 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=Role</service-name>
<class>org.jboss.portal.identity2.db.HibernateRoleModuleImpl</class>
- <jndi-name>java:/portal/RoleModule</jndi-name>
<!--set of options that are passed to a class constructor-->
<config>
@@ -150,7 +172,6 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=Membership</service-name>
<class>org.jboss.portal.identity2.db.HibernateMembershipModuleImpl</class>
- <jndi-name>java:/portal/MembershipModule</jndi-name>
<!--set of options that are passed to a class constructor-->
<config>
@@ -167,13 +188,12 @@
<module>
<!--type used to correctly map in IdentityContext registry-->
- <type>UserProfile</type>
+ <type>DBDelegateUserProfile</type>
<implementation>DB</implementation>
<!--name of service and class for creating mbean-->
- <service-name>portal:service=Module,type=UserProfile</service-name>
+ <service-name>portal:service=Module,type=DBUserProfile</service-name>
<class>org.jboss.portal.identity2.db.HibernateUserProfileModuleImpl</class>
- <jndi-name>java:/portal/UserProfileModule</jndi-name>
<!--set of options that are passed to a class constructor-->
<config>
@@ -183,7 +203,7 @@
</option>
<option>
<name>jndiName</name>
- <value>java:/portal/UserProfileModule</value>
+ <value>java:/portal/DBUserProfileModule</value>
</option>
</config>
</module>
@@ -197,7 +217,6 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=User</service-name>
<class>org.jboss.portal.identity2.ldap.LDAPUserModuleImpl</class>
- <jndi-name>java:/portal/UserModule</jndi-name>
<!--set of options that are passed to a class constructor-->
<config>
@@ -220,7 +239,6 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=Role</service-name>
<class>org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl</class>
- <jndi-name>java:/portal/RoleModule</jndi-name>
<!--set of options that are passed to a class constructor-->
<config>
@@ -243,7 +261,6 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=Membership</service-name>
<class>org.jboss.portal.identity2.ldap.LDAPStaticGroupMembershipModuleImpl</class>
- <jndi-name>java:/portal/MembershipModule</jndi-name>
<!--set of options that are passed to a class constructor-->
<config>
@@ -260,13 +277,12 @@
<module>
<!--type used to correctly map in IdentityContext registry-->
- <type>UserProfile</type>
+ <type>LDAPDelegateUserProfile</type>
<implementation>LDAP</implementation>
<!--name of service and class for creating mbean-->
- <service-name>portal:service=Module,type=UserProfile</service-name>
+ <service-name>portal:service=Module,type=LDAPUserProfile</service-name>
<class>org.jboss.portal.identity2.ldap.LDAPUserProfileModuleImpl</class>
- <jndi-name>java:/portal/UserProfileModule</jndi-name>
<!--set of options that are passed to a class constructor-->
<config>
@@ -285,7 +301,7 @@
</option>-->
<option>
<name>jndiName</name>
- <value>java:/portal/UserProfileModule</value>
+ <value>java:/portal/LDAPUserProfileModule</value>
</option>
<option>
<name>connectionJNDIName</name>
Modified: trunk/test/src/etc/directories.xml
===================================================================
--- trunk/test/src/etc/directories.xml 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/test/src/etc/directories.xml 2006-12-14 00:37:26 UTC (rev 5853)
@@ -26,7 +26,7 @@
<directory-name>OpenDS</directory-name>
<description>OpenDS service deployed on JBoss AS as an mbean</description>
<!--identity configuration file-->
- <config-file>identityconfig/opends-config.xml</config-file>
+ <config-file>test/config/opends-config.xml</config-file>
<host>localhost</host>
<port>10389</port>
<context-factory>com.sun.jndi.ldap.LdapCtxFactory</context-factory>
@@ -37,11 +37,11 @@
<!--DN that will be removed to perform cleanup after each test-->
<cleanup-dn>dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</cleanup-dn>
</directory>
- <!--<directory> in
+ <!--<directory>
<directory-name>RedHatDS</directory-name>
<description>RedHat Directory in QA Labs (need vpn access)</description>
- <config-file>identityconfig/rhds-config.xml</config-file>
+ <config-file>test/config/rhds-config.xml</config-file>
<host>dev39.qa.atl.jboss.com</host>
<port>10389</port>
<context-factory>com.sun.jndi.ldap.LdapCtxFactory</context-factory>
Modified: trunk/test/src/etc/ldap/ldif/initial-tests.ldif
===================================================================
--- trunk/test/src/etc/ldap/ldif/initial-tests.ldif 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/test/src/etc/ldap/ldif/initial-tests.ldif 2006-12-14 00:37:26 UTC (rev 5853)
@@ -18,6 +18,7 @@
cn: Java Duke
sn: Duke
userPassword: theduke
+mail: email(a)email.com
dn: uid=jduke1,ou=People,dc=jboss,dc=org
objectclass: top
Modified: trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java
===================================================================
--- trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java 2006-12-13 22:47:58 UTC (rev 5852)
+++ trunk/test/src/main/org/jboss/portal/test/framework/embedded/DSConfig.java 2006-12-14 00:37:26 UTC (rev 5853)
@@ -98,15 +98,17 @@
public String toString()
{
- return new StringBuffer().//append(name).
+ return new StringBuffer().append("[").
+ //append(name).
//append("-").
append(description).
+ append("]/[").
//append(";").
- //append(host).
- //append(":").
- //append(port).
- append("/").
- append(configFile).
+ append(host).
+ append(":").
+ append(port).
+ //append(configFile).
+ append("]").
toString();
}
19 years, 5 months
JBoss Portal SVN: r5852 - in trunk: common/src/main/org/jboss/portal/common/junit wsrp/src/main/org/jboss/portal/test/wsrp wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer wsrp/src/main/org/jboss/portal/wsrp wsrp/src/main/org/jboss/portal/wsrp/producer
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-12-13 17:47:58 -0500 (Wed, 13 Dec 2006)
New Revision: 5852
Modified:
trunk/common/src/main/org/jboss/portal/common/junit/ExtendedAssert.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPBaseTest.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
Log:
- Moved assert methods and support classes from WSRPBaseTest to ExtendedAssert.
- Added test for getPortletPropertyDescription and fixed a bug in implementation.
- Added creation methods to WSRPTypeFactory.
- Minor other code improvements.
Modified: trunk/common/src/main/org/jboss/portal/common/junit/ExtendedAssert.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/junit/ExtendedAssert.java 2006-12-13 22:16:24 UTC (rev 5851)
+++ trunk/common/src/main/org/jboss/portal/common/junit/ExtendedAssert.java 2006-12-13 22:47:58 UTC (rev 5852)
@@ -25,6 +25,7 @@
import junit.framework.Assert;
import java.util.Arrays;
+import java.util.List;
/**
* Add more assert methods.
@@ -35,17 +36,13 @@
public class ExtendedAssert extends Assert
{
- /**
- * @see #assertEquals(Object[], Object[])
- */
+ /** @see #assertEquals(Object[],Object[]) */
public static void assertEquals(Object[] expected, Object[] actual)
{
assertEquals(null, (Object[])expected, (Object[])actual);
}
- /**
- * Test equality as defined by java.util.Array#equals(Object[], Object[]).
- */
+ /** Test equality as defined by java.util.Array#equals(Object[], Object[]). */
public static void assertEquals(String message, Object[] expected, Object[] actual)
{
if (Arrays.equals(expected, actual))
@@ -55,17 +52,13 @@
fail(format(message, expected, actual));
}
- /**
- * @see #assertEquals(byte[], byte[])
- */
+ /** @see #assertEquals(byte[],byte[]) */
public static void assertEquals(byte[] expected, byte[] actual)
{
assertEquals(null, expected, actual);
}
- /**
- * Test equality as defined by java.util.Array#equals(Object[], Object[]).
- */
+ /** Test equality as defined by java.util.Array#equals(Object[], Object[]). */
public static void assertEquals(String message, byte[] expected, byte[] actual)
{
if (Arrays.equals(expected, actual))
@@ -75,8 +68,9 @@
fail(format(message, expected, actual));
}
- private static String format(String message, Object expected, Object actual) {
- String formatted= "";
+ private static String format(String message, Object expected, Object actual)
+ {
+ String formatted = "";
if (message != null)
{
formatted = message + " ";
@@ -103,4 +97,109 @@
}
}
+ public static void assertEquals(Object[] expected, Object[] tested, boolean isOrderRelevant, String failMessage)
+ {
+ if (isOrderRelevant)
+ {
+ if (!Arrays.equals(expected, tested))
+ {
+ fail(failMessage);
+ }
+ }
+ else
+ {
+ boolean equals = (expected == tested);
+
+ if (!equals)
+ {
+ if (expected == null || tested == null)
+ {
+ fail(failMessage + " Not both null.");
+ }
+
+ if (expected.getClass().getComponentType() != tested.getClass().getComponentType())
+ {
+ fail(failMessage + " Different classes.");
+ }
+
+ if (expected.length != tested.length)
+ {
+ fail(failMessage + " Different sizes (tested: " + tested.length + ", expected: " + expected.length + ").");
+ }
+
+ List expectedList = Arrays.asList(expected);
+ List testedList = Arrays.asList(tested);
+ if (!expectedList.containsAll(testedList))
+ {
+ fail(failMessage);
+ }
+ }
+ }
+ }
+
+ public static void assertEquals(Object[] expected, Object[] tested, boolean isOrderRelevant, String failMessage, Decorator decorator)
+ {
+ Object[] decoratedExpected = null, decoratedTested = null;
+ if (decorator != null)
+ {
+ decoratedExpected = decorate(expected, decorator);
+ decoratedTested = decorate(tested, decorator);
+ }
+
+ assertEquals(decoratedExpected, decoratedTested, isOrderRelevant, failMessage);
+ }
+
+ public static Object[] decorate(Object[] toBeDecorated, Decorator decorator)
+ {
+ if (toBeDecorated != null)
+ {
+ DecoratedObject[] decorated = new DecoratedObject[toBeDecorated.length];
+ for (int i = 0; i < decorated.length; i++)
+ {
+ decorated[i] = new DecoratedObject(toBeDecorated[i], decorator);
+ }
+ return decorated;
+ }
+ return null;
+
+ }
+
+ public static void assertString1ContainsString2(String string1, String string2)
+ {
+ assertTrue("<" + string1 + "> does not contain <" + string2 + ">", string1.indexOf(string2) >= 0);
+ }
+
+ public static interface Decorator
+ {
+ void decorate(Object decorated);
+ }
+
+ public static class DecoratedObject
+ {
+ private Decorator decorator;
+ private Object decorated;
+
+ public Object getDecorated()
+ {
+ return decorated;
+ }
+
+ public DecoratedObject(Object decorated, Decorator decorator)
+ {
+ this.decorator = decorator;
+ this.decorated = decorated;
+ }
+
+ public boolean equals(Object obj)
+ {
+ decorator.decorate(decorated);
+ return decorator.equals(obj);
+ }
+
+ public String toString()
+ {
+ decorator.decorate(decorated);
+ return decorator.toString();
+ }
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPBaseTest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPBaseTest.java 2006-12-13 22:16:24 UTC (rev 5851)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/WSRPBaseTest.java 2006-12-13 22:47:58 UTC (rev 5852)
@@ -30,20 +30,16 @@
package org.jboss.portal.test.wsrp;
import org.jboss.logging.Logger;
-import org.jboss.portal.test.framework.driver.http.HttpTestContext;
-import org.jboss.portal.test.framework.driver.http.HttpTestDriverServer;
-import org.jboss.portal.test.framework.server.driver.HttpTestDriverRegistry;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.common.test.driver.DriverResponse;
import org.jboss.portal.common.test.driver.DriverCommand;
+import org.jboss.portal.common.test.driver.DriverResponse;
import org.jboss.portal.common.test.driver.TestDriverException;
import org.jboss.portal.common.test.info.TestItemInfo;
import org.jboss.portal.common.test.junit.POJOJUnitTest;
-import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.test.framework.driver.http.HttpTestContext;
+import org.jboss.portal.test.framework.driver.http.HttpTestDriverServer;
+import org.jboss.portal.test.framework.server.driver.HttpTestDriverRegistry;
-import java.util.Arrays;
-import java.util.List;
-
/**
* Base Class for all WSRP Test Cases
*
@@ -112,112 +108,6 @@
{
}
- public static void assertEquals(Object[] expected, Object[] tested, boolean isOrderRelevant, String failMessage)
- {
- if (isOrderRelevant)
- {
- if (!Arrays.equals(expected, tested))
- {
- ExtendedAssert.fail(failMessage);
- }
- }
- else
- {
- boolean equals = (expected == tested);
-
- if (!equals)
- {
- if (expected == null || tested == null)
- {
- ExtendedAssert.fail(failMessage + " Not both null.");
- }
-
- if (expected.getClass().getComponentType() != tested.getClass().getComponentType())
- {
- ExtendedAssert.fail(failMessage + " Different classes.");
- }
-
- if (expected.length != tested.length)
- {
- ExtendedAssert.fail(failMessage + " Different sizes (tested: " + tested.length + ", expected: " + expected.length + ").");
- }
-
- List expectedList = Arrays.asList(expected);
- List testedList = Arrays.asList(tested);
- if (!expectedList.containsAll(testedList))
- {
- ExtendedAssert.fail(failMessage);
- }
- }
- }
- }
-
- public static void assertEquals(Object[] expected, Object[] tested, boolean isOrderRelevant, String failMessage, Decorator decorator)
- {
- Object[] decoratedExpected = null, decoratedTested = null;
- if (decorator != null)
- {
- decoratedExpected = decorate(expected, decorator);
- decoratedTested = decorate(tested, decorator);
- }
-
- assertEquals(decoratedExpected, decoratedTested, isOrderRelevant, failMessage);
- }
-
- private static Object[] decorate(Object[] toBeDecorated, Decorator decorator)
- {
- if (toBeDecorated != null)
- {
- DecoratedObject[] decorated = new DecoratedObject[toBeDecorated.length];
- for (int i = 0; i < decorated.length; i++)
- {
- decorated[i] = new DecoratedObject(toBeDecorated[i], decorator);
- }
- return decorated;
- }
- return null;
-
- }
-
- public static interface Decorator
- {
- void decorate(Object decorated);
- }
-
- public static class DecoratedObject
- {
- private Decorator decorator;
- private Object decorated;
-
- public Object getDecorated()
- {
- return decorated;
- }
-
- public DecoratedObject(Object decorated, Decorator decorator)
- {
- this.decorator = decorator;
- this.decorated = decorated;
- }
-
- public boolean equals(Object obj)
- {
- decorator.decorate(decorated);
- return decorator.equals(obj);
- }
-
- public String toString()
- {
- decorator.decorate(decorated);
- return decorator.toString();
- }
- }
-
- public static void assertString1ContainsString2(String string1, String string2)
- {
- ExtendedAssert.assertTrue("<" + string1 + "> does not contain <" + string2 + ">", string1.indexOf(string2) >= 0);
- }
-
protected void deploy(String archiveId) throws Exception
{
context.deploy(archiveId);
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2006-12-13 22:16:24 UTC (rev 5851)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/MarkupTestCase.java 2006-12-13 22:47:58 UTC (rev 5852)
@@ -114,8 +114,8 @@
String julienLink = extractLink(markupString, 0);
WSRPPortletURL julienURL = WSRPPortletURL.create(julienLink);
- assertString1ContainsString2(markupString, "Hello, Anonymous!");
- assertString1ContainsString2(markupString, "Counter: 0");
+ ExtendedAssert.assertString1ContainsString2(markupString, "Hello, Anonymous!");
+ ExtendedAssert.assertString1ContainsString2(markupString, "Counter: 0");
ExtendedAssert.assertTrue(julienURL instanceof WSRPRenderURL);
WSRPRenderURL julienRender = (WSRPRenderURL)julienURL;
@@ -124,7 +124,7 @@
gm.getMarkupParams().setNavigationalState(julienRender.getNavigationalState().getStringValue());
res = markupService.getMarkup(gm);
markupString = res.getMarkupContext().getMarkupString();
- assertString1ContainsString2(markupString, "Hello, Julien!");
+ ExtendedAssert.assertString1ContainsString2(markupString, "Hello, Julien!");
// julien.length() * 2 to bypass second link
WSRPPortletURL incrementURL = WSRPPortletURL.create(extractLink(markupString, julienLink.length() * 2));
@@ -139,7 +139,7 @@
markupService.performBlockingInteraction(performBlockingInteraction);
res = markupService.getMarkup(gm);
markupString = res.getMarkupContext().getMarkupString();
- assertString1ContainsString2(markupString, "Counter: 1");
+ ExtendedAssert.assertString1ContainsString2(markupString, "Counter: 1");
undeploy(archiveName);
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java 2006-12-13 22:16:24 UTC (rev 5851)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/PortletManagementTestCase.java 2006-12-13 22:47:58 UTC (rev 5852)
@@ -24,11 +24,16 @@
package org.jboss.portal.test.wsrp.v1.producer;
import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.core.GetPortletDescription;
import org.jboss.portal.wsrp.core.GetPortletProperties;
+import org.jboss.portal.wsrp.core.GetPortletPropertyDescription;
+import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.PortletDescriptionResponse;
+import org.jboss.portal.wsrp.core.PortletPropertyDescriptionResponse;
import org.jboss.portal.wsrp.core.Property;
+import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.PropertyList;
import javax.xml.soap.SOAPElement;
@@ -78,8 +83,8 @@
PropertyList response = portletManagementService.getPortletProperties(getPortletProperties);
Property[] expected = new Property[]{
- new Property("prefName1", "en", "prefValue1", null),
- new Property("prefName2", "en", "prefValue2", null)
+ WSRPTypeFactory.createProperty("prefName1", "en", "prefValue1"),
+ WSRPTypeFactory.createProperty("prefName2", "en", "prefValue2")
};
checkGetPropertiesResponse(response, expected);
@@ -89,7 +94,7 @@
getPortletProperties.setNames(new String[]{"prefName2"});
response = portletManagementService.getPortletProperties(getPortletProperties);
- expected = new Property[]{new Property("prefName2", "en", "prefValue2", null)};
+ expected = new Property[]{WSRPTypeFactory.createProperty("prefName2", "en", "prefValue2")};
checkGetPropertiesResponse(response, expected);
}
@@ -97,13 +102,48 @@
{
ExtendedAssert.assertNotNull(response);
Property[] properties = response.getProperties();
- assertEquals(expected, properties, false, "Didn't receive expected properties!", new PropertyDecorator());
+ ExtendedAssert.assertEquals(expected, properties, false, "Didn't receive expected properties!", new PropertyDecorator());
return properties;
}
- public void testGetPortletPropertyDescription()
+ public void testGetPortletPropertyDescription() throws Exception
{
- // todo: implement
+ String handle = getDefaultHandle();
+ GetPortletPropertyDescription getPortletPropertyDescription = WSRPTypeFactory.createSimpleGetPortletPropertyDescription(handle);
+
+ PortletPropertyDescriptionResponse response = portletManagementService.getPortletPropertyDescription(getPortletPropertyDescription);
+
+ ModelDescription desc = response.getModelDescription();
+ ExtendedAssert.assertNotNull(desc);
+ PropertyDescription[] propertyDescriptions = desc.getPropertyDescriptions();
+ ExtendedAssert.assertNotNull(propertyDescriptions);
+
+ PropertyDescription[] expected = new PropertyDescription[2];
+ expected[0] = WSRPTypeFactory.createPropertyDescription("prefName1", WSRPConstants.XSD_STRING);
+ expected[0].setHint(WSRPTypeFactory.createLocalizedString("prefName1"));
+ expected[0].setLabel(WSRPTypeFactory.createLocalizedString("prefName1"));
+ expected[1] = WSRPTypeFactory.createPropertyDescription("prefName2", WSRPConstants.XSD_STRING);
+ expected[1].setHint(WSRPTypeFactory.createLocalizedString("prefName2"));
+ expected[1].setLabel(WSRPTypeFactory.createLocalizedString("prefName2"));
+
+ ExtendedAssert.assertEquals(2, propertyDescriptions.length);
+ PropertyDescription propDesc = propertyDescriptions[0];
+ ExtendedAssert.assertNotNull(propDesc);
+ String name = propDesc.getName();
+ if ("prefName1".equals(name))
+ {
+ assertEquals(expected[0], propDesc);
+ assertEquals(expected[1], propertyDescriptions[1]);
+ }
+ else if ("prefName2".equals(name))
+ {
+ assertEquals(expected[1], propDesc);
+ assertEquals(expected[0], propertyDescriptions[1]);
+ }
+ else
+ {
+ ExtendedAssert.fail("Unexpected PropertyDescription named '" + name + "'");
+ }
}
public void testSetPortletProperties()
@@ -116,7 +156,7 @@
return TEST_BASIC_PORTLET_WAR;
}
- private static class PropertyDecorator implements Decorator
+ private static class PropertyDecorator implements ExtendedAssert.Decorator
{
private Property prop;
@@ -127,9 +167,9 @@
public boolean equals(Object o)
{
- if (o instanceof DecoratedObject)
+ if (o instanceof ExtendedAssert.DecoratedObject)
{
- DecoratedObject decoratedObject = (DecoratedObject)o;
+ ExtendedAssert.DecoratedObject decoratedObject = (ExtendedAssert.DecoratedObject)o;
Property that = (Property)decoratedObject.getDecorated();
String name = prop.getName();
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2006-12-13 22:16:24 UTC (rev 5851)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2006-12-13 22:47:58 UTC (rev 5852)
@@ -195,10 +195,10 @@
}
- assertEquals(expected.getExtensions(), tested.getExtensions(), false, message + "Extensions");
- assertEquals(expected.getLocales(), tested.getLocales(), false, message + "Locales");
- assertEquals(expected.getModes(), tested.getModes(), false, message + "Modes");
- assertEquals(expected.getWindowStates(), tested.getWindowStates(), false, message + "Window states");
+ ExtendedAssert.assertEquals(expected.getExtensions(), tested.getExtensions(), false, message + "Extensions");
+ ExtendedAssert.assertEquals(expected.getLocales(), tested.getLocales(), false, message + "Locales");
+ ExtendedAssert.assertEquals(expected.getModes(), tested.getModes(), false, message + "Modes");
+ ExtendedAssert.assertEquals(expected.getWindowStates(), tested.getWindowStates(), false, message + "Window states");
}
}
@@ -213,7 +213,7 @@
ExtendedAssert.fail(message + "Different classes or not both null.");
}
- assertEquals(expected.getExtensions(), tested.getExtensions(), false, message + "Extensions");
+ ExtendedAssert.assertEquals(expected.getExtensions(), tested.getExtensions(), false, message + "Extensions");
assertEquals(message + "Hint", expected.getHint(), tested.getHint());
assertEquals(message + "Label", expected.getLabel(), tested.getLabel());
ExtendedAssert.assertEquals(message + "Name", expected.getName(), tested.getName());
@@ -227,7 +227,7 @@
{
if (expected == null || tested == null)
{
- ExtendedAssert.fail(message + "Different classes or not both null.");
+ ExtendedAssert.fail(message + ": Different classes or not both null.");
}
ExtendedAssert.assertEquals(expected.getLang(), tested.getLang());
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2006-12-13 22:16:24 UTC (rev 5851)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2006-12-13 22:47:58 UTC (rev 5852)
@@ -38,6 +38,7 @@
import org.jboss.portal.wsrp.core.GetMarkup;
import org.jboss.portal.wsrp.core.GetPortletDescription;
import org.jboss.portal.wsrp.core.GetPortletProperties;
+import org.jboss.portal.wsrp.core.GetPortletPropertyDescription;
import org.jboss.portal.wsrp.core.GetServiceDescription;
import org.jboss.portal.wsrp.core.InitCookie;
import org.jboss.portal.wsrp.core.InteractionParams;
@@ -694,6 +695,7 @@
*/
public static PortletDescriptionResponse createPortletDescriptionResponse(PortletDescription portletDescription)
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletDescription, "PortletDescription");
return new PortletDescriptionResponse(portletDescription, null, null);
}
@@ -706,6 +708,34 @@
*/
public static PortletPropertyDescriptionResponse createPortletPropertyDescriptionResponse(PropertyDescription[] propertyDescriptions)
{
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(propertyDescriptions, "PropertyDescriptions");
return new PortletPropertyDescriptionResponse(createModelDescription(propertyDescriptions), null, null);
}
+
+ /**
+ * registrationContext(RegistrationContext)?, portletContext(PortletContext), userContext(UserContext)?,
+ * desiredLocales(xsd:string)*
+ *
+ * @return
+ * @since 2.6
+ */
+ public static GetPortletPropertyDescription createGetPortletPropertyDescription(RegistrationContext registrationContext,
+ PortletContext portletContext,
+ UserContext userContext, String[] desiredLocales)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
+ return new GetPortletPropertyDescription(registrationContext, portletContext, userContext, desiredLocales);
+ }
+
+ /**
+ * Same as createGetPortletPropertyDescription(null, createPortletContext(portletHandle), null, null)
+ *
+ * @param portletHandle
+ * @return
+ * @since 2.6
+ */
+ public static GetPortletPropertyDescription createSimpleGetPortletPropertyDescription(String portletHandle)
+ {
+ return createGetPortletPropertyDescription(null, createPortletContext(portletHandle), null, null);
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2006-12-13 22:16:24 UTC (rev 5851)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/PortletManagementHandler.java 2006-12-13 22:47:58 UTC (rev 5852)
@@ -130,9 +130,9 @@
int index = 0;
for (Iterator keys = keySey.iterator(); keys.hasNext();)
{
- PreferenceInfo prefInfo = (PreferenceInfo)keys.next();
+ PreferenceInfo prefInfo = prefsInfo.getPreference((String)keys.next());
- // WSRP Spec 8.7: return only the portion of the Portlet's persistent state is allowed to modify
+ // WSRP Spec 8.7: return only the portion of the Portlet's persistent state the user is allowed to modify
if (!prefInfo.isReadOnly().booleanValue())
{
//todo: check what we should use key
19 years, 5 months
JBoss Portal SVN: r5851 - in trunk/core/src: main/org/jboss/portal/core/portlet/dashboard resources/portal-core-war/WEB-INF/jsp/dashboard
by portal-commits@lists.jboss.org
Author: roy.russo(a)jboss.com
Date: 2006-12-13 17:16:24 -0500 (Wed, 13 Dec 2006)
New Revision: 5851
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
ui prettification of dashboards
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-12-13 18:38:05 UTC (rev 5850)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-12-13 22:16:24 UTC (rev 5851)
@@ -33,6 +33,7 @@
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.ThemeConstants;
+import org.jboss.portal.theme.ThemeService;
import org.jboss.portlet.JBossActionRequest;
import org.jboss.portlet.JBossActionResponse;
import org.jboss.portlet.JBossPortlet;
@@ -41,9 +42,9 @@
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
-import javax.portlet.PortletSecurityException;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
@@ -67,6 +68,8 @@
private LayoutService layoutService;
+ private ThemeService themeService;
+
public void init()
throws PortletException
{
@@ -78,6 +81,8 @@
layoutService = (LayoutService)getPortletContext().getAttribute("LayoutService");
+ themeService = (ThemeService)getPortletContext().getAttribute("ThemeService");
+
if (instanceContainer == null)
{
throw new PortletException("No InstanceContainer found");
@@ -90,6 +95,10 @@
{
throw new PortletException("No LayoutService found");
}
+ if (themeService == null)
+ {
+ throw new PortletException("No ThemeService found");
+ }
}
private PortalObjectId dashboardId = PortalObjectId.parse("/dashboard", PortalObjectId.CANONICAL_FORMAT);
@@ -106,6 +115,7 @@
String errorMessage = (String)req.getParameter("errorMsg");
+ // load portal + page for editting.
Portal portal = (Portal)portalObjectContainer.getObject(dashboardId).getChild(req.getUser().getUserName());
Page page;
if (req.getParameter("editPageSelect") != null)
@@ -118,6 +128,7 @@
page = (Page)portal.getDefaultPage();
}
+ // load insances this user has access to.
List available_instances = (List)instanceContainer.getInstances();
resp.setContentType("text/html");
@@ -126,6 +137,7 @@
Map windowMap = getWindows(page);
List regions = new ArrayList(windowMap.keySet());
+ regions.remove("unknown");
Collections.sort(regions);
req.setAttribute("windowMap", windowMap);
@@ -137,7 +149,7 @@
log.error(errorMessage, e);
}
- // page select box
+ // loads avabailable pages for user to edit.
List pages = new ArrayList();
for (Iterator j = portal.getChildren().iterator(); j.hasNext();)
{
@@ -148,10 +160,27 @@
}
}
+ // load available layouts/themes
+ Collection layouts = layoutService.getLayouts();
+ for (Iterator iterator = layouts.iterator(); iterator.hasNext();)
+ {
+ PortalLayout layout = (PortalLayout)iterator.next();
+ layout.getLayoutInfo().getName();
+ }
+ Collection themes = themeService.getThemes();
+
+ // Get the current layout and theme
+ String layoutId = page.getDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
+ PortalLayout currentLayout = layoutService.getLayout(layoutId, true);
+ String themeId = page.getProperty(ThemeConstants.PORTAL_PROP_THEME);
+
+ // dispatch
req.setAttribute("available_instances", available_instances);
req.setAttribute("pages", pages);
req.setAttribute("currentPage", page.getName());
-
+ req.setAttribute("layouts", layouts);
+ req.setAttribute("currentLayout", currentLayout.getLayoutInfo().getName());
+ req.setAttribute("themes", themes);
if (errorMessage != null)
{
req.setAttribute("errorMsg", errorMessage);
@@ -333,6 +362,31 @@
actionResponse.setRenderParameter("op", "editPage");
}
+ else if ("assignLayout".equals(op))
+ {
+ String selectedLayout = actionRequest.getParameter("layout");
+
+ PortalLayout checkLayout = layoutService.getLayout(selectedLayout, true);
+ if (checkLayout != null)
+ {
+ page.setDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT, checkLayout.getLayoutInfo().getName());
+ }
+
+ actionResponse.setRenderParameter("editPageSelect", editPage);
+ }
+ else if ("assignTheme".equals(op))
+ {
+ String selectedLayout = actionRequest.getParameter("theme");
+
+ PortalLayout checkLayout = layoutService.getLayout(selectedLayout, true);
+
+ if (checkLayout != null)
+ {
+ page.setDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT, checkLayout.getLayoutInfo().getName());
+ }
+
+ actionResponse.setRenderParameter("editPageSelect", editPage);
+ }
else
{
actionResponse.setRenderParameter("editPageSelect", editPage);
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-13 18:38:05 UTC (rev 5850)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-13 22:16:24 UTC (rev 5851)
@@ -1,7 +1,10 @@
<%@ page import="org.jboss.portal.core.model.instance.Instance" %>
<%@ page import="org.jboss.portal.core.model.portal.Page" %>
<%@ page import="org.jboss.portal.core.model.portal.Window" %>
+<%@ page import="org.jboss.portal.theme.PortalLayout" %>
+<%@ page import="org.jboss.portal.theme.PortalTheme" %>
<%@ page import="java.util.ArrayList" %>
+<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Collections" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.List" %>
@@ -21,7 +24,13 @@
Map windowMap = (Map)request.getAttribute("windowMap");
String currentPage = (String)request.getAttribute("currentPage");
+ String currentLayout = (String)request.getAttribute("currentLayout");
+ String currentTheme = (String)request.getAttribute("currentTheme");
+
String errorMessage = (String)request.getAttribute("errorMsg");
+
+ Collection layouts = (Collection)request.getAttribute("layouts");
+ Collection themes = (Collection)request.getAttribute("themes");
%>
<script type="text/javascript" language="JavaScript">
@@ -43,11 +52,16 @@
this.document.instancesform.sortRegion.value = region;
}
- function newPage(op)
+ function switchLayout(op)
{
this.document.instancesform.op.value = op;
}
+ function switchTheme(op)
+ {
+ this.document.instancesform.op.value = op;
+ }
+
function debug()
{
//alert("OP: '" + this.instancesForm.op.value + "' toRegion: '" + this.instancesForm.toRegion.value + "' fromRegion: '" + this.instancesForm.fromRegion.value + "' sortRegion: '" + this.instancesForm.sortRegion.value + "'");
@@ -67,144 +81,201 @@
%>
<table width="100%">
-<th colspan="2" class="portlet-section-header" align="center">Edit Page '<%= currentPage %>'</th>
+<th colspan="2" class="portlet-section-header" align="center">Personal Dashboard Editor</th>
<tr>
- <td class="portlet-section-body" align="left">
- Use this to manage the content on your page. You can control the page title, select number of columns, and add,
- order, or remove portlets.
+ <td class="portlet-section-body" align="center">
+ <table width="500">
+ <tr>
+ <td align="left">
+ Use this tool to manage the content and appearance of your dashboard pages. <br/>
+ You can control the page titles, column layouts, page themes,
+ and add,
+ order, or remove portlets.
+ </td>
+ <td>
+ <table class="bottombuttonbar">
+ <tr>
+ <td align="left" valign="top"><b>Create a New Page:</b><br/>Page name:
+ <form name="createpageform" action="<portlet:actionURL><portlet:param name="op" value="newpage"></portlet:param>
+ </portlet:actionURL>" method="POST" style="padding:0;margin:0">
+ <input type="text" class="portlet-form-input-field" name="pagename"><input type="submit"
+ name="save"
+ value="Save"
+ class="portlet-form-button"/>
+ </form>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
</td>
</tr>
+<th colspan="2" class="portlet-section-header" align="center">Currently editing page '<%= currentPage %>'</th>
<tr>
- <td>
- <hr/>
- </td>
-</tr>
-<tr>
- <td class="portlet-section-body" align="left"><b>Select a page to edit:</b><br/>
-
+ <td class="portlet-section-body" align="center">
<form action="<portlet:actionURL><portlet:param name="op" value="editPage"></portlet:param>
</portlet:actionURL>" method="POST" style="padding:0;margin:0">
- <select name="editPageSelect">
- <%
- for (int i = 0; i < pages.size(); i++)
+ Select: <select name="editPageSelect">
+ <%
+ for (int i = 0; i < pages.size(); i++)
+ {
+ Page onePage = (Page)pages.get(i);
+ String selected = "";
+ if (onePage.getName().equals(currentPage))
{
- Page onePage = (Page)pages.get(i);
- if (onePage.getName().equals(currentPage))
- {
- %>
- <option selected="true" value="<%= onePage.getName() %>"><%= onePage.getName() %>
- </option>
- <%
+ selected = " selected=\"true\" ";
+ }
+ %>
+ <option <%= selected %> value="<%= onePage.getName() %>"><%= onePage.getName() %>
+ </option>
+ <%
}
- else
- {
- %>
- <option value="<%= onePage.getName() %>"><%= onePage.getName() %>
- </option>
- <%
- }
- }
- %>
- </select>
+ %>
+ </select>
<input type="submit" name="submit" value="Go" class="portlet-form-button"/>
</form>
+
+ <br/>
</td>
</tr>
-<tr>
+<!--<tr>
<td>
<hr/>
</td>
-</tr>
+</tr>-->
<tr>
- <td>
- <form action="<portlet:actionURL>
+<td>
+<form action="<portlet:actionURL>
</portlet:actionURL>" name="instancesform" method="POST" onsubmit="debug();">
- <input type="hidden" name="op" value=""/>
- <input type="hidden" name="toRegion" value=""/>
- <input type="hidden" name="fromRegion" value=""/>
- <input type="hidden" name="sortRegion" value=""/>
- <input type="hidden" name="editPageSelect" value="<%= currentPage %>"/>
- <table width="100%">
- <tr>
- <td valign="top" class="portlet-section-alternate" width="250">
- <table>
- <tr>
- <td valign="top">
- <b>Title and Layout</b>
- <br/>
- Title the page and select the number of columns for the layout
- <hr/>
- <b>Page Title:</b><br/>
- <input type="text" class="portlet-form-input-field" name="pagename">
- <br/>
- <input type="submit" name="save" value="Save" class="portlet-form-button"
- onclick="newPage('newpage');"/>
- </td>
- </tr>
- </table>
- </td>
- <td class="portlet-section-body" valign="top" align="right"><b>Available Content</b><br/>
- <select name="available_instances" multiple="true" size="20">
- <%
- for (int i = 0; i < available_instances.size(); i++)
- {
- Instance instance = (Instance)available_instances.get(i);
- %>
- <option value="<%= instance.getId() %>"><%= instance.getId()%>
- </option>
- <%
- }
- %>
- </select>
- </td>
- <td>
- <table>
- <%
- List regions = new ArrayList(windowMap.keySet());
- Collections.sort(regions);
- for (Iterator i = regions.iterator(); i.hasNext();)
+<input type="hidden" name="op" value=""/>
+<input type="hidden" name="toRegion" value=""/>
+<input type="hidden" name="fromRegion" value=""/>
+<input type="hidden" name="sortRegion" value=""/>
+<input type="hidden" name="editPageSelect" value="<%= currentPage %>"/>
+<table width="100%">
+<tr>
+<td valign="top" width="250">
+ <table class="bottombuttonbar">
+ <tr>
+ <td valign="top">
+ <b>Theme and Layout</b>
+ <br/>
+ Apply a theme to your page, or select the number of columns for the layout.
+ <hr/>
+ </td>
+ </tr>
+ <tr>
+ <td>
+
+ <select name="layout">
+ <%
+ for (Iterator iterator = layouts.iterator(); iterator.hasNext();)
+ {
+ PortalLayout layout = (PortalLayout)iterator.next();
+ String selected = "";
+ if (layout.getLayoutInfo().getName().equals(currentLayout))
{
- String region = (String)i.next();
- TreeSet windows = (TreeSet)windowMap.get(region);
- %>
- <tr>
- <td>
- <input type="submit" class="portlet-form-button" name=">" value=">"
- onclick="assignPortlet('copy','<%= region %>');"/><br/><input
- type="submit" class="portlet-form-button" name="<" value="<"
- onclick="unassignPortlet('remove','<%= region %>');"/></td>
- <td class="portlet-section-body" valign="top">
- <b><%= region %> Column</b><br/>
- <select name="<%= region %>_instances" multiple="true" size="6">
- <%
- for (Iterator j = windows.iterator(); j.hasNext();)
- {
- Window window = (Window)j.next();
- %>
- <option value="<%= window.getName() %>"><%= window.getInstanceRef() %>
- </option>
- <%
- }
- %>
- </select>
- </td>
- <td>
- <input type="submit" class="portlet-form-button" name="Up" value="Up"
- onclick="sortPortlet('up','<%= region %>');"/><br/><input
- type="submit" class="portlet-form-button" name="Down" value="Down"
- onclick="sortPortlet('down','<%= region %>');"/>
- </td>
- </tr>
- <%
+ selected = " selected=\"true\" ";
}
- %>
- </table>
- </tr>
- </table>
- </form>
- </td>
+ %>
+ <option <%=selected %>
+ value="<%= layout.getLayoutInfo().getName() %>"><%= layout.getLayoutInfo().getName() %>
+ </option>
+ <%
+ }
+ %>
+ </select> <input type="submit" class="portlet-form-button" name="Select" value="Select"
+ onclick="switchLayout('assignLayout');"/>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <select name="theme">
+ <%
+ for (Iterator iterator = themes.iterator(); iterator.hasNext();)
+ {
+ PortalTheme theme = (PortalTheme)iterator.next();
+ String selected = "";
+ if (theme.getThemeInfo().getName().equals(currentTheme))
+ {
+ selected = " selected=\"true\" ";
+ }
+ %>
+ <option <%=selected %>
+ value="<%= theme.getThemeInfo().getName() %>"><%= theme.getThemeInfo().getName() %>
+ </option>
+ <%
+ }
+ %>
+ </select> <input type="submit" class="portlet-form-button" name="Select" value="Select"
+ onclick="switchTheme('assignTheme');"/>
+ </td>
+ </tr>
+ </table>
+</td>
+<td class="portlet-section-body" valign="top" align="right"><b>Available Content</b><br/>
+ <select name="available_instances" multiple="true" size="20">
+ <%
+ for (int i = 0; i < available_instances.size(); i++)
+ {
+ Instance instance = (Instance)available_instances.get(i);
+ %>
+ <option value="<%= instance.getId() %>"><%= instance.getId()%>
+ </option>
+ <%
+ }
+ %>
+ </select>
+</td>
+<td>
+<table>
+ <%
+ List regions = new ArrayList(windowMap.keySet());
+ Collections.sort(regions);
+ for (Iterator i = regions.iterator(); i.hasNext();)
+ {
+ String region = (String)i.next();
+ TreeSet windows = (TreeSet)windowMap.get(region);
+ %>
+ <tr>
+ <td>
+ <input type="submit" class="portlet-form-button" name=">" value=">"
+ onclick="assignPortlet('copy','<%= region %>');"/><br/><input
+ type="submit" class="portlet-form-button" name="<" value="<"
+ onclick="unassignPortlet('remove','<%= region %>');"/></td>
+ <td class="portlet-section-body" valign="top">
+ <b><%= region %> Column</b><br/>
+ <select name="<%= region %>_instances" multiple="true" size="6">
+ <%
+ for (Iterator j = windows.iterator(); j.hasNext();)
+ {
+ Window window = (Window)j.next();
+ %>
+ <option value="<%= window.getName() %>"><%= window.getInstanceRef() %>
+ </option>
+ <%
+ }
+ %>
+ </select>
+ </td>
+ <td>
+ <input type="submit" class="portlet-form-button" name="Up" value="Up"
+ onclick="sortPortlet('up','<%= region %>');"/><br/><input
+ type="submit" class="portlet-form-button" name="Down" value="Down"
+ onclick="sortPortlet('down','<%= region %>');"/>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+</table>
</tr>
</table>
+</form>
+</td>
+</tr>
+</table>
<hr/>
<%
if (!"default".equals(currentPage))
@@ -216,7 +287,7 @@
<form action="<portlet:actionURL><portlet:param name="op" value="delete"></portlet:param>
</portlet:actionURL>" method="POST" style="padding:0;margin:0">
<input type="hidden" name="pagename" value="<%= currentPage %>"/>
- <input type="submit" name="submit" value="Delete this Page"/>
+ <input type="submit" name="submit" value="Delete this Page" class="portlet-form-button"/>
<br/>
<font color="red">You cannot undo this action!</font>
</form>
19 years, 5 months
JBoss Portal SVN: r5850 - trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard
by portal-commits@lists.jboss.org
Author: roy.russo(a)jboss.com
Date: 2006-12-13 13:38:05 -0500 (Wed, 13 Dec 2006)
New Revision: 5850
Modified:
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
JBPORTAL-1160 - fixed, Javascript error in dashboard in FF
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-13 16:18:16 UTC (rev 5849)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-13 18:38:05 UTC (rev 5850)
@@ -27,25 +27,25 @@
<script type="text/javascript" language="JavaScript">
function assignPortlet(op, to)
{
- this.instancesForm.op.value = op;
- this.instancesForm.toRegion.value = to;
+ this.document.instancesform.op.value = op;
+ this.document.instancesform.toRegion.value = to;
}
function unassignPortlet(op, from)
{
- this.instancesForm.op.value = op;
- this.instancesForm.fromRegion.value = from;
+ this.document.instancesform.op.value = op;
+ this.document.instancesform.fromRegion.value = from;
}
function sortPortlet(op, region)
{
- this.instancesForm.op.value = op;
- this.instancesForm.sortRegion.value = region;
+ this.document.instancesform.op.value = op;
+ this.document.instancesform.sortRegion.value = region;
}
function newPage(op)
{
- this.instancesForm.op.value = op;
+ this.document.instancesform.op.value = op;
}
function debug()
@@ -118,11 +118,11 @@
<tr>
<td>
<form action="<portlet:actionURL>
- </portlet:actionURL>" name="instancesForm" method="POST" onsubmit="debug();">
- <input type="hidden" name="op"/>
- <input type="hidden" name="toRegion"/>
- <input type="hidden" name="fromRegion"/>
- <input type="hidden" name="sortRegion"/>
+ </portlet:actionURL>" name="instancesform" method="POST" onsubmit="debug();">
+ <input type="hidden" name="op" value=""/>
+ <input type="hidden" name="toRegion" value=""/>
+ <input type="hidden" name="fromRegion" value=""/>
+ <input type="hidden" name="sortRegion" value=""/>
<input type="hidden" name="editPageSelect" value="<%= currentPage %>"/>
<table width="100%">
<tr>
19 years, 5 months
JBoss Portal SVN: r5849 - trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard
by portal-commits@lists.jboss.org
Author: roy.russo(a)jboss.com
Date: 2006-12-13 11:18:16 -0500 (Wed, 13 Dec 2006)
New Revision: 5849
Removed:
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/addpage.jsp
Log:
not needed
Deleted: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/addpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/addpage.jsp 2006-12-13 16:09:25 UTC (rev 5848)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/addpage.jsp 2006-12-13 16:18:16 UTC (rev 5849)
@@ -1,82 +0,0 @@
-<%@ page language="java" extends="org.jboss.portal.core.servlet.jsp.PortalJsp" %>
-<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
-<%@ taglib uri="/WEB-INF/portal-lib.tld" prefix="n" %>
-<%@ page isELIgnored="false" %>
-
-<portlet:defineObjects/>
-
-<table width="100%">
- <th colspan="2" class="portlet-section-header" align="center">Add Page</th>
- <tr>
- <td class="portlet-section-body" align="left">
- Use this to manage the content on your page. You can control the page title, select number of columns, and add,
- order, or remove portlets.
- </td>
- </tr>
- <tr>
- <td>
- <hr/>
- </td>
- </tr>
- <tr>
- <td>
- <form action="addpage" method="POST">
- <table>
- <tr>
- <td>title/layout table</td>
- <td>
- <table>
- <tr>
- <td class="portlet-section-body" valign="top"><b>Available Content</b><br/>
- <select name="available_instances" multiple="true" size="20">
- <option value="">Instance 1</option>
- <option value="">Instance 2</option>
- <option value="">Instance 3</option>
- <option value="">Instance 4</option>
- <option value="">Instance 5</option>
- </select>
- </td>
- <td>arrows</td>
- <td class="portlet-section-body" valign="top">
- <b>Left Column</b><br/>
- <select name="instances_left" multiple="true">
- <option value="">Instance 1</option>
- <option value="">Instance 2</option>
- <option value="">Instance 3</option>
- <option value="">Instance 4</option>
- <option value="">Instance 5</option>
- </select>
- <br/><br/>
- <b>Middle Column</b><br/>
- <select name="instances_middle" multiple="true">
- <option value="">Instance 1</option>
- <option value="">Instance 2</option>
- <option value="">Instance 3</option>
- <option value="">Instance 4</option>
- <option value="">Instance 5</option>
- </select>
- <br/><br/>
- <b>Right Column</b><br/>
- <select name="instances_right" multiple="true">
- <option value="">Instance 1</option>
- <option value="">Instance 2</option>
- <option value="">Instance 3</option>
- <option value="">Instance 4</option>
- <option value="">Instance 5</option>
- </select>
- </td>
- <td>arrows</td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td class="portlet-section-alternate" width="100%" colspan="4" align="center">
- <input type="submit" name="save" value="Save" class="portlet-form-button"/>
- </td>
- </tr>
- </table>
- </form>
- </td>
- </tr>
-</table>
\ No newline at end of file
19 years, 5 months