Author: nscavell
Date: 2011-07-29 12:17:05 -0400 (Fri, 29 Jul 2011)
New Revision: 6949
Modified:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java
Log:
Fix site names read resource operation.
Modified:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java 2011-07-29
03:51:39 UTC (rev 6948)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteReadResource.java 2011-07-29
16:17:05 UTC (rev 6949)
@@ -28,9 +28,11 @@
import org.gatein.management.api.operation.ResultHandler;
import org.gatein.management.api.operation.model.ReadResourceModel;
import org.gatein.mop.api.workspace.Navigation;
+import org.gatein.mop.api.workspace.ObjectType;
import org.gatein.mop.api.workspace.Page;
import org.gatein.mop.api.workspace.Site;
+import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -64,7 +66,26 @@
{
children.add("portal");
}
+ else
+ {
+ if (site.getObjectType() == ObjectType.GROUP_SITE)
+ {
+ Collection<? extends Site> groupsites =
site.getWorkspace().getSites(site.getObjectType());
+ for (Site groupsite : groupsites)
+ {
+ String siteName = site.getName();
+ String groupName = groupsite.getName();
+ if (siteName.equals(groupName)) continue;
+ int index = groupName.indexOf(siteName);
+ if (index == 0)
+ {
+ children.add(groupName.substring(siteName.length(),
groupName.length()));
+ }
+ }
+ }
+ }
+
resultHandler.completed(new ReadResourceModel("Available artifacts for site
" + getSiteKey(site), children));
}
}
Modified:
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java
===================================================================
---
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java 2011-07-29
03:51:39 UTC (rev 6948)
+++
portal/branches/gatein-management/component/portal/src/main/java/org/exoplatform/portal/mop/management/operations/site/SiteTypeReadResource.java 2011-07-29
16:17:05 UTC (rev 6949)
@@ -28,7 +28,9 @@
import org.gatein.management.api.operation.OperationContext;
import org.gatein.management.api.operation.ResultHandler;
import org.gatein.management.api.operation.model.ReadResourceModel;
+import org.gatein.mop.api.workspace.Navigation;
import org.gatein.mop.api.workspace.ObjectType;
+import org.gatein.mop.api.workspace.Page;
import org.gatein.mop.api.workspace.Site;
import org.gatein.mop.api.workspace.Workspace;
@@ -49,7 +51,31 @@
Set<String> children = new LinkedHashSet<String>(sites.size());
for (Site site : sites)
{
- children.add(site.getName());
+ boolean pageOrNav = false;
+ Page pages = site.getRootPage().getChild("pages");
+ if (pages != null && !pages.getChildren().isEmpty())
+ {
+ pageOrNav = true;
+ }
+ Navigation defaultNav = site.getRootNavigation().getChild("default");
+ if (defaultNav != null && !defaultNav.getChildren().isEmpty())
+ {
+ pageOrNav = true;
+ }
+
+ //TODO: Until invalid site entries without a leading slash is corrected, this is
needed to ignore them.
+ if (siteType == ObjectType.GROUP_SITE)
+ {
+ String name = site.getName();
+ if (name.charAt(0) == '/' && pageOrNav)
+ {
+ children.add(site.getName());
+ }
+ }
+ else if (pageOrNav)
+ {
+ children.add(site.getName());
+ }
}
resultHandler.completed(new ReadResourceModel("Available sites for site type
'" + getSiteType(siteType).getName() + "'", children));
}
Show replies by date