Author: chris.laprun(a)jboss.com
Date: 2009-05-06 10:37:18 -0400 (Wed, 06 May 2009)
New Revision: 13309
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectUtil.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
Log:
- Extracted checking for default status to PortalObjectUtil so that it can be reused
elsewhere.
Added:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectUtil.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectUtil.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/PortalObjectUtil.java 2009-05-06
14:37:18 UTC (rev 13309)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.core.model.portal;
+
+import org.jboss.portal.common.util.ParameterValidation;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class PortalObjectUtil
+{
+ /**
+ * Checks whether the given PortalObject is the default child for its parent.
+ *
+ * @param object the object which default status we want to check
+ * @return <code>true</code> if the specified object is the default child
for its parent, <code>false</code>
+ * otherwise
+ */
+ public static boolean isDefault(PortalObject object)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(object,
"PortalObject");
+
+ // get the parent, if parent doesn't exist, consider the object as its own
parent
+ PortalObject parent = object.getParent();
+ if (parent == null)
+ {
+ parent = object;
+ }
+
+ return
object.getName().equals(parent.getDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME));
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2009-05-06
14:18:00 UTC (rev 13308)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2009-05-06
14:37:18 UTC (rev 13309)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -33,6 +33,7 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectPath;
+import org.jboss.portal.core.model.portal.PortalObjectUtil;
import org.jboss.portal.core.portlet.info.PortletIconInfo;
import org.jboss.portal.core.portlet.info.PortletInfoInfo;
import org.jboss.portal.core.portlet.info.WSRPInfo;
@@ -67,7 +68,6 @@
import javax.faces.el.PropertyResolver;
import javax.faces.model.SelectItem;
import javax.xml.namespace.QName;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -196,7 +196,7 @@
public Object getValue(Object bean) throws IllegalArgumentException
{
Portlet portlet = (Portlet)bean;
- Set<WindowStateInfo> set =
portlet.getInfo().getCapabilities().getWindowStates(MediaType.TEXT_HTML);
+ Set<WindowStateInfo> set =
portlet.getInfo().getCapabilities().getWindowStates(MediaType.TEXT_HTML);
return Tools.toList(set.iterator());
}
});
@@ -205,7 +205,7 @@
public Object getValue(Object bean) throws IllegalArgumentException
{
Portlet portlet = (Portlet)bean;
- Set<MediaType> set =
portlet.getInfo().getCapabilities().getMediaTypes();
+ Set<MediaType> set =
portlet.getInfo().getCapabilities().getMediaTypes();
return Tools.toList(set.iterator());
}
});
@@ -262,7 +262,7 @@
public Object getValue(Object bean) throws IllegalArgumentException
{
Portlet portlet = (Portlet)bean;
-
+
NavigationInfo navigationInfo = portlet.getInfo().getNavigation();
if (navigationInfo == null)
{
@@ -412,16 +412,7 @@
{
public Object getValue(Object bean)
{
- PortalObject object = (PortalObject)bean;
-
- // get the parent, if parent doesn't exist, consider the object as its
own parent
- PortalObject portalObject = object.getParent();
- if (portalObject == null)
- {
- portalObject = object;
- }
-
- return
Boolean.valueOf(object.getName().equals(portalObject.getDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME)));
+ return PortalObjectUtil.isDefault((PortalObject)bean);
}
});
portalObjectDecorator.setProperty("typeName", new
AbstractPropertyDecorator(String.class)