Author: julien_viet
Date: 2009-11-23 12:22:31 -0500 (Mon, 23 Nov 2009)
New Revision: 768
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/MOPFormatter.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ComparisonException.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentManagerRegistry.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentRegistration.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextComparator.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextProviderRegistry.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextResolver.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSite.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSiteContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/LinkImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageLinkImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSite.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSiteContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SharedSite.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SharedSiteContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIBodyImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIComponentImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIContainerImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIWindowImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/URLLinkImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSite.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSiteContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceObjectImpl.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/AbstractCustomization.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContentState.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextSpecialization.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextType.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextTypeContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/CustomizationContainer.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceClone.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceCustomization.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceSpecialization.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/spi/content/WorkspaceCustomizationPolicy.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/AbstractAttributes.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/SimpleAttributes.java
components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/Tools.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/AbstractPOMTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/POMFormatterTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/composer/StructureIteratorTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/BiltoTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/CustomizationContextComparatorTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/CustomizationTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/AttributesTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/ObjectTypeTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/POMTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/QueryTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/WorkspaceTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/content/CustomizationTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/Gadget.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/GadgetContentProvider.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/GadgetState.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletContentProvider.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletDefinition.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletPreferenceState.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletPreferencesState.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/Preference.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/Preferences.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PreferencesBuilder.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/KeyTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/ToolsTestCase.java
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/ValueTypeTestCase.java
Log:
code reformat to GateIn conventions
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/MOPFormatter.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/MOPFormatter.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/MOPFormatter.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -25,122 +25,150 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class MOPFormatter implements ObjectFormatter {
+public class MOPFormatter implements ObjectFormatter
+{
- private static boolean isSpecialChar(char c) {
- return getCode(c) != null;
- }
+ private static boolean isSpecialChar(char c)
+ {
+ return getCode(c) != null;
+ }
- private static String getCode(char c) {
- if (c == 0x9
- || c == 0xA
- || c == 0xD
- || (c >= 0x20 && c <= 0xD7FF)
- || (c >= 0xE000 && c <= 0xFFFD)
- || (c >= 0x10000 && c <= 0x10FFFF)) {
- switch (c) {
- case '{':
- return "00";
- case '}':
- return "01";
- case '.':
- return "02";
- case '/':
- return "03";
- case ':':
- return "04";
- case '[':
- return "05";
- case ']':
- return "06";
- case '|':
- return "07";
- case '*':
- return "08";
- case '%':
- return "09";
- default:
- return null;
+ private static String getCode(char c)
+ {
+ if (c == 0x9
+ || c == 0xA
+ || c == 0xD
+ || (c >= 0x20 && c <= 0xD7FF)
+ || (c >= 0xE000 && c <= 0xFFFD)
+ || (c >= 0x10000 && c <= 0x10FFFF))
+ {
+ switch (c)
+ {
+ case '{':
+ return "00";
+ case '}':
+ return "01";
+ case '.':
+ return "02";
+ case '/':
+ return "03";
+ case ':':
+ return "04";
+ case '[':
+ return "05";
+ case ']':
+ return "06";
+ case '|':
+ return "07";
+ case '*':
+ return "08";
+ case '%':
+ return "09";
+ default:
+ return null;
+ }
}
- } else {
- throw new UnsupportedOperationException();
- }
- }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
- private static final char[] table = new char[] {
- '{', '}', '.', '/', ':', '[',
']', '|', '*', '%'
- };
+ private static final char[] table = new char[]{
+ '{', '}', '.', '/', ':', '[',
']', '|', '*', '%'
+ };
- private String decode(String s, int from) {
- StringBuffer buffer = new StringBuffer(s.length());
- buffer.append(s, 0, from);
- int to = s.length();
- while (from < to) {
- char c = s.charAt(from++);
- if (c == '%') {
- if (from + 1 >= to) {
- throw new IllegalStateException("Cannot decode wrong name " + s);
- }
- char c1 = s.charAt(from++);
- if (c1 != '0') {
- throw new IllegalStateException("Cannot decode wrong name " + s);
- }
- char c2 = s.charAt(from++);
- if (c2 < '0' || c2 > '9') {
- throw new IllegalStateException("Cannot decode wrong name " + s);
- }
- buffer.append(table[c2 - '0']);
- } else {
- buffer.append(c);
+ private String decode(String s, int from)
+ {
+ StringBuffer buffer = new StringBuffer(s.length());
+ buffer.append(s, 0, from);
+ int to = s.length();
+ while (from < to)
+ {
+ char c = s.charAt(from++);
+ if (c == '%')
+ {
+ if (from + 1 >= to)
+ {
+ throw new IllegalStateException("Cannot decode wrong name " +
s);
+ }
+ char c1 = s.charAt(from++);
+ if (c1 != '0')
+ {
+ throw new IllegalStateException("Cannot decode wrong name " +
s);
+ }
+ char c2 = s.charAt(from++);
+ if (c2 < '0' || c2 > '9')
+ {
+ throw new IllegalStateException("Cannot decode wrong name " +
s);
+ }
+ buffer.append(table[c2 - '0']);
+ }
+ else
+ {
+ buffer.append(c);
+ }
}
- }
- return buffer.toString();
- }
+ return buffer.toString();
+ }
- public String decodeNodeName(FormatterContext context, String internalName) {
- int length = internalName.length();
- for (int i = 0;i < length;i++) {
- char c = internalName.charAt(i);
- if (c == '%') {
- return decode(internalName, i);
+ public String decodeNodeName(FormatterContext context, String internalName)
+ {
+ int length = internalName.length();
+ for (int i = 0; i < length; i++)
+ {
+ char c = internalName.charAt(i);
+ if (c == '%')
+ {
+ return decode(internalName, i);
+ }
}
- }
- return internalName;
- }
+ return internalName;
+ }
- private String encode(String s, int from) {
- StringBuffer buffer = new StringBuffer((s.length() * 5) >> 2);
- buffer.append(s, 0, from);
- int to = s.length();
- while (from < to) {
- char c = s.charAt(from++);
- String code = getCode(c);
- if (code != null) {
- buffer.append('%');
- buffer.append(code);
- } else {
- buffer.append(c);
+ private String encode(String s, int from)
+ {
+ StringBuffer buffer = new StringBuffer((s.length() * 5) >> 2);
+ buffer.append(s, 0, from);
+ int to = s.length();
+ while (from < to)
+ {
+ char c = s.charAt(from++);
+ String code = getCode(c);
+ if (code != null)
+ {
+ buffer.append('%');
+ buffer.append(code);
+ }
+ else
+ {
+ buffer.append(c);
+ }
}
- }
- return buffer.toString();
- }
+ return buffer.toString();
+ }
- public String encodeNodeName(FormatterContext context, String externalName) {
- int length = externalName.length();
- for (int i = 0;i < length;i++) {
- char c = externalName.charAt(i);
- if (isSpecialChar(c)) {
- return encode(externalName, i);
+ public String encodeNodeName(FormatterContext context, String externalName)
+ {
+ int length = externalName.length();
+ for (int i = 0; i < length; i++)
+ {
+ char c = externalName.charAt(i);
+ if (isSpecialChar(c))
+ {
+ return encode(externalName, i);
+ }
}
- }
- return externalName;
- }
+ return externalName;
+ }
- public String decodePropertyName(FormatterContext context, String internalName) {
- return internalName;
- }
+ public String decodePropertyName(FormatterContext context, String internalName)
+ {
+ return internalName;
+ }
- public String encodePropertyName(FormatterContext context, String externalName) {
- return externalName;
- }
+ public String encodePropertyName(FormatterContext context, String externalName)
+ {
+ return externalName;
+ }
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ComparisonException.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ComparisonException.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ComparisonException.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -22,20 +22,25 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class ComparisonException extends RuntimeException {
+public class ComparisonException extends RuntimeException
+{
- public ComparisonException() {
- }
+ public ComparisonException()
+ {
+ }
- public ComparisonException(String message) {
- super(message);
- }
+ public ComparisonException(String message)
+ {
+ super(message);
+ }
- public ComparisonException(String message, Throwable cause) {
- super(message, cause);
- }
+ public ComparisonException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
- public ComparisonException(Throwable cause) {
- super(cause);
- }
+ public ComparisonException(Throwable cause)
+ {
+ super(cause);
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentManagerRegistry.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentManagerRegistry.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentManagerRegistry.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -30,29 +30,36 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class ContentManagerRegistry {
+public class ContentManagerRegistry
+{
- /** The various providers. */
- public final transient Map<String, ContentRegistration> providers;
+ /** The various providers. */
+ public final transient Map<String, ContentRegistration> providers;
- public ContentManagerRegistry() {
- providers = new HashMap<String, ContentRegistration>();
- }
+ public ContentManagerRegistry()
+ {
+ providers = new HashMap<String, ContentRegistration>();
+ }
- public synchronized <S> void register(ContentType<S> contentType,
ContentProvider<S> contentProvider) {
- if (contentType == null) {
- throw new NullPointerException();
- }
- if (contentProvider == null) {
- throw new NullPointerException();
- }
- providers.put(contentType.getMimeType(), new ContentRegistration(contentType,
contentProvider));
- }
+ public synchronized <S> void register(ContentType<S> contentType,
ContentProvider<S> contentProvider)
+ {
+ if (contentType == null)
+ {
+ throw new NullPointerException();
+ }
+ if (contentProvider == null)
+ {
+ throw new NullPointerException();
+ }
+ providers.put(contentType.getMimeType(), new ContentRegistration(contentType,
contentProvider));
+ }
- public synchronized void unregister(ContentType contentType) {
- if (contentType == null) {
- throw new NullPointerException();
- }
- providers.remove(contentType.getMimeType());
- }
+ public synchronized void unregister(ContentType contentType)
+ {
+ if (contentType == null)
+ {
+ throw new NullPointerException();
+ }
+ providers.remove(contentType.getMimeType());
+ }
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentRegistration.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentRegistration.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/ContentRegistration.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -25,24 +25,28 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class ContentRegistration {
+public class ContentRegistration
+{
- /** . */
- private final ContentType<?> contentType;
+ /** . */
+ private final ContentType<?> contentType;
- /** . */
- private final ContentProvider provider;
+ /** . */
+ private final ContentProvider provider;
- public ContentRegistration(ContentType<?> contentType, ContentProvider provider)
{
- this.contentType = contentType;
- this.provider = provider;
- }
+ public ContentRegistration(ContentType<?> contentType, ContentProvider
provider)
+ {
+ this.contentType = contentType;
+ this.provider = provider;
+ }
- public ContentType<?> getContentType() {
- return contentType;
- }
+ public ContentType<?> getContentType()
+ {
+ return contentType;
+ }
- public ContentProvider getProvider() {
- return provider;
- }
+ public ContentProvider getProvider()
+ {
+ return provider;
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextComparator.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextComparator.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextComparator.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,53 +28,71 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class CustomizationContextComparator implements
Comparator<CustomizationContext> {
+public class CustomizationContextComparator implements
Comparator<CustomizationContext>
+{
- /** . */
- private List<String> contextOrder;
+ /** . */
+ private List<String> contextOrder;
- public CustomizationContextComparator(List<String> contextOrder) {
- this.contextOrder = contextOrder;
- }
+ public CustomizationContextComparator(List<String> contextOrder)
+ {
+ this.contextOrder = contextOrder;
+ }
- public CustomizationContextComparator(String... contextOrder) {
- this(Arrays.asList(contextOrder));
- }
+ public CustomizationContextComparator(String... contextOrder)
+ {
+ this(Arrays.asList(contextOrder));
+ }
- public int compare(CustomizationContext c1, CustomizationContext c2) {
- String t1 = c1.getContextType();
- int i1 = contextOrder.indexOf(t1);
- if (i1 == -1) {
- throw new ComparisonException("Context type " + t1 + " cannot be
used for comparison");
- }
+ public int compare(CustomizationContext c1, CustomizationContext c2)
+ {
+ String t1 = c1.getContextType();
+ int i1 = contextOrder.indexOf(t1);
+ if (i1 == -1)
+ {
+ throw new ComparisonException("Context type " + t1 + " cannot be
used for comparison");
+ }
- //
- String t2 = c2.getContextType();
- int i2 = contextOrder.indexOf(t2);
- if (i2 == -1) {
- throw new ComparisonException("Context type " + t1 + " cannot be
used for comparison");
- }
+ //
+ String t2 = c2.getContextType();
+ int i2 = contextOrder.indexOf(t2);
+ if (i2 == -1)
+ {
+ throw new ComparisonException("Context type " + t1 + " cannot be
used for comparison");
+ }
- //
- if (i1 < i2) {
- return -1;
- } else if (i1 > i2) {
- return 1;
- }
+ //
+ if (i1 < i2)
+ {
+ return -1;
+ }
+ else if (i1 > i2)
+ {
+ return 1;
+ }
- //
- if (c1.contains(c2)) {
- if (c2.contains(c1)) {
- return 0;
- } else {
- return -1;
+ //
+ if (c1.contains(c2))
+ {
+ if (c2.contains(c1))
+ {
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
}
- } else {
- if (c2.contains(c1)) {
- return 1;
- } else {
- throw new ComparisonException("Cannot compare customization contexts "
+ c1 + " and " + c2);
+ else
+ {
+ if (c2.contains(c1))
+ {
+ return 1;
+ }
+ else
+ {
+ throw new ComparisonException("Cannot compare customization contexts
" + c1 + " and " + c2);
+ }
}
- }
- }
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextProviderRegistry.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextProviderRegistry.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextProviderRegistry.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -30,49 +30,60 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class CustomizationContextProviderRegistry implements CustomizationContextResolver
{
+public class CustomizationContextProviderRegistry implements
CustomizationContextResolver
+{
- /** The various providers. */
- final transient Map<String, CustomizationContextProvider> resolvers;
+ /** The various providers. */
+ final transient Map<String, CustomizationContextProvider> resolvers;
- public CustomizationContextProviderRegistry() {
- resolvers = new HashMap<String, CustomizationContextProvider>();
- }
+ public CustomizationContextProviderRegistry()
+ {
+ resolvers = new HashMap<String, CustomizationContextProvider>();
+ }
- public synchronized void register(String contextType, CustomizationContextProvider
contentProvider) {
- if (contextType == null) {
- throw new NullPointerException();
- }
- if (contentProvider == null) {
- throw new NullPointerException();
- }
- resolvers.put(contextType, contentProvider);
- }
+ public synchronized void register(String contextType, CustomizationContextProvider
contentProvider)
+ {
+ if (contextType == null)
+ {
+ throw new NullPointerException();
+ }
+ if (contentProvider == null)
+ {
+ throw new NullPointerException();
+ }
+ resolvers.put(contextType, contentProvider);
+ }
- public synchronized void unregister(String contextType) {
- if (contextType == null) {
- throw new NullPointerException();
- }
- resolvers.remove(contextType);
- }
+ public synchronized void unregister(String contextType)
+ {
+ if (contextType == null)
+ {
+ throw new NullPointerException();
+ }
+ resolvers.remove(contextType);
+ }
- public CustomizationContext resolve(String contextType, String contextId) {
- if (contextType == null) {
- throw new NullPointerException();
- }
- if (contextId == null) {
- throw new NullPointerException();
- }
+ public CustomizationContext resolve(String contextType, String contextId)
+ {
+ if (contextType == null)
+ {
+ throw new NullPointerException();
+ }
+ if (contextId == null)
+ {
+ throw new NullPointerException();
+ }
- //
- CustomizationContextProvider provider = resolvers.get(contextType);
+ //
+ CustomizationContextProvider provider = resolvers.get(contextType);
- //
- if (provider != null) {
- return provider.resolveContext(contextId);
- }
+ //
+ if (provider != null)
+ {
+ return provider.resolveContext(contextId);
+ }
- //
- return null;
- }
+ //
+ return null;
+ }
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextResolver.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextResolver.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/content/CustomizationContextResolver.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -24,8 +24,9 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public interface CustomizationContextResolver {
+public interface CustomizationContextResolver
+{
- CustomizationContext resolve(String contextType, String contextId);
+ CustomizationContext resolve(String contextType, String contextId);
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSite.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSite.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSite.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,11 +28,13 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:groupsite")
-public abstract class GroupSite extends SiteImpl {
+public abstract class GroupSite extends SiteImpl
+{
- // Site implementation
***********************************************************************************************
+ // Site implementation
***********************************************************************************************
- public ObjectType<? extends Site> getObjectType() {
- return ObjectType.GROUP_SITE;
- }
+ public ObjectType<? extends Site> getObjectType()
+ {
+ return ObjectType.GROUP_SITE;
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSiteContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSiteContainer.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/GroupSiteContainer.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,9 +28,10 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:groupsites")
-public abstract class GroupSiteContainer extends SiteContainer<GroupSite> {
+public abstract class GroupSiteContainer extends SiteContainer<GroupSite>
+{
- @RelatedMappedBy("groupsites")
- public abstract WorkspaceImpl getWorkspace();
+ @RelatedMappedBy("groupsites")
+ public abstract WorkspaceImpl getWorkspace();
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/LinkImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/LinkImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/LinkImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -25,8 +25,9 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class LinkImpl extends WorkspaceObjectImpl implements Link {
+public abstract class LinkImpl extends WorkspaceObjectImpl implements Link
+{
- public abstract ObjectType<? extends Link> getObjectType();
+ public abstract ObjectType<? extends Link> getObjectType();
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationContainer.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationContainer.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -32,25 +32,27 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:navigationcontainer")
-public abstract class NavigationContainer {
+public abstract class NavigationContainer
+{
- @OneToOne
- @RelatedMappedBy("navigations")
- public abstract NavigationImpl getOwner();
+ @OneToOne
+ @RelatedMappedBy("navigations")
+ public abstract NavigationImpl getOwner();
- @OneToMany
- public abstract Map<String, NavigationImpl> getNavigationMap();
+ @OneToMany
+ public abstract Map<String, NavigationImpl> getNavigationMap();
@OneToMany
- public abstract List<NavigationImpl> getNavigationList();
+ public abstract List<NavigationImpl> getNavigationList();
- @Create
- public abstract NavigationImpl createNavigation();
+ @Create
+ public abstract NavigationImpl createNavigation();
- public NavigationImpl addNavigation(String name) {
- NavigationImpl page = createNavigation();
- page.setName(name);
- getNavigationList().add(page);
- return page;
- }
+ public NavigationImpl addNavigation(String name)
+ {
+ NavigationImpl page = createNavigation();
+ page.setName(name);
+ getNavigationList().add(page);
+ return page;
+ }
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/NavigationImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -40,107 +40,128 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:navigation")
-public abstract class NavigationImpl extends WorkspaceObjectImpl implements Navigation {
+public abstract class NavigationImpl extends WorkspaceObjectImpl implements Navigation
+{
- @OneToOne
- @RelatedMappedBy("rootnavigation")
- public abstract SiteImpl getParentSite();
+ @OneToOne
+ @RelatedMappedBy("rootnavigation")
+ public abstract SiteImpl getParentSite();
- @OneToOne
- @MappedBy("children")
- public abstract NavigationContainer getChildrenContainer();
+ @OneToOne
+ @MappedBy("children")
+ public abstract NavigationContainer getChildrenContainer();
- @ManyToOne
- public abstract NavigationContainer getParentContainer();
+ @ManyToOne
+ public abstract NavigationContainer getParentContainer();
- @OneToOne
- @MappedBy("link")
- public abstract LinkImpl getLink();
+ @OneToOne
+ @MappedBy("link")
+ public abstract LinkImpl getLink();
- public abstract LinkImpl setLink(LinkImpl target);
+ public abstract LinkImpl setLink(LinkImpl target);
- @Create
- public abstract NavigationImpl createNavigation(String name);
+ @Create
+ public abstract NavigationImpl createNavigation(String name);
- @Create
- public abstract URLLinkImpl createURLTarget();
+ @Create
+ public abstract URLLinkImpl createURLTarget();
- @Create
- public abstract PageLinkImpl createPageLink();
+ @Create
+ public abstract PageLinkImpl createPageLink();
- @ManyToOne(type = RelationshipType.PATH)
- @MappedBy("template")
- public abstract PageImpl getPageTemplate();
+ @ManyToOne(type = RelationshipType.PATH)
+ @MappedBy("template")
+ public abstract PageImpl getPageTemplate();
- public abstract void setPageTemplate(PageImpl template);
+ public abstract void setPageTemplate(PageImpl template);
- @Destroy
- public abstract void destroy();
+ @Destroy
+ public abstract void destroy();
- public ObjectType<? extends Navigation> getObjectType() {
- return ObjectType.NAVIGATION;
- }
+ public ObjectType<? extends Navigation> getObjectType()
+ {
+ return ObjectType.NAVIGATION;
+ }
- public Page getTemplate() {
- return getPageTemplate();
- }
+ public Page getTemplate()
+ {
+ return getPageTemplate();
+ }
- public void setTemplate(Page template) {
- setPageTemplate((PageImpl)template);
- }
+ public void setTemplate(Page template)
+ {
+ setPageTemplate((PageImpl)template);
+ }
- public Navigation getParent() {
- NavigationContainer parent = getParentContainer();
- if (parent != null) {
- return parent.getOwner();
- } else {
- return null;
- }
- }
+ public Navigation getParent()
+ {
+ NavigationContainer parent = getParentContainer();
+ if (parent != null)
+ {
+ return parent.getOwner();
+ }
+ else
+ {
+ return null;
+ }
+ }
- public List<? extends Navigation> getChildren() {
- NavigationContainer childrenContainer = getChildrenContainer();
- return childrenContainer.getNavigationList();
- }
+ public List<? extends Navigation> getChildren()
+ {
+ NavigationContainer childrenContainer = getChildrenContainer();
+ return childrenContainer.getNavigationList();
+ }
- public Navigation getChild(String name) {
- if (name == null) {
- throw new NullPointerException();
- }
- NavigationContainer childrenContainer = getChildrenContainer();
- return childrenContainer.getNavigationMap().get(name);
- }
+ public Navigation getChild(String name)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException();
+ }
+ NavigationContainer childrenContainer = getChildrenContainer();
+ return childrenContainer.getNavigationMap().get(name);
+ }
- public NavigationImpl addChild(String name) {
- NavigationContainer childrenContainer = getChildrenContainer();
- return childrenContainer.addNavigation(name);
- }
+ public NavigationImpl addChild(String name)
+ {
+ NavigationContainer childrenContainer = getChildrenContainer();
+ return childrenContainer.addNavigation(name);
+ }
- public <L extends Link> L linkTo(ObjectType<L> linkType) {
- setLink(null);
+ public <L extends Link> L linkTo(ObjectType<L> linkType)
+ {
+ setLink(null);
- //
- L link = null;
- if (linkType != null) {
- if (linkType.getJavaType().equals(PageLink.class)) {
- PageLinkImpl pl = createPageLink();
- setLink(pl);
- link = (L)pl;
- } else {
- throw new UnsupportedOperationException("Links of type " + linkType +
" are not supported");
+ //
+ L link = null;
+ if (linkType != null)
+ {
+ if (linkType.getJavaType().equals(PageLink.class))
+ {
+ PageLinkImpl pl = createPageLink();
+ setLink(pl);
+ link = (L)pl;
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Links of type " + linkType
+ " are not supported");
+ }
}
- }
- //
- return link;
- }
+ //
+ return link;
+ }
- public Site getSite() {
- SiteImpl parent = getParentSite();
- if (parent != null) {
- return parent;
- } else {
- return getParent().getSite();
- }
- }
+ public Site getSite()
+ {
+ SiteImpl parent = getParentSite();
+ if (parent != null)
+ {
+ return parent;
+ }
+ else
+ {
+ return getParent().getSite();
+ }
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageContainer.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageContainer.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -31,21 +31,23 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:pagecontainer")
-public abstract class PageContainer {
+public abstract class PageContainer
+{
- @OneToOne
- @RelatedMappedBy("pages")
- public abstract PageImpl getOwner();
+ @OneToOne
+ @RelatedMappedBy("pages")
+ public abstract PageImpl getOwner();
- @OneToMany
- public abstract Map<String, PageImpl> getPages();
+ @OneToMany
+ public abstract Map<String, PageImpl> getPages();
- @Create
- public abstract PageImpl createPage();
+ @Create
+ public abstract PageImpl createPage();
- public PageImpl addPage(String name) {
- PageImpl page = createPage();
- getPages().put(name, page);
- return page;
- }
+ public PageImpl addPage(String name)
+ {
+ PageImpl page = createPage();
+ getPages().put(name, page);
+ return page;
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -49,177 +49,219 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:page")
-public abstract class PageImpl extends WorkspaceObjectImpl implements Page,
WorkspaceCustomizationContext {
+public abstract class PageImpl extends WorkspaceObjectImpl implements Page,
WorkspaceCustomizationContext
+{
- /** . */
- private final Attributes cascadingAttributes = new AbstractAttributes() {
- public Set<String> getKeys() {
- throw new UnsupportedOperationException("todo ?");
- }
- protected Object get(String name) {
- return getCascadedPropertyValue(name);
- }
- protected void set(String name, Object o) {
- throw new UnsupportedOperationException("read only");
- }
- };
+ /** . */
+ private final Attributes cascadingAttributes = new AbstractAttributes()
+ {
+ public Set<String> getKeys()
+ {
+ throw new UnsupportedOperationException("todo ?");
+ }
- @ManyToOne(type = RelationshipType.PATH)
- @MappedBy("template")
- public abstract PageImpl getPageTemplate();
+ protected Object get(String name)
+ {
+ return getCascadedPropertyValue(name);
+ }
- public abstract void setPageTemplate(PageImpl template);
+ protected void set(String name, Object o)
+ {
+ throw new UnsupportedOperationException("read only");
+ }
+ };
- @OneToMany(type = RelationshipType.PATH)
- @RelatedMappedBy("template")
- public abstract Collection<NavigationImpl> getTemplatizedNavigations();
+ @ManyToOne(type = RelationshipType.PATH)
+ @MappedBy("template")
+ public abstract PageImpl getPageTemplate();
- @OneToMany(type = RelationshipType.PATH)
- @RelatedMappedBy("template")
- public abstract Collection<PageImpl> getTemplatizedPages();
+ public abstract void setPageTemplate(PageImpl template);
- @OneToMany(type = RelationshipType.PATH)
- @RelatedMappedBy("template")
- public abstract Collection<? extends WorkspaceObject> getTemplatizedObjects();
+ @OneToMany(type = RelationshipType.PATH)
+ @RelatedMappedBy("template")
+ public abstract Collection<NavigationImpl> getTemplatizedNavigations();
- @OneToOne
- @MappedBy("children")
- public abstract PageContainer getChildrenContainer();
+ @OneToMany(type = RelationshipType.PATH)
+ @RelatedMappedBy("template")
+ public abstract Collection<PageImpl> getTemplatizedPages();
- @OneToOne
- @RelatedMappedBy("children")
- public abstract PageContainer getParentContainer();
+ @OneToMany(type = RelationshipType.PATH)
+ @RelatedMappedBy("template")
+ public abstract Collection<? extends WorkspaceObject> getTemplatizedObjects();
- @OneToOne
- @RelatedMappedBy("rootpage")
- public abstract SiteImpl getSiteParent();
+ @OneToOne
+ @MappedBy("children")
+ public abstract PageContainer getChildrenContainer();
- @OneToOne
- @MappedBy("rootcomponent")
- public abstract UIContainerImpl getRootComponent();
+ @OneToOne
+ @RelatedMappedBy("children")
+ public abstract PageContainer getParentContainer();
- @Destroy
- public abstract void destroy();
+ @OneToOne
+ @RelatedMappedBy("rootpage")
+ public abstract SiteImpl getSiteParent();
- @OneToOne
- @MappedBy("customizations")
- public abstract CustomizationContainer getCustomizations();
+ @OneToOne
+ @MappedBy("rootcomponent")
+ public abstract UIContainerImpl getRootComponent();
- // WorkspaceCustomizationContext implementation
**********************************************************************
+ @Destroy
+ public abstract void destroy();
- public String getContextType() {
- return WorkspaceCustomizationContext.TYPE;
- }
+ @OneToOne
+ @MappedBy("customizations")
+ public abstract CustomizationContainer getCustomizations();
- public String getContextId() {
- return getObjectId();
- }
+ // WorkspaceCustomizationContext implementation
**********************************************************************
- public boolean contains(CustomizationContext that) {
- return contains(this, that);
- }
+ public String getContextType()
+ {
+ return WorkspaceCustomizationContext.TYPE;
+ }
- public Customization<?> getCustomization(String name) {
- return getCustomizations().getCustomization(name);
- }
+ public String getContextId()
+ {
+ return getObjectId();
+ }
- public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state) {
- return getCustomizations().customize(name, contentType, contentId, state);
- }
+ public boolean contains(CustomizationContext that)
+ {
+ return contains(this, that);
+ }
- public <S> Customization<S> customize(String name, Customization<S>
customization) {
- return getCustomizations().customize(name, customization);
- }
+ public Customization<?> getCustomization(String name)
+ {
+ return getCustomizations().getCustomization(name);
+ }
- public String nameOf(Customization customization) {
- return getCustomizations().nameOf(customization);
- }
+ public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state)
+ {
+ return getCustomizations().customize(name, contentType, contentId, state);
+ }
- //
*******************************************************************************************************************
+ public <S> Customization<S> customize(String name, Customization<S>
customization)
+ {
+ return getCustomizations().customize(name, customization);
+ }
- public <T extends TemplatizedObject> Collection<? extends T>
getTemplatizedObjects(ObjectType<T> templatizedType) {
- if (Page.class.equals(templatizedType.getJavaType())) {
- ArrayList bilto = new ArrayList();
- for (Page page : getTemplatizedPages()) {
- bilto.add(page);
+ public String nameOf(Customization customization)
+ {
+ return getCustomizations().nameOf(customization);
+ }
+
+ //
*******************************************************************************************************************
+
+ public <T extends TemplatizedObject> Collection<? extends T>
getTemplatizedObjects(ObjectType<T> templatizedType)
+ {
+ if (Page.class.equals(templatizedType.getJavaType()))
+ {
+ ArrayList bilto = new ArrayList();
+ for (Page page : getTemplatizedPages())
+ {
+ bilto.add(page);
+ }
+ return bilto;
}
- return bilto;
- } else if (Navigation.class.isAssignableFrom(templatizedType.getJavaType())) {
- ArrayList bilto = new ArrayList();
- for (Navigation page : getTemplatizedNavigations()) {
- bilto.add(page);
+ else if (Navigation.class.isAssignableFrom(templatizedType.getJavaType()))
+ {
+ ArrayList bilto = new ArrayList();
+ for (Navigation page : getTemplatizedNavigations())
+ {
+ bilto.add(page);
+ }
+ return bilto;
}
- return bilto;
- } else {
- throw new IllegalArgumentException("Unaccepted templatized type");
- }
- }
+ else
+ {
+ throw new IllegalArgumentException("Unaccepted templatized type");
+ }
+ }
- public ObjectType<? extends Page> getObjectType() {
- return ObjectType.PAGE;
- }
+ public ObjectType<? extends Page> getObjectType()
+ {
+ return ObjectType.PAGE;
+ }
- public Attributes getCascadingAttributes() {
- return cascadingAttributes;
- }
+ public Attributes getCascadingAttributes()
+ {
+ return cascadingAttributes;
+ }
- public SiteImpl getSite() {
- PageContainer parent = getParentContainer();
- if (parent != null) {
- return parent.getOwner().getSite();
- } else {
- return getSiteParent();
- }
- }
+ public SiteImpl getSite()
+ {
+ PageContainer parent = getParentContainer();
+ if (parent != null)
+ {
+ return parent.getOwner().getSite();
+ }
+ else
+ {
+ return getSiteParent();
+ }
+ }
- public PageImpl getParent() {
- PageContainer parent = getParentContainer();
- if (parent != null) {
- return parent.getOwner();
- } else {
- return null;
- }
- }
+ public PageImpl getParent()
+ {
+ PageContainer parent = getParentContainer();
+ if (parent != null)
+ {
+ return parent.getOwner();
+ }
+ else
+ {
+ return null;
+ }
+ }
- public PageImpl addChild(String name) throws NullPointerException,
IllegalArgumentException {
- PageContainer childrenContainer = getChildrenContainer();
- return childrenContainer.addPage(name);
- }
+ public PageImpl addChild(String name) throws NullPointerException,
IllegalArgumentException
+ {
+ PageContainer childrenContainer = getChildrenContainer();
+ return childrenContainer.addPage(name);
+ }
- public Collection<? extends Page> getChildren() {
- PageContainer childrenContainer = getChildrenContainer();
- return childrenContainer.getPages().values();
- }
+ public Collection<? extends Page> getChildren()
+ {
+ PageContainer childrenContainer = getChildrenContainer();
+ return childrenContainer.getPages().values();
+ }
- public PageImpl getChild(String name) {
- if (name == null) {
- throw new NullPointerException();
- }
- PageContainer childrenContainer = getChildrenContainer();
- return childrenContainer.getPages().get(name);
- }
+ public PageImpl getChild(String name)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException();
+ }
+ PageContainer childrenContainer = getChildrenContainer();
+ return childrenContainer.getPages().get(name);
+ }
- public Collection<PageLink> getNavigations() {
- throw new UnsupportedOperationException();
- }
+ public Collection<PageLink> getNavigations()
+ {
+ throw new UnsupportedOperationException();
+ }
- public void setTemplate(Page template) {
- setPageTemplate((PageImpl)template);
- }
+ public void setTemplate(Page template)
+ {
+ setPageTemplate((PageImpl)template);
+ }
- public Page getTemplate() {
- return getPageTemplate();
- }
+ public Page getTemplate()
+ {
+ return getPageTemplate();
+ }
- private Object getCascadedPropertyValue(String propertyName) {
- Attributes attributes = getAttributes();
- Object value = attributes.getObject(propertyName);
- if (value == null) {
- PageImpl parent = getParent();
- if (parent != null) {
- value = parent.getCascadedPropertyValue(propertyName);
+ private Object getCascadedPropertyValue(String propertyName)
+ {
+ Attributes attributes = getAttributes();
+ Object value = attributes.getObject(propertyName);
+ if (value == null)
+ {
+ PageImpl parent = getParent();
+ if (parent != null)
+ {
+ value = parent.getCascadedPropertyValue(propertyName);
+ }
}
- }
- return value;
- }
+ return value;
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageLinkImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageLinkImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PageLinkImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -33,25 +33,28 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:pagelink")
-public abstract class PageLinkImpl extends LinkImpl implements PageLink {
+public abstract class PageLinkImpl extends LinkImpl implements PageLink
+{
- @ManyToOne(type = RelationshipType.PATH)
- @MappedBy("page")
- public abstract PageImpl getPage();
+ @ManyToOne(type = RelationshipType.PATH)
+ @MappedBy("page")
+ public abstract PageImpl getPage();
- public abstract void setPage(PageImpl page);
+ public abstract void setPage(PageImpl page);
- @Path
- @Property(name = "path")
- public abstract String getPathPath();
+ @Path
+ @Property(name = "path")
+ public abstract String getPathPath();
- public abstract void setPagePath(String path);
+ public abstract void setPagePath(String path);
- public void setPage(Page page) {
- setPage((PageImpl)page);
- }
+ public void setPage(Page page)
+ {
+ setPage((PageImpl)page);
+ }
- public ObjectType<? extends PageLink> getObjectType() {
- return ObjectType.PAGE_LINK;
- }
+ public ObjectType<? extends PageLink> getObjectType()
+ {
+ return ObjectType.PAGE_LINK;
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSite.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSite.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSite.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -27,25 +27,30 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:portalsite")
-public abstract class PortalSite extends SiteImpl {
+public abstract class PortalSite extends SiteImpl
+{
- // Site implementation
***********************************************************************************************
+ // Site implementation
***********************************************************************************************
- public ObjectType<? extends Site> getObjectType() {
- return ObjectType.PORTAL_SITE;
- }
+ public ObjectType<? extends Site> getObjectType()
+ {
+ return ObjectType.PORTAL_SITE;
+ }
- // Portal implementation
*********************************************************************************************
+ // Portal implementation
*********************************************************************************************
- public String getSkinId() {
- throw new UnsupportedOperationException();
- }
+ public String getSkinId()
+ {
+ throw new UnsupportedOperationException();
+ }
- public String getTitle() {
- throw new UnsupportedOperationException();
- }
+ public String getTitle()
+ {
+ throw new UnsupportedOperationException();
+ }
- public String getLocale() {
- throw new UnsupportedOperationException();
- }
+ public String getLocale()
+ {
+ throw new UnsupportedOperationException();
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSiteContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSiteContainer.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/PortalSiteContainer.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,10 +28,11 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:portalsites")
-public abstract class PortalSiteContainer extends SiteContainer<PortalSite> {
+public abstract class PortalSiteContainer extends SiteContainer<PortalSite>
+{
- @RelatedMappedBy("portalsites")
- public abstract WorkspaceImpl getWorkspace();
-
+ @RelatedMappedBy("portalsites")
+ public abstract WorkspaceImpl getWorkspace();
+
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SharedSite.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SharedSite.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SharedSite.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,11 +28,13 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:sharedsite")
-public abstract class SharedSite extends SiteImpl {
+public abstract class SharedSite extends SiteImpl
+{
- // Site implementation
***********************************************************************************************
+ // Site implementation
***********************************************************************************************
- public ObjectType<? extends Site> getObjectType() {
- return ObjectType.SHARED_SITE;
- }
+ public ObjectType<? extends Site> getObjectType()
+ {
+ return ObjectType.SHARED_SITE;
+ }
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SharedSiteContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SharedSiteContainer.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SharedSiteContainer.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,9 +28,10 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:sharedsites")
-public abstract class SharedSiteContainer extends SiteContainer<SharedSite> {
+public abstract class SharedSiteContainer extends SiteContainer<SharedSite>
+{
- @RelatedMappedBy("sharedsites")
- public abstract WorkspaceImpl getWorkspace();
+ @RelatedMappedBy("sharedsites")
+ public abstract WorkspaceImpl getWorkspace();
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteContainer.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteContainer.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -30,30 +30,34 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class SiteContainer<T extends Site> {
+public abstract class SiteContainer<T extends Site>
+{
- @OneToMany
- public abstract Map<String, T> getSites();
+ @OneToMany
+ public abstract Map<String, T> getSites();
- @OneToOne
- public abstract WorkspaceImpl getWorkspace();
+ @OneToOne
+ public abstract WorkspaceImpl getWorkspace();
- public T addSite(String siteName) {
- T site = createSite();
- getSites().put(siteName, site);
- return site;
- }
+ public T addSite(String siteName)
+ {
+ T site = createSite();
+ getSites().put(siteName, site);
+ return site;
+ }
- @Create
- public abstract T createSite();
+ @Create
+ public abstract T createSite();
- public T getSite(String name) {
- Map<String, T> sites = getSites();
- return sites.get(name);
- }
+ public T getSite(String name)
+ {
+ Map<String, T> sites = getSites();
+ return sites.get(name);
+ }
- public Collection<T> getAllSites() {
- Map<String, T> sites = getSites();
- return sites.values();
- }
+ public Collection<T> getAllSites()
+ {
+ Map<String, T> sites = getSites();
+ return sites.values();
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/SiteImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -35,66 +35,76 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class SiteImpl extends WorkspaceObjectImpl implements Site,
WorkspaceCustomizationContext {
+public abstract class SiteImpl extends WorkspaceObjectImpl implements Site,
WorkspaceCustomizationContext
+{
- @OneToOne
- @MappedBy("rootpage")
- public abstract PageImpl getRoot();
+ @OneToOne
+ @MappedBy("rootpage")
+ public abstract PageImpl getRoot();
- @OneToOne
- @MappedBy("rootnavigation")
- public abstract NavigationImpl getRootNavigation();
+ @OneToOne
+ @MappedBy("rootnavigation")
+ public abstract NavigationImpl getRootNavigation();
- @ManyToOne
- public abstract SiteContainer getSites();
+ @ManyToOne
+ public abstract SiteContainer getSites();
- @Destroy
- public abstract void destroy();
+ @Destroy
+ public abstract void destroy();
- @OneToOne
- @MappedBy("customizations")
- public abstract CustomizationContainer getCustomizations();
+ @OneToOne
+ @MappedBy("customizations")
+ public abstract CustomizationContainer getCustomizations();
- public abstract ObjectType<? extends Site> getObjectType();
+ public abstract ObjectType<? extends Site> getObjectType();
- // Site implementation
***********************************************************************************************
+ // Site implementation
***********************************************************************************************
- public WorkspaceImpl getWorkspace() {
- SiteContainer sites = getSites();
- return sites.getWorkspace();
- }
+ public WorkspaceImpl getWorkspace()
+ {
+ SiteContainer sites = getSites();
+ return sites.getWorkspace();
+ }
- public Page getRootPage() {
- return getRoot();
- }
+ public Page getRootPage()
+ {
+ return getRoot();
+ }
- // WorkspaceCustomizationContext implementation
**********************************************************************
+ // WorkspaceCustomizationContext implementation
**********************************************************************
- public String getContextType() {
- return WorkspaceCustomizationContext.TYPE;
- }
+ public String getContextType()
+ {
+ return WorkspaceCustomizationContext.TYPE;
+ }
- public String getContextId() {
- return getObjectId();
- }
+ public String getContextId()
+ {
+ return getObjectId();
+ }
- public boolean contains(CustomizationContext that) {
- return contains(this, that);
- }
+ public boolean contains(CustomizationContext that)
+ {
+ return contains(this, that);
+ }
- public Customization<?> getCustomization(String name) {
- return getCustomizations().getCustomization(name);
- }
+ public Customization<?> getCustomization(String name)
+ {
+ return getCustomizations().getCustomization(name);
+ }
- public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state) {
- return getCustomizations().customize(name, contentType, contentId, state);
- }
+ public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state)
+ {
+ return getCustomizations().customize(name, contentType, contentId, state);
+ }
- public <S> Customization<S> customize(String name, Customization<S>
customization) {
- return getCustomizations().customize(name, customization);
- }
+ public <S> Customization<S> customize(String name, Customization<S>
customization)
+ {
+ return getCustomizations().customize(name, customization);
+ }
- public String nameOf(Customization customization) {
- return getCustomizations().nameOf(customization);
- }
+ public String nameOf(Customization customization)
+ {
+ return getCustomizations().nameOf(customization);
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIBodyImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIBodyImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIBodyImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -27,9 +27,11 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:uibody")
-public abstract class UIBodyImpl extends UIComponentImpl implements UIBody {
+public abstract class UIBodyImpl extends UIComponentImpl implements UIBody
+{
- public ObjectType<? extends UIBody> getObjectType() {
- return ObjectType.BODY;
- }
+ public ObjectType<? extends UIBody> getObjectType()
+ {
+ return ObjectType.BODY;
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIComponentImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIComponentImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIComponentImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -27,26 +27,32 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class UIComponentImpl extends WorkspaceObjectImpl implements UIComponent
{
+public abstract class UIComponentImpl extends WorkspaceObjectImpl implements UIComponent
+{
- @ManyToOne
- public abstract UIContainerImpl getParentContainer();
+ @ManyToOne
+ public abstract UIContainerImpl getParentContainer();
- @ManyToOne
- public abstract PageImpl getParentPage();
+ @ManyToOne
+ public abstract PageImpl getParentPage();
- public abstract ObjectType<? extends UIComponent> getObjectType();
+ public abstract ObjectType<? extends UIComponent> getObjectType();
- public final UIContainerImpl getParent() {
- return getParentContainer();
- }
+ public final UIContainerImpl getParent()
+ {
+ return getParentContainer();
+ }
- public final PageImpl getPage() {
- UIContainerImpl container = getParentContainer();
- if (container != null) {
- return container.getPage();
- } else {
- return getParentPage();
- }
- }
+ public final PageImpl getPage()
+ {
+ UIContainerImpl container = getParentContainer();
+ if (container != null)
+ {
+ return container.getPage();
+ }
+ else
+ {
+ return getParentPage();
+ }
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIContainerImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIContainerImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIContainerImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -37,156 +37,198 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:uicontainer")
-public abstract class UIContainerImpl extends UIComponentImpl implements UIContainer {
+public abstract class UIContainerImpl extends UIComponentImpl implements UIContainer
+{
- @Create
- public abstract UIContainerImpl createContainer();
+ @Create
+ public abstract UIContainerImpl createContainer();
- @Create
- public abstract UIBodyImpl createInsertion();
+ @Create
+ public abstract UIBodyImpl createInsertion();
- @Create
- public abstract UIWindowImpl createWindow();
+ @Create
+ public abstract UIWindowImpl createWindow();
- @OneToMany
- public abstract Map<String, UIComponentImpl> getComponentMap();
-
- @OneToMany
- public abstract List<UIComponent> getComponentList();
+ @OneToMany
+ public abstract Map<String, UIComponentImpl> getComponentMap();
- public ObjectType<? extends UIContainer> getObjectType() {
- return ObjectType.CONTAINER;
- }
+ @OneToMany
+ public abstract List<UIComponent> getComponentList();
- public UIComponent get(String componentName) {
- Map<String, UIComponentImpl> children = getComponentMap();
- return children.get(componentName);
- }
+ public ObjectType<? extends UIContainer> getObjectType()
+ {
+ return ObjectType.CONTAINER;
+ }
- public <T extends UIComponent> T add(ObjectType<T> componentType, String
name) {
- UIComponentImpl child;
- if (componentType == ObjectType.WINDOW) {
- child = createWindow();
- } else if (componentType == ObjectType.CONTAINER) {
- child = createContainer();
- } else if (componentType == ObjectType.BODY) {
- child = createInsertion();
- } else {
- throw new UnsupportedOperationException();
- }
- Map<String, UIComponentImpl> children = getComponentMap();
- children.put(name, child);
- return componentType.cast(child);
- }
+ public UIComponent get(String componentName)
+ {
+ Map<String, UIComponentImpl> children = getComponentMap();
+ return children.get(componentName);
+ }
- public <T extends UIComponent> T add(int index, ObjectType<T>
componentType, String name) {
- UIComponentImpl child;
- if (componentType == ObjectType.WINDOW) {
- child = createWindow();
- } else if (componentType == ObjectType.CONTAINER) {
- child = createContainer();
- } else if (componentType == ObjectType.BODY) {
- child = createInsertion();
- } else {
- throw new UnsupportedOperationException();
- }
- child.setName(name);
- List<UIComponent> children = getComponentList();
- children.add(index, child);
- return componentType.cast(child);
- }
+ public <T extends UIComponent> T add(ObjectType<T> componentType, String
name)
+ {
+ UIComponentImpl child;
+ if (componentType == ObjectType.WINDOW)
+ {
+ child = createWindow();
+ }
+ else if (componentType == ObjectType.CONTAINER)
+ {
+ child = createContainer();
+ }
+ else if (componentType == ObjectType.BODY)
+ {
+ child = createInsertion();
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ Map<String, UIComponentImpl> children = getComponentMap();
+ children.put(name, child);
+ return componentType.cast(child);
+ }
- // List<UIComponent> implementation
**********************************************************************************
+ public <T extends UIComponent> T add(int index, ObjectType<T>
componentType, String name)
+ {
+ UIComponentImpl child;
+ if (componentType == ObjectType.WINDOW)
+ {
+ child = createWindow();
+ }
+ else if (componentType == ObjectType.CONTAINER)
+ {
+ child = createContainer();
+ }
+ else if (componentType == ObjectType.BODY)
+ {
+ child = createInsertion();
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ child.setName(name);
+ List<UIComponent> children = getComponentList();
+ children.add(index, child);
+ return componentType.cast(child);
+ }
- public int size() {
- return getComponentList().size();
- }
+ // List<UIComponent> implementation
**********************************************************************************
- public boolean isEmpty() {
- return getComponentList().isEmpty();
- }
+ public int size()
+ {
+ return getComponentList().size();
+ }
- public boolean contains(Object o) {
- return getComponentList().contains(o);
- }
+ public boolean isEmpty()
+ {
+ return getComponentList().isEmpty();
+ }
- public Iterator<UIComponent> iterator() {
- return getComponentList().iterator();
- }
+ public boolean contains(Object o)
+ {
+ return getComponentList().contains(o);
+ }
- public Object[] toArray() {
- return new Object[0];
- }
+ public Iterator<UIComponent> iterator()
+ {
+ return getComponentList().iterator();
+ }
- public <T> T[] toArray(T[] a) {
- return getComponentList().toArray(a);
- }
+ public Object[] toArray()
+ {
+ return new Object[0];
+ }
- public boolean add(UIComponent uiComponent) {
- return getComponentList().add(uiComponent);
- }
+ public <T> T[] toArray(T[] a)
+ {
+ return getComponentList().toArray(a);
+ }
- public boolean remove(Object o) {
- return getComponentList().remove(o);
- }
+ public boolean add(UIComponent uiComponent)
+ {
+ return getComponentList().add(uiComponent);
+ }
- public boolean containsAll(Collection<?> c) {
- return getComponentList().containsAll(c);
- }
+ public boolean remove(Object o)
+ {
+ return getComponentList().remove(o);
+ }
- public boolean addAll(Collection<? extends UIComponent> c) {
- return getComponentList().addAll(c);
- }
+ public boolean containsAll(Collection<?> c)
+ {
+ return getComponentList().containsAll(c);
+ }
- public boolean addAll(int index, Collection<? extends UIComponent> c) {
- return getComponentList().addAll(index, c);
- }
+ public boolean addAll(Collection<? extends UIComponent> c)
+ {
+ return getComponentList().addAll(c);
+ }
- public boolean removeAll(Collection<?> c) {
- return getComponentList().removeAll(c);
- }
+ public boolean addAll(int index, Collection<? extends UIComponent> c)
+ {
+ return getComponentList().addAll(index, c);
+ }
- public boolean retainAll(Collection<?> c) {
- return getComponentList().retainAll(c);
- }
+ public boolean removeAll(Collection<?> c)
+ {
+ return getComponentList().removeAll(c);
+ }
- public void clear() {
- getComponentList().clear();
- }
+ public boolean retainAll(Collection<?> c)
+ {
+ return getComponentList().retainAll(c);
+ }
- public UIComponent get(int index) {
- return getComponentList().get(index);
- }
+ public void clear()
+ {
+ getComponentList().clear();
+ }
- public UIComponent set(int index, UIComponent element) {
- return getComponentList().set(index, element);
- }
+ public UIComponent get(int index)
+ {
+ return getComponentList().get(index);
+ }
- public void add(int index, UIComponent element) {
- getComponentList().add(index, element);
- }
+ public UIComponent set(int index, UIComponent element)
+ {
+ return getComponentList().set(index, element);
+ }
- public UIComponent remove(int index) {
- return getComponentList().remove(index);
- }
+ public void add(int index, UIComponent element)
+ {
+ getComponentList().add(index, element);
+ }
- public int indexOf(Object o) {
- return getComponentList().indexOf(o);
- }
+ public UIComponent remove(int index)
+ {
+ return getComponentList().remove(index);
+ }
- public int lastIndexOf(Object o) {
- return getComponentList().lastIndexOf(o);
- }
+ public int indexOf(Object o)
+ {
+ return getComponentList().indexOf(o);
+ }
- public ListIterator<UIComponent> listIterator() {
- return getComponentList().listIterator();
- }
+ public int lastIndexOf(Object o)
+ {
+ return getComponentList().lastIndexOf(o);
+ }
- public ListIterator<UIComponent> listIterator(int index) {
- return getComponentList().listIterator(index);
- }
+ public ListIterator<UIComponent> listIterator()
+ {
+ return getComponentList().listIterator();
+ }
- public List<UIComponent> subList(int fromIndex, int toIndex) {
- return getComponentList().subList(fromIndex, toIndex);
- }
+ public ListIterator<UIComponent> listIterator(int index)
+ {
+ return getComponentList().listIterator(index);
+ }
+
+ public List<UIComponent> subList(int fromIndex, int toIndex)
+ {
+ return getComponentList().subList(fromIndex, toIndex);
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIWindowImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIWindowImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UIWindowImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -37,82 +37,96 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:uiwindow")
-public abstract class UIWindowImpl extends UIComponentImpl implements UIWindow,
CustomizationContext {
+public abstract class UIWindowImpl extends UIComponentImpl implements UIWindow,
CustomizationContext
+{
- public ObjectType<? extends UIWindow> getObjectType() {
- return ObjectType.WINDOW;
- }
+ public ObjectType<? extends UIWindow> getObjectType()
+ {
+ return ObjectType.WINDOW;
+ }
- // Abstract
**********************************************************************************************************
+ // Abstract
**********************************************************************************************************
- @OneToOne
- @MappedBy("customization")
- public abstract WorkspaceCustomization getCustomization();
+ @OneToOne
+ @MappedBy("customization")
+ public abstract WorkspaceCustomization getCustomization();
- public abstract void setCustomization(WorkspaceCustomization customization);
+ public abstract void setCustomization(WorkspaceCustomization customization);
- @Create
- public abstract WorkspaceClone create();
+ @Create
+ public abstract WorkspaceClone create();
- @Create
- public abstract WorkspaceSpecialization create2();
+ @Create
+ public abstract WorkspaceSpecialization create2();
- // UIWindow implementation
*******************************************************************************************
+ // UIWindow implementation
*******************************************************************************************
- public <S> Customization<S> customize(ContentType<S> contentType,
String contentId, S state) {
- if (getCustomization() != null) {
- throw new IllegalStateException("Already customized");
- }
- WorkspaceClone customization = create();
- setCustomization(customization);
- customization.setMimeType(contentType.getMimeType());
- customization.setContentId(contentId);
- customization.setState(state);
- return (Customization<S>)customization;
- }
+ public <S> Customization<S> customize(ContentType<S> contentType,
String contentId, S state)
+ {
+ if (getCustomization() != null)
+ {
+ throw new IllegalStateException("Already customized");
+ }
+ WorkspaceClone customization = create();
+ setCustomization(customization);
+ customization.setMimeType(contentType.getMimeType());
+ customization.setContentId(contentId);
+ customization.setState(state);
+ return (Customization<S>)customization;
+ }
- public <S> Customization<S> customize(Customization<S> customization)
{
- if (customization == null) {
- throw new NullPointerException();
- } else if (customization instanceof WorkspaceCustomization) {
- if (getCustomization() != null) {
- throw new IllegalStateException("Already customized");
+ public <S> Customization<S> customize(Customization<S>
customization)
+ {
+ if (customization == null)
+ {
+ throw new NullPointerException();
}
+ else if (customization instanceof WorkspaceCustomization)
+ {
+ if (getCustomization() != null)
+ {
+ throw new IllegalStateException("Already customized");
+ }
- // Get parent customization
- WorkspaceCustomization parentCustomization =
(WorkspaceCustomization)customization;
+ // Get parent customization
+ WorkspaceCustomization parentCustomization =
(WorkspaceCustomization)customization;
- // Create
- WorkspaceSpecialization specialization = create2();
+ // Create
+ WorkspaceSpecialization specialization = create2();
- // Persist
- setCustomization(specialization);
+ // Persist
+ setCustomization(specialization);
- // Configuration
- specialization.setMimeType(parentCustomization.getMimeType());
- specialization.setContentId(parentCustomization.getContentId());
+ // Configuration
+ specialization.setMimeType(parentCustomization.getMimeType());
+ specialization.setContentId(parentCustomization.getContentId());
- // Create relationship
- specialization.setCustomization(parentCustomization);
+ // Create relationship
+ specialization.setCustomization(parentCustomization);
- //
- return (Customization<S>)specialization;
- } else {
- throw new IllegalArgumentException("implement customization of "+
customization);
- }
- }
+ //
+ return (Customization<S>)specialization;
+ }
+ else
+ {
+ throw new IllegalArgumentException("implement customization of " +
customization);
+ }
+ }
- // WorkspaceCustomizationContext implementation
**********************************************************************
+ // WorkspaceCustomizationContext implementation
**********************************************************************
- public String getContextType() {
- return WorkspaceCustomizationContext.TYPE;
- }
+ public String getContextType()
+ {
+ return WorkspaceCustomizationContext.TYPE;
+ }
- public String getContextId() {
- return getObjectId();
- }
+ public String getContextId()
+ {
+ return getObjectId();
+ }
- public boolean contains(CustomizationContext that) {
- return contains(this, that);
- }
+ public boolean contains(CustomizationContext that)
+ {
+ return contains(this, that);
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/URLLinkImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/URLLinkImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/URLLinkImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,14 +28,16 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:urllink")
-public abstract class URLLinkImpl extends LinkImpl implements URLLink {
+public abstract class URLLinkImpl extends LinkImpl implements URLLink
+{
- @Property(name = "url")
- public abstract String getURL();
+ @Property(name = "url")
+ public abstract String getURL();
- public abstract void setURL(String url);
+ public abstract void setURL(String url);
- public ObjectType<? extends URLLink> getObjectType() {
- return ObjectType.URL_LINK;
- }
+ public ObjectType<? extends URLLink> getObjectType()
+ {
+ return ObjectType.URL_LINK;
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSite.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSite.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSite.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,11 +28,13 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:usersite")
-public abstract class UserSite extends SiteImpl {
+public abstract class UserSite extends SiteImpl
+{
- // Site implementation
***********************************************************************************************
+ // Site implementation
***********************************************************************************************
- public ObjectType<? extends Site> getObjectType() {
- return ObjectType.USER_SITE;
- }
+ public ObjectType<? extends Site> getObjectType()
+ {
+ return ObjectType.USER_SITE;
+ }
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSiteContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSiteContainer.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/UserSiteContainer.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -26,9 +26,10 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:usersites")
-public abstract class UserSiteContainer extends SiteContainer<UserSite> {
+public abstract class UserSiteContainer extends SiteContainer<UserSite>
+{
- @RelatedMappedBy("usersites")
- public abstract WorkspaceImpl getWorkspace();
+ @RelatedMappedBy("usersites")
+ public abstract WorkspaceImpl getWorkspace();
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -39,106 +39,130 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:workspace")
-public abstract class WorkspaceImpl extends WorkspaceObjectImpl implements Workspace,
WorkspaceCustomizationContext {
+public abstract class WorkspaceImpl extends WorkspaceObjectImpl implements Workspace,
WorkspaceCustomizationContext
+{
- public ObjectType<? extends Workspace> getObjectType() {
- return ObjectType.WORKSPACE;
- }
+ public ObjectType<? extends Workspace> getObjectType()
+ {
+ return ObjectType.WORKSPACE;
+ }
- // Abstract
**********************************************************************************************************
+ // Abstract
**********************************************************************************************************
- @OneToOne
- @MappedBy("portalsites")
- public abstract PortalSiteContainer getPortalSites();
+ @OneToOne
+ @MappedBy("portalsites")
+ public abstract PortalSiteContainer getPortalSites();
- @OneToOne
- @MappedBy("groupsites")
- public abstract GroupSiteContainer getGroupSites();
+ @OneToOne
+ @MappedBy("groupsites")
+ public abstract GroupSiteContainer getGroupSites();
- @OneToOne
- @MappedBy("usersites")
- public abstract UserSiteContainer getUserSites();
+ @OneToOne
+ @MappedBy("usersites")
+ public abstract UserSiteContainer getUserSites();
- @OneToOne
- @MappedBy("sharedsites")
- public abstract UserSiteContainer getSharedSites();
+ @OneToOne
+ @MappedBy("sharedsites")
+ public abstract UserSiteContainer getSharedSites();
- @OneToOne
- @MappedBy("customizations")
- public abstract CustomizationContainer getCustomizations();
+ @OneToOne
+ @MappedBy("customizations")
+ public abstract CustomizationContainer getCustomizations();
- // CustomizationContextResolver implementation
***********************************************************************
+ // CustomizationContextResolver implementation
***********************************************************************
- @FindById
- public abstract CustomizationContext resolveContext(String contextId);
+ @FindById
+ public abstract CustomizationContext resolveContext(String contextId);
- // WorkspaceCustomizationContext implementation
**********************************************************************
+ // WorkspaceCustomizationContext implementation
**********************************************************************
- public String getContextType() {
- return WorkspaceCustomizationContext.TYPE;
- }
+ public String getContextType()
+ {
+ return WorkspaceCustomizationContext.TYPE;
+ }
- public String getContextId() {
- return getObjectId();
- }
+ public String getContextId()
+ {
+ return getObjectId();
+ }
- public boolean contains(CustomizationContext that) {
- return contains(this, that);
- }
+ public boolean contains(CustomizationContext that)
+ {
+ return contains(this, that);
+ }
- public Customization<?> getCustomization(String name) {
- return getCustomizations().getCustomization(name);
- }
+ public Customization<?> getCustomization(String name)
+ {
+ return getCustomizations().getCustomization(name);
+ }
- public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state) {
- return getCustomizations().customize(name, contentType, contentId, state);
- }
+ public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state)
+ {
+ return getCustomizations().customize(name, contentType, contentId, state);
+ }
- public <S> Customization<S> customize(String name, Customization<S>
customization) {
- return getCustomizations().customize(name, customization);
- }
+ public <S> Customization<S> customize(String name, Customization<S>
customization)
+ {
+ return getCustomizations().customize(name, customization);
+ }
- public String nameOf(Customization customization) {
- return getCustomizations().nameOf(customization);
- }
+ public String nameOf(Customization customization)
+ {
+ return getCustomizations().nameOf(customization);
+ }
- // Workspace implementation
******************************************************************************************
+ // Workspace implementation
******************************************************************************************
- @SuppressWarnings("unchecked")
- private <S extends Site> SiteContainer<S>
getSiteContainer(ObjectType<S> siteType) {
- if (siteType == ObjectType.PORTAL_SITE) {
- return (SiteContainer<S>)getPortalSites();
- } else if (siteType == ObjectType.GROUP_SITE) {
- return (SiteContainer<S>)getGroupSites();
- } else if (siteType == ObjectType.USER_SITE) {
- return (SiteContainer<S>)getUserSites();
- } else if (siteType == ObjectType.SHARED_SITE) {
- return (SiteContainer<S>)getSharedSites();
- } else {
- throw new UnsupportedOperationException();
- }
- }
+ @SuppressWarnings("unchecked")
+ private <S extends Site> SiteContainer<S>
getSiteContainer(ObjectType<S> siteType)
+ {
+ if (siteType == ObjectType.PORTAL_SITE)
+ {
+ return (SiteContainer<S>)getPortalSites();
+ }
+ else if (siteType == ObjectType.GROUP_SITE)
+ {
+ return (SiteContainer<S>)getGroupSites();
+ }
+ else if (siteType == ObjectType.USER_SITE)
+ {
+ return (SiteContainer<S>)getUserSites();
+ }
+ else if (siteType == ObjectType.SHARED_SITE)
+ {
+ return (SiteContainer<S>)getSharedSites();
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
- public <S extends Site> S getSite(ObjectType<S> siteType, String siteName)
{
- SiteContainer<S> sites = getSiteContainer(siteType);
- return sites.getSite(siteName);
- }
+ public <S extends Site> S getSite(ObjectType<S> siteType, String
siteName)
+ {
+ SiteContainer<S> sites = getSiteContainer(siteType);
+ return sites.getSite(siteName);
+ }
- public Collection<Site> getSites() {
- throw new UnsupportedOperationException();
- }
+ public Collection<Site> getSites()
+ {
+ throw new UnsupportedOperationException();
+ }
- public <S extends Site> Collection<S> getSites(ObjectType<S>
siteType) {
- SiteContainer<S> sites = getSiteContainer(siteType);
- return sites.getAllSites();
- }
+ public <S extends Site> Collection<S> getSites(ObjectType<S>
siteType)
+ {
+ SiteContainer<S> sites = getSiteContainer(siteType);
+ return sites.getAllSites();
+ }
- public <S extends Site> S addSite(ObjectType<S> siteType, String name) {
- SiteContainer<S> sites = getSiteContainer(siteType);
- return sites.addSite(name);
- }
+ public <S extends Site> S addSite(ObjectType<S> siteType, String name)
+ {
+ SiteContainer<S> sites = getSiteContainer(siteType);
+ return sites.addSite(name);
+ }
- public Site getSharedSite() {
- return getSite(ObjectType.SHARED_SITE, "default");
- }
+ public Site getSharedSite()
+ {
+ return getSite(ObjectType.SHARED_SITE, "default");
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceObjectImpl.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceObjectImpl.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/WorkspaceObjectImpl.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -37,118 +37,152 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class WorkspaceObjectImpl implements WorkspaceObject {
+public abstract class WorkspaceObjectImpl implements WorkspaceObject
+{
- /** . */
- private final Set<String> keys = new AbstractSet<String>() {
- @Override
- public Iterator<String> iterator() {
- Map<String, Object> properties = getProperties();
- return new AbstractFilterIterator<String,
String>(properties.keySet().iterator()) {
- protected String adapt(String internal) {
- if (internal.startsWith("mop:")) {
- return internal.substring(4);
- } else {
- return null;
- }
- }
- };
- }
- public int size() {
- Map<String, Object> properties = getProperties();
- int count = 0;
- for (String key : properties.keySet()) {
- if (key.startsWith("mop:")) {
- count++;
- }
+ /** . */
+ private final Set<String> keys = new AbstractSet<String>()
+ {
+ @Override
+ public Iterator<String> iterator()
+ {
+ Map<String, Object> properties = getProperties();
+ return new AbstractFilterIterator<String,
String>(properties.keySet().iterator())
+ {
+ protected String adapt(String internal)
+ {
+ if (internal.startsWith("mop:"))
+ {
+ return internal.substring(4);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ };
}
- return count;
- }
- };
- /** . */
- private final AbstractAttributes attributes = new AbstractAttributes() {
- @Override
- protected Object get(String name) {
- Map<String, Object> properties = getProperties();
- return properties.get("mop:" + name);
- }
+ public int size()
+ {
+ Map<String, Object> properties = getProperties();
+ int count = 0;
+ for (String key : properties.keySet())
+ {
+ if (key.startsWith("mop:"))
+ {
+ count++;
+ }
+ }
+ return count;
+ }
+ };
- @Override
- protected void set(String name, Object o) {
- Map<String, Object> properties = getProperties();
- properties.put("mop:" + name, o);
- }
+ /** . */
+ private final AbstractAttributes attributes = new AbstractAttributes()
+ {
+ @Override
+ protected Object get(String name)
+ {
+ Map<String, Object> properties = getProperties();
+ return properties.get("mop:" + name);
+ }
- public Set<String> getKeys() {
- return keys;
- }
- };
+ @Override
+ protected void set(String name, Object o)
+ {
+ Map<String, Object> properties = getProperties();
+ properties.put("mop:" + name, o);
+ }
- public Attributes getAttributes() {
- return attributes;
- }
+ public Set<String> getKeys()
+ {
+ return keys;
+ }
+ };
- @Name
- public abstract String getName();
+ public Attributes getAttributes()
+ {
+ return attributes;
+ }
- public abstract void setName(String name);
+ @Name
+ public abstract String getName();
- @Id
- public abstract String getObjectId();
+ public abstract void setName(String name);
- @Properties
- public abstract Map<String, Object> getProperties();
+ @Id
+ public abstract String getObjectId();
- @Override
- public String toString() {
- ObjectType<?> objectType = getObjectType();
- Class<? extends WorkspaceObject> javaType = objectType.getJavaType();
- String typeName = javaType.getSimpleName();
- String name = getName();
- String id = getObjectId();
- return typeName + "[name=" + name + ",id=" + id + "]";
- }
+ @Properties
+ public abstract Map<String, Object> getProperties();
- static boolean contains(CustomizationContext container, CustomizationContext contained)
{
- if (container == null) {
- throw new NullPointerException("No null container accepted");
- }
- if (contained == null) {
- throw new NullPointerException("No null contained accepted");
- }
+ @Override
+ public String toString()
+ {
+ ObjectType<?> objectType = getObjectType();
+ Class<? extends WorkspaceObject> javaType = objectType.getJavaType();
+ String typeName = javaType.getSimpleName();
+ String name = getName();
+ String id = getObjectId();
+ return typeName + "[name=" + name + ",id=" + id +
"]";
+ }
- //
- if (container == contained) {
- return true;
- }
- if (container instanceof WorkspaceImpl) {
- if (contained instanceof SiteImpl) {
- SiteImpl site = (SiteImpl)contained;
- return contains(container, site.getWorkspace());
- } else if (contained instanceof PageImpl) {
- PageImpl page = (PageImpl)contained;
- return contains(container, page.getSite());
- } else if (contained instanceof UIWindowImpl) {
- UIWindowImpl window = (UIWindowImpl)contained;
- return contains(container, window.getPage());
+ static boolean contains(CustomizationContext container, CustomizationContext
contained)
+ {
+ if (container == null)
+ {
+ throw new NullPointerException("No null container accepted");
}
- }
- if (container instanceof SiteImpl) {
- if (contained instanceof PageImpl) {
- PageImpl page = (PageImpl)contained;
- return contains(container, page.getSite());
- } else if (contained instanceof UIWindowImpl) {
- UIWindowImpl window = (UIWindowImpl)contained;
- return contains(container, window.getPage());
+ if (contained == null)
+ {
+ throw new NullPointerException("No null contained accepted");
}
- }
- if (container instanceof PageImpl) {
- if (contained instanceof UIWindowImpl) {
- UIWindowImpl window = (UIWindowImpl)contained;
- return contains(container, window.getPage());
+
+ //
+ if (container == contained)
+ {
+ return true;
}
- }
- return false;
- }
+ if (container instanceof WorkspaceImpl)
+ {
+ if (contained instanceof SiteImpl)
+ {
+ SiteImpl site = (SiteImpl)contained;
+ return contains(container, site.getWorkspace());
+ }
+ else if (contained instanceof PageImpl)
+ {
+ PageImpl page = (PageImpl)contained;
+ return contains(container, page.getSite());
+ }
+ else if (contained instanceof UIWindowImpl)
+ {
+ UIWindowImpl window = (UIWindowImpl)contained;
+ return contains(container, window.getPage());
+ }
+ }
+ if (container instanceof SiteImpl)
+ {
+ if (contained instanceof PageImpl)
+ {
+ PageImpl page = (PageImpl)contained;
+ return contains(container, page.getSite());
+ }
+ else if (contained instanceof UIWindowImpl)
+ {
+ UIWindowImpl window = (UIWindowImpl)contained;
+ return contains(container, window.getPage());
+ }
+ }
+ if (container instanceof PageImpl)
+ {
+ if (contained instanceof UIWindowImpl)
+ {
+ UIWindowImpl window = (UIWindowImpl)contained;
+ return contains(container, window.getPage());
+ }
+ }
+ return false;
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/AbstractCustomization.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/AbstractCustomization.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/AbstractCustomization.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -44,181 +44,212 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class AbstractCustomization implements Customization<Object>,
StateContainer {
+public abstract class AbstractCustomization implements Customization<Object>,
StateContainer
+{
- /** . */
- protected static final CustomizationContextComparator comparator;
+ /** . */
+ protected static final CustomizationContextComparator comparator;
- static {
- CustomizationContextComparator _comparator = new CustomizationContextComparator(
- WorkspaceCustomizationContext.TYPE
- );
+ static
+ {
+ CustomizationContextComparator _comparator = new CustomizationContextComparator(
+ WorkspaceCustomizationContext.TYPE
+ );
- //
- comparator = _comparator;
- }
+ //
+ comparator = _comparator;
+ }
- /** . */
- public ContentManagerRegistry registry;
+ /** . */
+ public ContentManagerRegistry registry;
- /** . */
- public ChromatticSession session;
+ /** . */
+ public ChromatticSession session;
- @Id
- public abstract String getId();
+ @Id
+ public abstract String getId();
- @OneToOne
- @MappedBy("contexttypes")
- abstract ContextTypeContainer getContextTypes();
+ @OneToOne
+ @MappedBy("contexttypes")
+ abstract ContextTypeContainer getContextTypes();
- @Create
- abstract ContextType create();
+ @Create
+ abstract ContextType create();
- @Create
- abstract ContextSpecialization createContextSpecialization();
+ @Create
+ abstract ContextSpecialization createContextSpecialization();
- public abstract CustomizationContext getContext();
+ public abstract CustomizationContext getContext();
- public abstract AbstractCustomization getParent();
+ public abstract AbstractCustomization getParent();
- public Object getVirtualState() {
+ public Object getVirtualState()
+ {
- ContentType contentType = getType();
+ ContentType contentType = getType();
- String mimeType = contentType.getMimeType();
+ String mimeType = contentType.getMimeType();
- ContentProvider contentProvider = registry.providers.get(mimeType).getProvider();
+ ContentProvider contentProvider = registry.providers.get(mimeType).getProvider();
- //
- Object childPayload = contentProvider.getState(this);
+ //
+ Object childPayload = contentProvider.getState(this);
- //
- Object parentPayload = null;
- AbstractCustomization parent = getParent();
- if (parent != null) {
- parentPayload = parent.getVirtualState();
- }
+ //
+ Object parentPayload = null;
+ AbstractCustomization parent = getParent();
+ if (parent != null)
+ {
+ parentPayload = parent.getVirtualState();
+ }
- //
- if (parentPayload != null) {
- if (childPayload != null) {
- return contentProvider.combine(Arrays.asList(parentPayload, childPayload));
- } else {
- return parentPayload;
+ //
+ if (parentPayload != null)
+ {
+ if (childPayload != null)
+ {
+ return contentProvider.combine(Arrays.asList(parentPayload, childPayload));
+ }
+ else
+ {
+ return parentPayload;
+ }
}
- } else {
- return childPayload;
- }
- }
+ else
+ {
+ return childPayload;
+ }
+ }
- public Object getState() {
- ContentType contentType = getType();
- String mimeType = contentType.getMimeType();
- ContentProvider contentProvider = registry.providers.get(mimeType).getProvider();
- return contentProvider.getState(this);
- }
+ public Object getState()
+ {
+ ContentType contentType = getType();
+ String mimeType = contentType.getMimeType();
+ ContentProvider contentProvider = registry.providers.get(mimeType).getProvider();
+ return contentProvider.getState(this);
+ }
- public void setState(Object state) {
- ContentType contentType = getType();
- String mimeType = contentType.getMimeType();
- ContentProvider contentProvider = registry.providers.get(mimeType).getProvider();
- contentProvider.setState(this, state);
- }
+ public void setState(Object state)
+ {
+ ContentType contentType = getType();
+ String mimeType = contentType.getMimeType();
+ ContentProvider contentProvider = registry.providers.get(mimeType).getProvider();
+ contentProvider.setState(this, state);
+ }
- public Customization<Object> getCustomization(Set<CustomizationContext>
contexts) {
- return get(contexts, false);
- }
+ public Customization<Object> getCustomization(Set<CustomizationContext>
contexts)
+ {
+ return get(contexts, false);
+ }
- public Customization<Object> customize(Collection<CustomizationContext>
contexts) {
- if (contexts == null) {
- throw new NullPointerException();
- }
- return get(contexts, true);
- }
-
- public Set<CustomizationContext> getContexts() {
- //
- AbstractCustomization current = this;
- LinkedHashSet<CustomizationContext> contexts = new
LinkedHashSet<CustomizationContext>();
-
- //
- while (true) {
- CustomizationContext currentContext = current.getContext();
- if (currentContext == null) {
- throw new IllegalStateException("Could not resolve customization context for
customization " + this);
+ public Customization<Object> customize(Collection<CustomizationContext>
contexts)
+ {
+ if (contexts == null)
+ {
+ throw new NullPointerException();
}
+ return get(contexts, true);
+ }
+ public Set<CustomizationContext> getContexts()
+ {
//
- contexts.add(currentContext);
+ AbstractCustomization current = this;
+ LinkedHashSet<CustomizationContext> contexts = new
LinkedHashSet<CustomizationContext>();
//
- AbstractCustomization parent = current.getParent();
- if (parent != null) {
- current = parent;
- } else {
- break;
- }
- }
+ while (true)
+ {
+ CustomizationContext currentContext = current.getContext();
+ if (currentContext == null)
+ {
+ throw new IllegalStateException("Could not resolve customization context
for customization " + this);
+ }
- //
- return contexts;
- }
+ //
+ contexts.add(currentContext);
- //
+ //
+ AbstractCustomization parent = current.getParent();
+ if (parent != null)
+ {
+ current = parent;
+ }
+ else
+ {
+ break;
+ }
+ }
- protected final Customization<Object> get(Collection<CustomizationContext>
contexts, boolean create) {
+ //
+ return contexts;
+ }
- // The sorted contexts
- TreeSet<CustomizationContext> sortedContexts = new
TreeSet<CustomizationContext>(comparator);
+ //
- // Contexts up to this node
- Set<CustomizationContext> existingContexts = getContexts();
+ protected final Customization<Object> get(Collection<CustomizationContext>
contexts, boolean create)
+ {
- // Add all existing contexts
- sortedContexts.addAll(existingContexts);
+ // The sorted contexts
+ TreeSet<CustomizationContext> sortedContexts = new
TreeSet<CustomizationContext>(comparator);
- // Sort everything and check consistency
- sortedContexts.addAll(contexts);
+ // Contexts up to this node
+ Set<CustomizationContext> existingContexts = getContexts();
- // Remove existing contexts
- sortedContexts.removeAll(existingContexts);
+ // Add all existing contexts
+ sortedContexts.addAll(existingContexts);
- //
- return get(sortedContexts.iterator(), create);
- }
+ // Sort everything and check consistency
+ sortedContexts.addAll(contexts);
- protected final Customization<Object> get(Iterator<CustomizationContext>
contexts, boolean create) {
- if (contexts.hasNext()) {
- CustomizationContext context = contexts.next();
- String type = context.getContextType();
- ContextTypeContainer typeContainer = getContextTypes();
- Map<String, ContextType> contextTypes = typeContainer.getContextTypes();
- ContextType tmp = contextTypes.get(type);
- if (tmp == null) {
- if (create) {
- tmp = create();
- contextTypes.put(type, tmp);
- } else {
- return null;
- }
- }
- Map<String, ContextSpecialization> c = tmp.getSpecializations();
- String id = context.getContextId();
- ContextSpecialization blah = c.get(id);
+ // Remove existing contexts
+ sortedContexts.removeAll(existingContexts);
//
- if (blah != null || !create) {
- return blah;
- }
+ return get(sortedContexts.iterator(), create);
+ }
- //
- blah = createContextSpecialization();
- c.put(id, blah);
+ protected final Customization<Object> get(Iterator<CustomizationContext>
contexts, boolean create)
+ {
+ if (contexts.hasNext())
+ {
+ CustomizationContext context = contexts.next();
+ String type = context.getContextType();
+ ContextTypeContainer typeContainer = getContextTypes();
+ Map<String, ContextType> contextTypes = typeContainer.getContextTypes();
+ ContextType tmp = contextTypes.get(type);
+ if (tmp == null)
+ {
+ if (create)
+ {
+ tmp = create();
+ contextTypes.put(type, tmp);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ Map<String, ContextSpecialization> c = tmp.getSpecializations();
+ String id = context.getContextId();
+ ContextSpecialization blah = c.get(id);
- //
- return blah.get(contexts, create);
- } else {
- return this;
- }
- }
+ //
+ if (blah != null || !create)
+ {
+ return blah;
+ }
+
+ //
+ blah = createContextSpecialization();
+ c.put(id, blah);
+
+ //
+ return blah.get(contexts, create);
+ }
+ else
+ {
+ return this;
+ }
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContentState.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContentState.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContentState.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -22,10 +22,11 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class ContentState {
+public abstract class ContentState
+{
- public abstract Object getPayload();
+ public abstract Object getPayload();
- public abstract void setPayload(Object payload);
+ public abstract void setPayload(Object payload);
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextSpecialization.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextSpecialization.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextSpecialization.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -30,45 +30,53 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:contextspecialization")
-public abstract class ContextSpecialization extends AbstractCustomization {
+public abstract class ContextSpecialization extends AbstractCustomization
+{
- /** . */
- private CustomizationContextResolver customizationContextResolver;
+ /** . */
+ private CustomizationContextResolver customizationContextResolver;
- public CustomizationContextResolver getCustomizationContextResolver() {
- return customizationContextResolver;
- }
+ public CustomizationContextResolver getCustomizationContextResolver()
+ {
+ return customizationContextResolver;
+ }
- public void setCustomizationContextResolver(CustomizationContextResolver
customizationContextResolver) {
- this.customizationContextResolver = customizationContextResolver;
- }
+ public void setCustomizationContextResolver(CustomizationContextResolver
customizationContextResolver)
+ {
+ this.customizationContextResolver = customizationContextResolver;
+ }
- @Name
- public abstract String getContextId();
+ @Name
+ public abstract String getContextId();
- @ManyToOne
- public abstract ContextType getContextType();
+ @ManyToOne
+ public abstract ContextType getContextType();
- public ContentType<Object> getType() {
- throw new UnsupportedOperationException();
- }
+ public ContentType<Object> getType()
+ {
+ throw new UnsupportedOperationException();
+ }
- public CustomizationContext getContext() {
- ContextType currentContextType = getContextType();
- String contextType = currentContextType.getName();
- return customizationContextResolver.resolve(contextType, getContextId());
- }
+ public CustomizationContext getContext()
+ {
+ ContextType currentContextType = getContextType();
+ String contextType = currentContextType.getName();
+ return customizationContextResolver.resolve(contextType, getContextId());
+ }
- public AbstractCustomization getParent() {
- ContextType contextType = getContextType();
- return contextType.getContainer().getCustomization();
- }
+ public AbstractCustomization getParent()
+ {
+ ContextType contextType = getContextType();
+ return contextType.getContainer().getCustomization();
+ }
- public String getContentId() {
- throw new UnsupportedOperationException();
- }
+ public String getContentId()
+ {
+ throw new UnsupportedOperationException();
+ }
- public void destroy() {
- throw new UnsupportedOperationException("todo");
- }
+ public void destroy()
+ {
+ throw new UnsupportedOperationException("todo");
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextType.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextType.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextType.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -30,15 +30,16 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:contexttype")
-public abstract class ContextType {
+public abstract class ContextType
+{
- @Name
- public abstract String getName();
+ @Name
+ public abstract String getName();
- @OneToMany
- public abstract Map<String, ContextSpecialization> getSpecializations();
+ @OneToMany
+ public abstract Map<String, ContextSpecialization> getSpecializations();
- @ManyToOne
- public abstract ContextTypeContainer getContainer();
+ @ManyToOne
+ public abstract ContextTypeContainer getContainer();
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextTypeContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextTypeContainer.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/ContextTypeContainer.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -29,12 +29,13 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:contexttypecontainer")
-public abstract class ContextTypeContainer {
+public abstract class ContextTypeContainer
+{
- @OneToMany
- public abstract Map<String, ContextType> getContextTypes();
+ @OneToMany
+ public abstract Map<String, ContextType> getContextTypes();
- @ManyToOne
- public abstract AbstractCustomization getCustomization();
+ @ManyToOne
+ public abstract AbstractCustomization getCustomization();
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/CustomizationContainer.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/CustomizationContainer.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/CustomizationContainer.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -34,55 +34,62 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:customizationcontainer")
-public abstract class CustomizationContainer {
+public abstract class CustomizationContainer
+{
- @OneToOne
- @RelatedMappedBy("customizations")
- public abstract WorkspaceCustomizationContext getOwner();
+ @OneToOne
+ @RelatedMappedBy("customizations")
+ public abstract WorkspaceCustomizationContext getOwner();
- @OneToMany
- public abstract Map<String, WorkspaceCustomization> getCustomizations();
+ @OneToMany
+ public abstract Map<String, WorkspaceCustomization> getCustomizations();
- @Create
- public abstract WorkspaceClone createClone();
+ @Create
+ public abstract WorkspaceClone createClone();
- @Create
- public abstract WorkspaceSpecialization createSpecialization();
+ @Create
+ public abstract WorkspaceSpecialization createSpecialization();
- public Customization<?> getCustomization(String name) {
- Map<String, WorkspaceCustomization> customizations = getCustomizations();
- return customizations.get(name);
- }
+ public Customization<?> getCustomization(String name)
+ {
+ Map<String, WorkspaceCustomization> customizations = getCustomizations();
+ return customizations.get(name);
+ }
- public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state) {
- Map<String, WorkspaceCustomization> contents = getCustomizations();
- WorkspaceClone content = createClone();
- contents.put(name, content);
- content.setContentId(contentId);
- content.setMimeType(contentType.getMimeType());
- content.setState(state);
- return (Customization<S>)content;
- }
+ public <S> Customization<S> customize(String name, ContentType<S>
contentType, String contentId, S state)
+ {
+ Map<String, WorkspaceCustomization> contents = getCustomizations();
+ WorkspaceClone content = createClone();
+ contents.put(name, content);
+ content.setContentId(contentId);
+ content.setMimeType(contentType.getMimeType());
+ content.setState(state);
+ return (Customization<S>)content;
+ }
- public <S> Customization<S> customize(String name, Customization<S>
customization) {
- Map<String, WorkspaceCustomization> contents = getCustomizations();
- WorkspaceCustomization workspaceCustomization =
(WorkspaceCustomization)customization;
- WorkspaceSpecialization content = createSpecialization();
- contents.put(name, content);
- content.setMimeType(workspaceCustomization.getMimeType());
- content.setContentId(workspaceCustomization.getContentId());
- content.setCustomization(workspaceCustomization);
- return (Customization<S>)content;
- }
+ public <S> Customization<S> customize(String name, Customization<S>
customization)
+ {
+ Map<String, WorkspaceCustomization> contents = getCustomizations();
+ WorkspaceCustomization workspaceCustomization =
(WorkspaceCustomization)customization;
+ WorkspaceSpecialization content = createSpecialization();
+ contents.put(name, content);
+ content.setMimeType(workspaceCustomization.getMimeType());
+ content.setContentId(workspaceCustomization.getContentId());
+ content.setCustomization(workspaceCustomization);
+ return (Customization<S>)content;
+ }
- public String nameOf(Customization customization) {
- if (customization instanceof WorkspaceClone) {
- WorkspaceClone wc = (WorkspaceClone)customization;
- Map<String, WorkspaceCustomization> contents = getCustomizations();
- if (contents.containsValue(wc)) {
- return wc.getFooName();
+ public String nameOf(Customization customization)
+ {
+ if (customization instanceof WorkspaceClone)
+ {
+ WorkspaceClone wc = (WorkspaceClone)customization;
+ Map<String, WorkspaceCustomization> contents = getCustomizations();
+ if (contents.containsValue(wc))
+ {
+ return wc.getFooName();
+ }
}
- }
- return null;
- }
+ return null;
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceClone.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceClone.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceClone.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -37,49 +37,58 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:workspaceclone")
-public abstract class WorkspaceClone extends WorkspaceCustomization {
+public abstract class WorkspaceClone extends WorkspaceCustomization
+{
- public Set<CustomizationContext> getContexts() {
- return Collections.emptySet();
- }
+ public Set<CustomizationContext> getContexts()
+ {
+ return Collections.emptySet();
+ }
- @Name
- public abstract String getFooName();
+ @Name
+ public abstract String getFooName();
- @OneToMany(type = RelationshipType.PATH)
- @RelatedMappedBy("customization")
- public abstract Collection<WorkspaceSpecialization> getSpecializations();
+ @OneToMany(type = RelationshipType.PATH)
+ @RelatedMappedBy("customization")
+ public abstract Collection<WorkspaceSpecialization> getSpecializations();
- //
+ //
- public String getName() {
- CustomizationContext customizationContext = getContext();
- if (customizationContext instanceof WorkspaceCustomizationContext) {
- return getFooName();
- } else {
+ public String getName()
+ {
+ CustomizationContext customizationContext = getContext();
+ if (customizationContext instanceof WorkspaceCustomizationContext)
+ {
+ return getFooName();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public AbstractCustomization getParent()
+ {
return null;
- }
- }
+ }
- public AbstractCustomization getParent() {
- return null;
- }
+ public void destroy()
+ {
+ // Get specializations (clone for now because of bug with concurrent modif in
chromattic)
+ Collection<WorkspaceSpecialization> specializations = new
ArrayList<WorkspaceSpecialization>(getSpecializations());
- public void destroy() {
- // Get specializations (clone for now because of bug with concurrent modif in
chromattic)
- Collection<WorkspaceSpecialization> specializations = new
ArrayList<WorkspaceSpecialization>(getSpecializations());
+ //
+ for (WorkspaceSpecialization specialization : specializations)
+ {
+ // Update the specialization with its virtual state
+ Object state = specialization.getVirtualState();
+ specialization.setState(state);
- //
- for (WorkspaceSpecialization specialization : specializations) {
- // Update the specialization with its virtual state
- Object state = specialization.getVirtualState();
- specialization.setState(state);
+ // Clear ref
+ specialization.setCustomization(null);
+ }
- // Clear ref
- specialization.setCustomization(null);
- }
-
- //
- doDestroy();
- }
+ //
+ doDestroy();
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceCustomization.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceCustomization.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceCustomization.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -30,41 +30,52 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class WorkspaceCustomization extends AbstractCustomization {
+public abstract class WorkspaceCustomization extends AbstractCustomization
+{
- @Property(name = "mimetype")
- public abstract String getMimeType();
+ @Property(name = "mimetype")
+ public abstract String getMimeType();
- public abstract void setMimeType(String mimeType);
+ public abstract void setMimeType(String mimeType);
- @Property(name = "contentid")
- public abstract String getContentId();
+ @Property(name = "contentid")
+ public abstract String getContentId();
- public abstract void setContentId(String contentId);
+ public abstract void setContentId(String contentId);
- @ManyToOne
- public abstract Object getOwner();
+ @ManyToOne
+ public abstract Object getOwner();
- @Destroy
- public abstract void doDestroy();
+ @Destroy
+ public abstract void doDestroy();
- public final CustomizationContext getContext() {
- Object owner = getOwner();
- if (owner instanceof CustomizationContainer) {
- return ((CustomizationContainer)owner).getOwner();
- } else if (owner instanceof UIWindowImpl) {
- return (UIWindowImpl)owner;
- } else {
- throw new AssertionError();
- }
- }
+ public final CustomizationContext getContext()
+ {
+ Object owner = getOwner();
+ if (owner instanceof CustomizationContainer)
+ {
+ return ((CustomizationContainer)owner).getOwner();
+ }
+ else if (owner instanceof UIWindowImpl)
+ {
+ return (UIWindowImpl)owner;
+ }
+ else
+ {
+ throw new AssertionError();
+ }
+ }
- public final ContentType<Object> getType() {
- ContentRegistration registration = registry.providers.get(getMimeType());
- if (registration != null) {
- return (ContentType<Object>)registration.getContentType();
- } else {
- return null;
- }
- }
+ public final ContentType<Object> getType()
+ {
+ ContentRegistration registration = registry.providers.get(getMimeType());
+ if (registration != null)
+ {
+ return (ContentType<Object>)registration.getContentType();
+ }
+ else
+ {
+ return null;
+ }
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceSpecialization.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceSpecialization.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/api/workspace/content/WorkspaceSpecialization.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,19 +28,22 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:workspacespecialization")
-public abstract class WorkspaceSpecialization extends WorkspaceCustomization {
+public abstract class WorkspaceSpecialization extends WorkspaceCustomization
+{
- @ManyToOne(type = RelationshipType.PATH)
- @MappedBy("customization")
- public abstract WorkspaceCustomization getCustomization();
+ @ManyToOne(type = RelationshipType.PATH)
+ @MappedBy("customization")
+ public abstract WorkspaceCustomization getCustomization();
- public abstract void setCustomization(WorkspaceCustomization customization);
+ public abstract void setCustomization(WorkspaceCustomization customization);
- public void destroy() {
- doDestroy();
- }
+ public void destroy()
+ {
+ doDestroy();
+ }
- public AbstractCustomization getParent() {
- return getCustomization();
- }
+ public AbstractCustomization getParent()
+ {
+ return getCustomization();
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/spi/content/WorkspaceCustomizationPolicy.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/spi/content/WorkspaceCustomizationPolicy.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/spi/content/WorkspaceCustomizationPolicy.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -24,9 +24,11 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class WorkspaceCustomizationPolicy {
+public class WorkspaceCustomizationPolicy
+{
- public boolean contains(WorkspaceCustomizationContext c1, WorkspaceCustomizationContext
c2) {
+ public boolean contains(WorkspaceCustomizationContext c1,
WorkspaceCustomizationContext c2)
+ {
/*
if (c1 instanceof Workspace) {
if (c2 instanceof Workspace) {
@@ -74,6 +76,6 @@
throw new AssertionError();
}
*/
- throw new UnsupportedOperationException();
- }
+ throw new UnsupportedOperationException();
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/AbstractAttributes.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/AbstractAttributes.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/AbstractAttributes.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,110 +28,144 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class AbstractAttributes implements Attributes {
+public abstract class AbstractAttributes implements Attributes
+{
- protected abstract Object get(String name);
+ protected abstract Object get(String name);
- protected abstract void set(String name, Object o);
+ protected abstract void set(String name, Object o);
- private <T> T getObject(String name, ValueType<T> type, T defaultValue) {
- if (name == null) {
- throw new NullPointerException();
- }
- Object o = get(name);
- if (o == null) {
- return defaultValue;
- } else {
- return type.cast(o);
- }
- }
+ private <T> T getObject(String name, ValueType<T> type, T defaultValue)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException();
+ }
+ Object o = get(name);
+ if (o == null)
+ {
+ return defaultValue;
+ }
+ else
+ {
+ return type.cast(o);
+ }
+ }
- public final Object getObject(String name) {
- if (name == null) {
- throw new NullPointerException();
- }
- Object o = get(name);
- if (o == null) {
- return null;
- } else {
- ValueType.get(o);
- return o;
- }
- }
+ public final Object getObject(String name)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException();
+ }
+ Object o = get(name);
+ if (o == null)
+ {
+ return null;
+ }
+ else
+ {
+ ValueType.get(o);
+ return o;
+ }
+ }
- public final <T> void setObject(String name, T value) {
- if (name == null) {
- throw new NullPointerException();
- }
- if (value == null) {
- set(name, null);
- } else {
- ValueType.get(value);
- set(name, value);
- }
- }
+ public final <T> void setObject(String name, T value)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException();
+ }
+ if (value == null)
+ {
+ set(name, null);
+ }
+ else
+ {
+ ValueType.get(value);
+ set(name, value);
+ }
+ }
- public final ValueType<?> getType(String name) {
- if (name == null) {
- throw new NullPointerException();
- }
- Object o = get(name);
- if (o == null) {
- return null;
- } else {
- return ValueType.get(o);
- }
- }
+ public final ValueType<?> getType(String name)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException();
+ }
+ Object o = get(name);
+ if (o == null)
+ {
+ return null;
+ }
+ else
+ {
+ return ValueType.get(o);
+ }
+ }
- public final String getString(String name) {
- return getObject(name, ValueType.STRING, null);
- }
+ public final String getString(String name)
+ {
+ return getObject(name, ValueType.STRING, null);
+ }
- public final void setString(String name, String value) {
- setObject(name, value);
- }
+ public final void setString(String name, String value)
+ {
+ setObject(name, value);
+ }
- public final Boolean getBoolean(String name) {
- return getObject(name, ValueType.BOOLEAN, null);
- }
+ public final Boolean getBoolean(String name)
+ {
+ return getObject(name, ValueType.BOOLEAN, null);
+ }
- public final void setBoolean(String name, Boolean value) {
- setObject(name, value);
- }
+ public final void setBoolean(String name, Boolean value)
+ {
+ setObject(name, value);
+ }
- public final Integer getInteger(String name) {
- return getObject(name, ValueType.INTEGER, null);
- }
+ public final Integer getInteger(String name)
+ {
+ return getObject(name, ValueType.INTEGER, null);
+ }
- public final void setInteger(String name, Integer value) {
- setObject(name, value);
- }
+ public final void setInteger(String name, Integer value)
+ {
+ setObject(name, value);
+ }
- public final Date getDate(String name) {
- return getObject(name, ValueType.DATE, null);
- }
+ public final Date getDate(String name)
+ {
+ return getObject(name, ValueType.DATE, null);
+ }
- public final void setDate(String name, Date value) {
- setObject(name, value);
- }
+ public final void setDate(String name, Date value)
+ {
+ setObject(name, value);
+ }
- public final Double getDouble(String name) {
- return getObject(name, ValueType.DOUBLE, null);
- }
+ public final Double getDouble(String name)
+ {
+ return getObject(name, ValueType.DOUBLE, null);
+ }
- public final void setDouble(String name, Double value) {
- setObject(name, value);
- }
+ public final void setDouble(String name, Double value)
+ {
+ setObject(name, value);
+ }
- public final <T> T getValue(Key<T> key, T defaultValue) {
- return getObject(key.getName(), key.getType(), defaultValue);
- }
+ public final <T> T getValue(Key<T> key, T defaultValue)
+ {
+ return getObject(key.getName(), key.getType(), defaultValue);
+ }
- public final <T> T getValue(Key<T> key) {
- return getObject(key.getName(), key.getType(), null);
- }
+ public final <T> T getValue(Key<T> key)
+ {
+ return getObject(key.getName(), key.getType(), null);
+ }
- public final <T> void setValue(Key<T> key, T value) {
- setObject(key.getName(), value);
- }
+ public final <T> void setValue(Key<T> key, T value)
+ {
+ setObject(key.getName(), value);
+ }
}
Modified:
components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/SimpleAttributes.java
===================================================================
---
components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/SimpleAttributes.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/SimpleAttributes.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -26,31 +26,40 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class SimpleAttributes extends AbstractAttributes {
+public class SimpleAttributes extends AbstractAttributes
+{
- private final Map<String, Object> map;
+ private final Map<String, Object> map;
- public SimpleAttributes(Map<String, Object> map) {
- this.map = map;
- }
+ public SimpleAttributes(Map<String, Object> map)
+ {
+ this.map = map;
+ }
- public SimpleAttributes() {
- this(new HashMap<String, Object>());
- }
+ public SimpleAttributes()
+ {
+ this(new HashMap<String, Object>());
+ }
- public Set<String> getKeys() {
- return map.keySet();
- }
+ public Set<String> getKeys()
+ {
+ return map.keySet();
+ }
- protected Object get(String name) {
- return map.get(name);
- }
+ protected Object get(String name)
+ {
+ return map.get(name);
+ }
- protected void set(String name, Object o) {
- if (o == null) {
- map.remove(name);
- } else {
- map.put(name, o);
- }
- }
+ protected void set(String name, Object o)
+ {
+ if (o == null)
+ {
+ map.remove(name);
+ }
+ else
+ {
+ map.put(name, o);
+ }
+ }
}
Modified: components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/Tools.java
===================================================================
--- components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/Tools.java 2009-11-23
17:17:11 UTC (rev 767)
+++ components/mop/trunk/core/src/main/java/org/gatein/mop/core/util/Tools.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -29,91 +29,115 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class Tools {
+public class Tools
+{
- public static <N> List<N> list(Iterator<N> iterable) {
- ArrayList<N> set = new ArrayList<N>();
- while (iterable.hasNext()) {
- set.add(iterable.next());
- }
- return set;
- }
+ public static <N> List<N> list(Iterator<N> iterable)
+ {
+ ArrayList<N> set = new ArrayList<N>();
+ while (iterable.hasNext())
+ {
+ set.add(iterable.next());
+ }
+ return set;
+ }
- public static <N> Set<N> set(Iterable<N> iterable) {
- HashSet<N> set = new HashSet<N>();
- for (N n : iterable) {
- set.add(n);
- }
- return set;
- }
+ public static <N> Set<N> set(Iterable<N> iterable)
+ {
+ HashSet<N> set = new HashSet<N>();
+ for (N n : iterable)
+ {
+ set.add(n);
+ }
+ return set;
+ }
- public static <N> Set<N> set(Iterator<N> iterator) {
- HashSet<N> set = new HashSet<N>();
- while (iterator.hasNext()) {
- set.add(iterator.next());
- }
- return set;
- }
+ public static <N> Set<N> set(Iterator<N> iterator)
+ {
+ HashSet<N> set = new HashSet<N>();
+ while (iterator.hasNext())
+ {
+ set.add(iterator.next());
+ }
+ return set;
+ }
- public static <N> Set<N> set() {
- return new HashSet<N>();
- }
+ public static <N> Set<N> set()
+ {
+ return new HashSet<N>();
+ }
- public static <N> Set<N> set(N object) {
- HashSet<N> set = new HashSet<N>();
- set.add(object);
- return set;
- }
-
- public static <N> Set<N> set(N... objects) throws NullPointerException {
- if (objects == null) {
- throw new NullPointerException();
- }
- HashSet<N> set = new HashSet<N>();
- for (N object : objects) {
+ public static <N> Set<N> set(N object)
+ {
+ HashSet<N> set = new HashSet<N>();
set.add(object);
- }
- return set;
- }
+ return set;
+ }
- public static int max(int value, int... values) {
- int max = value;
- for (int v : values) {
- if (v > max) {
- max = v;
+ public static <N> Set<N> set(N... objects) throws NullPointerException
+ {
+ if (objects == null)
+ {
+ throw new NullPointerException();
}
- }
- return max;
- }
+ HashSet<N> set = new HashSet<N>();
+ for (N object : objects)
+ {
+ set.add(object);
+ }
+ return set;
+ }
- public static <E> Iterator<E> iterator(final Iterator<? extends E>...
iterators) {
- return new Iterator<E>() {
+ public static int max(int value, int... values)
+ {
+ int max = value;
+ for (int v : values)
+ {
+ if (v > max)
+ {
+ max = v;
+ }
+ }
+ return max;
+ }
- int index = 0;
+ public static <E> Iterator<E> iterator(final Iterator<? extends
E>... iterators)
+ {
+ return new Iterator<E>()
+ {
- public boolean hasNext() {
- while (index < iterators.length) {
- if (iterators[index].hasNext()) {
- return true;
- }
- index++;
- }
- return false;
- }
+ int index = 0;
- public E next() {
- while (index < iterators.length) {
- if (iterators[index].hasNext()) {
- return iterators[index].next();
- }
- index++;
- }
- throw new NoSuchElementException();
- }
+ public boolean hasNext()
+ {
+ while (index < iterators.length)
+ {
+ if (iterators[index].hasNext())
+ {
+ return true;
+ }
+ index++;
+ }
+ return false;
+ }
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- }
+ public E next()
+ {
+ while (index < iterators.length)
+ {
+ if (iterators[index].hasNext())
+ {
+ return iterators[index].next();
+ }
+ index++;
+ }
+ throw new NoSuchElementException();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/AbstractPOMTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/AbstractPOMTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/AbstractPOMTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -31,28 +31,30 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class AbstractPOMTestCase extends TestCase {
+public abstract class AbstractPOMTestCase extends TestCase
+{
- /** . */
- protected MOPService pomService;
+ /** . */
+ protected MOPService pomService;
- @Override
- protected void setUp() throws Exception {
- Preferences weatherPreferences = new Preferences(Collections.<String,
Preference>singletonMap(
- "zip", new Preference("zip",
Collections.singletonList("marseille"), false)));
- PortletContentProvider portletContentProvider = new PortletContentProvider();
+ @Override
+ protected void setUp() throws Exception
+ {
+ Preferences weatherPreferences = new Preferences(Collections.<String,
Preference>singletonMap(
+ "zip", new Preference("zip",
Collections.singletonList("marseille"), false)));
+ PortletContentProvider portletContentProvider = new PortletContentProvider();
- //
- MOPService pomService = new TestMOPService();
+ //
+ MOPService pomService = new TestMOPService();
- //
- pomService.start();
+ //
+ pomService.start();
- // Not needed for now
- // pomService.getContentManagerRegistry().register(Preferences.CONTENT_TYPE,
portletContentProvider);
+ // Not needed for now
+ // pomService.getContentManagerRegistry().register(Preferences.CONTENT_TYPE,
portletContentProvider);
- //
- this.pomService = pomService;
- }
+ //
+ this.pomService = pomService;
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/POMFormatterTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/POMFormatterTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/POMFormatterTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -25,45 +25,52 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class POMFormatterTestCase extends TestCase {
+public class POMFormatterTestCase extends TestCase
+{
- /** . */
- private final ObjectFormatter formatter = new MOPFormatter();
+ /** . */
+ private final ObjectFormatter formatter = new MOPFormatter();
- private void assertString(String expected, String s) {
- assertEquals(expected, formatter.encodeNodeName(null, s));
- assertEquals(s, formatter.decodeNodeName(null, expected));
- }
+ private void assertString(String expected, String s)
+ {
+ assertEquals(expected, formatter.encodeNodeName(null, s));
+ assertEquals(s, formatter.decodeNodeName(null, expected));
+ }
- private void assertCannotDecode(String s) {
- try {
- formatter.decodeNodeName(null, s);
- fail();
- }
- catch (IllegalStateException ignore) {
- }
- }
+ private void assertCannotDecode(String s)
+ {
+ try
+ {
+ formatter.decodeNodeName(null, s);
+ fail();
+ }
+ catch (IllegalStateException ignore)
+ {
+ }
+ }
- public void testStrings() {
- assertString("", "");
- assertString("a", "a");
- assertString("%00", "{");
- assertString("%01", "}");
- assertString("%02", ".");
- assertString("%03", "/");
- assertString("%04", ":");
- assertString("%05", "[");
- assertString("%06", "]");
- assertString("%07", "|");
- assertString("%08", "*");
- assertString("%09", "%");
- assertString("a%03b", "a/b");
- }
+ public void testStrings()
+ {
+ assertString("", "");
+ assertString("a", "a");
+ assertString("%00", "{");
+ assertString("%01", "}");
+ assertString("%02", ".");
+ assertString("%03", "/");
+ assertString("%04", ":");
+ assertString("%05", "[");
+ assertString("%06", "]");
+ assertString("%07", "|");
+ assertString("%08", "*");
+ assertString("%09", "%");
+ assertString("a%03b", "a/b");
+ }
- public void testDecodeFailure() {
- assertCannotDecode("%0");
- assertCannotDecode("%0" + (char)('0' - 1));
- assertCannotDecode("%0" + (char)('9' + 1));
- assertCannotDecode("%1");
- }
+ public void testDecodeFailure()
+ {
+ assertCannotDecode("%0");
+ assertCannotDecode("%0" + (char)('0' - 1));
+ assertCannotDecode("%0" + (char)('9' + 1));
+ assertCannotDecode("%1");
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/composer/StructureIteratorTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/composer/StructureIteratorTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/composer/StructureIteratorTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -35,128 +35,135 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class StructureIteratorTestCase extends AbstractPOMTestCase {
+public class StructureIteratorTestCase extends AbstractPOMTestCase
+{
- public void testCompoundPage() {
- ModelImpl model = pomService.getModel();
- Site site = model.getWorkspace().addSite(ObjectType.PORTAL_SITE, "site");
- Page root = site.getRootPage();
+ public void testCompoundPage()
+ {
+ ModelImpl model = pomService.getModel();
+ Site site = model.getWorkspace().addSite(ObjectType.PORTAL_SITE,
"site");
+ Page root = site.getRootPage();
- //
- Page t = root.addChild("t");
- UIContainer t0 = t.getRootComponent();
- UIComponent t1 = t0.add(ObjectType.WINDOW, "t1");
- UIComponent t2 = t0.add(ObjectType.BODY, "t2");
- UIComponent t3 = t0.add(ObjectType.WINDOW, "t3");
+ //
+ Page t = root.addChild("t");
+ UIContainer t0 = t.getRootComponent();
+ UIComponent t1 = t0.add(ObjectType.WINDOW, "t1");
+ UIComponent t2 = t0.add(ObjectType.BODY, "t2");
+ UIComponent t3 = t0.add(ObjectType.WINDOW, "t3");
- //
- Page u = root.addChild("u");
- UIContainer u0 = u.getRootComponent();
- UIComponent u1 = u0.add(ObjectType.WINDOW, "u1");
- UIComponent u2 = u0.add(ObjectType.BODY, "u2");
+ //
+ Page u = root.addChild("u");
+ UIContainer u0 = u.getRootComponent();
+ UIComponent u1 = u0.add(ObjectType.WINDOW, "u1");
+ UIComponent u2 = u0.add(ObjectType.BODY, "u2");
- //
- Page a = root.addChild("a");
- a.setTemplate(t);
- UIContainer a0 = a.getRootComponent();
- UIComponent a1 = a0.add(ObjectType.WINDOW, "a1");
- UIComponent a2 = a0.add(ObjectType.WINDOW, "a2");
- PageIterator ia = new PageIterator(a, PageIteratorStrategies.PAGE_TEMPLATE);
- assertStart(ia, t0);
- assertStart(ia, t1);
- assertEnd(ia, t1);
- assertStart(ia, a0);
- assertStart(ia, a1);
- assertEnd(ia, a1);
- assertStart(ia, a2);
- assertEnd(ia, a2);
- assertEnd(ia, a0);
- assertStart(ia, t3);
- assertEnd(ia, t3);
- assertEnd(ia, t0);
- assertDone(ia);
+ //
+ Page a = root.addChild("a");
+ a.setTemplate(t);
+ UIContainer a0 = a.getRootComponent();
+ UIComponent a1 = a0.add(ObjectType.WINDOW, "a1");
+ UIComponent a2 = a0.add(ObjectType.WINDOW, "a2");
+ PageIterator ia = new PageIterator(a, PageIteratorStrategies.PAGE_TEMPLATE);
+ assertStart(ia, t0);
+ assertStart(ia, t1);
+ assertEnd(ia, t1);
+ assertStart(ia, a0);
+ assertStart(ia, a1);
+ assertEnd(ia, a1);
+ assertStart(ia, a2);
+ assertEnd(ia, a2);
+ assertEnd(ia, a0);
+ assertStart(ia, t3);
+ assertEnd(ia, t3);
+ assertEnd(ia, t0);
+ assertDone(ia);
- //
- Page b = root.addChild("b");
- UIContainer b0 = b.getRootComponent();
- UIComponent b1 = b0.add(ObjectType.WINDOW, "b1");
- UIComponent b2 = b0.add(ObjectType.WINDOW, "b2");
+ //
+ Page b = root.addChild("b");
+ UIContainer b0 = b.getRootComponent();
+ UIComponent b1 = b0.add(ObjectType.WINDOW, "b1");
+ UIComponent b2 = b0.add(ObjectType.WINDOW, "b2");
- //
- Page c = root.addChild("c");
- c.setTemplate(u);
+ //
+ Page c = root.addChild("c");
+ c.setTemplate(u);
- }
+ }
- private void assertStart(StructureIterator i, UIComponent expectedComponent) {
- IterationType type = i.next();
- assertEquals(IterationType.START, type);
- UIComponent component = i.getComponent();
- assertSame(expectedComponent, component);
- }
+ private void assertStart(StructureIterator i, UIComponent expectedComponent)
+ {
+ IterationType type = i.next();
+ assertEquals(IterationType.START, type);
+ UIComponent component = i.getComponent();
+ assertSame(expectedComponent, component);
+ }
- private void assertEnd(StructureIterator i, UIComponent expectedComponent) {
- IterationType type = i.next();
- assertEquals(IterationType.END, type);
- UIComponent component = i.getComponent();
- assertSame(expectedComponent, component);
- }
+ private void assertEnd(StructureIterator i, UIComponent expectedComponent)
+ {
+ IterationType type = i.next();
+ assertEquals(IterationType.END, type);
+ UIComponent component = i.getComponent();
+ assertSame(expectedComponent, component);
+ }
- private void assertDone(StructureIterator i) {
- IterationType type = i.next();
- assertEquals(IterationType.DONE, type);
- UIComponent component = i.getComponent();
- assertSame(null, component);
- }
+ private void assertDone(StructureIterator i)
+ {
+ IterationType type = i.next();
+ assertEquals(IterationType.DONE, type);
+ UIComponent component = i.getComponent();
+ assertSame(null, component);
+ }
- public void testSimplePage() {
- ModelImpl model = pomService.getModel();
- Site site = model.getWorkspace().addSite(ObjectType.PORTAL_SITE, "site");
- Page root = site.getRootPage();
- UIContainer c0 = root.getRootComponent();
- UIComponent c1 = c0.add(ObjectType.WINDOW, "c1");
+ public void testSimplePage()
+ {
+ ModelImpl model = pomService.getModel();
+ Site site = model.getWorkspace().addSite(ObjectType.PORTAL_SITE,
"site");
+ Page root = site.getRootPage();
+ UIContainer c0 = root.getRootComponent();
+ UIComponent c1 = c0.add(ObjectType.WINDOW, "c1");
- //
- PageIterator i = new PageIterator(root, PageIteratorStrategies.PAGE_TEMPLATE);
- assertStart(i, c0);
- assertStart(i, c1);
- assertEnd(i, c1);
- assertEnd(i, c0);
- assertDone(i);
- }
+ //
+ PageIterator i = new PageIterator(root, PageIteratorStrategies.PAGE_TEMPLATE);
+ assertStart(i, c0);
+ assertStart(i, c1);
+ assertEnd(i, c1);
+ assertEnd(i, c0);
+ assertDone(i);
+ }
- public void testComponents() {
- ModelImpl model = pomService.getModel();
- Site site = model.getWorkspace().addSite(ObjectType.PORTAL_SITE, "site");
- Page root = site.getRootPage();
- UIContainer c0 = root.getRootComponent();
- UIComponent c1 = c0.add(ObjectType.WINDOW, "c1");
- UIContainer c2 = c0.add(ObjectType.CONTAINER, "c2");
- UIComponent c3 = c2.add(ObjectType.WINDOW, "c3");
- UIComponent c4 = c2.add(ObjectType.WINDOW, "c4");
- UIComponent c5 = c0.add(ObjectType.WINDOW, "c5");
+ public void testComponents()
+ {
+ ModelImpl model = pomService.getModel();
+ Site site = model.getWorkspace().addSite(ObjectType.PORTAL_SITE,
"site");
+ Page root = site.getRootPage();
+ UIContainer c0 = root.getRootComponent();
+ UIComponent c1 = c0.add(ObjectType.WINDOW, "c1");
+ UIContainer c2 = c0.add(ObjectType.CONTAINER, "c2");
+ UIComponent c3 = c2.add(ObjectType.WINDOW, "c3");
+ UIComponent c4 = c2.add(ObjectType.WINDOW, "c4");
+ UIComponent c5 = c0.add(ObjectType.WINDOW, "c5");
- //
- ComponentIterator i0 = new ComponentIterator(c1);
- assertStart(i0, c1);
- assertEnd(i0, c1);
- assertDone(i0);
+ //
+ ComponentIterator i0 = new ComponentIterator(c1);
+ assertStart(i0, c1);
+ assertEnd(i0, c1);
+ assertDone(i0);
- //
- ComponentIterator i1 = new ComponentIterator(c0);
- assertStart(i1, c0);
- assertStart(i1, c1);
- assertEnd(i1, c1);
- assertStart(i1, c2);
- assertStart(i1, c3);
- assertEnd(i1, c3);
- assertStart(i1, c4);
- assertEnd(i1, c4);
- assertEnd(i1, c2);
- assertStart(i1, c5);
- assertEnd(i1, c5);
- assertEnd(i1, c0);
- assertDone(i1);
- }
+ //
+ ComponentIterator i1 = new ComponentIterator(c0);
+ assertStart(i1, c0);
+ assertStart(i1, c1);
+ assertEnd(i1, c1);
+ assertStart(i1, c2);
+ assertStart(i1, c3);
+ assertEnd(i1, c3);
+ assertStart(i1, c4);
+ assertEnd(i1, c4);
+ assertEnd(i1, c2);
+ assertStart(i1, c5);
+ assertEnd(i1, c5);
+ assertEnd(i1, c0);
+ assertDone(i1);
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/BiltoTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/BiltoTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/BiltoTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -26,10 +26,11 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class BiltoTestCase extends AbstractPOMTestCase {
+public abstract class BiltoTestCase extends AbstractPOMTestCase
+{
- /** . */
- private final ContentType portletContentType = Preferences.CONTENT_TYPE;
+ /** . */
+ private final ContentType portletContentType = Preferences.CONTENT_TYPE;
/*
public void testBar() throws Exception {
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/CustomizationContextComparatorTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/CustomizationContextComparatorTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/CustomizationContextComparatorTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -34,129 +34,149 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class CustomizationContextComparatorTestCase extends TestCase {
+public class CustomizationContextComparatorTestCase extends TestCase
+{
- /** . */
- private final SimpleCustomizationContext s2 = new
SimpleCustomizationContext("foo", 2);
+ /** . */
+ private final SimpleCustomizationContext s2 = new
SimpleCustomizationContext("foo", 2);
- /** . */
- private final SimpleCustomizationContext s3 = new
SimpleCustomizationContext("foo", 3);
+ /** . */
+ private final SimpleCustomizationContext s3 = new
SimpleCustomizationContext("foo", 3);
- /** . */
- private final SimpleCustomizationContext s4 = new
SimpleCustomizationContext("foo", 4);
+ /** . */
+ private final SimpleCustomizationContext s4 = new
SimpleCustomizationContext("foo", 4);
- /** . */
- private final SimpleCustomizationContext b2 = new
SimpleCustomizationContext("bar", 2);
+ /** . */
+ private final SimpleCustomizationContext b2 = new
SimpleCustomizationContext("bar", 2);
- /** . */
- private final SimpleCustomizationContext b3 = new
SimpleCustomizationContext("bar", 3);
+ /** . */
+ private final SimpleCustomizationContext b3 = new
SimpleCustomizationContext("bar", 3);
- /** . */
- private final SimpleCustomizationContext b4 = new
SimpleCustomizationContext("bar", 4);
+ /** . */
+ private final SimpleCustomizationContext b4 = new
SimpleCustomizationContext("bar", 4);
- public void testKeepOrder() {
- CustomizationContextComparator comparator = new
CustomizationContextComparator("foo");
- List<SimpleCustomizationContext> contexts = new
ArrayList<SimpleCustomizationContext>();
- contexts.add(s2);
- contexts.add(s4);
- Collections.sort(contexts, comparator);
- List<SimpleCustomizationContext> blah = Arrays.asList(s2, s4);
- assertEquals(blah, contexts);
- }
+ public void testKeepOrder()
+ {
+ CustomizationContextComparator comparator = new
CustomizationContextComparator("foo");
+ List<SimpleCustomizationContext> contexts = new
ArrayList<SimpleCustomizationContext>();
+ contexts.add(s2);
+ contexts.add(s4);
+ Collections.sort(contexts, comparator);
+ List<SimpleCustomizationContext> blah = Arrays.asList(s2, s4);
+ assertEquals(blah, contexts);
+ }
- public void testSort() {
- CustomizationContextComparator comparator = new
CustomizationContextComparator("foo");
- List<SimpleCustomizationContext> contexts = new
ArrayList<SimpleCustomizationContext>();
- contexts.add(s4);
- contexts.add(s2);
- Collections.sort(contexts, comparator);
- List<SimpleCustomizationContext> blah = Arrays.asList(s2, s4);
- assertEquals(blah, contexts);
- }
-
- public void testFailWhenNotComparable() {
- CustomizationContextComparator comparator = new
CustomizationContextComparator("foo");
- List<SimpleCustomizationContext> contexts = new
ArrayList<SimpleCustomizationContext>();
- contexts.add(s2);
- contexts.add(s3);
- try {
+ public void testSort()
+ {
+ CustomizationContextComparator comparator = new
CustomizationContextComparator("foo");
+ List<SimpleCustomizationContext> contexts = new
ArrayList<SimpleCustomizationContext>();
+ contexts.add(s4);
+ contexts.add(s2);
Collections.sort(contexts, comparator);
- fail();
- }
- catch (ComparisonException e) {
- }
- }
+ List<SimpleCustomizationContext> blah = Arrays.asList(s2, s4);
+ assertEquals(blah, contexts);
+ }
- public void testFailWhenNonExpectedType() {
- CustomizationContextComparator comparator = new
CustomizationContextComparator("foo");
- List<SimpleCustomizationContext> contexts = new
ArrayList<SimpleCustomizationContext>();
- contexts.add(s2);
- contexts.add(b4);
- try {
+ public void testFailWhenNotComparable()
+ {
+ CustomizationContextComparator comparator = new
CustomizationContextComparator("foo");
+ List<SimpleCustomizationContext> contexts = new
ArrayList<SimpleCustomizationContext>();
+ contexts.add(s2);
+ contexts.add(s3);
+ try
+ {
+ Collections.sort(contexts, comparator);
+ fail();
+ }
+ catch (ComparisonException e)
+ {
+ }
+ }
+
+ public void testFailWhenNonExpectedType()
+ {
+ CustomizationContextComparator comparator = new
CustomizationContextComparator("foo");
+ List<SimpleCustomizationContext> contexts = new
ArrayList<SimpleCustomizationContext>();
+ contexts.add(s2);
+ contexts.add(b4);
+ try
+ {
+ Collections.sort(contexts, comparator);
+ fail();
+ }
+ catch (ComparisonException e)
+ {
+ }
+ }
+
+ public void testSortByTypes()
+ {
+ CustomizationContextComparator comparator = new
CustomizationContextComparator("foo", "bar");
+ List<SimpleCustomizationContext> contexts = new
ArrayList<SimpleCustomizationContext>();
+ contexts.add(b4);
+ contexts.add(s2);
+ contexts.add(s4);
+ contexts.add(b2);
Collections.sort(contexts, comparator);
- fail();
- }
- catch (ComparisonException e) {
- }
- }
+ List<?> blah = Arrays.asList(s2, s4, b2, b4);
+ assertEquals(blah, contexts);
+ }
- public void testSortByTypes() {
- CustomizationContextComparator comparator = new
CustomizationContextComparator("foo","bar");
- List<SimpleCustomizationContext> contexts = new
ArrayList<SimpleCustomizationContext>();
- contexts.add(b4);
- contexts.add(s2);
- contexts.add(s4);
- contexts.add(b2);
- Collections.sort(contexts, comparator);
- List<?> blah = Arrays.asList(s2, s4, b2, b4);
- assertEquals(blah, contexts);
- }
+ public void testRemoveDuplicates()
+ {
+ CustomizationContextComparator comparator = new
CustomizationContextComparator("foo");
+ SortedSet<SimpleCustomizationContext> contexts = new
TreeSet<SimpleCustomizationContext>(comparator);
+ contexts.add(s2);
+ contexts.add(s2);
+ assertEquals(1, contexts.size());
+ }
- public void testRemoveDuplicates() {
- CustomizationContextComparator comparator = new
CustomizationContextComparator("foo");
- SortedSet<SimpleCustomizationContext> contexts = new
TreeSet<SimpleCustomizationContext>(comparator);
- contexts.add(s2);
- contexts.add(s2);
- assertEquals(1, contexts.size());
- }
+ private static class SimpleCustomizationContext implements CustomizationContext
+ {
- private static class SimpleCustomizationContext implements CustomizationContext {
+ /** . */
+ private final String type;
- /** . */
- private final String type;
+ /** . */
+ private final int value;
- /** . */
- private final int value;
+ private SimpleCustomizationContext(String type, int value)
+ {
+ if (type == null)
+ {
+ throw new NullPointerException();
+ }
+ if (value < 1)
+ {
+ throw new IllegalArgumentException();
+ }
- private SimpleCustomizationContext(String type, int value) {
- if (type == null) {
- throw new NullPointerException();
+ //
+ this.type = type;
+ this.value = value;
}
- if (value < 1) {
- throw new IllegalArgumentException();
+
+ public String getContextId()
+ {
+ return type + "/" + value;
}
- //
- this.type = type;
- this.value = value;
- }
+ public String getContextType()
+ {
+ return type;
+ }
- public String getContextId() {
- return type + "/" + value;
- }
-
- public String getContextType() {
- return type;
- }
-
- public boolean contains(CustomizationContext that) {
- if (that instanceof SimpleCustomizationContext) {
- SimpleCustomizationContext thatSimple = (SimpleCustomizationContext)that;
- if (thatSimple.type.equals(type)) {
- return thatSimple.value % value == 0;
- }
+ public boolean contains(CustomizationContext that)
+ {
+ if (that instanceof SimpleCustomizationContext)
+ {
+ SimpleCustomizationContext thatSimple = (SimpleCustomizationContext)that;
+ if (thatSimple.type.equals(type))
+ {
+ return thatSimple.value % value == 0;
+ }
+ }
+ return false;
}
- return false;
- }
- }
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/CustomizationTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/CustomizationTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/content/CustomizationTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -24,7 +24,8 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public abstract class CustomizationTestCase extends AbstractPOMTestCase {
+public abstract class CustomizationTestCase extends AbstractPOMTestCase
+{
/*
public void tesGetPersistedCustomization() {
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/AttributesTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/AttributesTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/AttributesTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -29,33 +29,36 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class AttributesTestCase extends AbstractPOMTestCase {
+public class AttributesTestCase extends AbstractPOMTestCase
+{
- public void testAttributes() {
- ModelImpl model = pomService.getModel();
- Site portal = model.getWorkspace().addSite(ObjectType.PORTAL_SITE,
"portal");
- Attributes portalAttributes = portal.getAttributes();
- portalAttributes.setString("foo", "bar");
- assertEquals("bar", portalAttributes.getString("foo"));
- Attributes pageAttributes = portal.getRootPage().getAttributes();
- pageAttributes.setString("foo", "bar");
- assertEquals("bar", pageAttributes.getString("foo"));
- }
+ public void testAttributes()
+ {
+ ModelImpl model = pomService.getModel();
+ Site portal = model.getWorkspace().addSite(ObjectType.PORTAL_SITE,
"portal");
+ Attributes portalAttributes = portal.getAttributes();
+ portalAttributes.setString("foo", "bar");
+ assertEquals("bar", portalAttributes.getString("foo"));
+ Attributes pageAttributes = portal.getRootPage().getAttributes();
+ pageAttributes.setString("foo", "bar");
+ assertEquals("bar", pageAttributes.getString("foo"));
+ }
- public void testCascadedAttributes() {
- ModelImpl model = pomService.getModel();
- Site portal = model.getWorkspace().addSite(ObjectType.PORTAL_SITE,
"portal");
- Page root = portal.getRootPage();
- Page a = root.addChild("a");
- Attributes rootAttrs = root.getAttributes();
- Attributes aAttrs = a.getAttributes();
- rootAttrs.setString("foo", "foo_root");
- aAttrs.setString("bar", "bar_a");
- rootAttrs.setString("juu", "juu_root");
- aAttrs.setString("juu", "juu_a");
- Attributes combinedAttrs = a.getCascadingAttributes();
- assertEquals("foo_root", combinedAttrs.getString("foo"));
- assertEquals("bar_a", combinedAttrs.getString("bar"));
- assertEquals("juu_a", combinedAttrs.getString("juu"));
- }
+ public void testCascadedAttributes()
+ {
+ ModelImpl model = pomService.getModel();
+ Site portal = model.getWorkspace().addSite(ObjectType.PORTAL_SITE,
"portal");
+ Page root = portal.getRootPage();
+ Page a = root.addChild("a");
+ Attributes rootAttrs = root.getAttributes();
+ Attributes aAttrs = a.getAttributes();
+ rootAttrs.setString("foo", "foo_root");
+ aAttrs.setString("bar", "bar_a");
+ rootAttrs.setString("juu", "juu_root");
+ aAttrs.setString("juu", "juu_a");
+ Attributes combinedAttrs = a.getCascadingAttributes();
+ assertEquals("foo_root", combinedAttrs.getString("foo"));
+ assertEquals("bar_a", combinedAttrs.getString("bar"));
+ assertEquals("juu_a", combinedAttrs.getString("juu"));
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/ObjectTypeTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/ObjectTypeTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/ObjectTypeTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -25,21 +25,23 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class ObjectTypeTestCase extends TestCase {
+public class ObjectTypeTestCase extends TestCase
+{
- public void testAssignability() {
- assertFalse(ObjectType.WORKSPACE.isAssignableFrom(ObjectType.SITE));
- assertFalse(ObjectType.SITE.isAssignableFrom(ObjectType.WORKSPACE));
+ public void testAssignability()
+ {
+ assertFalse(ObjectType.WORKSPACE.isAssignableFrom(ObjectType.SITE));
+ assertFalse(ObjectType.SITE.isAssignableFrom(ObjectType.WORKSPACE));
- //
- assertTrue(ObjectType.SITE.isAssignableFrom(ObjectType.SITE));
+ //
+ assertTrue(ObjectType.SITE.isAssignableFrom(ObjectType.SITE));
- //
- assertTrue(ObjectType.SITE.isAssignableFrom(ObjectType.PORTAL_SITE));
- assertFalse(ObjectType.PORTAL_SITE.isAssignableFrom(ObjectType.SITE));
+ //
+ assertTrue(ObjectType.SITE.isAssignableFrom(ObjectType.PORTAL_SITE));
+ assertFalse(ObjectType.PORTAL_SITE.isAssignableFrom(ObjectType.SITE));
- //
- assertTrue(ObjectType.SITE.isAssignableFrom(ObjectType.GROUP_SITE));
- assertFalse(ObjectType.GROUP_SITE.isAssignableFrom(ObjectType.SITE));
- }
+ //
+ assertTrue(ObjectType.SITE.isAssignableFrom(ObjectType.GROUP_SITE));
+ assertFalse(ObjectType.GROUP_SITE.isAssignableFrom(ObjectType.SITE));
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/POMTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/POMTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/POMTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -33,81 +33,90 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class POMTestCase extends AbstractPOMTestCase {
+public class POMTestCase extends AbstractPOMTestCase
+{
- public void testPortals() throws Exception {
- test(0);
- }
+ public void testPortals() throws Exception
+ {
+ test(0);
+ }
- public void testGroups() throws Exception {
- test(1);
- }
+ public void testGroups() throws Exception
+ {
+ test(1);
+ }
- private void test(int type) throws Exception {
+ private void test(int type) throws Exception
+ {
- ModelImpl model = pomService.getModel();
+ ModelImpl model = pomService.getModel();
- Workspace workspace = model.getWorkspace();
+ Workspace workspace = model.getWorkspace();
- //
- ObjectType<? extends Site> siteType;
- if (type == 0) {
- siteType = ObjectType.PORTAL_SITE;
- } else if (type == 1) {
- siteType = ObjectType.GROUP_SITE;
- } else {
- throw new UnsupportedOperationException();
- }
+ //
+ ObjectType<? extends Site> siteType;
+ if (type == 0)
+ {
+ siteType = ObjectType.PORTAL_SITE;
+ }
+ else if (type == 1)
+ {
+ siteType = ObjectType.GROUP_SITE;
+ }
+ else
+ {
+ throw new UnsupportedOperationException();
+ }
- //
- Site site = workspace.addSite(siteType, "default");
- Page root = site.getRootPage();
- assertNotNull(root);
- Page template = root.addChild("template");
- assertNotNull(template);
+ //
+ Site site = workspace.addSite(siteType, "default");
+ Page root = site.getRootPage();
+ assertNotNull(root);
+ Page template = root.addChild("template");
+ assertNotNull(template);
- UIContainer container = template.getRootComponent();
- assertNotNull(container);
- container.add(ObjectType.WINDOW, "window");
+ UIContainer container = template.getRootComponent();
+ assertNotNull(container);
+ container.add(ObjectType.WINDOW, "window");
- //
- Page page = root.addChild("page");
- assertNotNull(page);
- page.setTemplate(template);
+ //
+ Page page = root.addChild("page");
+ assertNotNull(page);
+ page.setTemplate(template);
- //
- NavigationImpl nav = (NavigationImpl)site.getRootNavigation();
- assertNotNull(nav);
+ //
+ NavigationImpl nav = (NavigationImpl)site.getRootNavigation();
+ assertNotNull(nav);
// assertNull(nav.getLink());
- //
- nav.setTemplate(template);
+ //
+ nav.setTemplate(template);
- //
- PageLinkImpl pageTarget = nav.createPageLink();
+ //
+ PageLinkImpl pageTarget = nav.createPageLink();
// nav.setLink(pageTarget);
// pageTarget.setPage(page);
- //
- NavigationImpl subnav = nav.addChild("subnav");
- URLLinkImpl urlTarget = nav.createURLTarget();
+ //
+ NavigationImpl subnav = nav.addChild("subnav");
+ URLLinkImpl urlTarget = nav.createURLTarget();
// subnav.setLink(urlTarget);
// urlTarget.setURL("http://www.exoplatform.com");
- // Try something with template relationships
+ // Try something with template relationships
- Collection<? extends Page> templatizedPages =
template.getTemplatizedObjects(ObjectType.PAGE);
- assertNotNull(templatizedPages);
- assertEquals(1, templatizedPages.size());
+ Collection<? extends Page> templatizedPages =
template.getTemplatizedObjects(ObjectType.PAGE);
+ assertNotNull(templatizedPages);
+ assertEquals(1, templatizedPages.size());
- Collection<? extends Navigation> templatizedNavigations =
template.getTemplatizedObjects(ObjectType.NAVIGATION);
- assertNotNull(templatizedNavigations);
- assertEquals(1, templatizedNavigations.size());
+ Collection<? extends Navigation> templatizedNavigations =
template.getTemplatizedObjects(ObjectType.NAVIGATION);
+ assertNotNull(templatizedNavigations);
+ assertEquals(1, templatizedNavigations.size());
/*
Collection<Templatized> templatizedObjects =
template.getTemplatizedObjects(Templatized.class);
assertNotNull(templatizedObjects);
assertEquals(2, templatizedObjects.size());
*/
- }
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/QueryTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/QueryTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/QueryTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -30,16 +30,18 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class QueryTestCase extends AbstractPOMTestCase {
+public class QueryTestCase extends AbstractPOMTestCase
+{
- public void testFoo() {
- ModelImpl model = pomService.getModel();
- Workspace workspace = model.getWorkspace();
- Site site = workspace.addSite(ObjectType.PORTAL_SITE, "foo");
- model.save();
- Iterator<Site> sites = model.findObject(ObjectType.PORTAL_SITE,
"jcr:path='" + model.pathOf(site) + "'");
- assertTrue(sites.hasNext());
- assertSame(site, sites.next());
- assertFalse(sites.hasNext());
- }
+ public void testFoo()
+ {
+ ModelImpl model = pomService.getModel();
+ Workspace workspace = model.getWorkspace();
+ Site site = workspace.addSite(ObjectType.PORTAL_SITE, "foo");
+ model.save();
+ Iterator<Site> sites = model.findObject(ObjectType.PORTAL_SITE,
"jcr:path='" + model.pathOf(site) + "'");
+ assertTrue(sites.hasNext());
+ assertSame(site, sites.next());
+ assertFalse(sites.hasNext());
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/WorkspaceTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/WorkspaceTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/WorkspaceTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -37,81 +37,90 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class WorkspaceTestCase extends AbstractPOMTestCase {
+public class WorkspaceTestCase extends AbstractPOMTestCase
+{
- public void testGetSite() {
- ModelImpl model = pomService.getModel();
- Workspace workspace = model.getWorkspace();
- Site site = workspace.addSite(ObjectType.GROUP_SITE, "site");
- assertNotNull(site);
- Site s2 = model.findObjectById(ObjectType.SITE, site.getObjectId());
- assertEquals(site, s2);
- assertEquals(workspace, site.getWorkspace());
- }
+ public void testGetSite()
+ {
+ ModelImpl model = pomService.getModel();
+ Workspace workspace = model.getWorkspace();
+ Site site = workspace.addSite(ObjectType.GROUP_SITE, "site");
+ assertNotNull(site);
+ Site s2 = model.findObjectById(ObjectType.SITE, site.getObjectId());
+ assertEquals(site, s2);
+ assertEquals(workspace, site.getWorkspace());
+ }
- public void testGetPortal() {
- ModelImpl model = pomService.getModel();
- Workspace workspace = model.getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- assertNotNull(portal);
- Site s2 = model.findObjectById(ObjectType.SITE, portal.getObjectId());
- assertEquals(portal, s2);
- }
+ public void testGetPortal()
+ {
+ ModelImpl model = pomService.getModel();
+ Workspace workspace = model.getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ assertNotNull(portal);
+ Site s2 = model.findObjectById(ObjectType.SITE, portal.getObjectId());
+ assertEquals(portal, s2);
+ }
- public void testGetSites() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site s1 = workspace.addSite(ObjectType.GROUP_SITE, "foo");
- assertNotNull(s1);
- Site s2 = workspace.addSite(ObjectType.GROUP_SITE, "bar");
- assertNotNull(s2);
- assertEquals(Tools.set(workspace.getSites(ObjectType.GROUP_SITE)), Tools.set(s1,
s2));
- }
+ public void testGetSites()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site s1 = workspace.addSite(ObjectType.GROUP_SITE, "foo");
+ assertNotNull(s1);
+ Site s2 = workspace.addSite(ObjectType.GROUP_SITE, "bar");
+ assertNotNull(s2);
+ assertEquals(Tools.set(workspace.getSites(ObjectType.GROUP_SITE)), Tools.set(s1,
s2));
+ }
- public void testRootPage() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- Page root = portal.getRootPage();
- assertEquals(portal, root.getSite());
- }
+ public void testRootPage()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ Page root = portal.getRootPage();
+ assertEquals(portal, root.getSite());
+ }
- public void testPageAddChild() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- Page root = portal.getRootPage();
- assertEquals(portal, root.getSite());
- Page foo = root.addChild("foo");
- assertNotNull(foo);
- assertEquals(root, foo.getParent());
- assertEquals(portal, foo.getSite());
- Collection<? extends Page> children = root.getChildren();
- assertEquals(Tools.set(foo), new HashSet<Page>(children));
- }
+ public void testPageAddChild()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ Page root = portal.getRootPage();
+ assertEquals(portal, root.getSite());
+ Page foo = root.addChild("foo");
+ assertNotNull(foo);
+ assertEquals(root, foo.getParent());
+ assertEquals(portal, foo.getSite());
+ Collection<? extends Page> children = root.getChildren();
+ assertEquals(Tools.set(foo), new HashSet<Page>(children));
+ }
- public void testPortalTemplate() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- Page template = portal.getRootPage().addChild("template");
- portal.getRootNavigation().setTemplate(template);
- assertEquals(template, portal.getRootNavigation().getTemplate());
- }
+ public void testPortalTemplate()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ Page template = portal.getRootPage().addChild("template");
+ portal.getRootNavigation().setTemplate(template);
+ assertEquals(template, portal.getRootNavigation().getTemplate());
+ }
- public void testPageTemplate() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- Page template = portal.getRootPage().addChild("template");
- Page foo = portal.getRootPage().addChild("foo");
- foo.setTemplate(template);
- assertEquals(template, foo.getTemplate());
- }
+ public void testPageTemplate()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ Page template = portal.getRootPage().addChild("template");
+ Page foo = portal.getRootPage().addChild("foo");
+ foo.setTemplate(template);
+ assertEquals(template, foo.getTemplate());
+ }
- public void testLoading() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- String portalId = portal.getObjectId();
- Page root = portal.getRootPage();
- String rootId = root.getObjectId();
- Page foo = root.addChild("foo");
- String fooId= foo.getObjectId();
+ public void testLoading()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ String portalId = portal.getObjectId();
+ Page root = portal.getRootPage();
+ String rootId = root.getObjectId();
+ Page foo = root.addChild("foo");
+ String fooId = foo.getObjectId();
/*
// Test loading
@@ -127,111 +136,117 @@
assertEquals(portal, foo.getSite());
assertEquals(portal, root.getSite());
*/
- }
+ }
- public void testNavigationHierarchy() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- Navigation rootNav = portal.getRootNavigation();
- assertNotNull(rootNav);
- assertNotNull(rootNav.getAttributes());
- assertNull(rootNav.getParent());
- assertTrue(rootNav.getChildren().isEmpty());
- Navigation fooNav = rootNav.addChild("foo");
- assertNotNull(fooNav);
- assertNotNull(fooNav.getAttributes());
- assertSame(rootNav, fooNav.getParent());
- assertTrue(fooNav.getChildren().isEmpty());
- assertEquals(Collections.singleton(fooNav), new
HashSet<Navigation>(rootNav.getChildren()));
- }
+ public void testNavigationHierarchy()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ Navigation rootNav = portal.getRootNavigation();
+ assertNotNull(rootNav);
+ assertNotNull(rootNav.getAttributes());
+ assertNull(rootNav.getParent());
+ assertTrue(rootNav.getChildren().isEmpty());
+ Navigation fooNav = rootNav.addChild("foo");
+ assertNotNull(fooNav);
+ assertNotNull(fooNav.getAttributes());
+ assertSame(rootNav, fooNav.getParent());
+ assertTrue(fooNav.getChildren().isEmpty());
+ assertEquals(Collections.singleton(fooNav), new
HashSet<Navigation>(rootNav.getChildren()));
+ }
- public void testLink() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- Navigation rootNav = portal.getRootNavigation();
- assertNull(rootNav.getLink());
+ public void testLink()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ Navigation rootNav = portal.getRootNavigation();
+ assertNull(rootNav.getLink());
- //
- PageLink link = rootNav.linkTo(ObjectType.PAGE_LINK);
- assertNotNull(link);
- assertSame(link, rootNav.getLink());
- Page rootPage = portal.getRootPage();
- link.setPage(rootPage);
- assertEquals(rootPage, link.getPage());
- }
+ //
+ PageLink link = rootNav.linkTo(ObjectType.PAGE_LINK);
+ assertNotNull(link);
+ assertSame(link, rootNav.getLink());
+ Page rootPage = portal.getRootPage();
+ link.setPage(rootPage);
+ assertEquals(rootPage, link.getPage());
+ }
- public void testNavigationClear() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- Navigation rootNav = portal.getRootNavigation();
- rootNav.addChild("a");
- rootNav.addChild("b");
- assertEquals(2, rootNav.getChildren().size());
- rootNav.getChildren().clear();
- assertEquals(0, rootNav.getChildren().size());
- }
+ public void testNavigationClear()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ Navigation rootNav = portal.getRootNavigation();
+ rootNav.addChild("a");
+ rootNav.addChild("b");
+ assertEquals(2, rootNav.getChildren().size());
+ rootNav.getChildren().clear();
+ assertEquals(0, rootNav.getChildren().size());
+ }
- public void testNavigationGetSite() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- Navigation rootNav = portal.getRootNavigation();
- Navigation a = rootNav.addChild("a");
- Site site = a.getSite();
- assertSame(portal, site);
- }
+ public void testNavigationGetSite()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ Navigation rootNav = portal.getRootNavigation();
+ Navigation a = rootNav.addChild("a");
+ Site site = a.getSite();
+ assertSame(portal, site);
+ }
- public void testRemoveReferencedTemplate() {
- ModelImpl pom = pomService.getModel();
- Workspace workspace = pom.getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- Page root = portal.getRootPage();
- Page template = root.addChild("template");
- portal.getRootNavigation().setTemplate(template);
- pom.save();
+ public void testRemoveReferencedTemplate()
+ {
+ ModelImpl pom = pomService.getModel();
+ Workspace workspace = pom.getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ Page root = portal.getRootPage();
+ Page template = root.addChild("template");
+ portal.getRootNavigation().setTemplate(template);
+ pom.save();
- pom = pomService.getModel();
- portal = workspace.getSite(ObjectType.PORTAL_SITE, "portal");
- portal.getRootPage().getChild("template").destroy();
- pom.save();
+ pom = pomService.getModel();
+ portal = workspace.getSite(ObjectType.PORTAL_SITE, "portal");
+ portal.getRootPage().getChild("template").destroy();
+ pom.save();
- //
- pom = pomService.getModel();
- portal = workspace.getSite(ObjectType.PORTAL_SITE, "portal");
- portal.destroy();
- pom.save();
+ //
+ pom = pomService.getModel();
+ portal = workspace.getSite(ObjectType.PORTAL_SITE, "portal");
+ portal.destroy();
+ pom.save();
- pom = pomService.getModel();
- workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ pom = pomService.getModel();
+ workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- }
+ }
- public void testComponentOrder() {
- ModelImpl pom = pomService.getModel();
- Workspace workspace = pom.getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal2");
- Page root = portal.getRootPage();
+ public void testComponentOrder()
+ {
+ ModelImpl pom = pomService.getModel();
+ Workspace workspace = pom.getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal2");
+ Page root = portal.getRootPage();
- UIContainer container = root.getRootComponent();
+ UIContainer container = root.getRootComponent();
- container.add(ObjectType.WINDOW, "2");
- container.add(0, ObjectType.WINDOW, "0");
+ container.add(ObjectType.WINDOW, "2");
+ container.add(0, ObjectType.WINDOW, "0");
- assertEquals("0", container.get(0).getName());
- assertEquals("2", container.get(1).getName());
- assertEquals(2, container.size());
+ assertEquals("0", container.get(0).getName());
+ assertEquals("2", container.get(1).getName());
+ assertEquals(2, container.size());
- container.add(1, ObjectType.WINDOW, "1");
+ container.add(1, ObjectType.WINDOW, "1");
- assertEquals("0", container.get(0).getName());
- assertEquals("1", container.get(1).getName());
- assertEquals("2", container.get(2).getName());
- assertEquals(3, container.size());
+ assertEquals("0", container.get(0).getName());
+ assertEquals("1", container.get(1).getName());
+ assertEquals("2", container.get(2).getName());
+ assertEquals(3, container.size());
- container.add(0, container.get(2));
+ container.add(0, container.get(2));
- assertEquals("2", container.get(0).getName());
- assertEquals("0", container.get(1).getName());
- assertEquals("1", container.get(2).getName());
- assertEquals(3, container.size());
- }
+ assertEquals("2", container.get(0).getName());
+ assertEquals("0", container.get(1).getName());
+ assertEquals("1", container.get(2).getName());
+ assertEquals(3, container.size());
+ }
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/content/CustomizationTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/content/CustomizationTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/api/workspace/content/CustomizationTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -36,152 +36,161 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class CustomizationTestCase extends AbstractPOMTestCase {
+public class CustomizationTestCase extends AbstractPOMTestCase
+{
- /** . */
- private final Preferences marseille = new PreferencesBuilder().add("city",
"marseille").add("temperature", "celsius").build();
+ /** . */
+ private final Preferences marseille = new PreferencesBuilder().add("city",
"marseille").add("temperature", "celsius").build();
- /** . */
- private final Preferences paris = new PreferencesBuilder().add("city",
"paris").build();
+ /** . */
+ private final Preferences paris = new PreferencesBuilder().add("city",
"paris").build();
- /** . */
- private final Preferences parisCelsius = new PreferencesBuilder().add("city",
"paris").add("temperature", "celsius").build();
+ /** . */
+ private final Preferences parisCelsius = new
PreferencesBuilder().add("city", "paris").add("temperature",
"celsius").build();
- /** . */
- private final Preferences parisFarenheit = new
PreferencesBuilder().add("city", "paris").add("temperature",
"farenheit").build();
+ /** . */
+ private final Preferences parisFarenheit = new
PreferencesBuilder().add("city", "paris").add("temperature",
"farenheit").build();
- public void testVirtualCustomization() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Customization<Preferences> customization1 =
workspace.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
- Customization<Preferences> customization2 =
workspace.customize("paris", customization1);
+ public void testVirtualCustomization()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Customization<Preferences> customization1 =
workspace.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
+ Customization<Preferences> customization2 =
workspace.customize("paris", customization1);
- //
- customization2.setState(paris);
- assertEquals(paris, customization2.getState());
- assertEquals(parisCelsius, customization2.getVirtualState());
+ //
+ customization2.setState(paris);
+ assertEquals(paris, customization2.getState());
+ assertEquals(parisCelsius, customization2.getVirtualState());
- //
- customization2.setState(parisFarenheit);
- assertEquals(parisFarenheit, customization2.getState());
- assertEquals(parisFarenheit, customization2.getVirtualState());
+ //
+ customization2.setState(parisFarenheit);
+ assertEquals(parisFarenheit, customization2.getState());
+ assertEquals(parisFarenheit, customization2.getVirtualState());
- //
-
customization1.setState(customization1.getState().setReadOnly("temperature",
true));
- assertEquals(parisFarenheit, customization2.getState());
- assertEquals(parisCelsius, customization2.getVirtualState());
- }
+ //
+
customization1.setState(customization1.getState().setReadOnly("temperature",
true));
+ assertEquals(parisFarenheit, customization2.getState());
+ assertEquals(parisCelsius, customization2.getVirtualState());
+ }
- public void testCustomizeWorkspace() {
- Workspace workspace = pomService.getModel().getWorkspace();
- assertNull(workspace.getCustomization("marseille"));
- Customization<Preferences> customization =
workspace.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
- assertNotNull(customization);
- Preferences b = customization.getState();
- assertEquals(marseille, b);
- assertEquals(0, customization.getContexts().size());
- assertEquals("WeatherPortlet", customization.getContentId());
- assertEquals(Preferences.CONTENT_TYPE, customization.getType());
- assertEquals("marseille", workspace.nameOf(customization));
- }
+ public void testCustomizeWorkspace()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ assertNull(workspace.getCustomization("marseille"));
+ Customization<Preferences> customization =
workspace.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
+ assertNotNull(customization);
+ Preferences b = customization.getState();
+ assertEquals(marseille, b);
+ assertEquals(0, customization.getContexts().size());
+ assertEquals("WeatherPortlet", customization.getContentId());
+ assertEquals(Preferences.CONTENT_TYPE, customization.getType());
+ assertEquals("marseille", workspace.nameOf(customization));
+ }
- public void testCustomizeWindow() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- UIContainer layout = portal.getRootPage().getRootComponent();
- UIWindow window = layout.add(ObjectType.WINDOW, "window");
+ public void testCustomizeWindow()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ UIContainer layout = portal.getRootPage().getRootComponent();
+ UIWindow window = layout.add(ObjectType.WINDOW, "window");
- //
- Customization<Preferences> customization =
window.customize(Preferences.CONTENT_TYPE, "WeatherPortlet", marseille);
- assertSame(customization, window.getCustomization());
- assertEquals(marseille, customization.getVirtualState());
- assertEquals(marseille, customization.getState());
+ //
+ Customization<Preferences> customization =
window.customize(Preferences.CONTENT_TYPE, "WeatherPortlet", marseille);
+ assertSame(customization, window.getCustomization());
+ assertEquals(marseille, customization.getVirtualState());
+ assertEquals(marseille, customization.getState());
- //
- customization = (Customization<Preferences>)window.getCustomization();
- assertSame(customization, window.getCustomization());
- assertEquals(marseille, customization.getVirtualState());
- assertEquals(marseille, customization.getState());
- }
+ //
+ customization = (Customization<Preferences>)window.getCustomization();
+ assertSame(customization, window.getCustomization());
+ assertEquals(marseille, customization.getVirtualState());
+ assertEquals(marseille, customization.getState());
+ }
- public void testCustomizeWindowByCloneWithNoState() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- UIContainer layout = portal.getRootPage().getRootComponent();
- UIWindow window = layout.add(ObjectType.WINDOW, "window");
+ public void testCustomizeWindowByCloneWithNoState()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ UIContainer layout = portal.getRootPage().getRootComponent();
+ UIWindow window = layout.add(ObjectType.WINDOW, "window");
- //
- Customization<Preferences> customization =
window.customize(Preferences.CONTENT_TYPE, "WeatherPortlet", null);
- assertSame(customization, window.getCustomization());
- assertNull(customization.getState());
- }
+ //
+ Customization<Preferences> customization =
window.customize(Preferences.CONTENT_TYPE, "WeatherPortlet", null);
+ assertSame(customization, window.getCustomization());
+ assertNull(customization.getState());
+ }
- public void testCustomizeWindowBySpecialization() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- UIContainer layout = portal.getRootPage().getRootComponent();
- UIWindow window = layout.add(ObjectType.WINDOW, "window");
+ public void testCustomizeWindowBySpecialization()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ UIContainer layout = portal.getRootPage().getRootComponent();
+ UIWindow window = layout.add(ObjectType.WINDOW, "window");
- //
- Customization<Preferences> workspaceCustomization =
portal.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
- Customization<Preferences> windowCustomization =
window.customize(workspaceCustomization);
+ //
+ Customization<Preferences> workspaceCustomization =
portal.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
+ Customization<Preferences> windowCustomization =
window.customize(workspaceCustomization);
- //
- assertNotNull(windowCustomization);
- assertEquals(Arrays.<CustomizationContext>asList(window, portal), new
ArrayList<CustomizationContext>(windowCustomization.getContexts()));
- assertSame(windowCustomization, window.getCustomization());
- assertTrue(((Customization)windowCustomization) instanceof WorkspaceSpecialization);
+ //
+ assertNotNull(windowCustomization);
+ assertEquals(Arrays.<CustomizationContext>asList(window, portal), new
ArrayList<CustomizationContext>(windowCustomization.getContexts()));
+ assertSame(windowCustomization, window.getCustomization());
+ assertTrue(((Customization)windowCustomization) instanceof
WorkspaceSpecialization);
- //
- assertPreferences(null, windowCustomization.getState());
- assertPreferences(marseille, windowCustomization.getVirtualState());
- assertPreferences(marseille, workspaceCustomization.getState());
+ //
+ assertPreferences(null, windowCustomization.getState());
+ assertPreferences(marseille, windowCustomization.getVirtualState());
+ assertPreferences(marseille, workspaceCustomization.getState());
- //
- workspaceCustomization.setState(paris);
- assertPreferences(paris, windowCustomization.getVirtualState());
- assertPreferences(null, windowCustomization.getState());
- assertPreferences(paris, workspaceCustomization.getState());
+ //
+ workspaceCustomization.setState(paris);
+ assertPreferences(paris, windowCustomization.getVirtualState());
+ assertPreferences(null, windowCustomization.getState());
+ assertPreferences(paris, workspaceCustomization.getState());
- //
- windowCustomization.setState(parisFarenheit);
- assertPreferences(parisFarenheit, windowCustomization.getVirtualState());
- assertPreferences(parisFarenheit, windowCustomization.getState());
- assertPreferences(paris, workspaceCustomization.getState());
- }
+ //
+ windowCustomization.setState(parisFarenheit);
+ assertPreferences(parisFarenheit, windowCustomization.getVirtualState());
+ assertPreferences(parisFarenheit, windowCustomization.getState());
+ assertPreferences(paris, workspaceCustomization.getState());
+ }
- public void testDestroySpecializedCustomization() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- UIContainer layout = portal.getRootPage().getRootComponent();
- UIWindow window = layout.add(ObjectType.WINDOW, "window");
+ public void testDestroySpecializedCustomization()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ UIContainer layout = portal.getRootPage().getRootComponent();
+ UIWindow window = layout.add(ObjectType.WINDOW, "window");
- //
- Customization<Preferences> workspaceCustomization =
portal.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
- Customization<Preferences> windowCustomization =
window.customize(workspaceCustomization);
+ //
+ Customization<Preferences> workspaceCustomization =
portal.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
+ Customization<Preferences> windowCustomization =
window.customize(workspaceCustomization);
- //
- workspaceCustomization.destroy();
+ //
+ workspaceCustomization.destroy();
- //
- assertEquals(marseille, windowCustomization.getVirtualState());
- assertEquals(marseille, windowCustomization.getState());
- }
+ //
+ assertEquals(marseille, windowCustomization.getVirtualState());
+ assertEquals(marseille, windowCustomization.getState());
+ }
- public void testDestroySpecialization() {
- Workspace workspace = pomService.getModel().getWorkspace();
- Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
- UIContainer layout = portal.getRootPage().getRootComponent();
- UIWindow window = layout.add(ObjectType.WINDOW, "window");
+ public void testDestroySpecialization()
+ {
+ Workspace workspace = pomService.getModel().getWorkspace();
+ Site portal = workspace.addSite(ObjectType.PORTAL_SITE, "portal");
+ UIContainer layout = portal.getRootPage().getRootComponent();
+ UIWindow window = layout.add(ObjectType.WINDOW, "window");
- //
- Customization<Preferences> workspaceCustomization =
portal.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
- Customization<Preferences> windowCustomization =
window.customize(workspaceCustomization);
+ //
+ Customization<Preferences> workspaceCustomization =
portal.customize("marseille", Preferences.CONTENT_TYPE,
"WeatherPortlet", marseille);
+ Customization<Preferences> windowCustomization =
window.customize(workspaceCustomization);
- //
- windowCustomization.destroy();
- }
+ //
+ windowCustomization.destroy();
+ }
- private void assertPreferences(Preferences expectedPrefs, Preferences prefs) {
- assertEquals("Was expecting to have prefs " + prefs + " equals to
" + expectedPrefs, expectedPrefs, prefs);
- }
+ private void assertPreferences(Preferences expectedPrefs, Preferences prefs)
+ {
+ assertEquals("Was expecting to have prefs " + prefs + " equals to
" + expectedPrefs, expectedPrefs, prefs);
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/Gadget.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/Gadget.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/Gadget.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -24,19 +24,22 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class Gadget {
+public class Gadget
+{
- /** . */
- public static final ContentType<Gadget> CONTENT_TYPE = new
ContentType<Gadget>("application/gadget", Gadget.class);
+ /** . */
+ public static final ContentType<Gadget> CONTENT_TYPE = new
ContentType<Gadget>("application/gadget", Gadget.class);
- /** . */
- private String userPref;
+ /** . */
+ private String userPref;
- public String getUserPref() {
- return userPref;
- }
+ public String getUserPref()
+ {
+ return userPref;
+ }
- public void setUserPref(String userPref) {
- this.userPref = userPref;
- }
+ public void setUserPref(String userPref)
+ {
+ this.userPref = userPref;
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/GadgetContentProvider.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/GadgetContentProvider.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/GadgetContentProvider.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -32,68 +32,87 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class GadgetContentProvider implements ContentProvider<Gadget> {
+public class GadgetContentProvider implements ContentProvider<Gadget>
+{
- public Gadget combine(List<Gadget> states) {
- throw new UnsupportedOperationException();
- }
+ public Gadget combine(List<Gadget> states)
+ {
+ throw new UnsupportedOperationException();
+ }
- public void setState(StateContainer container, Gadget state) {
- try {
- ChromatticSession session = ((AbstractCustomization)container).session;
- String containerId = session.getId(container);
- Node node = session.getJCRSession().getNodeByUUID(containerId);
+ public void setState(StateContainer container, Gadget state)
+ {
+ try
+ {
+ ChromatticSession session = ((AbstractCustomization)container).session;
+ String containerId = session.getId(container);
+ Node node = session.getJCRSession().getNodeByUUID(containerId);
- //
- GadgetState prefs;
- if (node.hasNode("state")) {
- Node stateNode = node.getNode("state");
- prefs = (GadgetState)session.findById(Object.class, stateNode.getUUID());
- if (state == null) {
- session.remove(prefs);
- return;
- }
- } else {
- if (state == null) {
- return;
- } else {
- Node stateNode = node.addNode("state", "mop:gadget");
- prefs = (GadgetState)session.findById(Object.class, stateNode.getUUID());
- }
+ //
+ GadgetState prefs;
+ if (node.hasNode("state"))
+ {
+ Node stateNode = node.getNode("state");
+ prefs = (GadgetState)session.findById(Object.class, stateNode.getUUID());
+ if (state == null)
+ {
+ session.remove(prefs);
+ return;
+ }
+ }
+ else
+ {
+ if (state == null)
+ {
+ return;
+ }
+ else
+ {
+ Node stateNode = node.addNode("state", "mop:gadget");
+ prefs = (GadgetState)session.findById(Object.class, stateNode.getUUID());
+ }
+ }
+
+ //
+ prefs.setUserPrefs(state.getUserPref());
}
+ catch (RepositoryException e)
+ {
+ throw new UndeclaredRepositoryException(e);
+ }
+ }
- //
- prefs.setUserPrefs(state.getUserPref());
- }
- catch (RepositoryException e) {
- throw new UndeclaredRepositoryException(e);
- }
- }
+ public Gadget getState(StateContainer container)
+ {
+ try
+ {
+ ChromatticSession session = ((AbstractCustomization)container).session;
+ String containerId = session.getId(container);
+ Node node = session.getJCRSession().getNodeByUUID(containerId);
- public Gadget getState(StateContainer container) {
- try {
- ChromatticSession session = ((AbstractCustomization)container).session;
- String containerId = session.getId(container);
- Node node = session.getJCRSession().getNodeByUUID(containerId);
-
- //
- GadgetState prefs;
- if (node.hasNode("state")) {
- Node stateNode = node.getNode("state");
- prefs = (GadgetState)session.findById(Object.class, stateNode.getUUID());
- Gadget gadget = new Gadget();
- gadget.setUserPref(prefs.getUserPrefs());
- return gadget;
- } else {
- return null;
+ //
+ GadgetState prefs;
+ if (node.hasNode("state"))
+ {
+ Node stateNode = node.getNode("state");
+ prefs = (GadgetState)session.findById(Object.class, stateNode.getUUID());
+ Gadget gadget = new Gadget();
+ gadget.setUserPref(prefs.getUserPrefs());
+ return gadget;
+ }
+ else
+ {
+ return null;
+ }
}
- }
- catch (RepositoryException e) {
- throw new UndeclaredRepositoryException(e);
- }
- }
+ catch (RepositoryException e)
+ {
+ throw new UndeclaredRepositoryException(e);
+ }
+ }
- public Class<Gadget> getStateType() {
- return Gadget.class;
- }
+ public Class<Gadget> getStateType()
+ {
+ return Gadget.class;
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/GadgetState.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/GadgetState.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/gadget/GadgetState.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -26,12 +26,13 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:gadget")
-public abstract class GadgetState {
+public abstract class GadgetState
+{
- @Property(name = "prefs")
- public abstract String getUserPrefs();
+ @Property(name = "prefs")
+ public abstract String getUserPrefs();
- public abstract void setUserPrefs(String userPrefs);
+ public abstract void setUserPrefs(String userPrefs);
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletContentProvider.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletContentProvider.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletContentProvider.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -34,79 +34,101 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class PortletContentProvider implements ContentProvider<Preferences> {
+public class PortletContentProvider implements ContentProvider<Preferences>
+{
- public Preferences combine(List<Preferences> states) {
- Map<String, Preference> entries = new HashMap<String, Preference>();
+ public Preferences combine(List<Preferences> states)
+ {
+ Map<String, Preference> entries = new HashMap<String, Preference>();
- //
- for (Preferences preferences : states) {
- for (Preference preference : preferences) {
- Preference previous = entries.get(preference.getName());
- if (previous == null || !previous.isReadOnly()) {
- entries.put(preference.getName(), preference);
- }
+ //
+ for (Preferences preferences : states)
+ {
+ for (Preference preference : preferences)
+ {
+ Preference previous = entries.get(preference.getName());
+ if (previous == null || !previous.isReadOnly())
+ {
+ entries.put(preference.getName(), preference);
+ }
+ }
}
- }
- //
- return new Preferences(entries);
- }
+ //
+ return new Preferences(entries);
+ }
- public void setState(StateContainer container, Preferences state) {
- try {
- ChromatticSession session = ((AbstractCustomization)container).session;
- String containerId = session.getId(container);
- Node node = session.getJCRSession().getNodeByUUID(containerId);
+ public void setState(StateContainer container, Preferences state)
+ {
+ try
+ {
+ ChromatticSession session = ((AbstractCustomization)container).session;
+ String containerId = session.getId(container);
+ Node node = session.getJCRSession().getNodeByUUID(containerId);
- //
- PortletPreferencesState prefs;
- if (node.hasNode("state")) {
- Node stateNode = node.getNode("state");
- prefs = (PortletPreferencesState)session.findById(Object.class,
stateNode.getUUID());
- if (state == null) {
- session.remove(prefs);
- return;
- }
- } else {
- if (state == null) {
- return;
- } else {
- Node stateNode = node.addNode("state",
"mop:portletpreferences");
- prefs = (PortletPreferencesState)session.findById(Object.class,
stateNode.getUUID());
- }
+ //
+ PortletPreferencesState prefs;
+ if (node.hasNode("state"))
+ {
+ Node stateNode = node.getNode("state");
+ prefs = (PortletPreferencesState)session.findById(Object.class,
stateNode.getUUID());
+ if (state == null)
+ {
+ session.remove(prefs);
+ return;
+ }
+ }
+ else
+ {
+ if (state == null)
+ {
+ return;
+ }
+ else
+ {
+ Node stateNode = node.addNode("state",
"mop:portletpreferences");
+ prefs = (PortletPreferencesState)session.findById(Object.class,
stateNode.getUUID());
+ }
+ }
+
+ //
+ prefs.setPayload(state);
}
+ catch (RepositoryException e)
+ {
+ throw new UndeclaredRepositoryException(e);
+ }
+ }
- //
- prefs.setPayload(state);
- }
- catch (RepositoryException e) {
- throw new UndeclaredRepositoryException(e);
- }
- }
+ public Preferences getState(StateContainer container)
+ {
+ try
+ {
+ ChromatticSession session = ((AbstractCustomization)container).session;
+ String containerId = session.getId(container);
+ Node node = session.getJCRSession().getNodeByUUID(containerId);
- public Preferences getState(StateContainer container) {
- try {
- ChromatticSession session = ((AbstractCustomization)container).session;
- String containerId = session.getId(container);
- Node node = session.getJCRSession().getNodeByUUID(containerId);
-
- //
- PortletPreferencesState prefs;
- if (node.hasNode("state")) {
- Node stateNode = node.getNode("state");
- prefs = (PortletPreferencesState)session.findById(Object.class,
stateNode.getUUID());
- return (Preferences)prefs.getPayload();
- } else {
- return null;
+ //
+ PortletPreferencesState prefs;
+ if (node.hasNode("state"))
+ {
+ Node stateNode = node.getNode("state");
+ prefs = (PortletPreferencesState)session.findById(Object.class,
stateNode.getUUID());
+ return (Preferences)prefs.getPayload();
+ }
+ else
+ {
+ return null;
+ }
}
- }
- catch (RepositoryException e) {
- throw new UndeclaredRepositoryException(e);
- }
- }
+ catch (RepositoryException e)
+ {
+ throw new UndeclaredRepositoryException(e);
+ }
+ }
- public Class<Preferences> getStateType() {
- return Preferences.class;
- }
+ public Class<Preferences> getStateType()
+ {
+ return Preferences.class;
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletDefinition.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletDefinition.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletDefinition.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -24,24 +24,28 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class PortletDefinition {
+public class PortletDefinition
+{
- /** . */
- private final String name;
+ /** . */
+ private final String name;
- /** . */
- private final Preferences preferences;
+ /** . */
+ private final Preferences preferences;
- public PortletDefinition(String name, Preferences preferences) {
- this.name = name;
- this.preferences = preferences;
- }
+ public PortletDefinition(String name, Preferences preferences)
+ {
+ this.name = name;
+ this.preferences = preferences;
+ }
- public String getName() {
- return name;
- }
+ public String getName()
+ {
+ return name;
+ }
- public Preferences getPreferences() {
- return preferences;
- }
+ public Preferences getPreferences()
+ {
+ return preferences;
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletPreferenceState.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletPreferenceState.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletPreferenceState.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -30,28 +30,29 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:portletpreference")
-public abstract class PortletPreferenceState {
+public abstract class PortletPreferenceState
+{
- @ManyToOne
- public abstract PortletPreferenceState getParent();
+ @ManyToOne
+ public abstract PortletPreferenceState getParent();
- @Name
- public abstract String getName();
+ @Name
+ public abstract String getName();
- @Property(name = "value")
- public abstract List<String> getValue();
+ @Property(name = "value")
+ public abstract List<String> getValue();
- public abstract void setValue(List<String> value);
+ public abstract void setValue(List<String> value);
- @Property(name = "value")
- public abstract List<String> getValues();
+ @Property(name = "value")
+ public abstract List<String> getValues();
- public abstract void setValues(List<String> value);
+ public abstract void setValues(List<String> value);
- @Property(name = "readonly")
- public abstract boolean getReadOnly();
+ @Property(name = "readonly")
+ public abstract boolean getReadOnly();
- public abstract void setReadOnly(boolean readOnly);
+ public abstract void setReadOnly(boolean readOnly);
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletPreferencesState.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletPreferencesState.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PortletPreferencesState.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -35,49 +35,56 @@
* @version $Revision$
*/
@NodeMapping(name = "mop:portletpreferences")
-public abstract class PortletPreferencesState {
+public abstract class PortletPreferencesState
+{
- /** . */
- private Preferences payload;
+ /** . */
+ private Preferences payload;
- @OneToMany
- public abstract Map<String, PortletPreferenceState> getChildren();
+ @OneToMany
+ public abstract Map<String, PortletPreferenceState> getChildren();
- @Create
- public abstract PortletPreferenceState create();
+ @Create
+ public abstract PortletPreferenceState create();
- @OneToOne
- @RelatedMappedBy("state")
- public abstract AbstractCustomization getCustomization();
+ @OneToOne
+ @RelatedMappedBy("state")
+ public abstract AbstractCustomization getCustomization();
- private void setPayload(Preferences payload) {
+ private void setPayload(Preferences payload)
+ {
- this.payload = payload;
+ this.payload = payload;
- //
- Map<String, PortletPreferenceState> entries = getChildren();
- entries.clear();
+ //
+ Map<String, PortletPreferenceState> entries = getChildren();
+ entries.clear();
- for (Preference pref : payload) {
- PortletPreferenceState prefState = create();
- entries.put(pref.getName(), prefState);
- prefState.setValue(pref.getValues());
- prefState.setReadOnly(pref.isReadOnly());
- }
- }
+ for (Preference pref : payload)
+ {
+ PortletPreferenceState prefState = create();
+ entries.put(pref.getName(), prefState);
+ prefState.setValue(pref.getValues());
+ prefState.setReadOnly(pref.isReadOnly());
+ }
+ }
- public void setPayload(Object payload) {
- setPayload((Preferences)payload);
- }
+ public void setPayload(Object payload)
+ {
+ setPayload((Preferences)payload);
+ }
- public Object getPayload() {
- if (payload == null) {
- PreferencesBuilder builder = new PreferencesBuilder();
- for (PortletPreferenceState entry : getChildren().values()) {
- builder.add(entry.getName(), entry.getValues(), entry.getReadOnly());
+ public Object getPayload()
+ {
+ if (payload == null)
+ {
+ PreferencesBuilder builder = new PreferencesBuilder();
+ for (PortletPreferenceState entry : getChildren().values())
+ {
+ builder.add(entry.getName(), entry.getValues(), entry.getReadOnly());
+ }
+ payload = builder.build();
}
- payload = builder.build();
- }
- return payload;
- }
+ return payload;
+ }
}
\ No newline at end of file
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/Preference.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/Preference.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/Preference.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,91 +28,110 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public final class Preference {
+public final class Preference
+{
- /** . */
- private final String name;
+ /** . */
+ private final String name;
- /** . */
- private final List<String> values;
+ /** . */
+ private final List<String> values;
- /** . */
- private final boolean readOnly;
+ /** . */
+ private final boolean readOnly;
- public Preference(String name, List<String> values, boolean readOnly) {
- if (name == null) {
- throw new NullPointerException();
- }
- if (values == null) {
- throw new NullPointerException();
- }
+ public Preference(String name, List<String> values, boolean readOnly)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException();
+ }
+ if (values == null)
+ {
+ throw new NullPointerException();
+ }
- // Clone and check state
- values = Collections.unmodifiableList(new ArrayList<String>(values));
- if (values.size() == 0) {
- throw new IllegalArgumentException();
- }
- for (String value : values) {
- if (value == null) {
- throw new IllegalArgumentException();
+ // Clone and check state
+ values = Collections.unmodifiableList(new ArrayList<String>(values));
+ if (values.size() == 0)
+ {
+ throw new IllegalArgumentException();
}
- }
+ for (String value : values)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
- //
- this.name = name;
- this.values = values;
- this.readOnly = readOnly;
- }
+ //
+ this.name = name;
+ this.values = values;
+ this.readOnly = readOnly;
+ }
- public Preference(String name, String value, boolean readOnly) {
- if (name == null) {
- throw new NullPointerException();
- }
- if (value == null) {
- throw new NullPointerException();
- }
+ public Preference(String name, String value, boolean readOnly)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException();
+ }
+ if (value == null)
+ {
+ throw new NullPointerException();
+ }
- //
- this.name = name;
- this.values = Collections.singletonList(value);
- this.readOnly = readOnly;
- }
+ //
+ this.name = name;
+ this.values = Collections.singletonList(value);
+ this.readOnly = readOnly;
+ }
- public String getName() {
- return name;
- }
+ public String getName()
+ {
+ return name;
+ }
- public String getValue() {
- return values.get(0);
- }
+ public String getValue()
+ {
+ return values.get(0);
+ }
- public List<String> getValues() {
- return values;
- }
+ public List<String> getValues()
+ {
+ return values;
+ }
- public boolean isReadOnly() {
- return readOnly;
- }
+ public boolean isReadOnly()
+ {
+ return readOnly;
+ }
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (obj instanceof Preference) {
- Preference that = (Preference)obj;
- return this.name.equals(that.name) &&
this.getValues().equals(that.getValues());
- }
- return false;
- }
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof Preference)
+ {
+ Preference that = (Preference)obj;
+ return this.name.equals(that.name) &&
this.getValues().equals(that.getValues());
+ }
+ return false;
+ }
- @Override
- public int hashCode() {
- return name.hashCode() ^ values.hashCode() ^ (readOnly ? -1 : 0);
- }
+ @Override
+ public int hashCode()
+ {
+ return name.hashCode() ^ values.hashCode() ^ (readOnly ? -1 : 0);
+ }
- @Override
- public String toString() {
- return "Preference[name=" + name + ",values=" + values +
",readOnly=" + readOnly + "]";
- }
+ @Override
+ public String toString()
+ {
+ return "Preference[name=" + name + ",values=" + values +
",readOnly=" + readOnly + "]";
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/Preferences.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/Preferences.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/Preferences.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -32,111 +32,136 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public final class Preferences implements Iterable<Preference> {
+public final class Preferences implements Iterable<Preference>
+{
- /** . */
- public static final ContentType<Preferences> CONTENT_TYPE = new
ContentType<Preferences>("application/portlet", Preferences.class);
+ /** . */
+ public static final ContentType<Preferences> CONTENT_TYPE = new
ContentType<Preferences>("application/portlet", Preferences.class);
- /** . */
- final Map<String, Preference> state;
+ /** . */
+ final Map<String, Preference> state;
- /** . */
- private final Map<String, Preference> entries;
+ /** . */
+ private final Map<String, Preference> entries;
- public Preferences() {
- this.state = new HashMap<String, Preference>();
- this.entries = Collections.unmodifiableMap(this.state);
- }
+ public Preferences()
+ {
+ this.state = new HashMap<String, Preference>();
+ this.entries = Collections.unmodifiableMap(this.state);
+ }
- public Preferences(Map<String, Preference> state) {
- if (state == null) {
- throw new NullPointerException();
- }
+ public Preferences(Map<String, Preference> state)
+ {
+ if (state == null)
+ {
+ throw new NullPointerException();
+ }
- //
- this.state = new HashMap<String, Preference>(state);
- this.entries = Collections.unmodifiableMap(this.state);
- }
+ //
+ this.state = new HashMap<String, Preference>(state);
+ this.entries = Collections.unmodifiableMap(this.state);
+ }
- public List<String> getValues(String name) {
- Preference entry = entries.get(name);
- return entry != null ? entry.getValues() : null;
- }
+ public List<String> getValues(String name)
+ {
+ Preference entry = entries.get(name);
+ return entry != null ? entry.getValues() : null;
+ }
- public Preferences setValues(String name, List<String> values) {
- Preference entry = entries.get(name);
- if (entry == null) {
- entry = new Preference(name, values, false);
- } else {
- entry = new Preference(entry.getName(), values, entry.isReadOnly());
- }
- entries.put(name, entry);
- return this;
- }
+ public Preferences setValues(String name, List<String> values)
+ {
+ Preference entry = entries.get(name);
+ if (entry == null)
+ {
+ entry = new Preference(name, values, false);
+ }
+ else
+ {
+ entry = new Preference(entry.getName(), values, entry.isReadOnly());
+ }
+ entries.put(name, entry);
+ return this;
+ }
- public String getValue(String name) {
- Preference entry = entries.get(name);
- return entry != null ? entry.getValue() : null;
- }
+ public String getValue(String name)
+ {
+ Preference entry = entries.get(name);
+ return entry != null ? entry.getValue() : null;
+ }
- public Preferences setValue(String name, String value) {
- Preference entry = entries.get(name);
- if (entry == null) {
- entry = new Preference(name, value, false);
- } else {
- entry = new Preference(entry.getName(), value, entry.isReadOnly());
- }
- state.put(name, entry);
- return this;
- }
+ public Preferences setValue(String name, String value)
+ {
+ Preference entry = entries.get(name);
+ if (entry == null)
+ {
+ entry = new Preference(name, value, false);
+ }
+ else
+ {
+ entry = new Preference(entry.getName(), value, entry.isReadOnly());
+ }
+ state.put(name, entry);
+ return this;
+ }
- public Boolean isReadOnly(String name) {
- Preference entry = entries.get(name);
- return entry != null ? entry.isReadOnly() : null;
- }
+ public Boolean isReadOnly(String name)
+ {
+ Preference entry = entries.get(name);
+ return entry != null ? entry.isReadOnly() : null;
+ }
- public Preferences setReadOnly(String name, boolean readOnly) {
- Preference entry = entries.get(name);
- if (entry == null) {
- throw new IllegalStateException();
- }
- entry = new Preference(entry.getName(), entry.getValues(), readOnly);
- state.put(name, entry);
- return this;
- }
+ public Preferences setReadOnly(String name, boolean readOnly)
+ {
+ Preference entry = entries.get(name);
+ if (entry == null)
+ {
+ throw new IllegalStateException();
+ }
+ entry = new Preference(entry.getName(), entry.getValues(), readOnly);
+ state.put(name, entry);
+ return this;
+ }
- public Preference getPreference(String name) {
- return entries.get(name);
- }
+ public Preference getPreference(String name)
+ {
+ return entries.get(name);
+ }
- public Preferences putPreference(Preference preference) {
- state.put(preference.getName(), preference);
- return this;
- }
+ public Preferences putPreference(Preference preference)
+ {
+ state.put(preference.getName(), preference);
+ return this;
+ }
- public Iterator<Preference> iterator() {
- return entries.values().iterator();
- }
+ public Iterator<Preference> iterator()
+ {
+ return entries.values().iterator();
+ }
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (obj instanceof Preferences) {
- Preferences that = (Preferences)obj;
- return state.equals(that.state);
- }
- return false;
- }
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof Preferences)
+ {
+ Preferences that = (Preferences)obj;
+ return state.equals(that.state);
+ }
+ return false;
+ }
- @Override
- public int hashCode() {
- return state.hashCode();
- }
+ @Override
+ public int hashCode()
+ {
+ return state.hashCode();
+ }
- @Override
- public String toString() {
- return "Preferences[state=" + state.toString() + "]";
- }
+ @Override
+ public String toString()
+ {
+ return "Preferences[state=" + state.toString() + "]";
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PreferencesBuilder.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PreferencesBuilder.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/support/content/portlet/PreferencesBuilder.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -24,68 +24,81 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class PreferencesBuilder {
+public class PreferencesBuilder
+{
- /** The state being configured. */
- private Preferences prefs;
+ /** The state being configured. */
+ private Preferences prefs;
- public PreferencesBuilder() {
- this.prefs = new Preferences();
- }
+ public PreferencesBuilder()
+ {
+ this.prefs = new Preferences();
+ }
- /**
- * Initialize the builder with the provided preferences.
- *
- * @param that the preferences to clone
- */
- public PreferencesBuilder(Preferences that) {
- Preferences prefs = new Preferences();
- prefs.state.putAll(that.state);
+ /**
+ * Initialize the builder with the provided preferences.
+ *
+ * @param that the preferences to clone
+ */
+ public PreferencesBuilder(Preferences that)
+ {
+ Preferences prefs = new Preferences();
+ prefs.state.putAll(that.state);
- //
- this.prefs = prefs;
- }
+ //
+ this.prefs = prefs;
+ }
- public PreferencesBuilder add(Preference preference) {
- if (preference == null) {
- throw new NullPointerException();
- }
- prefs.state.put(preference.getName(), preference);
- return this;
- }
+ public PreferencesBuilder add(Preference preference)
+ {
+ if (preference == null)
+ {
+ throw new NullPointerException();
+ }
+ prefs.state.put(preference.getName(), preference);
+ return this;
+ }
- public PreferencesBuilder add(String name, List<String> values, boolean readOnly)
{
- return add(new Preference(name, values, readOnly));
- }
+ public PreferencesBuilder add(String name, List<String> values, boolean
readOnly)
+ {
+ return add(new Preference(name, values, readOnly));
+ }
- public PreferencesBuilder add(String name, List<String> values) {
- return add(new Preference(name, values, false));
- }
+ public PreferencesBuilder add(String name, List<String> values)
+ {
+ return add(new Preference(name, values, false));
+ }
- public PreferencesBuilder add(String name, String value, boolean readOnly) {
- return add(new Preference(name, value, readOnly));
- }
+ public PreferencesBuilder add(String name, String value, boolean readOnly)
+ {
+ return add(new Preference(name, value, readOnly));
+ }
- public PreferencesBuilder add(String name, String value) {
- return add(name, value, false);
- }
+ public PreferencesBuilder add(String name, String value)
+ {
+ return add(name, value, false);
+ }
- public PreferencesBuilder remove(String name) {
- if (name == null) {
- throw new NullPointerException();
- }
- prefs.state.remove(name);
- return this;
- }
+ public PreferencesBuilder remove(String name)
+ {
+ if (name == null)
+ {
+ throw new NullPointerException();
+ }
+ prefs.state.remove(name);
+ return this;
+ }
- public PreferencesBuilder clear() {
- prefs.state.clear();
- return this;
- }
+ public PreferencesBuilder clear()
+ {
+ prefs.state.clear();
+ return this;
+ }
- public Preferences build() {
- Preferences tmp = prefs;
- prefs = new Preferences();
- return tmp;
- }
+ public Preferences build()
+ {
+ Preferences tmp = prefs;
+ prefs = new Preferences();
+ return tmp;
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/KeyTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/KeyTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/KeyTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -29,40 +29,44 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class KeyTestCase extends TestCase {
+public class KeyTestCase extends TestCase
+{
- public void testCreate() {
- Key<String> a = Key.create("a", ValueType.STRING);
- assertNotNull(a);
- assertEquals("a", a.getName());
+ public void testCreate()
+ {
+ Key<String> a = Key.create("a", ValueType.STRING);
+ assertNotNull(a);
+ assertEquals("a", a.getName());
- //
- Key<Integer> b = Key.create("a", ValueType.INTEGER);
- assertNotNull(b);
- assertEquals("a", b.getName());
+ //
+ Key<Integer> b = Key.create("a", ValueType.INTEGER);
+ assertNotNull(b);
+ assertEquals("a", b.getName());
- //
- Key<Boolean> c = Key.create("a", ValueType.BOOLEAN);
- assertNotNull(c);
- assertEquals("a", c.getName());
+ //
+ Key<Boolean> c = Key.create("a", ValueType.BOOLEAN);
+ assertNotNull(c);
+ assertEquals("a", c.getName());
- //
- Key<Date> d = Key.create("a", ValueType.DATE);
- assertNotNull(d);
- assertEquals("a", d.getName());
+ //
+ Key<Date> d = Key.create("a", ValueType.DATE);
+ assertNotNull(d);
+ assertEquals("a", d.getName());
- //
- Key<Double> e = Key.create("a", ValueType.DOUBLE);
- assertNotNull(e);
- assertEquals("a", e.getName());
+ //
+ Key<Double> e = Key.create("a", ValueType.DOUBLE);
+ assertNotNull(e);
+ assertEquals("a", e.getName());
- //
- try {
- Key.create("a", null);
- fail();
- }
- catch (NullPointerException ignore) {
- }
- }
+ //
+ try
+ {
+ Key.create("a", null);
+ fail();
+ }
+ catch (NullPointerException ignore)
+ {
+ }
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/ToolsTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/ToolsTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/ToolsTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -28,13 +28,15 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class ToolsTestCase extends TestCase {
+public class ToolsTestCase extends TestCase
+{
- public void testIterators() {
- List<String> s1 = Arrays.asList();
- List<String> s2 = Arrays.asList("a");
- List<String> s3 = Arrays.asList("b", "c");
- Iterator<String> it = Tools.iterator(s1.iterator(), s2.iterator(),
s3.iterator());
- assertEquals(Arrays.asList("a", "b", "c"),
Tools.list(it));
- }
+ public void testIterators()
+ {
+ List<String> s1 = Arrays.asList();
+ List<String> s2 = Arrays.asList("a");
+ List<String> s3 = Arrays.asList("b", "c");
+ Iterator<String> it = Tools.iterator(s1.iterator(), s2.iterator(),
s3.iterator());
+ assertEquals(Arrays.asList("a", "b", "c"),
Tools.list(it));
+ }
}
Modified:
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/ValueTypeTestCase.java
===================================================================
---
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/ValueTypeTestCase.java 2009-11-23
17:17:11 UTC (rev 767)
+++
components/mop/trunk/core/src/test/java/org/gatein/mop/core/util/ValueTypeTestCase.java 2009-11-23
17:22:31 UTC (rev 768)
@@ -27,86 +27,95 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class ValueTypeTestCase extends TestCase {
+public class ValueTypeTestCase extends TestCase
+{
- public void testGet() {
- assertEquals(ValueType.INTEGER, ValueType.get(5));
- assertEquals(ValueType.BOOLEAN, ValueType.get(true));
- assertEquals(ValueType.STRING, ValueType.get(""));
- assertEquals(ValueType.DATE, ValueType.get(new Date()));
- assertEquals(ValueType.DOUBLE, ValueType.get(0.5D));
- try {
- ValueType.get(null);
- fail();
- }
- catch (NullPointerException ignore) {
- }
- try {
- ValueType.get(new Object());
- fail();
- }
- catch (IllegalArgumentException ignore) {
- }
- }
+ public void testGet()
+ {
+ assertEquals(ValueType.INTEGER, ValueType.get(5));
+ assertEquals(ValueType.BOOLEAN, ValueType.get(true));
+ assertEquals(ValueType.STRING, ValueType.get(""));
+ assertEquals(ValueType.DATE, ValueType.get(new Date()));
+ assertEquals(ValueType.DOUBLE, ValueType.get(0.5D));
+ try
+ {
+ ValueType.get(null);
+ fail();
+ }
+ catch (NullPointerException ignore)
+ {
+ }
+ try
+ {
+ ValueType.get(new Object());
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
- public void testDecode() {
- assertEquals(ValueType.INTEGER, ValueType.decode(5));
- assertEquals(ValueType.BOOLEAN, ValueType.decode(true));
- assertEquals(ValueType.STRING, ValueType.decode(""));
- assertEquals(ValueType.DATE, ValueType.decode(new Date()));
- assertEquals(ValueType.DOUBLE, ValueType.decode(0.5D));
- assertEquals(null, ValueType.decode(null));
- assertEquals(null, ValueType.decode(new Object()));
- }
+ public void testDecode()
+ {
+ assertEquals(ValueType.INTEGER, ValueType.decode(5));
+ assertEquals(ValueType.BOOLEAN, ValueType.decode(true));
+ assertEquals(ValueType.STRING, ValueType.decode(""));
+ assertEquals(ValueType.DATE, ValueType.decode(new Date()));
+ assertEquals(ValueType.DOUBLE, ValueType.decode(0.5D));
+ assertEquals(null, ValueType.decode(null));
+ assertEquals(null, ValueType.decode(new Object()));
+ }
- public void testAccept() {
- assertTrue(ValueType.INTEGER.isInstance(5));
- assertFalse(ValueType.INTEGER.isInstance(""));
- assertFalse(ValueType.INTEGER.isInstance(new Date()));
- assertFalse(ValueType.INTEGER.isInstance(true));
- assertFalse(ValueType.INTEGER.isInstance(0.5D));
- assertFalse(ValueType.INTEGER.isInstance(null));
- assertFalse(ValueType.INTEGER.isInstance(new Object()));
+ public void testAccept()
+ {
+ assertTrue(ValueType.INTEGER.isInstance(5));
+ assertFalse(ValueType.INTEGER.isInstance(""));
+ assertFalse(ValueType.INTEGER.isInstance(new Date()));
+ assertFalse(ValueType.INTEGER.isInstance(true));
+ assertFalse(ValueType.INTEGER.isInstance(0.5D));
+ assertFalse(ValueType.INTEGER.isInstance(null));
+ assertFalse(ValueType.INTEGER.isInstance(new Object()));
- //
- assertFalse(ValueType.BOOLEAN.isInstance(5));
- assertFalse(ValueType.BOOLEAN.isInstance(""));
- assertFalse(ValueType.BOOLEAN.isInstance(new Date()));
- assertTrue(ValueType.BOOLEAN.isInstance(true));
- assertFalse(ValueType.BOOLEAN.isInstance(0.5D));
- assertFalse(ValueType.BOOLEAN.isInstance(null));
- assertFalse(ValueType.BOOLEAN.isInstance(new Object()));
+ //
+ assertFalse(ValueType.BOOLEAN.isInstance(5));
+ assertFalse(ValueType.BOOLEAN.isInstance(""));
+ assertFalse(ValueType.BOOLEAN.isInstance(new Date()));
+ assertTrue(ValueType.BOOLEAN.isInstance(true));
+ assertFalse(ValueType.BOOLEAN.isInstance(0.5D));
+ assertFalse(ValueType.BOOLEAN.isInstance(null));
+ assertFalse(ValueType.BOOLEAN.isInstance(new Object()));
- //
- assertFalse(ValueType.DATE.isInstance(5));
- assertFalse(ValueType.DATE.isInstance(""));
- assertTrue(ValueType.DATE.isInstance(new Date()));
- assertFalse(ValueType.DATE.isInstance(true));
- assertFalse(ValueType.DATE.isInstance(0.5D));
- assertFalse(ValueType.DATE.isInstance(null));
- assertFalse(ValueType.DATE.isInstance(new Object()));
+ //
+ assertFalse(ValueType.DATE.isInstance(5));
+ assertFalse(ValueType.DATE.isInstance(""));
+ assertTrue(ValueType.DATE.isInstance(new Date()));
+ assertFalse(ValueType.DATE.isInstance(true));
+ assertFalse(ValueType.DATE.isInstance(0.5D));
+ assertFalse(ValueType.DATE.isInstance(null));
+ assertFalse(ValueType.DATE.isInstance(new Object()));
- //
- assertFalse(ValueType.STRING.isInstance(5));
- assertTrue(ValueType.STRING.isInstance(""));
- assertFalse(ValueType.STRING.isInstance(new Date()));
- assertFalse(ValueType.STRING.isInstance(true));
- assertFalse(ValueType.STRING.isInstance(0.5D));
- assertFalse(ValueType.STRING.isInstance(null));
- assertFalse(ValueType.STRING.isInstance(new Object()));
+ //
+ assertFalse(ValueType.STRING.isInstance(5));
+ assertTrue(ValueType.STRING.isInstance(""));
+ assertFalse(ValueType.STRING.isInstance(new Date()));
+ assertFalse(ValueType.STRING.isInstance(true));
+ assertFalse(ValueType.STRING.isInstance(0.5D));
+ assertFalse(ValueType.STRING.isInstance(null));
+ assertFalse(ValueType.STRING.isInstance(new Object()));
- //
- assertFalse(ValueType.DOUBLE.isInstance(5));
- assertFalse(ValueType.DOUBLE.isInstance(""));
- assertFalse(ValueType.DOUBLE.isInstance(new Date()));
- assertFalse(ValueType.DOUBLE.isInstance(true));
- assertTrue(ValueType.DOUBLE.isInstance(0.5D));
- assertFalse(ValueType.DOUBLE.isInstance(null));
- assertFalse(ValueType.DOUBLE.isInstance(new Object()));
- }
+ //
+ assertFalse(ValueType.DOUBLE.isInstance(5));
+ assertFalse(ValueType.DOUBLE.isInstance(""));
+ assertFalse(ValueType.DOUBLE.isInstance(new Date()));
+ assertFalse(ValueType.DOUBLE.isInstance(true));
+ assertTrue(ValueType.DOUBLE.isInstance(0.5D));
+ assertFalse(ValueType.DOUBLE.isInstance(null));
+ assertFalse(ValueType.DOUBLE.isInstance(new Object()));
+ }
- public void testCast() {
- // todo
- }
+ public void testCast()
+ {
+ // todo
+ }
}