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));
Show replies by date