gatein SVN: r7016 - in portal/branches/api/component/api-impl/src: test/java/org/gatein/portal/api/impl/id and 1 other directory.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-09 03:12:55 -0400 (Tue, 09 Aug 2011)
New Revision: 7016
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
Log:
- Improved handling of ComplexApplicationIds.
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-09 06:34:27 UTC (rev 7015)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-09 07:12:55 UTC (rev 7016)
@@ -70,11 +70,20 @@
final int index = idAsString.indexOf(ComplexApplicationId.START);
if (index < 0)
{
- throw new IllegalArgumentException("'" + idAsString + "' cannot be understood by ComplexApplicationContext. Understood format is 'category/local.(_|/)applicationName.portletName'");
+ throw new IllegalArgumentException("'" + idAsString + "' cannot be understood by ComplexApplicationContext. Understood format is '{category/}local.(_|/)applicationName.portletName'");
}
- final int slash = idAsString.indexOf('/');
- String category = idAsString.substring(0, slash);
+ String category;
+ if (index == 0)
+ {
+ // we're in the regular portletcontext case: local./applicationName.portletName
+ category = null;
+ }
+ else
+ {
+ // we're in the application registry imported portlet: category/local._applicationName.portletName
+ category = idAsString.substring(0, idAsString.indexOf('/'));
+ }
final int length = ComplexApplicationId.START.length();
final int sepIndex = idAsString.indexOf('.', index + length);
@@ -99,7 +108,7 @@
public boolean isComponentRequired(String component)
{
- return true; // all components are required
+ return !GateInImpl.CATEGORY_COMPONENT.equals(component);
}
public boolean isComponentUnboundedHierarchical(String component)
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-09 06:34:27 UTC (rev 7015)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-09 07:12:55 UTC (rev 7016)
@@ -58,7 +58,16 @@
{
if (this.context.equals(context))
{
- return category + '/' + START + separator + app + '.' + portlet;
+ if ("/".equals(separator))
+ {
+ // we're in the regular portletcontext case: local./applicationName.portletName
+ return START + separator + app + '.' + portlet;
+ }
+ else
+ {
+ // we're in the application registry imported portlet: category/local._applicationName.portletName
+ return category + '/' + START + separator + app + '.' + portlet;
+ }
}
else
{
@@ -84,7 +93,7 @@
{
return false;
}
- if (!category.equals(that.category))
+ if (category != null ? !category.equals(that.category) : that.category != null)
{
return false;
}
@@ -99,7 +108,7 @@
@Override
public int hashCode()
{
- int result = category.hashCode();
+ int result = category != null ? category.hashCode() : 0;
result = 31 * result + app.hashCode();
result = 31 * result + portlet.hashCode();
return result;
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-09 06:34:27 UTC (rev 7015)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-09 07:12:55 UTC (rev 7016)
@@ -41,8 +41,8 @@
assert id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
- id = ComplexApplicationContext.INSTANCE.parse("category/local./webapp.portlet", Portlet.class);
- assert "category".equals(id.getComponent(GateInImpl.CATEGORY_COMPONENT));
+ id = ComplexApplicationContext.INSTANCE.parse("local./webapp.portlet", Portlet.class);
+ assert id.getComponent(GateInImpl.CATEGORY_COMPONENT) == null;
assert "webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT));
assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT));
13 years, 5 months
gatein SVN: r7015 - epp/portal/branches/EPP_5_1_RH_Branch.
by do-not-reply@jboss.org
Author: theute
Date: 2011-08-09 02:34:27 -0400 (Tue, 09 Aug 2011)
New Revision: 7015
Modified:
epp/portal/branches/EPP_5_1_RH_Branch/pom.xml
Log:
Upgrading eXo JCR to 1.12.9 (and dependencies)
Modified: epp/portal/branches/EPP_5_1_RH_Branch/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_1_RH_Branch/pom.xml 2011-08-08 22:53:56 UTC (rev 7014)
+++ epp/portal/branches/EPP_5_1_RH_Branch/pom.xml 2011-08-09 06:34:27 UTC (rev 7015)
@@ -37,10 +37,10 @@
<name>GateIn - Portal</name>
<properties>
- <org.exoplatform.kernel.version>2.2.6-GA</org.exoplatform.kernel.version>
- <org.exoplatform.core.version>2.3.6-GA</org.exoplatform.core.version>
- <org.exoplatform.ws.version>2.1.6-GA</org.exoplatform.ws.version>
- <org.exoplatform.jcr.version>1.12.6-GA</org.exoplatform.jcr.version>
+ <org.exoplatform.kernel.version>2.2.9-GA</org.exoplatform.kernel.version>
+ <org.exoplatform.core.version>2.3.9-GA</org.exoplatform.core.version>
+ <org.exoplatform.ws.version>2.1.9-GA</org.exoplatform.ws.version>
+ <org.exoplatform.jcr.version>1.12.9-GA</org.exoplatform.jcr.version>
<org.jibx.version>1.2.1</org.jibx.version>
<org.shindig.version>1.0-r790473-Patch04</org.shindig.version>
<nl.captcha.simplecaptcha.version>1.1.1-GA-Patch01</nl.captcha.simplecaptcha.version>
13 years, 5 months
gatein SVN: r7014 - in portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl: content and 1 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-08 18:53:56 -0400 (Mon, 08 Aug 2011)
New Revision: 7014
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
Log:
- Added implementation for getSite.
- Added more cases to get(Id).
- Renamed SITE_OWNER_COMPONENT to SITE_TYPE_COMPONENT.
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-08 22:51:54 UTC (rev 7013)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-08 22:53:56 UTC (rev 7014)
@@ -96,7 +96,7 @@
private static final String GROUP_CHARS = "\\w|-|_";
- public static final String SITE_OWNER_COMPONENT = "owner";
+ public static final String SITE_TYPE_COMPONENT = "type";
public static final String SITE_NAME_COMPONENT = "name";
public static final String APPLICATION_COMPONENT = "application";
public static final String PORTLET_COMPONENT = "portlet";
@@ -115,7 +115,7 @@
.withDefaultSeparator(".").build();
public static final Context SITE_CONTEXT = GenericContext.builder().named("Site")
- .requiredComponent(SITE_OWNER_COMPONENT, Identifiable.class, Pattern.compile(Site.PORTAL_TYPE_NAME + "|" + Site.GROUP_TYPE_NAME + "|" + Site.DASHBOARD_TYPE_NAME))
+ .requiredComponent(SITE_TYPE_COMPONENT, Identifiable.class, Pattern.compile(Site.PORTAL_TYPE_NAME + "|" + Site.GROUP_TYPE_NAME + "|" + Site.DASHBOARD_TYPE_NAME))
.requiredComponent(SITE_NAME_COMPONENT, Site.class, Pattern.compile("(" + GROUP_CHARS + "|\\/)+"))
.optionalComponent("page", Page.class, Pattern.compile("\\w+"))
.withDefaultSeparator("::").build();
@@ -470,15 +470,13 @@
{
Class<T> type = id.getIdentifiableType();
- Object result;
+ Object result = null;
- // todo: fix the use canonical names to avoid classloader issues?
- String canonicalName = type.getCanonicalName();
- if (Portal.class.getCanonicalName().equals(canonicalName))
+ if (Portal.class.equals(type))
{
result = getPortal((Id<Portal>)id);
}
- else if (Page.class.getCanonicalName().equals(canonicalName))
+ else if (Page.class.equals(type))
{
try
{
@@ -495,6 +493,23 @@
end();
}
}
+ else if (Site.class.equals(type))
+ {
+ Id<Site> siteId = (Id<Site>)id;
+ result = getSite(siteId, null);
+ }
+ else if (Content.class.equals(type))
+ {
+ final IterableIdentifiableCollection<Portal> portals = getPortals();
+ for (Portal portal : portals)
+ {
+ result = portal.getContentRegistry().get((Id<? extends Content>)id);
+ if (result != null)
+ {
+ break;
+ }
+ }
+ }
else
{
// todo: finish support of other types
@@ -506,8 +521,25 @@
public <T extends Site> T getSite(Id<T> siteId, Type<T> type)
{
- // todo
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ final String siteType = siteId.getComponent(SITE_TYPE_COMPONENT);
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(siteType, "Site type", "A valid Site Id");
+
+ if (Site.PORTAL.equals(siteType))
+ {
+ return (T)getPortal((Id<Portal>)siteId);
+ }
+ else if (Site.GROUP_TYPE_NAME.equals(siteType))
+ {
+ return (T)getGroupSite(groupId(siteId.getComponent(SITE_NAME_COMPONENT)));
+ }
+ else if (Site.DASHBOARD_TYPE_NAME.equals(siteType))
+ {
+ return (T)getDashboard(userId(siteId.getComponent(SITE_NAME_COMPONENT)));
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown Site type: " + siteType);
+ }
}
public Id userId(String user)
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-08 22:51:54 UTC (rev 7013)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-08 22:53:56 UTC (rev 7014)
@@ -22,7 +22,6 @@
package org.gatein.portal.api.impl.content;
-import org.exoplatform.application.registry.Application;
import org.exoplatform.application.registry.ApplicationCategory;
import org.exoplatform.application.registry.ApplicationRegistryService;
import org.gatein.api.content.Category;
@@ -37,12 +36,16 @@
import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.api.util.Query;
import org.gatein.pc.api.PortletContext;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.federation.FederatingPortletInvoker;
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.portal.PortalImpl;
import org.gatein.portal.api.impl.util.AdaptedIterableCollection;
import org.gatein.portal.api.impl.util.AdaptedIterableIdentifiableCollection;
+import org.gatein.portal.api.impl.util.AggregatedIterableIdentifiableCollection;
import java.util.List;
+import java.util.Set;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
public class ContentRegistryImpl implements ContentRegistry
@@ -205,17 +208,7 @@
gateIn.begin();
if (Portlet.class.equals(type) || WSRP.class.equals(type))
{
- final PortletContext portletContext;
- if (!id.knowsComponent(GateInImpl.INVOKER_COMPONENT))
- {
- portletContext = PortletContext.createPortletContext(id.getComponent(GateInImpl.APPLICATION_COMPONENT), id.getComponent(GateInImpl.PORTLET_COMPONENT));
- regitryItem = gateIn.getPortletInvoker().getFederatedInvoker("local").getPortletInvoker().getPortlet(portletContext);
- }
- else
- {
- portletContext = PortletContext.createPortletContext(id.toString());
- regitryItem = gateIn.getPortletInvoker().getPortlet(portletContext);
- }
+ regitryItem = getPortletFrom(id);
}
else if (Gadget.class.equals(type))
{
@@ -239,6 +232,23 @@
}
}
+ private <T extends Content> Object getPortletFrom(Id<T> id) throws PortletInvokerException
+ {
+ PortletContext portletContext;
+ Object regitryItem;
+ if (!id.knowsComponent(GateInImpl.INVOKER_COMPONENT))
+ {
+ portletContext = PortletContext.createPortletContext(id.getComponent(GateInImpl.APPLICATION_COMPONENT), id.getComponent(GateInImpl.PORTLET_COMPONENT));
+ regitryItem = gateIn.getPortletInvoker().getFederatedInvoker("local").getPortletInvoker().getPortlet(portletContext);
+ }
+ else
+ {
+ portletContext = PortletContext.createPortletContext(id.toString());
+ regitryItem = gateIn.getPortletInvoker().getPortlet(portletContext);
+ }
+ return regitryItem;
+ }
+
private <T extends Content> Content newContentFrom(Id id, Object registryItem, Class<T> wanted)
{
Object result;
@@ -277,23 +287,119 @@
try
{
gateIn.begin();
- final List<Application> applications = gateIn.getRegistryService().getAllApplications();
+ IterableIdentifiableCollection<? extends Content> localPortlets = getLocalPortlets();
+ IterableIdentifiableCollection<? extends Content> gadgets = getGadgets();
+ IterableIdentifiableCollection<? extends Content> remotePortlets = getRemotePortlets();
- return new AdaptedIterableIdentifiableCollection<Application, Content>(applications.size(), applications.iterator())
+ final AggregatedIterableIdentifiableCollection result = new AggregatedIterableIdentifiableCollection();
+ result.addCollection(localPortlets);
+ result.addCollection(remotePortlets);
+ result.addCollection(gadgets);
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public IterableIdentifiableCollection<Portlet> getLocalPortlets()
+ {
+ try
+ {
+ gateIn.begin();
+ final FederatingPortletInvoker portletInvoker = gateIn.getPortletInvoker();
+ final Set<org.gatein.pc.api.Portlet> initialLocalPortlets = portletInvoker.getLocalPortlets();
+ return new AdaptedIterableIdentifiableCollection<org.gatein.pc.api.Portlet, Portlet>(initialLocalPortlets.size(), initialLocalPortlets.iterator())
{
- public Content adapt(Application old)
+ public Portlet adapt(org.gatein.pc.api.Portlet old)
{
- final Id<? extends Content> id = GateInImpl.getContentIdFrom(old);
+ return (Portlet)newContentFrom(GateInImpl.parsePortletId(old.getContext().getId()), old, Portlet.class);
+ }
- return get(id);
+ public boolean contains(Id<Portlet> t)
+ {
+ try
+ {
+ return getPortletFrom(t) != null;
+ }
+ catch (PortletInvokerException e)
+ {
+ return false;
+ }
}
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
- public boolean contains(Id<Content> t)
+ public IterableIdentifiableCollection<WSRP> getRemotePortlets()
+ {
+ try
+ {
+ gateIn.begin();
+ final FederatingPortletInvoker portletInvoker = gateIn.getPortletInvoker();
+ final Set<org.gatein.pc.api.Portlet> initialRemotePortlets = portletInvoker.getRemotePortlets();
+ return new AdaptedIterableIdentifiableCollection<org.gatein.pc.api.Portlet, WSRP>(initialRemotePortlets.size(), initialRemotePortlets.iterator())
+ {
+ public WSRP adapt(org.gatein.pc.api.Portlet old)
{
+ return (WSRP)newContentFrom(GateInImpl.parseWSRPPortletId(old.getContext().getId()), old, WSRP.class);
+ }
+
+ public boolean contains(Id<WSRP> id)
+ {
try
{
- return gateIn.getRegistryService().getApplication(t.toString()) != null;
+ return getPortletFrom(id) != null;
}
+ catch (PortletInvokerException e)
+ {
+ return false;
+ }
+ }
+ };
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
+ }
+
+ public IterableIdentifiableCollection<Gadget> getGadgets()
+ {
+ try
+ {
+ gateIn.begin();
+ final List<org.exoplatform.application.gadget.Gadget> initialGadgets = gateIn.getGadgetService().getAllGadgets();
+ return new AdaptedIterableIdentifiableCollection<org.exoplatform.application.gadget.Gadget, Gadget>(initialGadgets.size(), initialGadgets.iterator())
+ {
+ public Gadget adapt(org.exoplatform.application.gadget.Gadget old)
+ {
+ return (Gadget)newContentFrom(gateIn.gadgetId(old.getName()), old, Gadget.class);
+ }
+
+ public boolean contains(Id<Gadget> id)
+ {
+ try
+ {
+ return gateIn.getGadgetService().getGadget(id.toString()) != null;
+ }
catch (Exception e)
{
return false;
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-08 22:51:54 UTC (rev 7013)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/NavigationImpl.java 2011-08-08 22:53:56 UTC (rev 7014)
@@ -328,7 +328,7 @@
Locale locale = Util.getPortalRequestContext().getLocale();
bundle = rbMgr.getNavigationResourceBundle(
locale.getLanguage(),
- site.getComponent(GateInImpl.SITE_OWNER_COMPONENT),
+ site.getComponent(GateInImpl.SITE_TYPE_COMPONENT),
site.getComponent(GateInImpl.SITE_NAME_COMPONENT));
if (bundle == null)
13 years, 5 months
gatein SVN: r7013 - portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-08 18:51:54 -0400 (Mon, 08 Aug 2011)
New Revision: 7013
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java
Log:
- Ignore empty collections since it would otherwise break the iterator.
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java 2011-08-08 22:50:34 UTC (rev 7012)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/util/AggregatedIterableIdentifiableCollection.java 2011-08-08 22:51:54 UTC (rev 7013)
@@ -31,14 +31,21 @@
import java.util.List;
import java.util.NoSuchElementException;
-/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
+/**
+ * TODO: fix logic, adding empty collections shouldn't break the iteration process, just move to the next collection
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ */
public class AggregatedIterableIdentifiableCollection<T extends Identifiable<T>> implements IterableIdentifiableCollection<T>
{
private List<IterableIdentifiableCollection> aggregated = new ArrayList<IterableIdentifiableCollection>(7);
public void addCollection(IterableIdentifiableCollection<? extends T> collection)
{
- aggregated.add(collection);
+ if (collection.size() != 0)
+ {
+ aggregated.add(collection);
+ }
}
13 years, 5 months
gatein SVN: r7012 - in portal/branches/api/component/api-impl/src: test/java/org/gatein/portal/api/impl/id and 1 other directory.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-08 18:50:34 -0400 (Mon, 08 Aug 2011)
New Revision: 7012
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
Log:
- Made ComplexApplication* able to handle more id formats.
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-08 21:30:11 UTC (rev 7011)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-08 22:50:34 UTC (rev 7012)
@@ -50,9 +50,9 @@
throw new IllegalArgumentException("ComplexApplicationContext can only create Id<Portlet>. Was asked to create Id<" + type.getSimpleName() + ">");
}
- if (additionalComponents != null && additionalComponents.length == 2)
+ if (additionalComponents != null && additionalComponents.length == 3)
{
- return (Id<T>)new ComplexApplicationId(rootComponent, additionalComponents[0], additionalComponents[1], this);
+ return (Id<T>)new ComplexApplicationId(rootComponent, additionalComponents[0], additionalComponents[1], additionalComponents[2], this);
}
else
{
@@ -70,17 +70,19 @@
final int index = idAsString.indexOf(ComplexApplicationId.START);
if (index < 0)
{
- throw new IllegalArgumentException("'" + idAsString + "' cannot be understood by ComplexApplicationContext. Understood format is 'local._applicationName.portletName'");
+ throw new IllegalArgumentException("'" + idAsString + "' cannot be understood by ComplexApplicationContext. Understood format is 'category/local.(_|/)applicationName.portletName'");
}
final int slash = idAsString.indexOf('/');
String category = idAsString.substring(0, slash);
- final int separator = idAsString.indexOf('.', index + ComplexApplicationId.START.length());
- String app = idAsString.substring(index + ComplexApplicationId.START.length(), separator);
- String portlet = idAsString.substring(separator + 1);
+ final int length = ComplexApplicationId.START.length();
+ final int sepIndex = idAsString.indexOf('.', index + length);
+ String separator = idAsString.substring(index + length, index + length + 1);
+ String app = idAsString.substring(index + length + 1, sepIndex);
+ String portlet = idAsString.substring(sepIndex + 1);
- return create(expectedType, category, app, portlet);
+ return create(expectedType, category, app, portlet, separator);
}
public String toString(Id id)
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-08 21:30:11 UTC (rev 7011)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-08 22:50:34 UTC (rev 7012)
@@ -32,18 +32,20 @@
public class ComplexApplicationId implements Id<Portlet>
{
public static final String LOCAL = "local";
- public static final String START = LOCAL + "._";
+ public static final String START = LOCAL + ".";
private final String category;
private final String app;
private final String portlet;
private final Context context;
+ private final String separator;
- public ComplexApplicationId(String category, String appName, String portletName, ComplexApplicationContext context)
+ public ComplexApplicationId(String category, String appName, String portletName, String separator, ComplexApplicationContext context)
{
this.category = category;
this.app = appName;
this.portlet = portletName;
this.context = context;
+ this.separator = separator;
}
@Override
@@ -56,7 +58,7 @@
{
if (this.context.equals(context))
{
- return category + '/' + START + app + '.' + portlet;
+ return category + '/' + START + separator + app + '.' + portlet;
}
else
{
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-08 21:30:11 UTC (rev 7011)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-08 22:50:34 UTC (rev 7012)
@@ -33,11 +33,19 @@
@Test
public void checkParsing()
{
- final Id<Portlet> id = ComplexApplicationContext.INSTANCE.parse("category/local._webapp.portlet", Portlet.class);
+ Id<Portlet> id = ComplexApplicationContext.INSTANCE.parse("category/local._webapp.portlet", Portlet.class);
assert "category".equals(id.getComponent(GateInImpl.CATEGORY_COMPONENT));
assert "webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT));
assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT));
assert id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
+
+
+ id = ComplexApplicationContext.INSTANCE.parse("category/local./webapp.portlet", Portlet.class);
+ assert "category".equals(id.getComponent(GateInImpl.CATEGORY_COMPONENT));
+ assert "webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT));
+ assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT));
+
+ assert id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
}
}
13 years, 5 months
gatein SVN: r7011 - portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-08 17:30:11 -0400 (Mon, 08 Aug 2011)
New Revision: 7011
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
Log:
- GTNPORTAL-1992: removed remains of older code.
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-08 17:51:25 UTC (rev 7010)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-08 21:30:11 UTC (rev 7011)
@@ -285,15 +285,7 @@
{
final Id<? extends Content> id = GateInImpl.getContentIdFrom(old);
- // if we're asking for a gadget, we need to retrieve it from the gadget registry first
- if (Gadget.class.isAssignableFrom(id.getIdentifiableType()))
- {
- return get(id);
- }
- else
- {
- return newContentFrom(id, old, id.getIdentifiableType());
- }
+ return get(id);
}
public boolean contains(Id<Content> t)
13 years, 5 months
gatein SVN: r7010 - in portal/branches/api: component/application-registry/src/main/java/org/exoplatform/application/registry and 2 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-08 13:51:25 -0400 (Mon, 08 Aug 2011)
New Revision: 7010
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
portal/branches/api/component/application-registry/src/main/java/org/exoplatform/application/registry/ApplicationRegistryService.java
portal/branches/api/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java
portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
Log:
- Updated for API changes.
- GTNPORTAL-1981: now properly saving changes to ManagedContent.
- Renamed ApplicationRegistryService.createOrReplaceContentIn to createOrUpdateApplication.
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-08-08 17:17:41 UTC (rev 7009)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-08-08 17:51:25 UTC (rev 7010)
@@ -24,10 +24,10 @@
import org.exoplatform.application.registry.Application;
import org.exoplatform.application.registry.ApplicationCategory;
+import org.exoplatform.application.registry.ApplicationRegistryService;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.exoplatform.portal.pom.spi.wsrp.WSRP;
-import org.gatein.api.GateIn;
import org.gatein.api.content.Category;
import org.gatein.api.content.Content;
import org.gatein.api.content.ContentRegistry;
@@ -65,7 +65,7 @@
{
public ManagedContent adapt(Application old)
{
- return new ManagedContentImpl(old.getApplicationName(), GateInImpl.getContentIdFrom(old), CategoryImpl.this);
+ return new ManagedContentImpl(old.getApplicationName(), GateInImpl.getContentIdFrom(old), old, CategoryImpl.this);
}
public boolean contains(ManagedContent managedContent)
@@ -126,9 +126,22 @@
ArrayList<String> permissions = new ArrayList<String>();
permissions.add(UserACL.EVERYONE);
- gateIn.getRegistryService().createOrReplaceContentIn(category.getName(), name, contentType, contentId.toString(), name, null, permissions);
+ try
+ {
+ gateIn.begin();
- return new ManagedContentImpl<T>(name, contentId, this);
+ final ApplicationRegistryService registryService = gateIn.getRegistryService();
+ final Application application = registryService.createOrUpdateApplication(category.getName(), name, contentType, contentId.toString(), name, null, permissions);
+ return new ManagedContentImpl<T>(name, contentId, application, this);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ gateIn.end();
+ }
}
private ContentType<?> getContentTypeFor(Type type)
@@ -235,7 +248,7 @@
}
final Id<? extends Content> contentId = GateInImpl.getContentIdFrom(application);
- return new ManagedContentImpl(name, contentId, this);
+ return new ManagedContentImpl(name, contentId, application, this);
}
public IterableCollection<String> getKnownManagedContentNames()
@@ -270,30 +283,8 @@
return category.getDisplayName();
}
- public GateIn getGateIn()
+ public GateInImpl getGateIn()
{
return gateIn;
}
-
- void renameManagedContent(String oldName, String newName)
- {
- Application application = getApplication(oldName);
- if (application != null)
- {
- application.setApplicationName(newName); // todo: correct?
- try
- {
- gateIn.begin();
- gateIn.getRegistryService().save(category, application);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- gateIn.end();
- }
- }
- }
}
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java 2011-08-08 17:17:41 UTC (rev 7009)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java 2011-08-08 17:51:25 UTC (rev 7010)
@@ -23,11 +23,11 @@
package org.gatein.portal.api.impl.content;
-import org.gatein.api.GateIn;
+import org.exoplatform.application.registry.Application;
import org.gatein.api.content.Content;
import org.gatein.api.content.ManagedContent;
import org.gatein.api.id.Id;
-import org.gatein.common.util.ParameterValidation;
+import org.gatein.portal.api.impl.GateInImpl;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -39,26 +39,14 @@
private final Id<T> contentId;
private final Id<ManagedContent<T>> id;
private final CategoryImpl category;
- private String name;
- private String displayName;
- private String description;
+ private final Application application;
-
- ManagedContentImpl(T content, CategoryImpl category)
+ ManagedContentImpl(String name, Id contentId, Application application, CategoryImpl category)
{
- ParameterValidation.throwIllegalArgExceptionIfNull(content, "Content");
- this.content = content;
- this.contentId = content.getId();
- this.id = content.getGateIn().managedContentId(category.getId(), content.getName(), content.getId());
- this.category = category;
- }
-
- ManagedContentImpl(String name, Id contentId, CategoryImpl category)
- {
- this.name = name;
this.contentId = contentId;
this.id = category.getGateIn().managedContentId(category.getId(), name, contentId);
this.category = category;
+ this.application = application;
}
@Override
@@ -74,38 +62,36 @@
public String getName()
{
- if (name != null)
- {
- return name;
- }
- return getContent().getName();
+ return application.getApplicationName();
}
- public void setName(String name)
+ public String getDisplayName()
{
- category.renameManagedContent(this.name, name);
- this.name = name;
+ return application.getDisplayName();
}
- public String getDisplayName()
+ public void setDisplayName(String displayName)
{
- if (displayName != null)
- {
- return displayName;
- }
- return getContent().getDisplayName();
+ application.setDisplayName(displayName);
+ save();
}
- public GateIn getGateIn()
+ public String getDescription()
{
- return getContent().getGateIn();
+ return application.getDescription();
}
- public void setDisplayName(String displayName)
+ public void setDescription(String description)
{
- this.displayName = displayName;
+ application.setDescription(description);
+ save();
}
+ public GateInImpl getGateIn()
+ {
+ return category.getGateIn();
+ }
+
public T getContent()
{
if (content == null)
@@ -116,13 +102,20 @@
return content;
}
- public String getDescription()
+ private void save()
{
- return description;
+ try
+ {
+ getGateIn().begin();
+ getGateIn().getRegistryService().update(application);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ getGateIn().end();
+ }
}
-
- public void setDescription(String description)
- {
- this.description = description;
- }
}
Modified: portal/branches/api/component/application-registry/src/main/java/org/exoplatform/application/registry/ApplicationRegistryService.java
===================================================================
--- portal/branches/api/component/application-registry/src/main/java/org/exoplatform/application/registry/ApplicationRegistryService.java 2011-08-08 17:17:41 UTC (rev 7009)
+++ portal/branches/api/component/application-registry/src/main/java/org/exoplatform/application/registry/ApplicationRegistryService.java 2011-08-08 17:51:25 UTC (rev 7010)
@@ -159,7 +159,7 @@
*/
public void importExoGadgets() throws Exception;
- void createOrReplaceContentIn(String categoryName, String definitionName, ContentType<?> contentType, String contentId, String displayName, String description, List<String> permissions);
+ Application createOrUpdateApplication(String categoryName, String definitionName, ContentType<?> contentType, String contentId, String displayName, String description, List<String> permissions);
Application createApplicationFrom(org.gatein.pc.api.Portlet portlet);
}
\ No newline at end of file
Modified: portal/branches/api/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java
===================================================================
--- portal/branches/api/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java 2011-08-08 17:17:41 UTC (rev 7009)
+++ portal/branches/api/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java 2011-08-08 17:51:25 UTC (rev 7010)
@@ -402,7 +402,7 @@
}
}
- public void createOrReplaceContentIn(String categoryName, String definitionName, ContentType<?> contentType, String contentId, String displayName, String description, List<String> permissions)
+ public Application createOrUpdateApplication(String categoryName, String definitionName, ContentType<?> contentType, String contentId, String displayName, String description, List<String> permissions)
{
CategoryDefinition definition = getOrCreateCategoryDefinition(categoryName, permissions);
ContentDefinition content = definition.getContentMap().get(definitionName);
@@ -410,6 +410,13 @@
{
content = createContent(definitionName, contentType, contentId, displayName, description, permissions, definition);
}
+ else
+ {
+ content.setAccessPermissions(permissions);
+ content.setDescription(description);
+ content.setDisplayName(displayName);
+ }
+ return load(content);
}
private ContentDefinition createContent(String definitionName, ContentType<?> contentType, String contentId, String displayName, String description, List<String> permissions, CategoryDefinition category)
Modified: portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
===================================================================
--- portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java 2011-08-08 17:17:41 UTC (rev 7009)
+++ portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java 2011-08-08 17:51:25 UTC (rev 7010)
@@ -83,6 +83,7 @@
private void outputManagedContent(ManagedContent content, PrintWriter writer) throws IOException
{
writer.println("<h3>" + content.getDisplayName() + "</h3>");
+ writer.println("<h4>Name:" + content.getName() + "</h4>");
writer.println("Content: " + content.getContent());
writer.println("<br/>");
}
13 years, 5 months
gatein SVN: r7009 - in epp/portal/branches/EPP_5_2_Branch: web/portal/src/main/webapp/groovy/portal/webui and 1 other directories.
by do-not-reply@jboss.org
Author: hfnukal
Date: 2011-08-08 13:17:41 -0400 (Mon, 08 Aug 2011)
New Revision: 7009
Modified:
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/jcr/jcr-configuration.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl
epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UILoginForm.java
Log:
JBEPP-1001 Remember my login redirects at blank page
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/jcr/jcr-configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/jcr/jcr-configuration.xml 2011-08-08 16:23:15 UTC (rev 7008)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/jcr/jcr-configuration.xml 2011-08-08 17:17:41 UTC (rev 7009)
@@ -121,7 +121,8 @@
<value>jar:/conf/gatein-nodetypes.xml</value>
<value>jar:/conf/mop-nodetypes.xml</value>
<value>jar:/conf/application-nodetypes.xml</value>
- <value>jar:/conf/content-nodetypes.xml</value>
+ <value>jar:/conf/content-nodetypes.xml</value>
+ <value>jar:/conf/autologin-nodetypes.xml</value>
</values-param>
</init-params>
</component-plugin>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl 2011-08-08 16:23:15 UTC (rev 7008)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl 2011-08-08 17:17:41 UTC (rev 7009)
@@ -22,22 +22,20 @@
<div class="MiddleRightLoginDecorator">
<div class="LoginDecoratorBackground">
<div class="LoginDetailBox">
- <% uiform.begin(); %>
- <!--<form class="UIForm" id="$uicomponent.id" name="loginForm" action="<%= rcontext.getRequestContextPath() + "/login"%>" method="post" style="margin: 0px;">
- <input type="hidden" name="<%= uiform.ACTION %>" value=""/>-->
+ <form class="UIForm" id="$uicomponent.id" name="loginForm" action="<%= rcontext.getRequestContextPath() + "/login"%>" method="post" style="margin: 0px;">
<input type="hidden" name="initialURI" value="<%=requestPath %>"/>
<div class="VerticalLayout">
<table class="UIFormGrid">
<tr class="UserNameField">
<td class="FieldLabel"><%=_ctx.appRes("UILoginForm.label.UserName")%></td>
- <td><% uiform.renderChild(0)%></td>
+ <td><input class="UserName" name="username"/></td>
</tr>
<tr class="PasswordField" id="UIPortalLoginFormControl" onkeypress="eXo.portal.UIPortalControl.onEnterPress(event)">
<td class="FieldLabel"><%=_ctx.appRes("UILoginForm.label.password")%></td>
- <td><% uiform.renderChild(1)%></td>
+ <td><input class="Password" type="password" name="password"/></td>
</tr>
<tr class="RememberField" onkeypress="eXo.portal.UIPortalControl.onEnterPress(event)">
- <td class="FieldLabel"><% uiform.renderChild(2)%></td>
+ <td class="FieldLabel"><input type="checkbox" class="checkbox" value="true" name="rememberme"/></td>
<td><%=_ctx.appRes("UILoginForm.label.RememberOnComputer")%></td>
</tr>
</table>
@@ -69,7 +67,7 @@
</table>
</div>
</div>
- <%uiform.end()%>
+ </form>
</div>
</div>
</div>
@@ -84,7 +82,6 @@
<script>
function login(ele) {
var formEle = eXo.core.DOMUtil.findAncestorByTagName(ele,'form');
- formEle.action = eXo.env.portal.context + "/login";
formEle.submit();
}
</script>
Modified: epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UILoginForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UILoginForm.java 2011-08-08 16:23:15 UTC (rev 7008)
+++ epp/portal/branches/EPP_5_2_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/login/UILoginForm.java 2011-08-08 17:17:41 UTC (rev 7009)
@@ -20,17 +20,13 @@
package org.exoplatform.portal.webui.login;
import org.exoplatform.portal.webui.workspace.UIMaskWorkspace;
-import org.exoplatform.web.login.InitiateLoginServlet;
+import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
+import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.event.Event;
import org.exoplatform.webui.event.EventListener;
import org.exoplatform.webui.event.Event.Phase;
-import org.exoplatform.webui.form.UIForm;
-import org.exoplatform.webui.form.UIFormCheckBoxInput;
-import org.exoplatform.webui.form.UIFormStringInput;
-import org.exoplatform.webui.form.validator.MandatoryValidator;
/**
* Created by The eXo Platform SARL
@@ -38,58 +34,16 @@
* nhudinhthuan(a)exoplatform.com
* Jul 11, 2006
*/
-@ComponentConfig(lifecycle = UIFormLifecycle.class, template = "system:/groovy/portal/webui/UILoginForm.gtmpl", events = {
- // @EventConfig(listeners = UILoginForm.SigninActionListener.class),
+@ComponentConfig(template = "system:/groovy/portal/webui/UILoginForm.gtmpl", events = {
@EventConfig(phase = Phase.DECODE, listeners = UIMaskWorkspace.CloseActionListener.class),
@EventConfig(phase = Phase.DECODE, listeners = UILoginForm.ForgetPasswordActionListener.class)})
-public class UILoginForm extends UIForm
+public class UILoginForm extends UIComponent
{
- final static String USER_NAME = "username";
- final static String PASSWORD = "password";
-
public UILoginForm() throws Exception
{
- addUIFormInput(new UIFormStringInput(USER_NAME, USER_NAME, null).addValidator(MandatoryValidator.class))
- .addUIFormInput(
- new UIFormStringInput(PASSWORD, PASSWORD, null).setType(UIFormStringInput.PASSWORD_TYPE).addValidator(
- MandatoryValidator.class));
- addUIFormInput(new UIFormCheckBoxInput<String>(InitiateLoginServlet.COOKIE_NAME,
- InitiateLoginServlet.COOKIE_NAME, Boolean.TRUE.toString()));
}
- static public class SigninActionListener extends EventListener<UILoginForm>
- {
-
- public void execute(Event<UILoginForm> event) throws Exception
- {
- // UILoginForm uiForm = event.getSource();
- // String username = uiForm.getUIStringInput(USER_NAME).getValue();
- // String password = uiForm.getUIStringInput(PASSWORD).getValue();
- // OrganizationService orgService = uiForm.getApplicationComponent(OrganizationService.class);
- // boolean authentication = orgService.getUserHandler().authenticate(username, password);
- // if(!authentication){
- // throw new MessageException(new ApplicationMessage("UILoginForm.msg.Invalid-account", null));
- // }
- // PortalRequestContext prContext = Util.getPortalRequestContext();
- // HttpServletRequest request = prContext.getRequest();
- // HttpSession session = request.getSession();
- // session.setAttribute("authentication.username", username);
- // session.setAttribute("authentication.password", password);
- // UIPortal uiPortal = Util.getUIPortal();
- // prContext.setResponseComplete(true);
- // String portalName = uiPortal.getName() ;
- // HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request) ;
- // wrapper.getParameterMap().put("username", username) ;
- // wrapper.getParameterMap().put("password", password) ;
- // portalName = URLEncoder.encode(portalName, "UTF-8") ;
- // String redirect = request.getContextPath() + "/private/" + portalName + "/";
- // prContext.getResponse().sendRedirect(redirect);
- }
-
- }
-
- //TODO: dang.tung - forget password
static public class ForgetPasswordActionListener extends EventListener<UILoginForm>
{
public void execute(Event<UILoginForm> event) throws Exception
@@ -100,4 +54,18 @@
event.getRequestContext().addUIComponentToUpdateByAjax(uiLogin);
}
}
+
+ @Override
+ public void processDecode(WebuiRequestContext context) throws Exception
+ {
+ super.processDecode(context);
+ String action = context.getRequestParameter(context.getActionParameterName());
+ Event<UIComponent> event = createEvent(action, Event.Phase.DECODE, context);
+ if (event != null)
+ {
+ event.broadcast();
+ }
+ }
+
+
}
13 years, 5 months
gatein SVN: r7008 - in portal/branches/api/component/api-impl/src: main/java/org/gatein/portal/api/impl/content and 2 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2011-08-08 12:23:15 -0400 (Mon, 08 Aug 2011)
New Revision: 7008
Added:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
Log:
- Adapted for API changes.
- GateInImpl now waits on ExoKernelIntegration before being instantiated so that it's properly resolved when the component is started (via constructor dependency).
- Fixed Content implementation. Previous implementation was just a proxy to the Application provided by the ApplicationRegistry (which actually maps to ManagedContent). Content now maps to PC portlets. Gadget side was fine.
- ManagedContent is now late-binding.
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/GateInImpl.java 2011-08-08 16:23:15 UTC (rev 7008)
@@ -38,6 +38,7 @@
import org.exoplatform.portal.mop.SiteType;
import org.exoplatform.portal.mop.description.DescriptionService;
import org.exoplatform.portal.mop.navigation.NavigationService;
+import org.exoplatform.portal.pc.ExoKernelIntegration;
import org.exoplatform.portal.pom.data.ModelDataStorage;
import org.exoplatform.portal.pom.data.PageData;
import org.exoplatform.portal.pom.data.PageKey;
@@ -69,6 +70,7 @@
import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.api.util.Type;
import org.gatein.common.util.ParameterValidation;
+import org.gatein.pc.federation.FederatingPortletInvoker;
import org.gatein.portal.api.impl.id.ComplexApplicationContext;
import org.gatein.portal.api.impl.id.ComplexApplicationId;
import org.gatein.portal.api.impl.portal.DashboardSiteImpl;
@@ -93,8 +95,25 @@
private static final Query<PortalData> PORTALS = new Query<PortalData>(SiteType.PORTAL.getName(), null, PortalData.class);
private static final String GROUP_CHARS = "\\w|-|_";
+
public static final String SITE_OWNER_COMPONENT = "owner";
public static final String SITE_NAME_COMPONENT = "name";
+ public static final String APPLICATION_COMPONENT = "application";
+ public static final String PORTLET_COMPONENT = "portlet";
+ public static final String INVOKER_COMPONENT = "invoker";
+ public static final String CATEGORY_COMPONENT = "category";
+
+ public static final Pattern INVOKER_COMPONENT_PATTERN = Pattern.compile("\\w+");
+
+ public static final Context LOCAL_PORTLET_CONTEXT = GenericContext.builder().named("Local Portlet")
+ .requiredComponent(APPLICATION_COMPONENT, Identifiable.class, Pattern.compile("(" + GROUP_CHARS + "|\\.)+"))
+ .requiredComponent(PORTLET_COMPONENT, Portlet.class, Pattern.compile("\\w+"))
+ .withDefaultSeparator("/").build();
+ private static final Context WSRP_PORTLET_CONTEXT = GenericContext.builder().named("WSRP Portlet")
+ .requiredComponent(INVOKER_COMPONENT, Identifiable.class, INVOKER_COMPONENT_PATTERN)
+ .requiredComponent("portletcontext", WSRP.class, Pattern.compile("(" + GROUP_CHARS + ")+"))
+ .withDefaultSeparator(".").build();
+
public static final Context SITE_CONTEXT = GenericContext.builder().named("Site")
.requiredComponent(SITE_OWNER_COMPONENT, Identifiable.class, Pattern.compile(Site.PORTAL_TYPE_NAME + "|" + Site.GROUP_TYPE_NAME + "|" + Site.DASHBOARD_TYPE_NAME))
.requiredComponent(SITE_NAME_COMPONENT, Site.class, Pattern.compile("(" + GROUP_CHARS + "|\\/)+"))
@@ -102,18 +121,12 @@
.withDefaultSeparator("::").build();
public static final Context GROUP_CONTEXT = GenericContext.builder().named("Group").requiredUnboundedHierarchicalComponent("group", Identifiable.class, Pattern.compile("(" + GROUP_CHARS + ")+"))
.withDefaultSeparator("/").requireSeparatorInFirstPosition().build();
- public static final String APPLICATION_COMPONENT_NAME = "application";
- public static final String PORTLET_COMPONENT_NAME = "portlet";
- public static final Context APPLICATION_CONTEXT = GenericContext.builder().named("Application").requiredComponent(APPLICATION_COMPONENT_NAME, Identifiable.class, Pattern.compile("\\w+"))
- .requiredComponent(PORTLET_COMPONENT_NAME, Portlet.class, Pattern.compile("\\w+")).withDefaultSeparator("/").build();
private static final Context GADGET_CONTEXT = GenericContext.builder().named("Gadget").requiredComponent("name", Gadget.class, Pattern.compile("\\w+")).build();
private static final Context USER_CONTEXT = GenericContext.builder().named("User").requiredComponent("name", Identifiable.class, Pattern.compile("[a-zA-Z0-9]+")).build();
private static final Context CATEGORY_CONTEXT = GenericContext.builder().named("Category").requiredComponent("name", Category.class, Pattern.compile("\\w+")).build();
- private static final Context WSRP_CONTEXT = GenericContext.builder().named("WSRP").requiredComponent("invoker", Identifiable.class, Pattern.compile("\\w+"))
- .requiredComponent("portletcontext", WSRP.class, Pattern.compile(GROUP_CHARS + "+")).withDefaultSeparator(".").build();
- private static final String MANAGED = "managed";
- private static final Context MANAGED_CONTENT_CONTEXT = GenericContext.builder().named("ManagedContent")
- .requiredComponent(MANAGED, ManagedContent.class, Pattern.compile(MANAGED))
+ public static final Context MANAGED_CONTENT_CONTEXT = GenericContext.builder().named("ManagedContent")
+ .requiredComponent(CATEGORY_COMPONENT, Category.class, Pattern.compile("\\w+"))
+ .requiredComponent("name", ManagedContent.class, Pattern.compile("(" + GROUP_CHARS + "|\\.)+"))
.requiredComponent("content", Content.class, Pattern.compile(".+"))
.withDefaultSeparator(":")
.build();
@@ -126,8 +139,9 @@
private UserPortalConfigService configService;
private Map<Type, Object> properties = new HashMap<Type, Object>(7);
private LifecycleManager lcManager = GateIn.NO_OP_MANAGER;
+ private FederatingPortletInvoker portletInvoker;
- public GateInImpl(ExoContainerContext context, InitParams params, ConfigurationManager configurationManager)
+ public GateInImpl(ExoContainerContext context, InitParams params, ConfigurationManager configurationManager, ExoKernelIntegration exoKernelIntegration)
{
container = context.getContainer();
}
@@ -138,16 +152,15 @@
Class<Content> contentClass = getContentClassFor(type);
if (Gadget.class.isAssignableFrom(contentClass))
{
- //TODO: for a gadget, it should probably be using application.getID instead of getContentId
return staticGadgetId(application.getContentId());
}
else if (WSRP.class.isAssignableFrom(contentClass))
{
- return parseWSRPPortletId(application.getId());
+ return parseWSRPPortletId(application.getContentId());
}
else if (Portlet.class.isAssignableFrom(contentClass))
{
- return parsePortletId(application.getId());
+ return parsePortletId(application.getContentId());
}
else
{
@@ -509,7 +522,7 @@
public Id<Portlet> portletId(String application, String portlet)
{
- return APPLICATION_CONTEXT.create(Portlet.class, application, portlet);
+ return LOCAL_PORTLET_CONTEXT.create(Portlet.class, application, portlet);
}
public static Id<Portlet> parsePortletId(String contentId)
@@ -520,7 +533,7 @@
}
else
{
- return APPLICATION_CONTEXT.parse(contentId, Portlet.class);
+ return LOCAL_PORTLET_CONTEXT.parse(contentId, Portlet.class);
}
}
@@ -531,12 +544,12 @@
private static Id<WSRP> staticWSRPPortletId(String invoker, String portlet)
{
- return WSRP_CONTEXT.create(WSRP.class, invoker, portlet);
+ return WSRP_PORTLET_CONTEXT.create(WSRP.class, invoker, portlet);
}
public static Id<WSRP> parseWSRPPortletId(String compositeId)
{
- return WSRP_CONTEXT.parse(compositeId, WSRP.class);
+ return WSRP_PORTLET_CONTEXT.parse(compositeId, WSRP.class);
}
public Id<Gadget> gadgetId(String gadgetName)
@@ -554,9 +567,9 @@
return null; //To change body of implemented methods use File | Settings | File Templates.
}
- public <T extends Content> Id<ManagedContent> managedContentId(Id<T> contentId)
+ public <T extends Content> Id<ManagedContent> managedContentId(Id<Category> categoryId, String name, Id<T> contentId)
{
- return MANAGED_CONTENT_CONTEXT.create(ManagedContent.class, MANAGED, contentId.toString());
+ return MANAGED_CONTENT_CONTEXT.create(ManagedContent.class, categoryId.toString(), name, contentId.toString());
}
public Id<Category> categoryId(String name)
@@ -582,6 +595,7 @@
gadgetService = (GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
sourceStorage = (SourceStorage)container.getComponentInstanceOfType(SourceStorage.class);
configService = (UserPortalConfigService)container.getComponentInstanceOfType(UserPortalConfigService.class);
+ portletInvoker = (FederatingPortletInvoker)container.getComponentInstanceOfType(FederatingPortletInvoker.class);
}
public void stop()
@@ -609,6 +623,11 @@
return sourceStorage;
}
+ public FederatingPortletInvoker getPortletInvoker()
+ {
+ return portletInvoker;
+ }
+
private PortalData getPortalDataFor(Id<Portal> portalId)
{
ParameterValidation.throwIllegalArgExceptionIfNull(portalId, "Portal Id");
Added: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java (rev 0)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/AbstractPortlet.java 2011-08-08 16:23:15 UTC (rev 7008)
@@ -0,0 +1,47 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.gatein.portal.api.impl.content;
+
+import org.gatein.api.content.Content;
+import org.gatein.api.id.Id;
+import org.gatein.portal.api.impl.GateInImpl;
+import org.gatein.portal.api.impl.IdentifiableImpl;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
+public abstract class AbstractPortlet<T extends Content<T>> extends IdentifiableImpl<T> implements Content<T>
+{
+ private final org.gatein.pc.api.Portlet portlet;
+
+ public AbstractPortlet(Id<T> id, org.gatein.pc.api.Portlet application, GateInImpl gateIn)
+ {
+ super(id, application.getInfo().getName(), gateIn);
+ this.portlet = application;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getType().getName() + " Portlet '" + getName() + "' @" + getId();
+ }
+
+}
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/CategoryImpl.java 2011-08-08 16:23:15 UTC (rev 7008)
@@ -31,10 +31,12 @@
import org.gatein.api.content.Category;
import org.gatein.api.content.Content;
import org.gatein.api.content.ContentRegistry;
+import org.gatein.api.content.Gadget;
import org.gatein.api.content.ManagedContent;
import org.gatein.api.id.Id;
import org.gatein.api.util.IterableCollection;
import org.gatein.api.util.Type;
+import org.gatein.common.util.ParameterValidation;
import org.gatein.mop.api.content.ContentType;
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.util.AdaptedIterableCollection;
@@ -63,8 +65,7 @@
{
public ManagedContent adapt(Application old)
{
- Content content = registry.get(GateInImpl.getContentIdFrom(old));
- return new ManagedContentImpl(content, CategoryImpl.this);
+ return new ManagedContentImpl(old.getApplicationName(), GateInImpl.getContentIdFrom(old), CategoryImpl.this);
}
public boolean contains(ManagedContent managedContent)
@@ -87,6 +88,11 @@
return sb.toString();
}
+ ContentRegistry getRegistry()
+ {
+ return registry;
+ }
+
public boolean contains(String managedContentName)
{
return getApplication(managedContentName) != null;
@@ -109,27 +115,20 @@
}
}
- public <T extends Content> ManagedContent<T> addContent(Id<T> contentId)
+ public <T extends Content> ManagedContent<T> addContent(Id<T> contentId, String name)
{
- // get content from registry
- T t = registry.get(contentId);
+ ParameterValidation.throwIllegalArgExceptionIfNull(contentId, "Content Id");
+ GateInImpl.MANAGED_CONTENT_CONTEXT.validateValueFor("name", name);
- if (t == null)
- {
- throw new IllegalArgumentException("No Content with id " + contentId + " exists");
- }
+ final ContentType<?> contentType = getContentTypeFor(contentId);
- // figure out which type it is for the ApplicationRegistry
- Type type = t.getType();
- ContentType<?> contentType = getContentTypeFor(type);
-
// default permissions by default
ArrayList<String> permissions = new ArrayList<String>();
permissions.add(UserACL.EVERYONE);
- gateIn.getRegistryService().createOrReplaceContentIn(category.getName(), t.getName(), contentType, t.getId().toString(), t.getDisplayName(), null, permissions);
+ gateIn.getRegistryService().createOrReplaceContentIn(category.getName(), name, contentType, contentId.toString(), name, null, permissions);
- return new ManagedContentImpl<T>(t, this);
+ return new ManagedContentImpl<T>(name, contentId, this);
}
private ContentType<?> getContentTypeFor(Type type)
@@ -152,6 +151,27 @@
}
}
+ private ContentType<?> getContentTypeFor(Id id)
+ {
+ final Class type = id.getIdentifiableType();
+ if (Gadget.class.equals(type))
+ {
+ return org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE;
+ }
+ else if (org.gatein.api.content.Portlet.class.equals(type))
+ {
+ return Portlet.CONTENT_TYPE;
+ }
+ else if (org.gatein.api.content.WSRP.class.equals(type))
+ {
+ return WSRP.CONTENT_TYPE;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown Content type: " + type);
+ }
+ }
+
public String getDescription()
{
return category.getDescription();
@@ -214,8 +234,8 @@
return null;
}
- Content content = registry.get(GateInImpl.getContentIdFrom(application));
- return new ManagedContentImpl(content, this);
+ final Id<? extends Content> contentId = GateInImpl.getContentIdFrom(application);
+ return new ManagedContentImpl(name, contentId, this);
}
public IterableCollection<String> getKnownManagedContentNames()
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ContentRegistryImpl.java 2011-08-08 16:23:15 UTC (rev 7008)
@@ -36,6 +36,7 @@
import org.gatein.api.util.IterableCollection;
import org.gatein.api.util.IterableIdentifiableCollection;
import org.gatein.api.util.Query;
+import org.gatein.pc.api.PortletContext;
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.portal.PortalImpl;
import org.gatein.portal.api.impl.util.AdaptedIterableCollection;
@@ -204,7 +205,17 @@
gateIn.begin();
if (Portlet.class.equals(type) || WSRP.class.equals(type))
{
- regitryItem = gateIn.getRegistryService().getApplication(id.toString());
+ final PortletContext portletContext;
+ if (!id.knowsComponent(GateInImpl.INVOKER_COMPONENT))
+ {
+ portletContext = PortletContext.createPortletContext(id.getComponent(GateInImpl.APPLICATION_COMPONENT), id.getComponent(GateInImpl.PORTLET_COMPONENT));
+ regitryItem = gateIn.getPortletInvoker().getFederatedInvoker("local").getPortletInvoker().getPortlet(portletContext);
+ }
+ else
+ {
+ portletContext = PortletContext.createPortletContext(id.toString());
+ regitryItem = gateIn.getPortletInvoker().getPortlet(portletContext);
+ }
}
else if (Gadget.class.equals(type))
{
@@ -233,7 +244,7 @@
Object result;
if (Portlet.class.equals(wanted))
{
- result = new PortletImpl((Id<Portlet>)id, (Application)registryItem, gateIn);
+ result = new PortletImpl((Id<Portlet>)id, (org.gatein.pc.api.Portlet)registryItem, gateIn);
}
else if (Gadget.class.equals(wanted))
{
@@ -241,7 +252,7 @@
}
else if (WSRP.class.equals(wanted))
{
- result = new WSRPImpl((Id<WSRP>)id, (Application)registryItem, gateIn);
+ result = new WSRPImpl((Id<WSRP>)id, (org.gatein.pc.api.Portlet)registryItem, gateIn);
}
else
{
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java 2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/ManagedContentImpl.java 2011-08-08 16:23:15 UTC (rev 7008)
@@ -35,7 +35,8 @@
*/
public class ManagedContentImpl<T extends Content> implements ManagedContent<T>
{
- private final T content;
+ private T content;
+ private final Id<T> contentId;
private final Id<ManagedContent<T>> id;
private final CategoryImpl category;
private String name;
@@ -43,18 +44,27 @@
private String description;
- public ManagedContentImpl(T content, CategoryImpl category)
+ ManagedContentImpl(T content, CategoryImpl category)
{
ParameterValidation.throwIllegalArgExceptionIfNull(content, "Content");
this.content = content;
- this.id = content.getGateIn().managedContentId(content.getId());
+ this.contentId = content.getId();
+ this.id = content.getGateIn().managedContentId(category.getId(), content.getName(), content.getId());
this.category = category;
}
+ ManagedContentImpl(String name, Id contentId, CategoryImpl category)
+ {
+ this.name = name;
+ this.contentId = contentId;
+ this.id = category.getGateIn().managedContentId(category.getId(), name, contentId);
+ this.category = category;
+ }
+
@Override
public String toString()
{
- return "ManagedContent '" + getName() + "' =>" + content;
+ return "ManagedContent '" + getName() + "' =>" + getContent();
}
public Id<ManagedContent<T>> getId()
@@ -68,7 +78,7 @@
{
return name;
}
- return content.getName();
+ return getContent().getName();
}
public void setName(String name)
@@ -83,12 +93,12 @@
{
return displayName;
}
- return content.getDisplayName();
+ return getContent().getDisplayName();
}
public GateIn getGateIn()
{
- return content.getGateIn();
+ return getContent().getGateIn();
}
public void setDisplayName(String displayName)
@@ -98,6 +108,11 @@
public T getContent()
{
+ if (content == null)
+ {
+ content = category.getRegistry().get(contentId);
+ }
+
return content;
}
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java 2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/PortletImpl.java 2011-08-08 16:23:15 UTC (rev 7008)
@@ -22,31 +22,20 @@
package org.gatein.portal.api.impl.content;
-import org.exoplatform.application.registry.Application;
import org.gatein.api.content.Content;
import org.gatein.api.content.Portlet;
import org.gatein.api.id.Id;
import org.gatein.api.util.Type;
import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.IdentifiableImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
-public class PortletImpl extends IdentifiableImpl<Portlet> implements Portlet
+public class PortletImpl extends AbstractPortlet<Portlet> implements Portlet
{
- private final Application application;
-
- public PortletImpl(Id<Portlet> id, Application application, GateInImpl gateIn)
+ public PortletImpl(Id<Portlet> id, org.gatein.pc.api.Portlet application, GateInImpl gateIn)
{
- super(id, application.getApplicationName(), gateIn);
- this.application = application;
+ super(id, application, gateIn);
}
- @Override
- public String toString()
- {
- return "Application '" + getName() + "' @" + getId();
- }
-
public Type<Portlet> getType()
{
return Content.PORTLET;
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java 2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/content/WSRPImpl.java 2011-08-08 16:23:15 UTC (rev 7008)
@@ -22,20 +22,18 @@
package org.gatein.portal.api.impl.content;
-import org.exoplatform.application.registry.Application;
import org.gatein.api.content.Content;
import org.gatein.api.content.WSRP;
import org.gatein.api.id.Id;
import org.gatein.api.util.Type;
import org.gatein.portal.api.impl.GateInImpl;
-import org.gatein.portal.api.impl.IdentifiableImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
-public class WSRPImpl extends IdentifiableImpl<WSRP> implements WSRP
+public class WSRPImpl extends AbstractPortlet<WSRP> implements WSRP
{
- public WSRPImpl(Id<WSRP> id, Application application, GateInImpl gateIn)
+ public WSRPImpl(Id<WSRP> id, org.gatein.pc.api.Portlet application, GateInImpl gateIn)
{
- super(id, application.getApplicationName(), gateIn);
+ super(id, application, gateIn);
}
public Type<WSRP> getType()
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationContext.java 2011-08-08 16:23:15 UTC (rev 7008)
@@ -26,6 +26,7 @@
import org.gatein.api.id.Context;
import org.gatein.api.id.Id;
import org.gatein.api.id.Identifiable;
+import org.gatein.portal.api.impl.GateInImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
public class ComplexApplicationContext implements Context
@@ -103,4 +104,14 @@
{
return false; // no components are hierarchical
}
+
+ public boolean hasComponent(String component)
+ {
+ return GateInImpl.APPLICATION_COMPONENT.equals(component) || GateInImpl.PORTLET_COMPONENT.equals(component) || GateInImpl.CATEGORY_COMPONENT.equals(component) || GateInImpl.INVOKER_COMPONENT.equals(component);
+ }
+
+ public void validateValueFor(String component, String value) throws IllegalArgumentException
+ {
+ // todo
+ }
}
Modified: portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java
===================================================================
--- portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/id/ComplexApplicationId.java 2011-08-08 16:23:15 UTC (rev 7008)
@@ -25,6 +25,7 @@
import org.gatein.api.content.Portlet;
import org.gatein.api.id.Context;
import org.gatein.api.id.Id;
+import org.gatein.api.id.RenderingContext;
import org.gatein.portal.api.impl.GateInImpl;
/** @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a> */
@@ -37,9 +38,6 @@
private final String portlet;
private final Context context;
- public static final String INVOKER_COMPONENT = "invoker";
- public static final String CATEGORY_COMPONENT = "category";
-
public ComplexApplicationId(String category, String appName, String portletName, ComplexApplicationContext context)
{
this.category = category;
@@ -54,7 +52,7 @@
return toString(context);
}
- public String toString(Context context)
+ public String toString(RenderingContext context)
{
if (this.context.equals(context))
{
@@ -117,19 +115,19 @@
public String getComponent(String component)
{
- if (GateInImpl.APPLICATION_COMPONENT_NAME.equals(component))
+ if (GateInImpl.APPLICATION_COMPONENT.equals(component))
{
return app;
}
- else if (GateInImpl.PORTLET_COMPONENT_NAME.equals(component))
+ else if (GateInImpl.PORTLET_COMPONENT.equals(component))
{
return portlet;
}
- else if (INVOKER_COMPONENT.equals(component))
+ else if (GateInImpl.INVOKER_COMPONENT.equals(component))
{
return LOCAL;
}
- else if (CATEGORY_COMPONENT.equals(component))
+ else if (GateInImpl.CATEGORY_COMPONENT.equals(component))
{
return category;
}
@@ -169,6 +167,11 @@
// do nothing as it shouldn't be called
}
+ public boolean knowsComponent(String name)
+ {
+ return context.hasComponent(name);
+ }
+
public int compareTo(Id o)
{
return toString().compareTo(o.toString());
Modified: portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java
===================================================================
--- portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-08 14:25:29 UTC (rev 7007)
+++ portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/id/ComplexApplicationContextTestCase.java 2011-08-08 16:23:15 UTC (rev 7008)
@@ -34,9 +34,9 @@
public void checkParsing()
{
final Id<Portlet> id = ComplexApplicationContext.INSTANCE.parse("category/local._webapp.portlet", Portlet.class);
- assert "category".equals(id.getComponent(ComplexApplicationId.CATEGORY_COMPONENT));
- assert "webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT_NAME));
- assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT_NAME));
+ assert "category".equals(id.getComponent(GateInImpl.CATEGORY_COMPONENT));
+ assert "webapp".equals(id.getComponent(GateInImpl.APPLICATION_COMPONENT));
+ assert "portlet".equals(id.getComponent(GateInImpl.PORTLET_COMPONENT));
assert id.equals(ComplexApplicationContext.INSTANCE.parse(id.toString()));
}
13 years, 5 months
gatein SVN: r7007 - in epp/portal/branches/EPP_5_2_Branch: web/portal/src/main/webapp/WEB-INF and 14 other directories.
by do-not-reply@jboss.org
Author: hfnukal
Date: 2011-08-08 10:25:29 -0400 (Mon, 08 Aug 2011)
New Revision: 7007
Added:
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/ErrorLoginFilter.java
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidAttemptKey.java
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidLoginAttemptsService.java
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidLoginPolicy.java
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/LoginDetectorFilter.java
Modified:
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml
epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/web.xml
epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/src/main/webapp/WEB-INF/conf/configuration.xml
Log:
JBEPP-808 add ability to send email on registration and x successive failures
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java 2011-08-08 08:59:59 UTC (rev 7006)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java 2011-08-08 14:25:29 UTC (rev 7007)
@@ -19,10 +19,9 @@
package org.exoplatform.account.webui.component;
-import org.exoplatform.portal.webui.CaptchaValidator;
-import org.exoplatform.portal.webui.UICaptcha;
-import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.portal.registration.PostRegistrationService;
import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.User;
import org.exoplatform.services.organization.UserHandler;
import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.application.WebuiRequestContext;
@@ -45,9 +44,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
import nl.captcha.Captcha;
/**
@@ -65,6 +61,8 @@
{
private final static String[] ACTIONS = {"Subscribe", "Reset"};
+
+ static final String ATTR_USER = "UIRegisterForm$User";
public UIRegisterForm() throws Exception
{
@@ -121,9 +119,14 @@
if (registerInput.save(userHandler, context))
{
- //TODO: Send email and add Account Activating feature
+ //TODO: Add Account Activating feature
UIApplication uiApp = context.getUIApplication();
- uiApp.addMessage(new ApplicationMessage("UIRegisterForm.registerWithSuccess.message", null));
+ uiApp.addMessage(new ApplicationMessage("UIRegisterForm.registerWithSuccess.message", null));
+
+ // Send mail to administrator after successful registration of user
+ PostRegistrationService postRegistrationService = uiApp.getApplicationComponent(PostRegistrationService.class);
+ User user = (User)context.getAttribute(ATTR_USER);
+ postRegistrationService.sendMailAfterSuccessfulRegistration(user);
}
//Invalidate the capcha
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java 2011-08-08 08:59:59 UTC (rev 7006)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java 2011-08-08 14:25:29 UTC (rev 7007)
@@ -20,7 +20,6 @@
import javax.portlet.PortletPreferences;
-import org.exoplatform.portal.pom.config.Utils;
import org.exoplatform.portal.webui.CaptchaValidator;
import org.exoplatform.portal.webui.UICaptcha;
import org.exoplatform.services.organization.Query;
@@ -173,6 +172,9 @@
userHandler.createUser(user, true);//Broadcast user creaton event
reset();//Reset the input form
+
+ // save user as attribute to WebuiRequestContext for later use
+ context.setAttribute(UIRegisterForm.ATTR_USER, user);
return true;
}
}
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml 2011-08-08 08:59:59 UTC (rev 7006)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/conf/configuration.xml 2011-08-08 14:25:29 UTC (rev 7007)
@@ -55,4 +55,7 @@
<import>war:/conf/mail/portal-mail-configuration.xml</import>
<import>war:/conf/portal/portal-configuration.xml</import>
<import>war:/conf/portal/application-registry-configuration.xml</import>
+
+ <!-- Administration improvements -->
+ <import>war:/conf/admin/admin-configuration.xml</import>
</configuration>
Modified: epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/web.xml 2011-08-08 08:59:59 UTC (rev 7006)
+++ epp/portal/branches/EPP_5_2_Branch/web/portal/src/main/webapp/WEB-INF/web.xml 2011-08-08 14:25:29 UTC (rev 7007)
@@ -74,7 +74,7 @@
<filter>
<filter-name>RestEncodingFilter</filter-name>
<filter-class>org.exoplatform.services.rest.servlet.RestEncodingFilter</filter-class>
- <init-param>
+ <init-param>
<param-name>REQUEST_ENCODING</param-name>
<param-value>UTF-8</param-value>
</init-param>
@@ -99,6 +99,18 @@
<filter-class>org.exoplatform.container.web.PortalContainerFilter</filter-class>
</filter>
+ <!-- Uncomment ErrorLoginFilter and LoginDetectorFilter for sending mail after successive number of bad login attempts. -->
+ <!--
+ <filter>
+ <filter-name>ErrorLoginFilter</filter-name>
+ <filter-class>org.exoplatform.web.security.errorlogin.ErrorLoginFilter</filter-class>
+ </filter>
+ <filter>
+ <filter-name>LoginDetectorFilter</filter-name>
+ <filter-class>org.exoplatform.web.security.errorlogin.LoginDetectorFilter</filter-class>
+ </filter>
+ -->
+
<filter-mapping>
<filter-name>PortalContainerFilter</filter-name>
<url-pattern>/*</url-pattern>
Added: epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/ErrorLoginFilter.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/ErrorLoginFilter.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/ErrorLoginFilter.java 2011-08-08 14:25:29 UTC (rev 7007)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2010, 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.exoplatform.web.security.errorlogin;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.exoplatform.container.web.AbstractFilter;
+
+/**
+ * Filter should be called to detect invalid login attempt to portal.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ * @version $Revision$
+ */
+public class ErrorLoginFilter extends AbstractFilter
+{
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ HttpServletRequest httpRequest = (HttpServletRequest)request;
+
+ // get informations about user
+ String clientIPAddress = request.getRemoteAddr();
+ String sessionID = httpRequest.getSession().getId();
+ String username = httpRequest.getParameter("j_username");
+
+ // Call InvalidLoginService, which can perform some actions (aka send mail to portal administrator)
+ InvalidLoginAttemptsService invalidLoginService = (InvalidLoginAttemptsService)getContainer().getComponentInstanceOfType(InvalidLoginAttemptsService.class);
+ invalidLoginService.badLoginAttempt(sessionID, username, clientIPAddress);
+
+ // Continue with request
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void destroy()
+ {
+ }
+
+}
Added: epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidAttemptKey.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidAttemptKey.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidAttemptKey.java 2011-08-08 14:25:29 UTC (rev 7007)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2010, 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.exoplatform.web.security.errorlogin;
+
+import org.exoplatform.commons.utils.Safe;
+
+/**
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ * @version $Revision$
+ */
+class InvalidAttemptKey
+{
+ private final String sessionId;
+ private final String username;
+ private final String hostname;
+
+ private InvalidAttemptKey(String sessionId, String username, String hostname)
+ {
+ this.sessionId = sessionId;
+ this.username = username;
+ this.hostname = hostname;
+ }
+
+ public static InvalidAttemptKey createKey(InvalidLoginPolicy policy, String sessionId, String username, String hostname)
+ {
+ switch (policy)
+ {
+ case SESSION: return new InvalidAttemptKey(sessionId, null, null);
+
+ case SESSION_AND_USER: return new InvalidAttemptKey(sessionId, username, null);
+
+ case SERVER: return new InvalidAttemptKey(null, null, hostname);
+
+ default: throw new IllegalArgumentException("Non-expected value of InvalidLoginPolicy.");
+ }
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof InvalidAttemptKey)
+ {
+ InvalidAttemptKey that = (InvalidAttemptKey)obj;
+ return Safe.equals(sessionId, that.sessionId) && Safe.equals(username, that.username) && Safe.equals(hostname, that.hostname);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ int result = 1234567;
+ if (sessionId != null)
+ {
+ result = sessionId.hashCode();
+ }
+ if (username != null)
+ {
+ result = result ^ username.hashCode();
+ }
+ if (hostname != null)
+ {
+ result = result ^ hostname.hashCode();
+ }
+ return result;
+ }
+
+}
+
Added: epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidLoginAttemptsService.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidLoginAttemptsService.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidLoginAttemptsService.java 2011-08-08 14:25:29 UTC (rev 7007)
@@ -0,0 +1,200 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2010, 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.exoplatform.web.security.errorlogin;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.services.mail.MailService;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+/**
+ * Service can be used to track invalid login attempts of users and do some actions when
+ * some number of successive login attempts is detected.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ * @version $Revision$
+ */
+public class InvalidLoginAttemptsService
+{
+ private static final Logger log = LoggerFactory.getLogger(InvalidLoginAttemptsService.class);
+
+ /**
+ * If false, then feature of sending mails to administrator about bad login attempts is disabled.
+ */
+ private final Boolean sendMailEnabled;
+
+ /**
+ * Number of successive invalid login attempts of user, after the mail will be send.
+ */
+ private final Integer numberOfFailedAttempts;
+
+ /**
+ * Policy for indication that invalid login attempts are coming from same source.
+ * Valid values are SESSION, SESSION_AND_USER, SERVER. SESSION is default and it means that login attempts
+ * are coming from same HTTP session. SESSION_AND_USER is indicating login attempts of same user and from same HTTP session.
+ * SERVER means login attempts from same remote server.
+ */
+ private final InvalidLoginPolicy invalidLoginPolicy;
+
+ /**
+ * This will be used as 'from' header in admin mail
+ */
+ private final String mailFrom;
+
+ /**
+ * This should be admin e-mail address, where e-mail about invalid login attempts will be send.
+ */
+ private final String mailTo;
+
+ /**
+ * Subject of email about invalid login attempts.
+ */
+ private final String mailSubject;
+
+ /**
+ * Content of mail message, which will be send to administrator.
+ * Real content will be based on value of parameter "invalidLoginPolicy". Tokens like ${username}, ${sessionId}, ${hostname} will be replaced with real values from attacker.
+ */
+ private final String mailMessage;
+
+ /**
+ * MailService injected by exo kernel.
+ */
+ private final MailService mailService;
+
+ /**
+ * Helper map to track login attempts from different users.
+ */
+ private final ConcurrentMap<InvalidAttemptKey, Integer> attemptMap = new ConcurrentHashMap<InvalidAttemptKey, Integer>();
+
+ public InvalidLoginAttemptsService(InitParams params, MailService mailService)
+ {
+ this.mailService = mailService;
+ this.sendMailEnabled = Boolean.valueOf(params.getValueParam("sendingMailsEnabled").getValue());
+ this.numberOfFailedAttempts = Integer.parseInt(params.getValueParam("numberOfFailedAttempts").getValue());
+ this.invalidLoginPolicy = InvalidLoginPolicy.valueOf(params.getValueParam("invalidLoginPolicy").getValue());
+ this.mailFrom = params.getValueParam("mailFrom").getValue();
+ this.mailTo = params.getValueParam("mailTo").getValue();
+ this.mailSubject = params.getValueParam("mailSubject").getValue();
+ this.mailMessage = params.getPropertiesParam("mailMessage").getProperty(invalidLoginPolicy.toString());
+ }
+
+ /**
+ * This should be called each time when invalid login attempt is detected (typically from HttpFilter)
+ *
+ * @param sessionId
+ * @param username
+ * @param hostname
+ */
+ public void badLoginAttempt(String sessionId, String username, String hostname)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(new StringBuilder("Detected invalid login attempt. Session id=").append(sessionId).append(
+ ", username=").append(username).append(", hostname=").append(hostname));
+ }
+ if (numberOfFailedAttempts == 1)
+ {
+ sendMail(sessionId, username, hostname);
+ return;
+ }
+
+ InvalidAttemptKey key = InvalidAttemptKey.createKey(invalidLoginPolicy, sessionId, username, hostname);
+
+ // TODO: better synchronization
+ int currentCount = 1;
+ if (attemptMap.containsKey(key))
+ {
+ currentCount = attemptMap.get(key) + 1;
+ if (currentCount == numberOfFailedAttempts)
+ {
+ sendMail(sessionId, username, hostname);
+ attemptMap.remove(key);
+ }
+ else
+ {
+ attemptMap.put(key, currentCount);
+ }
+ }
+ else
+ {
+ attemptMap.put(key, currentCount);
+ }
+ }
+
+ /**
+ * This should be called each time successful login attempt is detected. We need to use it to clean previous bad attempts
+ * when we have good attempt.
+ *
+ * @param sessionId
+ * @param username
+ * @param hostname
+ */
+ public void successfulLoginAttempt(String sessionId, String username, String hostname)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(new StringBuilder("Detected successful login attempt. Session id=").append(sessionId).append(
+ ", username=").append(username).append(", hostname=").append(hostname));
+ }
+ InvalidAttemptKey key = InvalidAttemptKey.createKey(invalidLoginPolicy, sessionId, username, hostname);
+ attemptMap.remove(key);
+ }
+
+ private void sendMail(String sessionId, String username, String hostname)
+ {
+ // return if sending mails disabled in configuration.
+ if (!sendMailEnabled)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Sending of mails disabled. Mail won't be send about invalid login attempts.");
+ }
+ return;
+ }
+
+ // replace tokens from configuration with real values.
+ String result = mailMessage.replaceAll("\\$\\{sessionId\\}", sessionId);
+ result = result.replaceAll("\\$\\{username\\}", username);
+ result = result.replaceAll("\\$\\{hostname\\}", hostname);
+ result = result.replaceAll("\\$\\{number\\}", String.valueOf(numberOfFailedAttempts));
+
+ try
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Sending mail about the invalid login attempts. Mail message is: " + result);
+ }
+ mailService.sendMessage(mailFrom, mailTo, mailSubject, result);
+ }
+ catch (Exception e)
+ {
+ // log exception but not throw it when sending of mail happen
+ log.error("Error when sending mail to admin after detected invalid number of login attempts.", e);
+ }
+ }
+
+}
Added: epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidLoginPolicy.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidLoginPolicy.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/InvalidLoginPolicy.java 2011-08-08 14:25:29 UTC (rev 7007)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2010, 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.exoplatform.web.security.errorlogin;
+
+/**
+ * Policy for indication that invalid login attempts are coming from same source. For example: <br>
+ * If value is SERVER, then mail will be send after detection of 3 successive invalid login attempts from same remote server.<br>
+ * If value is SESSION, then mail will be send after detection of 3 successive invalid login attempts from same HTTP session.<br>
+ * etc.
+ *
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ * @version $Revision$
+ */
+public enum InvalidLoginPolicy
+{
+ /**
+ * SESSION is default and it means that login attempts are coming from same HTTP session.
+ */
+ SESSION,
+
+ /**
+ * SESSION_AND_USER is indicating login attempts of same user and from same HTTP session.
+ */
+ SESSION_AND_USER,
+
+ /**
+ * SERVER means login attempts from same remote server.
+ */
+ SERVER
+
+}
Added: epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/LoginDetectorFilter.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/LoginDetectorFilter.java (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/component/web/security/src/main/java/org/exoplatform/web/security/errorlogin/LoginDetectorFilter.java 2011-08-08 14:25:29 UTC (rev 7007)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2010, 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.exoplatform.web.security.errorlogin;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.exoplatform.container.web.AbstractFilter;
+import org.exoplatform.services.security.ConversationState;
+
+/**
+ * Filter should be called to detect successful login of user into portal and call InvalidLoginAttemptsService.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ * @version $Revision$
+ */
+public class LoginDetectorFilter extends AbstractFilter
+{
+ private static final String ATTR_LOGIN_DETECTED = "LoginDetectorFilter.loginDetected";
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException
+ {
+ HttpServletRequest httpRequest = (HttpServletRequest)request;
+ ConversationState state = ConversationState.getCurrent();
+
+ if (state != null)
+ {
+ if (state.getAttribute(ATTR_LOGIN_DETECTED) == null)
+ {
+ String clientIPAddress = request.getRemoteAddr();
+ String sessionID = httpRequest.getSession().getId();
+ String username = httpRequest.getRemoteUser();
+ state.setAttribute(ATTR_LOGIN_DETECTED, true);
+
+ InvalidLoginAttemptsService invalidLoginService = (InvalidLoginAttemptsService)getContainer().getComponentInstanceOfType(InvalidLoginAttemptsService.class);
+ invalidLoginService.successfulLoginAttempt(sessionID, username, clientIPAddress);
+ }
+ }
+ chain.doFilter(request, response);
+ }
+
+ @Override
+ public void destroy()
+ {
+ }
+
+}
Modified: epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/src/main/webapp/WEB-INF/conf/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/src/main/webapp/WEB-INF/conf/configuration.xml 2011-08-08 08:59:59 UTC (rev 7006)
+++ epp/portal/branches/EPP_5_2_Branch/wsrp-integration/extension-war/src/main/webapp/WEB-INF/conf/configuration.xml 2011-08-08 14:25:29 UTC (rev 7007)
@@ -28,4 +28,7 @@
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd">
<import profiles="jboss">war:/conf/wsrp/wsrp-configuration.xml</import>
<import profiles="jboss">war:/conf/wsrp/jcr-configuration.xml</import>
+
+ <!-- Administration improvements -->
+ <import>war:/conf/admin/admin-configuration.xml</import>
</configuration>
13 years, 5 months