Author: julien_viet
Date: 2009-12-04 15:11:50 -0500 (Fri, 04 Dec 2009)
New Revision: 933
Added:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryChromatticLifeCycle.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/CategoryDefinition.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentDefinition.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentRegistry.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/NodeAware.java
Removed:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryChromatticLifeCycle.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/CategoryDefinition.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentDefinition.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentRegistry.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/MOPApplicationRegistryService.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/NodeAware.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/
Modified:
portal/trunk/component/application-registry/src/main/java/conf/portal/configuration.xml
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java
portal/trunk/component/application-registry/src/test/java/conf/portal/test-configuration.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml
Log:
- rename mop package to impl package in application registry (as it's not related to
mop)
- rename MOPApplicationRegistryService to ApplicationRegistryServiceImpl
Modified:
portal/trunk/component/application-registry/src/main/java/conf/portal/configuration.xml
===================================================================
---
portal/trunk/component/application-registry/src/main/java/conf/portal/configuration.xml 2009-12-04
19:58:27 UTC (rev 932)
+++
portal/trunk/component/application-registry/src/main/java/conf/portal/configuration.xml 2009-12-04
20:11:50 UTC (rev 933)
@@ -37,7 +37,7 @@
<component>
<key>org.exoplatform.application.registry.ApplicationRegistryService</key>
-
<type>org.exoplatform.application.registry.mop.MOPApplicationRegistryService</type>
+
<type>org.exoplatform.application.registry.impl.ApplicationRegistryServiceImpl</type>
</component>
</configuration>
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2009-12-04
19:58:27 UTC (rev 932)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -22,7 +22,7 @@
import org.chromattic.api.ChromatticSession;
import org.exoplatform.application.gadget.Gadget;
import org.exoplatform.application.gadget.GadgetRegistryService;
-import org.exoplatform.application.registry.mop.ApplicationRegistryChromatticLifeCycle;
+import org.exoplatform.application.registry.impl.ApplicationRegistryChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticManager;
import org.exoplatform.container.xml.InitParams;
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java 2009-12-04
19:58:27 UTC (rev 932)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/LocalGadgetData.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -26,7 +26,7 @@
import org.chromattic.api.annotations.NodeMapping;
import org.chromattic.api.annotations.Property;
import org.exoplatform.application.gadget.EncodingDetector;
-import org.exoplatform.application.registry.mop.NodeAware;
+import org.exoplatform.application.registry.impl.NodeAware;
import org.gatein.common.io.IOTools;
import javax.jcr.Node;
Copied:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl
(from rev 929,
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop)
Deleted:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryChromatticLifeCycle.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/ApplicationRegistryChromatticLifeCycle.java 2009-12-04
18:07:13 UTC (rev 929)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryChromatticLifeCycle.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -1,44 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.application.registry.mop;
-
-import org.chromattic.core.DomainSession;
-import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
-import org.exoplatform.commons.chromattic.SessionContext;
-import org.exoplatform.container.xml.InitParams;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class ApplicationRegistryChromatticLifeCycle extends ChromatticLifeCycle
-{
-
- /** . */
- MOPApplicationRegistryService registry;
-
- public ApplicationRegistryChromatticLifeCycle(InitParams params) {
- super(params);
- }
-
- @Override
- protected void onOpenSession(SessionContext context) {
- context.getSession().addEventListener(new Injector(registry,
(DomainSession)context.getSession()));
- }
-}
Copied:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryChromatticLifeCycle.java
(from rev 932,
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/ApplicationRegistryChromatticLifeCycle.java)
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryChromatticLifeCycle.java
(rev 0)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryChromatticLifeCycle.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -0,0 +1,44 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.application.registry.impl;
+
+import org.chromattic.core.DomainSession;
+import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
+import org.exoplatform.commons.chromattic.SessionContext;
+import org.exoplatform.container.xml.InitParams;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ApplicationRegistryChromatticLifeCycle extends ChromatticLifeCycle
+{
+
+ /** . */
+ ApplicationRegistryServiceImpl registry;
+
+ public ApplicationRegistryChromatticLifeCycle(InitParams params) {
+ super(params);
+ }
+
+ @Override
+ protected void onOpenSession(SessionContext context) {
+ context.getSession().addEventListener(new Injector(registry,
(DomainSession)context.getSession()));
+ }
+}
Added:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java
(rev 0)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ApplicationRegistryServiceImpl.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -0,0 +1,755 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.application.registry.impl;
+
+import org.chromattic.api.ChromatticSession;
+import org.exoplatform.application.gadget.Gadget;
+import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.application.registry.Application;
+import org.exoplatform.application.registry.ApplicationCategoriesPlugins;
+import org.exoplatform.application.registry.ApplicationCategory;
+import org.exoplatform.application.registry.ApplicationRegistryService;
+import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
+import org.exoplatform.commons.chromattic.ChromatticManager;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.component.ComponentPlugin;
+import org.exoplatform.portal.config.UserACL;
+import org.exoplatform.portal.config.model.ApplicationType;
+import org.exoplatform.portal.pom.config.POMSessionManager;
+import org.exoplatform.portal.pom.spi.portlet.Portlet;
+import org.exoplatform.portal.pom.spi.wsrp.WSRP;
+import org.gatein.common.i18n.LocalizedString;
+import org.gatein.common.util.Tools;
+import org.gatein.mop.api.content.ContentType;
+import org.gatein.mop.api.content.Customization;
+import org.gatein.pc.api.PortletInvoker;
+import org.gatein.pc.api.info.MetaInfo;
+import org.gatein.pc.api.info.PortletInfo;
+import org.picocontainer.Startable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * The fundamental reason that motives to use tasks is because of the JMX access that
does not
+ * setup a context and therefore the task either reuse the existing context setup by the
portal
+ * or create a temporary context when accessed by JMX.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ApplicationRegistryServiceImpl implements ApplicationRegistryService,
Startable
+{
+
+ /** . */
+ private static final String REMOTE_CATEGORY_NAME = "remote";
+
+ /** . */
+ private List<ApplicationCategoriesPlugins> plugins;
+
+ /** . */
+ private final ChromatticManager manager;
+
+ /** . */
+ private final ChromatticLifeCycle lifeCycle;
+
+ /** . */
+ final POMSessionManager mopManager;
+
+ public ApplicationRegistryServiceImpl(ChromatticManager manager, POMSessionManager
mopManager)
+ {
+ ApplicationRegistryChromatticLifeCycle lifeCycle =
(ApplicationRegistryChromatticLifeCycle)manager.getLifeCycle("app");
+ lifeCycle.registry = this;
+
+ //
+ this.manager = manager;
+ this.lifeCycle = lifeCycle;
+ this.mopManager = mopManager;
+ }
+
+ public ContentRegistry getContentRegistry()
+ {
+ ChromatticSession session = lifeCycle.getChromattic().openSession();
+ ContentRegistry registry = session.findByPath(ContentRegistry.class,
"registry");
+ if (registry == null)
+ {
+ registry = session.insert(ContentRegistry.class, "registry");
+ }
+ return registry;
+ }
+
+ public void initListener(ComponentPlugin com) throws Exception
+ {
+ if (com instanceof ApplicationCategoriesPlugins)
+ {
+ if (plugins == null)
+ {
+ plugins = new ArrayList<ApplicationCategoriesPlugins>();
+ }
+ plugins.add((ApplicationCategoriesPlugins)com);
+ }
+ }
+
+ public List<ApplicationCategory> getApplicationCategories(
+ final Comparator<ApplicationCategory> sortComparator,
+ String accessUser,
+ final ApplicationType<?>... appTypes) throws Exception
+ {
+ final List<ApplicationCategory> categories = new
ArrayList<ApplicationCategory>();
+
+ //
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+
+ //
+ for (CategoryDefinition categoryDef : registry.getCategoryList())
+ {
+ ApplicationCategory category = load(categoryDef, appTypes);
+ categories.add(category);
+ }
+
+ //
+ if (sortComparator != null)
+ {
+ Collections.sort(categories, sortComparator);
+ }
+/*
+ }
+ });
+*/
+
+ //
+ return categories;
+ }
+
+ public List<ApplicationCategory> getApplicationCategories(String accessUser,
ApplicationType<?>... appTypes) throws Exception
+ {
+ return getApplicationCategories(null, accessUser, appTypes);
+ }
+
+ public List<ApplicationCategory> getApplicationCategories() throws Exception
+ {
+ return getApplicationCategories(null);
+ }
+
+ public List<ApplicationCategory>
getApplicationCategories(Comparator<ApplicationCategory> sortComparator) throws
Exception
+ {
+ return getApplicationCategories(sortComparator, null);
+ }
+
+ public ApplicationCategory getApplicationCategory(final String name) throws Exception
+ {
+ final AtomicReference<ApplicationCategory> a = new
AtomicReference<ApplicationCategory>();
+
+ //
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+
+ //
+ CategoryDefinition categoryDef = registry.getCategory(name);
+ if (categoryDef != null)
+ {
+ ApplicationCategory applicationCategory = load(categoryDef);
+ a.set(applicationCategory);
+ }
+/*
+ }
+ });
+*/
+
+ //
+ return a.get();
+ }
+
+ public void save(final ApplicationCategory category) throws Exception
+ {
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+
+ //
+ String categoryName = category.getName();
+
+ //
+ CategoryDefinition categoryDef = registry.getCategory(categoryName);
+ if (categoryDef == null)
+ {
+ categoryDef = registry.createCategory(categoryName);
+ }
+
+ //
+ categoryDef.setDisplayName(category.getDisplayName());
+ categoryDef.setCreationDate(category.getCreatedDate());
+ categoryDef.setLastModificationDate(category.getModifiedDate());
+ categoryDef.setDescription(category.getDescription());
+ categoryDef.setAccessPermissions(category.getAccessPermissions());
+ }
+/*
+ });
+ }
+*/
+
+ public void remove(final ApplicationCategory category) throws Exception
+ {
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+ registry.getCategoryMap().remove(category.getName());
+/*
+ }
+ });
+*/
+ }
+
+ public List<Application> getApplications(ApplicationCategory category,
ApplicationType<?>... appTypes) throws Exception
+ {
+ return getApplications(category, null, appTypes);
+ }
+
+ public List<Application> getApplications(
+ final ApplicationCategory category,
+ final Comparator<Application> sortComparator,
+ final ApplicationType<?>... appTypes) throws Exception
+ {
+ final AtomicReference<List<Application>> ref = new
AtomicReference<List<Application>>();
+
+ //
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+
+ //
+ CategoryDefinition categoryDef = registry.getCategory(category.getName());
+ List<Application> applications = load(categoryDef,
appTypes).getApplications();
+
+ //
+ if (sortComparator != null)
+ {
+ Collections.sort(applications, sortComparator);
+ }
+
+ //
+ ref.set(applications);
+/*
+ }
+ });
+*/
+
+ //
+ return ref.get();
+ }
+
+ public List<Application> getAllApplications() throws Exception
+ {
+ List<Application> applications = new ArrayList<Application>();
+ List<ApplicationCategory> categories = getApplicationCategories();
+ for (ApplicationCategory category : categories)
+ {
+ applications.addAll(getApplications(category));
+ }
+ return applications;
+ }
+
+ public Application getApplication(String id) throws Exception
+ {
+ String[] fragments = id.split("/");
+ if (fragments.length < 2)
+ {
+ throw new Exception("Invalid Application Id: [" + id +
"]");
+ }
+ return getApplication(fragments[0], fragments[1]);
+ }
+
+ public Application getApplication(final String category, final String name) throws
Exception
+ {
+ final AtomicReference<Application> ref = new
AtomicReference<Application>();
+
+ //
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+
+ //
+ CategoryDefinition categoryDef = registry.getCategory(category);
+ if (categoryDef != null)
+ {
+ ContentDefinition contentDef = categoryDef.getContentMap().get(name);
+ if (contentDef != null)
+ {
+ ref.set(load(contentDef));
+ }
+ }
+/*
+ }
+ });
+*/
+
+ //
+ return ref.get();
+ }
+
+ public void save(final ApplicationCategory category, final Application application)
throws Exception
+ {
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+
+ //
+ String categoryName = category.getName();
+ CategoryDefinition categoryDef = registry.getCategory(categoryName);
+ if (categoryDef == null)
+ {
+ categoryDef = registry.createCategory(categoryName);
+ save(category, categoryDef);
+ }
+
+ //
+ ContentDefinition contentDef = null;
+ CategoryDefinition applicationCategoryDef =
registry.getCategory(application.getCategoryName());
+ String applicationName = application.getApplicationName();
+ if (applicationCategoryDef != null)
+ {
+ contentDef = applicationCategoryDef.getContentMap().get(applicationName);
+ }
+ if (contentDef == null)
+ {
+ String contentId = application.getContentId();
+ ContentType<?> contentType =
application.getType().getContentType();
+ String definitionName = application.getApplicationName();
+ contentDef = categoryDef.createContent(definitionName, contentType,
contentId);
+ }
+ else
+ {
+ // A JCR move actually
+ categoryDef.getContentList().add(contentDef);
+ }
+
+ // Update state
+ save(application, contentDef);
+/*
+ }
+ });
+*/
+ }
+
+ public void update(final Application application) throws Exception
+ {
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+
+ //
+ String categoryName = application.getCategoryName();
+ CategoryDefinition categoryDef = registry.getCategory(categoryName);
+ if (categoryDef == null)
+ {
+ throw new IllegalStateException();
+ }
+
+ //
+ ContentDefinition contentDef =
categoryDef.getContentMap().get(application.getApplicationName());
+ if (contentDef == null)
+ {
+ throw new IllegalStateException();
+ }
+
+ // Update state
+ save(application, contentDef);
+/*
+ }
+ });
+*/
+ }
+
+ public void remove(final Application app) throws Exception
+ {
+ if (app == null)
+ {
+ throw new NullPointerException();
+ }
+
+ //
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+
+ //
+ String categoryName = app.getCategoryName();
+ CategoryDefinition categoryDef = registry.getCategory(categoryName);
+
+ //
+ if (categoryDef != null)
+ {
+
+ String contentName = app.getApplicationName();
+ categoryDef.getContentMap().remove(contentName);
+ }
+/*
+ }
+ });
+*/
+ }
+
+ public void importExoGadgets() throws Exception
+ {
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+
+ //
+ ExoContainer container = ExoContainerContext.getCurrentContainer();
+ GadgetRegistryService gadgetService =
(GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
+ List<Gadget> eXoGadgets = gadgetService.getAllGadgets();
+
+ //
+ if (eXoGadgets != null)
+ {
+ ArrayList<String> permissions = new ArrayList<String>();
+ permissions.add(UserACL.EVERYONE);
+ String categoryName = "Gadgets";
+
+ //
+ CategoryDefinition category = registry.getCategory(categoryName);
+ if (category == null)
+ {
+ category = registry.createCategory(categoryName);
+ category.setDisplayName(categoryName);
+ category.setDescription(categoryName);
+ category.setAccessPermissions(permissions);
+ }
+
+ //
+ for (Gadget ele : eXoGadgets)
+ {
+ ContentDefinition app = category.getContentMap().get(ele.getName());
+ if (app == null)
+ {
+ app = category.createContent(ele.getName(),
org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE, ele.getName());
+ app.setDisplayName(ele.getTitle());
+ app.setDescription(ele.getDescription());
+ app.setAccessPermissions(permissions);
+ }
+ }
+ }
+/*
+ }
+ });
+*/
+ }
+
+ public void importAllPortlets() throws Exception
+ {
+/*
+ pomMGr.execute(new POMTask()
+ {
+ public void run(POMSession session) throws Exception
+ {
+*/
+ ContentRegistry registry = getContentRegistry();
+
+ //
+ ExoContainer manager = ExoContainerContext.getCurrentContainer();
+ PortletInvoker portletInvoker =
(PortletInvoker)manager.getComponentInstance(PortletInvoker.class);
+ Set<org.gatein.pc.api.Portlet> portlets =
portletInvoker.getPortlets();
+
+ //
+ for (org.gatein.pc.api.Portlet portlet : portlets)
+ {
+ PortletInfo info = portlet.getInfo();
+ String portletApplicationName = info.getApplicationName();
+ String portletName = info.getName();
+
+ // Need to sanitize portlet and application names in case they contain
characters that would
+ // cause an improper Application name
+ portletApplicationName = portletApplicationName.replace('/',
'_');
+ portletName = portletName.replace('/', '_');
+
+ LocalizedString keywordsLS =
info.getMeta().getMetaValue(MetaInfo.KEYWORDS);
+
+ String[] categoryNames = null;
+ if (keywordsLS != null)
+ {
+ String keywords = keywordsLS.getDefaultString();
+ if (keywords != null && keywords.length() != 0)
+ {
+ categoryNames = keywords.split(",");
+ }
+ }
+
+ if (categoryNames == null || categoryNames.length == 0)
+ {
+ categoryNames = new String[]{portletApplicationName};
+ }
+
+ if (portlet.isRemote())
+ {
+ categoryNames = Tools.appendTo(categoryNames, REMOTE_CATEGORY_NAME);
+ }
+
+ //
+ for (String categoryName : categoryNames)
+ {
+ categoryName = categoryName.trim();
+
+ //
+ CategoryDefinition category = registry.getCategory(categoryName);
+
+ //
+ if (category == null)
+ {
+ category = registry.createCategory(categoryName);
+ category.setDisplayName(categoryName);
+ }
+
+ //
+ ContentDefinition app = category.getContentMap().get(portletName);
+ if (app == null)
+ {
+ LocalizedString descriptionLS =
portlet.getInfo().getMeta().getMetaValue(MetaInfo.DESCRIPTION);
+ LocalizedString displayNameLS =
portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+
+ // julien: ????
+ // getLocalizedStringValue(descriptionLS, portletName);
+
+ ContentType<?> contentType;
+ String contentId;
+ if (portlet.isRemote())
+ {
+ contentType = WSRP.CONTENT_TYPE;
+ contentId = portlet.getContext().getId();
+ }
+ else
+ {
+ contentType = Portlet.CONTENT_TYPE;
+ contentId = info.getApplicationName() + "/" +
info.getName();
+ }
+
+
+ //
+ app = category.createContent(portletName, contentType, contentId);
+ app.setDisplayName(getLocalizedStringValue(displayNameLS,
portletName));
+ app.setDescription(getLocalizedStringValue(descriptionLS,
portletName));
+ }
+ }
+ }
+/*
+ }
+ });
+*/
+ }
+
+ private boolean isApplicationType(Application app, ApplicationType<?>...
appTypes)
+ {
+ if (appTypes == null || appTypes.length == 0)
+ {
+ return true;
+ }
+ for (ApplicationType<?> appType : appTypes)
+ {
+ if (appType.equals(app.getType()))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void save(ApplicationCategory category, CategoryDefinition categoryDef)
+ {
+ categoryDef.setDisplayName(category.getDisplayName());
+ categoryDef.setDescription(category.getDescription());
+ categoryDef.setAccessPermissions(category.getAccessPermissions());
+ categoryDef.setCreationDate(category.getCreatedDate());
+ categoryDef.setLastModificationDate(category.getModifiedDate());
+ }
+
+ private ApplicationCategory load(CategoryDefinition categoryDef,
ApplicationType<?>... appTypes)
+ {
+ ApplicationCategory category = new ApplicationCategory();
+
+ //
+ category.setName(categoryDef.getName());
+ category.setDisplayName(categoryDef.getDisplayName());
+ category.setDescription(categoryDef.getDescription());
+ category.setAccessPermissions(new
ArrayList<String>(categoryDef.getAccessPermissions()));
+ category.setCreatedDate(categoryDef.getCreationDate());
+ category.setModifiedDate(categoryDef.getLastModificationDate());
+
+ //
+ for (ContentDefinition contentDef : categoryDef.getContentList())
+ {
+ Application application = load(contentDef);
+ if (isApplicationType(application, appTypes))
+ {
+ category.getApplications().add(application);
+ }
+ }
+
+ //
+ return category;
+ }
+
+ private void save(Application application, ContentDefinition contentDef)
+ {
+ contentDef.setDisplayName(application.getDisplayName());
+ contentDef.setDescription(application.getDescription());
+ contentDef.setAccessPermissions(application.getAccessPermissions());
+ contentDef.setCreationDate(application.getCreatedDate());
+ contentDef.setLastModificationDate(application.getModifiedDate());
+ }
+
+ private Application load(ContentDefinition contentDef)
+ {
+ ContentType<?> contentType = contentDef.getCustomization().getType();
+ ApplicationType<?> applicationType = ApplicationType.getType(contentType);
+
+ //
+ Application application = new Application();
+ application.setId(contentDef.getCategory().getName() + "/" +
contentDef.getName());
+ application.setCategoryName(contentDef.getCategory().getName());
+ application.setType(applicationType);
+ application.setApplicationName(contentDef.getName());
+ application.setIconURL(getApplicationIconURL(contentDef));
+ application.setDisplayName(contentDef.getDisplayName());
+ application.setDescription(contentDef.getDescription());
+ application.setAccessPermissions(new
ArrayList<String>(contentDef.getAccessPermissions()));
+ application.setCreatedDate(contentDef.getCreationDate());
+ application.setModifiedDate(contentDef.getLastModificationDate());
+ application.setStorageId(contentDef.getCustomization().getId());
+ application.setContentId(contentDef.getCustomization().getContentId());
+ return application;
+ }
+
+ private String getLocalizedStringValue(LocalizedString localizedString, String
portletName)
+ {
+ if (localizedString == null || localizedString.getDefaultString() == null)
+ {
+ return portletName;
+ }
+ else
+ {
+ return localizedString.getDefaultString();
+ }
+ }
+
+ private static String getApplicationIconURL(ContentDefinition contentDef)
+ {
+ Customization customization = contentDef.getCustomization();
+ if (customization != null)
+ {
+ ContentType type = customization.getType();
+ String contentId = customization.getContentId();
+ if (type == Portlet.CONTENT_TYPE)
+ {
+ String[] chunks = contentId.split("/");
+ if (chunks.length == 2)
+ {
+ return "/" + chunks[0] +
"/skin/DefaultSkin/portletIcons/" + chunks[1] + ".png";
+ }
+ }
+ else if (type == org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE)
+ {
+ return "/" + "eXoGadgets" +
"/skin/DefaultSkin/portletIcons/" + contentId + ".png";
+ }
+ }
+
+ //
+ return null;
+ }
+
+ public void start()
+ {
+ if (plugins != null)
+ {
+// POMSession session = pomMGr.openSession();
+// SessionContext context = lifeCycle.openContext();
+ manager.beginRequest();
+ boolean save = false;
+ try
+ {
+ for (ApplicationCategoriesPlugins plugin : plugins)
+ {
+ plugin.run();
+ }
+ save = true;
+ }
+ catch (Exception e)
+ {
+ // log.error(e);
+ e.printStackTrace();
+ }
+ finally
+ {
+ // lifeCycle.closeContext(context, true);
+ manager.endRequest(true);
+ }
+ }
+ }
+
+ public void stop()
+ {
+ }
+}
Deleted:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/CategoryDefinition.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/CategoryDefinition.java 2009-12-04
18:07:13 UTC (rev 929)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/CategoryDefinition.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -1,143 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.application.registry.mop;
-
-import org.chromattic.api.annotations.Create;
-import org.chromattic.api.annotations.Name;
-import org.chromattic.api.annotations.NodeMapping;
-import org.chromattic.api.annotations.OneToMany;
-import org.chromattic.api.annotations.Property;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.gatein.mop.api.content.ContentType;
-import org.gatein.mop.api.content.Customization;
-import org.gatein.mop.api.workspace.Workspace;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-@NodeMapping(name = "mop:contentcategory")
-public abstract class CategoryDefinition
-{
-
- /** The injected workspace. */
- public MOPApplicationRegistryService registry;
-
- @Name
- public abstract String getName();
-
- @Property(name = "displayname")
- public abstract String getDisplayName();
-
- public abstract void setDisplayName(String displayName);
-
- @Property(name = "description")
- public abstract String getDescription();
-
- public abstract void setDescription(String description);
-
- @Property(name = "creationdate")
- public abstract Date getCreationDate();
-
- public abstract void setCreationDate(Date date);
-
- @Property(name = "lastmodificationdate")
- public abstract Date getLastModificationDate();
-
- public abstract void setLastModificationDate(Date date);
-
- @Property(name = "accesspermissions")
- public abstract List<String> getAccessPermissions();
-
- public abstract void setAccessPermissions(List<String> accessPermissions);
-
- @OneToMany
- public abstract List<ContentDefinition> getContentList();
-
- @OneToMany
- public abstract Map<String, ContentDefinition> getContentMap();
-
- @Create
- public abstract ContentDefinition create();
-
- /**
- * Create a content definition for the target content.
- *
- * @param definitionName the definition name
- * @param contentType the target content type
- * @param contentId the target content id
- * @return the content definion
- */
- public ContentDefinition createContent(
- String definitionName,
- ContentType<?> contentType,
- String contentId)
- {
- if (definitionName == null)
- {
- throw new NullPointerException("No null definition name accepted");
- }
- if (contentType == null)
- {
- throw new NullPointerException("No null content type accepted");
- }
- if (contentId == null)
- {
- throw new NullPointerException("No null content id accepted");
- }
-
- //
- POMSession session = registry.mopManager.getSession();
-
- //
- Workspace workspace = session.getWorkspace();
-
- //
- Customization customization = workspace.getCustomization(definitionName);
-
- //
- if (customization == null)
- {
- workspace.customize(definitionName, contentType, contentId, null);
- }
- else if (customization.getContentId().equals(contentId))
- {
- // Do nothing here
- }
- else
- {
- throw new IllegalArgumentException("Cannot create a content with a content
id " + contentId +
- " with an existing different content id " +
customization.getContentId());
- }
-
- //
- ContentDefinition content = create();
-
- //
- Map<String, ContentDefinition> contents = getContentMap();
- contents.put(definitionName, content);
-
- //
- return content;
- }
-}
Copied:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/CategoryDefinition.java
(from rev 932,
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/CategoryDefinition.java)
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/CategoryDefinition.java
(rev 0)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/CategoryDefinition.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -0,0 +1,143 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.application.registry.impl;
+
+import org.chromattic.api.annotations.Create;
+import org.chromattic.api.annotations.Name;
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.OneToMany;
+import org.chromattic.api.annotations.Property;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.gatein.mop.api.content.ContentType;
+import org.gatein.mop.api.content.Customization;
+import org.gatein.mop.api.workspace.Workspace;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+@NodeMapping(name = "app:contentcategory")
+public abstract class CategoryDefinition
+{
+
+ /** The injected workspace. */
+ public ApplicationRegistryServiceImpl registry;
+
+ @Name
+ public abstract String getName();
+
+ @Property(name = "displayname")
+ public abstract String getDisplayName();
+
+ public abstract void setDisplayName(String displayName);
+
+ @Property(name = "description")
+ public abstract String getDescription();
+
+ public abstract void setDescription(String description);
+
+ @Property(name = "creationdate")
+ public abstract Date getCreationDate();
+
+ public abstract void setCreationDate(Date date);
+
+ @Property(name = "lastmodificationdate")
+ public abstract Date getLastModificationDate();
+
+ public abstract void setLastModificationDate(Date date);
+
+ @Property(name = "accesspermissions")
+ public abstract List<String> getAccessPermissions();
+
+ public abstract void setAccessPermissions(List<String> accessPermissions);
+
+ @OneToMany
+ public abstract List<ContentDefinition> getContentList();
+
+ @OneToMany
+ public abstract Map<String, ContentDefinition> getContentMap();
+
+ @Create
+ public abstract ContentDefinition create();
+
+ /**
+ * Create a content definition for the target content.
+ *
+ * @param definitionName the definition name
+ * @param contentType the target content type
+ * @param contentId the target content id
+ * @return the content definion
+ */
+ public ContentDefinition createContent(
+ String definitionName,
+ ContentType<?> contentType,
+ String contentId)
+ {
+ if (definitionName == null)
+ {
+ throw new NullPointerException("No null definition name accepted");
+ }
+ if (contentType == null)
+ {
+ throw new NullPointerException("No null content type accepted");
+ }
+ if (contentId == null)
+ {
+ throw new NullPointerException("No null content id accepted");
+ }
+
+ //
+ POMSession session = registry.mopManager.getSession();
+
+ //
+ Workspace workspace = session.getWorkspace();
+
+ //
+ Customization customization = workspace.getCustomization(definitionName);
+
+ //
+ if (customization == null)
+ {
+ workspace.customize(definitionName, contentType, contentId, null);
+ }
+ else if (customization.getContentId().equals(contentId))
+ {
+ // Do nothing here
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot create a content with a content
id " + contentId +
+ " with an existing different content id " +
customization.getContentId());
+ }
+
+ //
+ ContentDefinition content = create();
+
+ //
+ Map<String, ContentDefinition> contents = getContentMap();
+ contents.put(definitionName, content);
+
+ //
+ return content;
+ }
+}
Deleted:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentDefinition.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/ContentDefinition.java 2009-12-04
18:07:13 UTC (rev 929)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentDefinition.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -1,88 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.application.registry.mop;
-
-import org.chromattic.api.annotations.Id;
-import org.chromattic.api.annotations.ManyToOne;
-import org.chromattic.api.annotations.Name;
-import org.chromattic.api.annotations.NodeMapping;
-import org.chromattic.api.annotations.Property;
-import org.exoplatform.portal.pom.config.POMSession;
-import org.gatein.mop.api.content.Customization;
-import org.gatein.mop.api.workspace.Workspace;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-@NodeMapping(name = "mop:content")
-public abstract class ContentDefinition
-{
-
- @Id
- public abstract String getId();
-
- @Name
- public abstract String getName();
-
- @Property(name = "displayname")
- public abstract String getDisplayName();
-
- public abstract void setDisplayName(String displayName);
-
- @Property(name = "description")
- public abstract String getDescription();
-
- public abstract void setDescription(String description);
-
- @Property(name = "creationdate")
- public abstract Date getCreationDate();
-
- public abstract void setCreationDate(Date date);
-
- @Property(name = "lastmodificationdate")
- public abstract Date getLastModificationDate();
-
- public abstract void setLastModificationDate(Date date);
-
- @Property(name = "accesspermissions")
- public abstract List<String> getAccessPermissions();
-
- public abstract void setAccessPermissions(List<String> accessPermissions);
-
- @ManyToOne
- public abstract CategoryDefinition getCategory();
-
- public Customization getCustomization()
- {
- CategoryDefinition category = getCategory();
- POMSession session = category.registry.mopManager.getSession();
- Workspace workspace = session.getWorkspace();
- String name = getName();
- return workspace.getCustomization(name);
- }
-
-
-
-
-
-}
Copied:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentDefinition.java
(from rev 932,
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/ContentDefinition.java)
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentDefinition.java
(rev 0)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentDefinition.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -0,0 +1,88 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.application.registry.impl;
+
+import org.chromattic.api.annotations.Id;
+import org.chromattic.api.annotations.ManyToOne;
+import org.chromattic.api.annotations.Name;
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.Property;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.gatein.mop.api.content.Customization;
+import org.gatein.mop.api.workspace.Workspace;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+@NodeMapping(name = "app:content")
+public abstract class ContentDefinition
+{
+
+ @Id
+ public abstract String getId();
+
+ @Name
+ public abstract String getName();
+
+ @Property(name = "displayname")
+ public abstract String getDisplayName();
+
+ public abstract void setDisplayName(String displayName);
+
+ @Property(name = "description")
+ public abstract String getDescription();
+
+ public abstract void setDescription(String description);
+
+ @Property(name = "creationdate")
+ public abstract Date getCreationDate();
+
+ public abstract void setCreationDate(Date date);
+
+ @Property(name = "lastmodificationdate")
+ public abstract Date getLastModificationDate();
+
+ public abstract void setLastModificationDate(Date date);
+
+ @Property(name = "accesspermissions")
+ public abstract List<String> getAccessPermissions();
+
+ public abstract void setAccessPermissions(List<String> accessPermissions);
+
+ @ManyToOne
+ public abstract CategoryDefinition getCategory();
+
+ public Customization getCustomization()
+ {
+ CategoryDefinition category = getCategory();
+ POMSession session = category.registry.mopManager.getSession();
+ Workspace workspace = session.getWorkspace();
+ String name = getName();
+ return workspace.getCustomization(name);
+ }
+
+
+
+
+
+}
Deleted:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentRegistry.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/ContentRegistry.java 2009-12-04
18:07:13 UTC (rev 929)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentRegistry.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -1,62 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.application.registry.mop;
-
-import org.chromattic.api.annotations.Create;
-import org.chromattic.api.annotations.NodeMapping;
-import org.chromattic.api.annotations.OneToMany;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-@NodeMapping(name = "mop:contentregistry")
-public abstract class ContentRegistry
-{
-
- @OneToMany
- public abstract List<CategoryDefinition> getCategoryList();
-
- @OneToMany
- public abstract Map<String, CategoryDefinition> getCategoryMap();
-
- @Create
- public abstract CategoryDefinition create();
-
- public CategoryDefinition getCategory(String categoryName)
- {
- return getCategoryMap().get(categoryName);
- }
-
- public CategoryDefinition createCategory(String categoryName)
- {
- Map<String, CategoryDefinition> categories = getCategoryMap();
- if (categories.containsKey(categoryName))
- {
- throw new IllegalArgumentException("Duplicate category " +
categoryName);
- }
- CategoryDefinition category = create();
- categories.put(categoryName, category);
- return category;
- }
-
-}
Copied:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentRegistry.java
(from rev 932,
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/ContentRegistry.java)
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentRegistry.java
(rev 0)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/ContentRegistry.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -0,0 +1,62 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.application.registry.impl;
+
+import org.chromattic.api.annotations.Create;
+import org.chromattic.api.annotations.NodeMapping;
+import org.chromattic.api.annotations.OneToMany;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+@NodeMapping(name = "app:contentregistry")
+public abstract class ContentRegistry
+{
+
+ @OneToMany
+ public abstract List<CategoryDefinition> getCategoryList();
+
+ @OneToMany
+ public abstract Map<String, CategoryDefinition> getCategoryMap();
+
+ @Create
+ public abstract CategoryDefinition create();
+
+ public CategoryDefinition getCategory(String categoryName)
+ {
+ return getCategoryMap().get(categoryName);
+ }
+
+ public CategoryDefinition createCategory(String categoryName)
+ {
+ Map<String, CategoryDefinition> categories = getCategoryMap();
+ if (categories.containsKey(categoryName))
+ {
+ throw new IllegalArgumentException("Duplicate category " +
categoryName);
+ }
+ CategoryDefinition category = create();
+ categories.put(categoryName, category);
+ return category;
+ }
+
+}
Deleted:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/Injector.java 2009-12-04
18:07:13 UTC (rev 929)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -1,86 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.application.registry.mop;
-
-import org.chromattic.api.event.LifeCycleListener;
-import org.chromattic.core.DomainSession;
-
-import javax.jcr.Node;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class Injector implements LifeCycleListener
-{
-
- /** . */
- private final MOPApplicationRegistryService registry;
-
- /** . */
- private final DomainSession session;
-
- public Injector(MOPApplicationRegistryService registry, DomainSession session)
- {
- this.registry = registry;
- this.session = session;
- }
-
- public void created(Object o)
- {
- }
-
- public void loaded(String id, String path, String name, Object o)
- {
- if (o instanceof NodeAware)
- {
- Node node = session.getNode(o);
- ((NodeAware)o).setNode(node);
- }
- if (o instanceof CategoryDefinition)
- {
- ((CategoryDefinition)o).registry = registry;
- }
- }
-
- public void added(String id, String path, String name, Object o)
- {
- if (o instanceof NodeAware)
- {
- Node node = session.getNode(o);
- ((NodeAware)o).setNode(node);
- }
- if (o instanceof CategoryDefinition)
- {
- ((CategoryDefinition)o).registry = registry;
- }
- }
-
- public void removed(String id, String path, String name, Object o)
- {
- if (o instanceof NodeAware)
- {
- ((NodeAware)o).setNode(null);
- }
- if (o instanceof CategoryDefinition)
- {
- ((CategoryDefinition)o).registry = null;
- }
- }
-}
Copied:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java
(from rev 932,
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/Injector.java)
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java
(rev 0)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/Injector.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -0,0 +1,86 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.application.registry.impl;
+
+import org.chromattic.api.event.LifeCycleListener;
+import org.chromattic.core.DomainSession;
+
+import javax.jcr.Node;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class Injector implements LifeCycleListener
+{
+
+ /** . */
+ private final ApplicationRegistryServiceImpl registry;
+
+ /** . */
+ private final DomainSession session;
+
+ public Injector(ApplicationRegistryServiceImpl registry, DomainSession session)
+ {
+ this.registry = registry;
+ this.session = session;
+ }
+
+ public void created(Object o)
+ {
+ }
+
+ public void loaded(String id, String path, String name, Object o)
+ {
+ if (o instanceof NodeAware)
+ {
+ Node node = session.getNode(o);
+ ((NodeAware)o).setNode(node);
+ }
+ if (o instanceof CategoryDefinition)
+ {
+ ((CategoryDefinition)o).registry = registry;
+ }
+ }
+
+ public void added(String id, String path, String name, Object o)
+ {
+ if (o instanceof NodeAware)
+ {
+ Node node = session.getNode(o);
+ ((NodeAware)o).setNode(node);
+ }
+ if (o instanceof CategoryDefinition)
+ {
+ ((CategoryDefinition)o).registry = registry;
+ }
+ }
+
+ public void removed(String id, String path, String name, Object o)
+ {
+ if (o instanceof NodeAware)
+ {
+ ((NodeAware)o).setNode(null);
+ }
+ if (o instanceof CategoryDefinition)
+ {
+ ((CategoryDefinition)o).registry = null;
+ }
+ }
+}
Deleted:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/MOPApplicationRegistryService.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/MOPApplicationRegistryService.java 2009-12-04
18:07:13 UTC (rev 929)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/MOPApplicationRegistryService.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -1,755 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.application.registry.mop;
-
-import org.chromattic.api.ChromatticSession;
-import org.exoplatform.application.gadget.Gadget;
-import org.exoplatform.application.gadget.GadgetRegistryService;
-import org.exoplatform.application.registry.Application;
-import org.exoplatform.application.registry.ApplicationCategoriesPlugins;
-import org.exoplatform.application.registry.ApplicationCategory;
-import org.exoplatform.application.registry.ApplicationRegistryService;
-import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
-import org.exoplatform.commons.chromattic.ChromatticManager;
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.container.component.ComponentPlugin;
-import org.exoplatform.portal.config.UserACL;
-import org.exoplatform.portal.config.model.ApplicationType;
-import org.exoplatform.portal.pom.config.POMSessionManager;
-import org.exoplatform.portal.pom.spi.portlet.Portlet;
-import org.exoplatform.portal.pom.spi.wsrp.WSRP;
-import org.gatein.common.i18n.LocalizedString;
-import org.gatein.common.util.Tools;
-import org.gatein.mop.api.content.ContentType;
-import org.gatein.mop.api.content.Customization;
-import org.gatein.pc.api.PortletInvoker;
-import org.gatein.pc.api.info.MetaInfo;
-import org.gatein.pc.api.info.PortletInfo;
-import org.picocontainer.Startable;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * The fundamental reason that motives to use tasks is because of the JMX access that
does not
- * setup a context and therefore the task either reuse the existing context setup by the
portal
- * or create a temporary context when accessed by JMX.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public class MOPApplicationRegistryService implements ApplicationRegistryService,
Startable
-{
-
- /** . */
- private static final String REMOTE_CATEGORY_NAME = "remote";
-
- /** . */
- private List<ApplicationCategoriesPlugins> plugins;
-
- /** . */
- private final ChromatticManager manager;
-
- /** . */
- private final ChromatticLifeCycle lifeCycle;
-
- /** . */
- final POMSessionManager mopManager;
-
- public MOPApplicationRegistryService(ChromatticManager manager, POMSessionManager
mopManager)
- {
- ApplicationRegistryChromatticLifeCycle lifeCycle =
(ApplicationRegistryChromatticLifeCycle)manager.getLifeCycle("app");
- lifeCycle.registry = this;
-
- //
- this.manager = manager;
- this.lifeCycle = lifeCycle;
- this.mopManager = mopManager;
- }
-
- public ContentRegistry getContentRegistry()
- {
- ChromatticSession session = lifeCycle.getChromattic().openSession();
- ContentRegistry registry = session.findByPath(ContentRegistry.class,
"registry");
- if (registry == null)
- {
- registry = session.insert(ContentRegistry.class, "registry");
- }
- return registry;
- }
-
- public void initListener(ComponentPlugin com) throws Exception
- {
- if (com instanceof ApplicationCategoriesPlugins)
- {
- if (plugins == null)
- {
- plugins = new ArrayList<ApplicationCategoriesPlugins>();
- }
- plugins.add((ApplicationCategoriesPlugins)com);
- }
- }
-
- public List<ApplicationCategory> getApplicationCategories(
- final Comparator<ApplicationCategory> sortComparator,
- String accessUser,
- final ApplicationType<?>... appTypes) throws Exception
- {
- final List<ApplicationCategory> categories = new
ArrayList<ApplicationCategory>();
-
- //
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
-
- //
- for (CategoryDefinition categoryDef : registry.getCategoryList())
- {
- ApplicationCategory category = load(categoryDef, appTypes);
- categories.add(category);
- }
-
- //
- if (sortComparator != null)
- {
- Collections.sort(categories, sortComparator);
- }
-/*
- }
- });
-*/
-
- //
- return categories;
- }
-
- public List<ApplicationCategory> getApplicationCategories(String accessUser,
ApplicationType<?>... appTypes) throws Exception
- {
- return getApplicationCategories(null, accessUser, appTypes);
- }
-
- public List<ApplicationCategory> getApplicationCategories() throws Exception
- {
- return getApplicationCategories(null);
- }
-
- public List<ApplicationCategory>
getApplicationCategories(Comparator<ApplicationCategory> sortComparator) throws
Exception
- {
- return getApplicationCategories(sortComparator, null);
- }
-
- public ApplicationCategory getApplicationCategory(final String name) throws Exception
- {
- final AtomicReference<ApplicationCategory> a = new
AtomicReference<ApplicationCategory>();
-
- //
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
-
- //
- CategoryDefinition categoryDef = registry.getCategory(name);
- if (categoryDef != null)
- {
- ApplicationCategory applicationCategory = load(categoryDef);
- a.set(applicationCategory);
- }
-/*
- }
- });
-*/
-
- //
- return a.get();
- }
-
- public void save(final ApplicationCategory category) throws Exception
- {
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
-
- //
- String categoryName = category.getName();
-
- //
- CategoryDefinition categoryDef = registry.getCategory(categoryName);
- if (categoryDef == null)
- {
- categoryDef = registry.createCategory(categoryName);
- }
-
- //
- categoryDef.setDisplayName(category.getDisplayName());
- categoryDef.setCreationDate(category.getCreatedDate());
- categoryDef.setLastModificationDate(category.getModifiedDate());
- categoryDef.setDescription(category.getDescription());
- categoryDef.setAccessPermissions(category.getAccessPermissions());
- }
-/*
- });
- }
-*/
-
- public void remove(final ApplicationCategory category) throws Exception
- {
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
- registry.getCategoryMap().remove(category.getName());
-/*
- }
- });
-*/
- }
-
- public List<Application> getApplications(ApplicationCategory category,
ApplicationType<?>... appTypes) throws Exception
- {
- return getApplications(category, null, appTypes);
- }
-
- public List<Application> getApplications(
- final ApplicationCategory category,
- final Comparator<Application> sortComparator,
- final ApplicationType<?>... appTypes) throws Exception
- {
- final AtomicReference<List<Application>> ref = new
AtomicReference<List<Application>>();
-
- //
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
-
- //
- CategoryDefinition categoryDef = registry.getCategory(category.getName());
- List<Application> applications = load(categoryDef,
appTypes).getApplications();
-
- //
- if (sortComparator != null)
- {
- Collections.sort(applications, sortComparator);
- }
-
- //
- ref.set(applications);
-/*
- }
- });
-*/
-
- //
- return ref.get();
- }
-
- public List<Application> getAllApplications() throws Exception
- {
- List<Application> applications = new ArrayList<Application>();
- List<ApplicationCategory> categories = getApplicationCategories();
- for (ApplicationCategory category : categories)
- {
- applications.addAll(getApplications(category));
- }
- return applications;
- }
-
- public Application getApplication(String id) throws Exception
- {
- String[] fragments = id.split("/");
- if (fragments.length < 2)
- {
- throw new Exception("Invalid Application Id: [" + id +
"]");
- }
- return getApplication(fragments[0], fragments[1]);
- }
-
- public Application getApplication(final String category, final String name) throws
Exception
- {
- final AtomicReference<Application> ref = new
AtomicReference<Application>();
-
- //
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
-
- //
- CategoryDefinition categoryDef = registry.getCategory(category);
- if (categoryDef != null)
- {
- ContentDefinition contentDef = categoryDef.getContentMap().get(name);
- if (contentDef != null)
- {
- ref.set(load(contentDef));
- }
- }
-/*
- }
- });
-*/
-
- //
- return ref.get();
- }
-
- public void save(final ApplicationCategory category, final Application application)
throws Exception
- {
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
-
- //
- String categoryName = category.getName();
- CategoryDefinition categoryDef = registry.getCategory(categoryName);
- if (categoryDef == null)
- {
- categoryDef = registry.createCategory(categoryName);
- save(category, categoryDef);
- }
-
- //
- ContentDefinition contentDef = null;
- CategoryDefinition applicationCategoryDef =
registry.getCategory(application.getCategoryName());
- String applicationName = application.getApplicationName();
- if (applicationCategoryDef != null)
- {
- contentDef = applicationCategoryDef.getContentMap().get(applicationName);
- }
- if (contentDef == null)
- {
- String contentId = application.getContentId();
- ContentType<?> contentType =
application.getType().getContentType();
- String definitionName = application.getApplicationName();
- contentDef = categoryDef.createContent(definitionName, contentType,
contentId);
- }
- else
- {
- // A JCR move actually
- categoryDef.getContentList().add(contentDef);
- }
-
- // Update state
- save(application, contentDef);
-/*
- }
- });
-*/
- }
-
- public void update(final Application application) throws Exception
- {
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
-
- //
- String categoryName = application.getCategoryName();
- CategoryDefinition categoryDef = registry.getCategory(categoryName);
- if (categoryDef == null)
- {
- throw new IllegalStateException();
- }
-
- //
- ContentDefinition contentDef =
categoryDef.getContentMap().get(application.getApplicationName());
- if (contentDef == null)
- {
- throw new IllegalStateException();
- }
-
- // Update state
- save(application, contentDef);
-/*
- }
- });
-*/
- }
-
- public void remove(final Application app) throws Exception
- {
- if (app == null)
- {
- throw new NullPointerException();
- }
-
- //
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
-
- //
- String categoryName = app.getCategoryName();
- CategoryDefinition categoryDef = registry.getCategory(categoryName);
-
- //
- if (categoryDef != null)
- {
-
- String contentName = app.getApplicationName();
- categoryDef.getContentMap().remove(contentName);
- }
-/*
- }
- });
-*/
- }
-
- public void importExoGadgets() throws Exception
- {
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
-
- //
- ExoContainer container = ExoContainerContext.getCurrentContainer();
- GadgetRegistryService gadgetService =
(GadgetRegistryService)container.getComponentInstanceOfType(GadgetRegistryService.class);
- List<Gadget> eXoGadgets = gadgetService.getAllGadgets();
-
- //
- if (eXoGadgets != null)
- {
- ArrayList<String> permissions = new ArrayList<String>();
- permissions.add(UserACL.EVERYONE);
- String categoryName = "Gadgets";
-
- //
- CategoryDefinition category = registry.getCategory(categoryName);
- if (category == null)
- {
- category = registry.createCategory(categoryName);
- category.setDisplayName(categoryName);
- category.setDescription(categoryName);
- category.setAccessPermissions(permissions);
- }
-
- //
- for (Gadget ele : eXoGadgets)
- {
- ContentDefinition app = category.getContentMap().get(ele.getName());
- if (app == null)
- {
- app = category.createContent(ele.getName(),
org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE, ele.getName());
- app.setDisplayName(ele.getTitle());
- app.setDescription(ele.getDescription());
- app.setAccessPermissions(permissions);
- }
- }
- }
-/*
- }
- });
-*/
- }
-
- public void importAllPortlets() throws Exception
- {
-/*
- pomMGr.execute(new POMTask()
- {
- public void run(POMSession session) throws Exception
- {
-*/
- ContentRegistry registry = getContentRegistry();
-
- //
- ExoContainer manager = ExoContainerContext.getCurrentContainer();
- PortletInvoker portletInvoker =
(PortletInvoker)manager.getComponentInstance(PortletInvoker.class);
- Set<org.gatein.pc.api.Portlet> portlets =
portletInvoker.getPortlets();
-
- //
- for (org.gatein.pc.api.Portlet portlet : portlets)
- {
- PortletInfo info = portlet.getInfo();
- String portletApplicationName = info.getApplicationName();
- String portletName = info.getName();
-
- // Need to sanitize portlet and application names in case they contain
characters that would
- // cause an improper Application name
- portletApplicationName = portletApplicationName.replace('/',
'_');
- portletName = portletName.replace('/', '_');
-
- LocalizedString keywordsLS =
info.getMeta().getMetaValue(MetaInfo.KEYWORDS);
-
- String[] categoryNames = null;
- if (keywordsLS != null)
- {
- String keywords = keywordsLS.getDefaultString();
- if (keywords != null && keywords.length() != 0)
- {
- categoryNames = keywords.split(",");
- }
- }
-
- if (categoryNames == null || categoryNames.length == 0)
- {
- categoryNames = new String[]{portletApplicationName};
- }
-
- if (portlet.isRemote())
- {
- categoryNames = Tools.appendTo(categoryNames, REMOTE_CATEGORY_NAME);
- }
-
- //
- for (String categoryName : categoryNames)
- {
- categoryName = categoryName.trim();
-
- //
- CategoryDefinition category = registry.getCategory(categoryName);
-
- //
- if (category == null)
- {
- category = registry.createCategory(categoryName);
- category.setDisplayName(categoryName);
- }
-
- //
- ContentDefinition app = category.getContentMap().get(portletName);
- if (app == null)
- {
- LocalizedString descriptionLS =
portlet.getInfo().getMeta().getMetaValue(MetaInfo.DESCRIPTION);
- LocalizedString displayNameLS =
portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
-
- // julien: ????
- // getLocalizedStringValue(descriptionLS, portletName);
-
- ContentType<?> contentType;
- String contentId;
- if (portlet.isRemote())
- {
- contentType = WSRP.CONTENT_TYPE;
- contentId = portlet.getContext().getId();
- }
- else
- {
- contentType = Portlet.CONTENT_TYPE;
- contentId = info.getApplicationName() + "/" +
info.getName();
- }
-
-
- //
- app = category.createContent(portletName, contentType, contentId);
- app.setDisplayName(getLocalizedStringValue(displayNameLS,
portletName));
- app.setDescription(getLocalizedStringValue(descriptionLS,
portletName));
- }
- }
- }
-/*
- }
- });
-*/
- }
-
- private boolean isApplicationType(Application app, ApplicationType<?>...
appTypes)
- {
- if (appTypes == null || appTypes.length == 0)
- {
- return true;
- }
- for (ApplicationType<?> appType : appTypes)
- {
- if (appType.equals(app.getType()))
- {
- return true;
- }
- }
- return false;
- }
-
- private void save(ApplicationCategory category, CategoryDefinition categoryDef)
- {
- categoryDef.setDisplayName(category.getDisplayName());
- categoryDef.setDescription(category.getDescription());
- categoryDef.setAccessPermissions(category.getAccessPermissions());
- categoryDef.setCreationDate(category.getCreatedDate());
- categoryDef.setLastModificationDate(category.getModifiedDate());
- }
-
- private ApplicationCategory load(CategoryDefinition categoryDef,
ApplicationType<?>... appTypes)
- {
- ApplicationCategory category = new ApplicationCategory();
-
- //
- category.setName(categoryDef.getName());
- category.setDisplayName(categoryDef.getDisplayName());
- category.setDescription(categoryDef.getDescription());
- category.setAccessPermissions(new
ArrayList<String>(categoryDef.getAccessPermissions()));
- category.setCreatedDate(categoryDef.getCreationDate());
- category.setModifiedDate(categoryDef.getLastModificationDate());
-
- //
- for (ContentDefinition contentDef : categoryDef.getContentList())
- {
- Application application = load(contentDef);
- if (isApplicationType(application, appTypes))
- {
- category.getApplications().add(application);
- }
- }
-
- //
- return category;
- }
-
- private void save(Application application, ContentDefinition contentDef)
- {
- contentDef.setDisplayName(application.getDisplayName());
- contentDef.setDescription(application.getDescription());
- contentDef.setAccessPermissions(application.getAccessPermissions());
- contentDef.setCreationDate(application.getCreatedDate());
- contentDef.setLastModificationDate(application.getModifiedDate());
- }
-
- private Application load(ContentDefinition contentDef)
- {
- ContentType<?> contentType = contentDef.getCustomization().getType();
- ApplicationType<?> applicationType = ApplicationType.getType(contentType);
-
- //
- Application application = new Application();
- application.setId(contentDef.getCategory().getName() + "/" +
contentDef.getName());
- application.setCategoryName(contentDef.getCategory().getName());
- application.setType(applicationType);
- application.setApplicationName(contentDef.getName());
- application.setIconURL(getApplicationIconURL(contentDef));
- application.setDisplayName(contentDef.getDisplayName());
- application.setDescription(contentDef.getDescription());
- application.setAccessPermissions(new
ArrayList<String>(contentDef.getAccessPermissions()));
- application.setCreatedDate(contentDef.getCreationDate());
- application.setModifiedDate(contentDef.getLastModificationDate());
- application.setStorageId(contentDef.getCustomization().getId());
- application.setContentId(contentDef.getCustomization().getContentId());
- return application;
- }
-
- private String getLocalizedStringValue(LocalizedString localizedString, String
portletName)
- {
- if (localizedString == null || localizedString.getDefaultString() == null)
- {
- return portletName;
- }
- else
- {
- return localizedString.getDefaultString();
- }
- }
-
- private static String getApplicationIconURL(ContentDefinition contentDef)
- {
- Customization customization = contentDef.getCustomization();
- if (customization != null)
- {
- ContentType type = customization.getType();
- String contentId = customization.getContentId();
- if (type == Portlet.CONTENT_TYPE)
- {
- String[] chunks = contentId.split("/");
- if (chunks.length == 2)
- {
- return "/" + chunks[0] +
"/skin/DefaultSkin/portletIcons/" + chunks[1] + ".png";
- }
- }
- else if (type == org.exoplatform.portal.pom.spi.gadget.Gadget.CONTENT_TYPE)
- {
- return "/" + "eXoGadgets" +
"/skin/DefaultSkin/portletIcons/" + contentId + ".png";
- }
- }
-
- //
- return null;
- }
-
- public void start()
- {
- if (plugins != null)
- {
-// POMSession session = pomMGr.openSession();
-// SessionContext context = lifeCycle.openContext();
- manager.beginRequest();
- boolean save = false;
- try
- {
- for (ApplicationCategoriesPlugins plugin : plugins)
- {
- plugin.run();
- }
- save = true;
- }
- catch (Exception e)
- {
- // log.error(e);
- e.printStackTrace();
- }
- finally
- {
- // lifeCycle.closeContext(context, true);
- manager.endRequest(true);
- }
- }
- }
-
- public void stop()
- {
- }
-}
Deleted:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/NodeAware.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/NodeAware.java 2009-12-04
18:07:13 UTC (rev 929)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/NodeAware.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.application.registry.mop;
-
-import javax.jcr.Node;
-
-/**
- * Temporary hack.
- *
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
- * @version $Revision$
- */
-public interface NodeAware
-{
- void setNode(Node node);
-}
Copied:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/NodeAware.java
(from rev 932,
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/mop/NodeAware.java)
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/NodeAware.java
(rev 0)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/registry/impl/NodeAware.java 2009-12-04
20:11:50 UTC (rev 933)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.application.registry.impl;
+
+import javax.jcr.Node;
+
+/**
+ * Temporary hack.
+ *
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public interface NodeAware
+{
+ void setNode(Node node);
+}
Modified:
portal/trunk/component/application-registry/src/test/java/conf/portal/test-configuration.xml
===================================================================
---
portal/trunk/component/application-registry/src/test/java/conf/portal/test-configuration.xml 2009-12-04
19:58:27 UTC (rev 932)
+++
portal/trunk/component/application-registry/src/test/java/conf/portal/test-configuration.xml 2009-12-04
20:11:50 UTC (rev 933)
@@ -30,7 +30,7 @@
</component>
<component>
<key>org.exoplatform.application.registry.ApplicationRegistryService</key>
-
<type>org.exoplatform.application.registry.mop.MOPApplicationRegistryService</type>
+
<type>org.exoplatform.application.registry.impl.ApplicationRegistryServiceImpl</type>
<component-plugins>
<component-plugin>
<name>new.portal.portlets.registry</name>
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml 2009-12-04
19:58:27 UTC (rev 932)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/application-registry-configuration.xml 2009-12-04
20:11:50 UTC (rev 933)
@@ -66,7 +66,7 @@
<component>
<key>org.exoplatform.application.registry.ApplicationRegistryService</key>
-
<type>org.exoplatform.application.registry.mop.MOPApplicationRegistryService</type>
+
<type>org.exoplatform.application.registry.impl.ApplicationRegistryServiceImpl</type>
<component-plugins>
<component-plugin>
<name>new.portal.portlets.registry</name>
@@ -526,7 +526,7 @@
<component-plugin>
<name>chromattic</name>
<set-method>addLifeCycle</set-method>
-
<type>org.exoplatform.application.registry.mop.ApplicationRegistryChromatticLifeCycle</type>
+
<type>org.exoplatform.application.registry.impl.ApplicationRegistryChromatticLifeCycle</type>
<init-params>
<value-param>
<name>name</name>
@@ -538,9 +538,9 @@
</value-param>
<values-param>
<name>entities</name>
-
<value>org.exoplatform.application.registry.mop.ContentRegistry</value>
-
<value>org.exoplatform.application.registry.mop.CategoryDefinition</value>
-
<value>org.exoplatform.application.registry.mop.ContentDefinition</value>
+
<value>org.exoplatform.application.registry.impl.ContentRegistry</value>
+
<value>org.exoplatform.application.registry.impl.CategoryDefinition</value>
+
<value>org.exoplatform.application.registry.impl.ContentDefinition</value>
<value>org.exoplatform.application.gadget.impl.GadgetRegistry</value>
<value>org.exoplatform.application.gadget.impl.GadgetDefinition</value>
<value>org.exoplatform.application.gadget.impl.LocalGadgetData</value>