gatein SVN: r1622 - in components/wsrp/trunk/admin-gui/src/main/webapp: jsf and 4 other directories.
by do-not-reply@jboss.org
Author: wesleyhales
Date: 2010-02-10 20:51:38 -0500 (Wed, 10 Feb 2010)
New Revision: 1622
Added:
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/error.xhtml
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/errorTemplate.xhtml
Modified:
components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/web.xml
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/common/template.xhtml
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/confirmEraseRegistration.xhtml
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/editConsumer.xhtml
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/management/management.xhtml
components/wsrp/trunk/admin-gui/src/main/webapp/jsf/producer/confirmPropDeletion.xhtml
Log:
wsrp admin ui enhancements - fixed "Cannot reset a commited stream" error. Added general error message catch for the ui.
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/web.xml
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/web.xml 2010-02-10 21:52:19 UTC (rev 1621)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/WEB-INF/web.xml 2010-02-11 01:51:38 UTC (rev 1622)
@@ -73,7 +73,12 @@
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
+ <error-page>
+ <exception-type>java.lang.Exception</exception-type>
+ <location>/faces/jsf/error.xhtml</location>
+ </error-page>
+
</web-app>
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/common/template.xhtml
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/jsf/common/template.xhtml 2010-02-10 21:52:19 UTC (rev 1621)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/jsf/common/template.xhtml 2010-02-11 01:51:38 UTC (rev 1622)
@@ -46,7 +46,7 @@
<div style="width:98%;margin: 0 auto">
- <ui:insert name="objectpath">Object path if needed</ui:insert>
+ <ui:insert name="objectpath"/>
<div class="wsrp-content-container">
<ui:remove>
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/confirmEraseRegistration.xhtml
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/confirmEraseRegistration.xhtml 2010-02-10 21:52:19 UTC (rev 1621)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/confirmEraseRegistration.xhtml 2010-02-11 01:51:38 UTC (rev 1622)
@@ -57,8 +57,21 @@
action="eraseLocalRegistration"
backingBean="#{consumer}"/>
- <webui:commandLink id="cancel" value="#{i18n.confirm_delete_registration_cancel}"
- actionString="configureConsumer"/>
+ <table class="ActionContainer">
+ <tr>
+ <td>
+ <div class="ButtonLeft">
+ <div class="ButtonRight">
+ <div class="ButtonMiddle">
+ <h:commandLink id="cancel" action="configureConsumer"
+ value="#{i18n.confirm_delete_registration_cancel}"/>
+ </div>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+
</h:form>
</div>
</div>
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/editConsumer.xhtml
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/editConsumer.xhtml 2010-02-10 21:52:19 UTC (rev 1621)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/editConsumer.xhtml 2010-02-11 01:51:38 UTC (rev 1622)
@@ -109,8 +109,9 @@
backingBean="#{consumer}"
id="modify-reg-link"
rendered="#{consumer.registrationLocallyModified}"
- value="#{i18n.edit_consumer_registration_modify}"
- title="#{i18n.edit_consumer_registration_modify_title}"/>
+ value="#{i18n.edit_consumer_registration_modify}"
+ title="#{i18n.edit_consumer_registration_modify_title}"/>
+
<br style="clear:both;"/>
</h:panelGroup>
@@ -153,8 +154,9 @@
<webui:commandButton action="modifyRegistration"
backingBean="#{consumer}"
id="edit-reg-link"
- value="#{i18n.edit_consumer_registration_modify}"
- title="#{i18n.edit_consumer_registration_modify_title}"/>
+ value="#{i18n.edit_consumer_registration_modify}"
+ title="#{i18n.edit_consumer_registration_modify_title}"/>
+
<br style="clear:both;"/>
</h:panelGroup>
</c:if>
@@ -172,11 +174,24 @@
#{i18n.edit_consumer_registration_context_handle}
<h:outputText
value="#{consumer.producerInfo.registrationInfo.registrationHandle}"/>
- <webui:commandLink actionString="confirmEraseRegistration"
- id="erase-cons-link"
- value="#{i18n.edit_consumer_registration_context_erase}"
- title="#{i18n.edit_consumer_registration_context_erase_title}"/>
+ <table class="ActionContainer">
+ <tr>
+ <td>
+ <div class="ButtonLeft">
+ <div class="ButtonRight">
+ <div class="ButtonMiddle">
+ <h:commandLink action="confirmEraseRegistration"
+ id="erase-cons-link"
+ value="#{i18n.edit_consumer_registration_context_erase}"
+ title="#{i18n.edit_consumer_registration_context_erase_title}"/>
+ </div>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+
</td>
</tr>
</c:if>
@@ -190,11 +205,21 @@
value="#{i18n.edit_consumer_refresh}"
title="#{i18n.edit_consumer_refresh_title}"/>
- <webui:commandButton action="listConsumers"
- backingBean="#{consumersMgr}"
- id="list-cons-link"
- value="#{i18n.edit_consumer_cancel}"
- immediate="true"/>
+ <table class="ActionContainer">
+ <tr>
+ <td>
+ <div class="ButtonLeft">
+ <div class="ButtonRight">
+ <div class="ButtonMiddle">
+ <h:commandLink id="list-cons-link-two" action="#{consumersMgr.listConsumers}"
+ value="#{i18n.edit_consumer_cancel}">
+ </h:commandLink>
+ </div>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
</td>
</tr>
Added: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/error.xhtml
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/jsf/error.xhtml (rev 0)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/jsf/error.xhtml 2010-02-11 01:51:38 UTC (rev 1622)
@@ -0,0 +1,36 @@
+<!--
+ ~ 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.
+ -->
+
+<ui:decorate template="errorTemplate.xhtml" xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:c="http://java.sun.com/jstl/core"
+ xmlns:webui="http://jboss.org/gatein">
+
+ <ui:param name="title" value="Error"/>
+
+ <ui:define name="content">
+ An Error Has Occured.
+ </ui:define>
+</ui:decorate>
\ No newline at end of file
Copied: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/errorTemplate.xhtml (from rev 1620, components/wsrp/trunk/admin-gui/src/main/webapp/jsf/consumers/consumerTemplate.xhtml)
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/jsf/errorTemplate.xhtml (rev 0)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/jsf/errorTemplate.xhtml 2010-02-11 01:51:38 UTC (rev 1622)
@@ -0,0 +1,71 @@
+<!--
+ ~ JBoss, a division of Red Hat
+ ~ Copyright 2010, 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.
+ -->
+
+<ui:decorate template="common/template.xhtml" xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:c="http://java.sun.com/jstl/core"
+ xmlns:webui="http://jboss.org/gatein">
+
+ <ui:define name="topnav">
+ <h:form id="cons-temp-form" styleClass="cons-temp-form">
+
+ <div class="TabsContainer">
+ <table class="TabsActionContainer">
+ <tr>
+ <td>
+ <div class="UITab GrayTabStyle">
+ <div class="SelectedTab">
+ <div class="LeftTab">
+ <div class="RightTab">
+ <div class="MiddleTab">
+ #{i18n.nav_tabs_consumers}
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </td>
+ <td>
+ <div class="UITab GrayTabStyle">
+ <div class="NormalTab">
+ <div class="LeftTab">
+ <div class="RightTab">
+ <div class="MiddleTab">
+ <h:commandLink id="producer-link" value="#{i18n.nav_tabs_producer_config}"
+ action="producer"/>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ </h:form>
+ </ui:define>
+
+</ui:decorate>
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/management/management.xhtml
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/jsf/management/management.xhtml 2010-02-10 21:52:19 UTC (rev 1621)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/jsf/management/management.xhtml 2010-02-11 01:51:38 UTC (rev 1622)
@@ -32,4 +32,4 @@
<ui:define name="content">
<p>Feature not quite ready yet! Check again in future versions of Portal.</p>
</ui:define>
-</ui:decorate>
\ No newline at end of file
+</ui:decorate>
\ No newline at end of file
Modified: components/wsrp/trunk/admin-gui/src/main/webapp/jsf/producer/confirmPropDeletion.xhtml
===================================================================
--- components/wsrp/trunk/admin-gui/src/main/webapp/jsf/producer/confirmPropDeletion.xhtml 2010-02-10 21:52:19 UTC (rev 1621)
+++ components/wsrp/trunk/admin-gui/src/main/webapp/jsf/producer/confirmPropDeletion.xhtml 2010-02-11 01:51:38 UTC (rev 1622)
@@ -56,8 +56,21 @@
action="deleteRegistrationProperty"
backingBean="#{producer}"/>
- <webui:commandLink id="cancel-delete" value="#{i18n.confirm_delete_reg_property_cancel}"
- actionString="producer"/>
+ <table class="ActionContainer">
+ <tr>
+ <td>
+ <div class="ButtonLeft">
+ <div class="ButtonRight">
+ <div class="ButtonMiddle">
+ <h:commandLink id="cancel-delete" value="#{i18n.confirm_delete_reg_property_cancel}"
+ action="producer"/>
+ </div>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+
</h:form>
</div>
</div>
14 years, 11 months
gatein SVN: r1621 - in portal/trunk: component/identity/src/main/java/org/exoplatform/services/organization/idm and 9 other directories.
by do-not-reply@jboss.org
Author: bdaw
Date: 2010-02-10 16:52:19 -0500 (Wed, 10 Feb 2010)
New Revision: 1621
Added:
portal/trunk/component/identity/src/test/java/org/exoplatform/services/organization/TestConfigOrganizationService.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/filter/
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/filter/UserGroupFilter.java
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/examples/
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/examples/acme.ldif
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/examples/picketlink-idm-ldap-acme-config.xml
Modified:
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/Config.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/ExtGroup.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMService.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserProfileDAOImpl.java
portal/trunk/component/identity/src/test/java/conf/portal/idm-configuration.xml
portal/trunk/component/web/src/main/java/org/exoplatform/web/login/ClusteredSSOFilter.java
portal/trunk/pom.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/organization-configuration.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
Log:
- PLIDM 1.1.0.Beta3
- Bug fixes
- PLIDM association to MembershipType
- PLIDM exceptions not propagated outside of identity integration layer
- missing @author
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/Config.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/Config.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/Config.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -1,10 +1,5 @@
package org.exoplatform.services.organization.idm;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
/*
* JBoss, a division of Red Hat
* Copyright 2010, Red Hat Middleware, LLC, and individual contributors as indicated
@@ -26,6 +21,14 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public class Config
{
@@ -113,8 +116,24 @@
if (checkParents && !parentId.equals("/") && parentId.contains("/"))
{
- String newParentId = parentId.substring(0, parentId.lastIndexOf("/"));
- return getGroupType(newParentId);
+ // Check if any mapping that contains '/*' match this id
+ for (String key : groupTypeMappings.keySet())
+ {
+ id = key;
+ if (id.endsWith("/*"))
+ {
+ id = id.substring(0, id.length() - 2);
+ }
+ else
+ {
+ continue;
+ }
+
+ if (parentId.startsWith(id))
+ {
+ return groupTypeMappings.get(key);
+ }
+ }
}
return null;
@@ -139,7 +158,7 @@
for (String key : groupTypeMappings.keySet())
{
- if (key.startsWith("id"))
+ if (key.equals(id) || key.equals(id + "/*"))
{
types.add(groupTypeMappings.get(key));
}
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/ExtGroup.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/ExtGroup.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/ExtGroup.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -26,6 +26,9 @@
import java.io.Serializable;
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public class ExtGroup implements Group, Serializable
{
private String id;
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -29,15 +29,24 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public class GroupDAOImpl implements GroupHandler
{
+ private static Logger log = LoggerFactory.getLogger(GroupDAOImpl.class);
+
public static final String GROUP_LABEL = "label";
public static final String GROUP_DESCRIPTION = "description";
@@ -76,9 +85,18 @@
if (parent != null)
{
- parentGroup =
- getIdentitySession().getPersistenceManager().
- findGroup(parent.getGroupName(), orgService.getConfiguration().getGroupType(parent.getParentId()));
+ try
+ {
+ parentGroup =
+ getIdentitySession().getPersistenceManager().
+ findGroup(parent.getGroupName(), orgService.getConfiguration().getGroupType(parent.getParentId()));
+ }
+ catch (Exception e)
+ {
+ log.info("Cannot obtain group: " + parent.getGroupName(), e);
+
+ }
+
((ExtGroup)child).setId(parent.getId() + "/" + child.getGroupName());
}
@@ -98,14 +116,21 @@
}
org.picketlink.idm.api.Group childGroup = persistGroup(child);
- if (parentGroup != null)
+ try
{
- getIdentitySession().getRelationshipManager().associateGroups(parentGroup, childGroup);
+ if (parentGroup != null)
+ {
+ getIdentitySession().getRelationshipManager().associateGroups(parentGroup, childGroup);
+ }
+ else
+ {
+ getIdentitySession().getRelationshipManager().associateGroups(getRootGroup(), childGroup);
+ }
}
- else
+ catch (Exception e)
{
- getIdentitySession().getRelationshipManager().associateGroups(getRootGroup(), childGroup);
+ log.info("Cannot associate groups: ", e);
}
if (broadcast)
@@ -135,10 +160,19 @@
preDelete(group);
}
- org.picketlink.idm.api.Group jbidGroup =
- getIdentitySession().getPersistenceManager().
- findGroup(group.getGroupName(), orgService.getConfiguration().getGroupType(group.getParentId()));
+ org.picketlink.idm.api.Group jbidGroup = null;
+ try
+ {
+ jbidGroup =
+ getIdentitySession().getPersistenceManager().
+ findGroup(group.getGroupName(), orgService.getConfiguration().getGroupType(group.getParentId()));
+ }
+ catch (Exception e)
+ {
+ log.info("Cannot obtain group: " + group.getGroupName() + "; ", e);
+ }
+
if (jbidGroup == null)
{
return group;
@@ -146,21 +180,35 @@
// MembershipDAOImpl.removeMembershipEntriesOfGroup(group, getIdentitySession());
- Collection<org.picketlink.idm.api.Group> oneLevelChilds =
- getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, null, true, false);
+ try
+ {
+ Collection<org.picketlink.idm.api.Group> oneLevelChilds =
+ getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, null, true, false);
- Collection<org.picketlink.idm.api.Group> allChilds =
- getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, null, true, true);
+ Collection<org.picketlink.idm.api.Group> allChilds =
+ getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, null, true, true);
- getIdentitySession().getRelationshipManager().disassociateGroups(jbidGroup, oneLevelChilds);
+ getIdentitySession().getRelationshipManager().disassociateGroups(jbidGroup, oneLevelChilds);
- for (org.picketlink.idm.api.Group child : allChilds)
+ for (org.picketlink.idm.api.Group child : allChilds)
+ {
+ //TODO: impl force in IDM
+ getIdentitySession().getPersistenceManager().removeGroup(child, true);
+ }
+ }
+ catch (Exception e)
{
- //TODO: impl force in IDM
- getIdentitySession().getPersistenceManager().removeGroup(child, true);
+ log.info("Cannot clear group relationships: " + group.getGroupName() + "; ", e);
}
- getIdentitySession().getPersistenceManager().removeGroup(jbidGroup, true);
+ try
+ {
+ getIdentitySession().getPersistenceManager().removeGroup(jbidGroup, true);
+ }
+ catch (Exception e)
+ {
+ log.info("Cannot remove group: " + group.getGroupName() + "; ", e);
+ }
if (broadcast)
{
@@ -171,9 +219,17 @@
public Collection findGroupByMembership(String userName, String membershipType) throws Exception
{
- Collection<org.picketlink.idm.api.Role> allRoles =
- getIdentitySession().getRoleManager().findRoles(userName, membershipType);
+ Collection<org.picketlink.idm.api.Role> allRoles = new HashSet();
+ try
+ {
+ allRoles = getIdentitySession().getRoleManager().findRoles(userName, membershipType);
+ }
+ catch (Exception e)
+ {
+ log.info("Identity operation error: ", e);
+ }
+
Set<Group> exoGroups = new HashSet<Group>();
MembershipDAOImpl mmm = (MembershipDAOImpl)orgService.getMembershipHandler();
@@ -188,9 +244,17 @@
if (mmm.isAssociationMapped() && mmm.getAssociationMapping().equals(membershipType))
{
- Collection<org.picketlink.idm.api.Group> groups =
- getIdentitySession().getRelationshipManager().findAssociatedGroups(userName, null);
+ Collection<org.picketlink.idm.api.Group> groups = new HashSet();
+ try
+ {
+ groups = getIdentitySession().getRelationshipManager().findAssociatedGroups(userName, null);
+ }
+ catch (Exception e)
+ {
+ log.info("Identity operation error: ", e);
+ }
+
for (org.picketlink.idm.api.Group group : groups)
{
exoGroups.add(convertGroup(group));
@@ -226,9 +290,18 @@
}
else
{
- jbidGroup =
- getIdentitySession().getPersistenceManager().
- findGroup(parent.getGroupName(), orgService.getConfiguration().getGroupType(parent.getParentId()));
+ try
+ {
+ jbidGroup =
+ getIdentitySession().getPersistenceManager().
+ findGroup(parent.getGroupName(), orgService.getConfiguration().getGroupType(parent.getParentId()));
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
}
if (jbidGroup == null)
@@ -241,9 +314,18 @@
Set<org.picketlink.idm.api.Group> plGroups = new HashSet<org.picketlink.idm.api.Group>();
- plGroups.addAll(getIdentitySession().getRelationshipManager().
- findAssociatedGroups(jbidGroup, null, true, false));
+ try
+ {
+ plGroups.addAll(getIdentitySession().getRelationshipManager().
+ findAssociatedGroups(jbidGroup, null, true, false));
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
+
// Get members of all types mapped below the parent group id path.
if (orgService.getConfiguration().isForceMembershipOfMappedTypes())
{
@@ -252,17 +334,29 @@
for (String type : orgService.getConfiguration().getTypes(id))
{
- plGroups
- .addAll(getIdentitySession().getPersistenceManager().findGroup(type));
+ try
+ {
+ plGroups
+ .addAll(getIdentitySession().getPersistenceManager().findGroup(type));
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
}
}
Set<Group> exoGroups = new HashSet<Group>();
+ org.picketlink.idm.api.Group root = getRootGroup();
+
for (org.picketlink.idm.api.Group group : plGroups)
{
- exoGroups.add(convertGroup(group));
-
+ if (!group.equals(root))
+ {
+ exoGroups.add(convertGroup(group));
+ }
}
@@ -289,9 +383,19 @@
return Collections.emptyList();
}
- Collection<org.picketlink.idm.api.Group> allGroups =
- getIdentitySession().getRelationshipManager().findRelatedGroups(user, null, null);
+ Collection<org.picketlink.idm.api.Group> allGroups = new HashSet();
+ try
+ {
+ allGroups = getIdentitySession().getRelationshipManager().findRelatedGroups(user, null, null);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
List<Group> exoGroups = new LinkedList<Group>();
for (org.picketlink.idm.api.Group group : allGroups)
@@ -308,24 +412,46 @@
Set<org.picketlink.idm.api.Group> plGroups = new HashSet<org.picketlink.idm.api.Group>();
- plGroups
- .addAll(getIdentitySession().getRelationshipManager().findAssociatedGroups(getRootGroup(), null, true, true));
+ try
+ {
+ plGroups
+ .addAll(getIdentitySession().getRelationshipManager().findAssociatedGroups(getRootGroup(), null, true, true));
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
+
// Check for all type groups mapped as part of the group tree but not connected with the root group by association
if (orgService.getConfiguration().isForceMembershipOfMappedTypes())
{
for (String type : orgService.getConfiguration().getAllTypes())
{
- plGroups
- .addAll(getIdentitySession().getPersistenceManager().findGroup(type));
+ try
+ {
+ plGroups
+ .addAll(getIdentitySession().getPersistenceManager().findGroup(type));
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
}
}
Set<Group> exoGroups = new HashSet<Group>();
+ org.picketlink.idm.api.Group root = getRootGroup();
+
for (org.picketlink.idm.api.Group group : plGroups)
{
- exoGroups.add(convertGroup(group));
+ if (!group.equals(root))
+ {
+ exoGroups.add(convertGroup(group));
+ }
}
// UI has hardcoded casts to List
@@ -365,24 +491,21 @@
}
}
-// public Group getGroup(String groupName) throws Exception
-// {
-// org.picketlink.idm.api.Group jbidGroup =
-// getIdentitySession().getPersistenceManager().findGroup(groupName, orgService.getGtnGroupType());
-//
-// if (jbidGroup == null)
-// {
-// return null;
-// }
-//
-// return convertGroup(jbidGroup);
-//
-// }
protected Group convertGroup(org.picketlink.idm.api.Group jbidGroup) throws Exception
{
- Map<String, Attribute> attrs = getIdentitySession().getAttributesManager().getAttributes(jbidGroup);
+ Map<String, Attribute> attrs = new HashMap();
+ try
+ {
+ attrs = getIdentitySession().getAttributesManager().getAttributes(jbidGroup);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
+
ExtGroup exoGroup = new ExtGroup(jbidGroup.getName());
if (attrs.containsKey(GROUP_DESCRIPTION) && attrs.get(GROUP_DESCRIPTION).getValue() != null)
@@ -393,6 +516,11 @@
{
exoGroup.setLabel(attrs.get(GROUP_LABEL).getValue().toString());
}
+ // UI requires that group has label
+ else
+ {
+ exoGroup.setLabel(exoGroup.getGroupName());
+ }
// Resolve full ID
String id = getGroupId(jbidGroup);
@@ -415,14 +543,23 @@
private String getGroupId(org.picketlink.idm.api.Group jbidGroup) throws Exception
{
- if (jbidGroup.getName().equals(orgService.getConfiguration().getRootGroupName()))
+ if (jbidGroup.equals(getRootGroup()))
{
return "";
}
- Collection<org.picketlink.idm.api.Group> parents =
- getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, null, false, false);
+ Collection<org.picketlink.idm.api.Group> parents = new HashSet();
+ try
+ {
+ parents = getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, null, false, false);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
+
if (parents.size() > 1)
{
throw new IllegalStateException("Group has more than one parent: " + jbidGroup.getName());
@@ -440,7 +577,7 @@
id = id.substring(0, id.length() - 2);
}
- return id + jbidGroup.getName();
+ return id + "/" + jbidGroup.getName();
}
@@ -461,15 +598,32 @@
private org.picketlink.idm.api.Group persistGroup(Group exoGroup) throws Exception
{
- org.picketlink.idm.api.Group jbidGroup =
- getIdentitySession().getPersistenceManager().
- findGroup(exoGroup.getGroupName(), orgService.getConfiguration().getGroupType(exoGroup.getParentId()));
+ org.picketlink.idm.api.Group jbidGroup = null;
+ try
+ {
+ jbidGroup = getIdentitySession().getPersistenceManager().
+ findGroup(exoGroup.getGroupName(), orgService.getConfiguration().getGroupType(exoGroup.getParentId()));
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
+
if (jbidGroup == null)
{
- jbidGroup =
- getIdentitySession().getPersistenceManager().
- createGroup(exoGroup.getGroupName(), orgService.getConfiguration().getGroupType(exoGroup.getParentId()));
+ try
+ {
+ jbidGroup =
+ getIdentitySession().getPersistenceManager().
+ createGroup(exoGroup.getGroupName(), orgService.getConfiguration().getGroupType(exoGroup.getParentId()));
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
}
String description = exoGroup.getDescription();
@@ -492,7 +646,15 @@
attrs = attrsList.toArray(attrs);
- getIdentitySession().getAttributesManager().updateAttributes(jbidGroup, attrs);
+ try
+ {
+ getIdentitySession().getAttributesManager().updateAttributes(jbidGroup, attrs);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
}
@@ -506,17 +668,33 @@
private org.picketlink.idm.api.Group getRootGroup() throws Exception
{
- org.picketlink.idm.api.Group rootGroup =
- getIdentitySession().getPersistenceManager().
+ org.picketlink.idm.api.Group rootGroup = null;
+ try
+ {
+ rootGroup = getIdentitySession().getPersistenceManager().
findGroup(orgService.getConfiguration().getRootGroupName(), orgService.getConfiguration().getGroupType("/"));
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
if (rootGroup == null)
{
- rootGroup =
- getIdentitySession().getPersistenceManager().
- createGroup(
- orgService.getConfiguration().getRootGroupName(),
- orgService.getConfiguration().getGroupType("/"));
+ try
+ {
+ rootGroup =
+ getIdentitySession().getPersistenceManager().
+ createGroup(
+ orgService.getConfiguration().getRootGroupName(),
+ orgService.getConfiguration().getGroupType("/"));
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
}
return rootGroup;
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -26,6 +26,9 @@
import java.util.List;
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public class IDMUserListAccess implements ListAccess<User>
{
private final UserDAOImpl userDAO;
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -29,6 +29,8 @@
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.Role;
import org.picketlink.idm.api.RoleType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
@@ -39,10 +41,12 @@
import javax.naming.InvalidNameException;
-/**
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
*/
public class MembershipDAOImpl implements MembershipHandler
{
+ private static Logger log = LoggerFactory.getLogger(MembershipDAOImpl.class);
private PicketLinkIDMService service_;
@@ -147,8 +151,23 @@
getIdentitySession().getPersistenceManager().
createGroupKey(getGroupNameFromId(m.getGroupId()), getGroupTypeFromId(m.getGroupId()));
- if (getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
+
+ boolean hasRole = false;
+
+
+ try
{
+ hasRole = getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType());
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
+ if (hasRole)
+ {
return;
}
@@ -160,11 +179,29 @@
if (isCreateMembership(m.getMembershipType()))
{
- getIdentitySession().getRoleManager().createRole(m.getMembershipType(), m.getUserName(), groupId);
+ try
+ {
+ getIdentitySession().getRoleManager().createRole(m.getMembershipType(), m.getUserName(), groupId);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
}
if (isAssociationMapped() && getAssociationMapping().equals(m.getMembershipType()))
{
- getIdentitySession().getRelationshipManager().associateUserByKeys(groupId, m.getUserName());
+ try
+ {
+ getIdentitySession().getRelationshipManager().associateUserByKeys(groupId, m.getUserName());
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
}
if (broadcast)
@@ -182,8 +219,21 @@
getIdentitySession().getPersistenceManager().
createGroupKey(getGroupNameFromId(m.getGroupId()), getGroupTypeFromId(m.getGroupId()));
- if (!getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
+ boolean hasRole = false;
+
+ try
{
+ hasRole = getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType());
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
+ if (!hasRole)
+ {
return m;
}
@@ -195,15 +245,45 @@
if (isCreateMembership(m.getMembershipType()))
{
- getIdentitySession().getRoleManager().removeRole(m.getMembershipType(), m.getUserName(), groupId);
+ try
+ {
+ getIdentitySession().getRoleManager().removeRole(m.getMembershipType(), m.getUserName(), groupId);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
}
- if (isAssociationMapped() && getAssociationMapping().equals(m.getMembershipType()) &&
- getIdentitySession().getRelationshipManager().isAssociatedByKeys(m.getGroupId(), m.getUserName()))
+ boolean associated = false;
+
+ try
{
+ associated = getIdentitySession().getRelationshipManager().isAssociatedByKeys(m.getGroupId(), m.getUserName());
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
+ if (isAssociationMapped() && getAssociationMapping().equals(m.getMembershipType()) && associated)
+ {
Set<String> keys = new HashSet<String>();
keys.add(m.getUserName());
- getIdentitySession().getRelationshipManager().disassociateUsersByKeys(groupId, keys);
+ try
+ {
+ getIdentitySession().getRelationshipManager().disassociateUsersByKeys(groupId, keys);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
}
if (broadcast)
@@ -216,8 +296,19 @@
public Collection removeMembershipByUser(String userName, boolean broadcast) throws Exception
{
- Collection<Role> roles = getIdentitySession().getRoleManager().findRoles(userName, null);
+ Collection<Role> roles = new HashSet();
+ try
+ {
+ roles = getIdentitySession().getRoleManager().findRoles(userName, null);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
HashSet<MembershipImpl> memberships = new HashSet<MembershipImpl>();
for (Role role : roles)
@@ -246,15 +337,34 @@
if (isAssociationMapped())
{
- Collection<org.picketlink.idm.api.Group> groups =
- getIdentitySession().getRelationshipManager().findAssociatedGroups(userName, null);
+ Collection<org.picketlink.idm.api.Group> groups = new HashSet();
+ try
+ {
+ groups = getIdentitySession().getRelationshipManager().findAssociatedGroups(userName, null);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
Set<String> keys = new HashSet<String>();
keys.add(userName);
for (org.picketlink.idm.api.Group group : groups)
{
- getIdentitySession().getRelationshipManager().disassociateUsersByKeys(group.getKey(), keys);
+ try
+ {
+ getIdentitySession().getRelationshipManager().disassociateUsersByKeys(group.getKey(), keys);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
}
}
@@ -272,15 +382,38 @@
boolean hasMembership = false;
- if (isAssociationMapped() && getAssociationMapping().equals(type) &&
- getIdentitySession().getRelationshipManager().isAssociatedByKeys(gid, userName))
+ boolean associated = false;
+
+ try
{
+ associated = getIdentitySession().getRelationshipManager().isAssociatedByKeys(gid, userName);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
+ if (isAssociationMapped() && getAssociationMapping().equals(type) && associated)
+ {
hasMembership = true;
}
- Role role = getIdentitySession().getRoleManager().getRole(type, userName, gid);
+ Role role = null;
+ try
+ {
+ role = getIdentitySession().getRoleManager().getRole(type, userName, gid);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
if (role != null &&
(!isAssociationMapped() ||
!getAssociationMapping().equals(role.getRoleType()) ||
@@ -316,8 +449,19 @@
getIdentitySession().getPersistenceManager().
createGroupKey(getGroupNameFromId(groupId), getGroupTypeFromId(groupId));
- Collection<RoleType> roleTypes = getIdentitySession().getRoleManager().findRoleTypes(userName, gid, null);
+ Collection<RoleType> roleTypes = new HashSet();
+ try
+ {
+ roleTypes = getIdentitySession().getRoleManager().findRoleTypes(userName, gid, null);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
HashSet<MembershipImpl> memberships = new HashSet<MembershipImpl>();
for (RoleType roleType : roleTypes)
@@ -332,9 +476,21 @@
}
}
- if (isAssociationMapped() &&
- getIdentitySession().getRelationshipManager().isAssociatedByKeys(gid, userName))
+ boolean associated = false;
+
+ try
{
+ associated = getIdentitySession().getRelationshipManager().isAssociatedByKeys(gid, userName);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
+ if (isAssociationMapped() && associated)
+ {
MembershipImpl m = new MembershipImpl();
m.setGroupId(groupId);
m.setUserName(userName);
@@ -348,8 +504,19 @@
public Collection findMembershipsByUser(String userName) throws Exception
{
- Collection<Role> roles = getIdentitySession().getRoleManager().findRoles(userName, null);
+ Collection<Role> roles = new HashSet();
+ try
+ {
+ roles = getIdentitySession().getRoleManager().findRoles(userName, null);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
HashSet<MembershipImpl> memberships = new HashSet<MembershipImpl>();
for (Role role : roles)
@@ -368,9 +535,19 @@
if (isAssociationMapped())
{
- Collection<org.picketlink.idm.api.Group> groups =
- getIdentitySession().getRelationshipManager().findAssociatedGroups(userName, null);
+ Collection<org.picketlink.idm.api.Group> groups = new HashSet();
+ try
+ {
+ groups = getIdentitySession().getRelationshipManager().findAssociatedGroups(userName, null);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
for (org.picketlink.idm.api.Group group : groups)
{
MembershipImpl m = new MembershipImpl();
@@ -387,22 +564,6 @@
return new LinkedList(memberships);
}
-// static void removeMembershipEntriesOfGroup(PicketLinkIDMOrganizationServiceImpl orgService, Group group,
-// IdentitySession session) throws Exception
-// {
-// String gid = session.getPersistenceManager().
-// createGroupKey(group.getGroupName(), orgService.getConfiguration().getGroupType(group.getParentId()));
-//
-// Collection<Role> roles = session.getRoleManager().findRoles(gid, null);
-//
-// for (Role role : roles)
-// {
-// session.getRoleManager().removeRole(role);
-// }
-//
-//
-// }
-
public Collection findMembershipsByGroup(Group group) throws Exception
{
return findMembershipsByGroupId(group.getId());
@@ -414,8 +575,19 @@
getIdentitySession().getPersistenceManager().createGroupKey(getGroupNameFromId(groupId),
getGroupTypeFromId(groupId));
- Collection<Role> roles = getIdentitySession().getRoleManager().findRoles(gid, null);
+ Collection<Role> roles = new HashSet();
+ try
+ {
+ roles = getIdentitySession().getRoleManager().findRoles(gid, null);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
HashSet<MembershipImpl> memberships = new HashSet<MembershipImpl>();
for (Role role : roles)
@@ -434,9 +606,19 @@
if (isAssociationMapped())
{
- Collection<org.picketlink.idm.api.User> users =
- getIdentitySession().getRelationshipManager().findAssociatedUsers(gid, false, null);
+ Collection<org.picketlink.idm.api.User> users = new HashSet();
+ try
+ {
+ users = getIdentitySession().getRelationshipManager().findAssociatedUsers(gid, false, null);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+
+ }
+
for (org.picketlink.idm.api.User user : users)
{
MembershipImpl m = new MembershipImpl();
@@ -461,21 +643,38 @@
getIdentitySession().getPersistenceManager().createGroupKey(getGroupNameFromId(m.getGroupId()),
getGroupTypeFromId(m.getGroupId()));
- if (isCreateMembership(m.getMembershipType()) &&
- getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
+
+ try
{
- return m;
+ if (isCreateMembership(m.getMembershipType()) &&
+ getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
+ {
+ return m;
+ }
}
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
- if (isAssociationMapped() && getAssociationMapping().equals(m.getMembershipType()) &&
- getIdentitySession().getRelationshipManager().isAssociatedByKeys(groupId, m.getUserName()))
+ }
+
+ try
{
- return m;
+ if (isAssociationMapped() && getAssociationMapping().equals(m.getMembershipType()) &&
+ getIdentitySession().getRelationshipManager().isAssociatedByKeys(groupId, m.getUserName()))
+ {
+ return m;
+ }
}
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
-
return null;
}
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -21,6 +21,9 @@
import org.exoplatform.services.organization.Membership;
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public class MembershipImpl implements Membership
{
private String membershipType = "member";
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -33,6 +33,9 @@
import java.util.List;
import java.util.Map;
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public class MembershipTypeDAOImpl implements MembershipTypeHandler
{
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -33,6 +33,9 @@
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicInteger;
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public class PicketLinkIDMOrganizationServiceImpl extends BaseOrganizationService implements Startable,
ComponentRequestLifecycle
{
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMService.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMService.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMService.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -22,6 +22,9 @@
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.IdentitySessionFactory;
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public interface PicketLinkIDMService
{
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMServiceImpl.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -39,6 +39,9 @@
import javax.naming.InitialContext;
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public class PicketLinkIDMServiceImpl implements PicketLinkIDMService, Startable
{
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -32,7 +32,9 @@
import org.picketlink.idm.api.AttributesManager;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.query.UserQueryBuilder;
+import org.picketlink.idm.common.exception.IdentityException;
import org.picketlink.idm.impl.api.SimpleAttribute;
+import org.slf4j.LoggerFactory;
import java.text.DateFormat;
import java.util.ArrayList;
@@ -42,12 +44,16 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Logger;
-/**
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
*/
public class UserDAOImpl implements UserHandler
{
+ private static org.slf4j.Logger log = LoggerFactory.getLogger(UserDAOImpl.class);
+
private final PicketLinkIDMService service_;
private ExoCache cache_;
@@ -124,8 +130,16 @@
preSave(user, true);
}
- session.getPersistenceManager().createUser(user.getUserName());
+ try
+ {
+ session.getPersistenceManager().createUser(user.getUserName());
+ }
+ catch (IdentityException e)
+ {
+ log.info("Identity operation error: ", e);
+ }
+
persistUserInfo(user, session);
if (broadcast)
@@ -156,18 +170,36 @@
{
IdentitySession session = service_.getIdentitySession();
- org.picketlink.idm.api.User foundUser = session.getPersistenceManager().findUser(userName);
+ org.picketlink.idm.api.User foundUser = null;
+ try
+ {
+ foundUser = session.getPersistenceManager().findUser(userName);
+ }
+ catch (IdentityException e)
+ {
+ log.info("Cannot obtain user: " + userName + "; ", e);
+
+ }
+
if (foundUser == null)
{
cache_.remove(userName);
return null;
}
- // Remove all memberships and profile first
- orgService.getMembershipHandler().removeMembershipByUser(userName, false);
- orgService.getUserProfileHandler().removeUserProfile(userName, false);
-
+ try
+ {
+ // Remove all memberships and profile first
+ orgService.getMembershipHandler().removeMembershipByUser(userName, false);
+ orgService.getUserProfileHandler().removeUserProfile(userName, false);
+ }
+ catch (Exception e)
+ {
+ log.info("Cannot cleanup user relationships: " + userName + "; ", e);
+
+ }
+
User exoUser = getPopulatedUser(userName, session);
if (broadcast)
@@ -175,7 +207,16 @@
preDelete(exoUser);
}
- session.getPersistenceManager().removeUser(foundUser, true);
+ try
+ {
+ session.getPersistenceManager().removeUser(foundUser, true);
+ }
+ catch (IdentityException e)
+ {
+ log.info("Cannot remove user: " + userName + "; ", e);
+
+ }
+
if (broadcast)
{
postDelete(exoUser);
@@ -231,10 +272,18 @@
}
else
{
- IdentitySession session = service_.getIdentitySession();
- org.picketlink.idm.api.User idmUser = session.getPersistenceManager().findUser(user.getUserName());
+ try
+ {
+ IdentitySession session = service_.getIdentitySession();
+ org.picketlink.idm.api.User idmUser = session.getPersistenceManager().findUser(user.getUserName());
- authenticated = session.getAttributesManager().validatePassword(idmUser, password);
+ authenticated = session.getAttributesManager().validatePassword(idmUser, password);
+ }
+ catch (Exception e)
+ {
+ log.info("Cannot authenticate user: " + username + "; ", e);
+
+ }
}
if (authenticated)
@@ -285,8 +334,17 @@
{
UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
- org.picketlink.idm.api.Group jbidGroup = orgService.getJBIDMGroup(groupId);
+ org.picketlink.idm.api.Group jbidGroup = null;
+ try
+ {
+ jbidGroup = orgService.getJBIDMGroup(groupId);
+ }
+ catch (Exception e)
+ {
+ log.info("Cannot obtain group: " + groupId + "; ", e);
+ }
+
qb.addRelatedGroup(jbidGroup);
return new LazyPageList(new IDMUserListAccess(this, service_, qb, 20, false), 20);
@@ -297,8 +355,18 @@
IdentitySession session = service_.getIdentitySession();
- org.picketlink.idm.api.User plUser;
- plUser = session.getAttributesManager().findUserByUniqueAttribute(USER_EMAIL, email);
+ org.picketlink.idm.api.User plUser = null;
+
+ try
+ {
+ plUser = session.getAttributesManager().findUserByUniqueAttribute(USER_EMAIL, email);
+ }
+ catch (IdentityException e)
+ {
+ log.info("Cannot find user by email: " + email + "; ", e );
+
+ }
+
User user = null;
if (plUser != null)
@@ -389,20 +457,49 @@
}
else
{
- am.updatePassword(session.getPersistenceManager().findUser(user.getUserName()), user.getPassword());
+ try
+ {
+ am.updatePassword(session.getPersistenceManager().findUser(user.getUserName()), user.getPassword());
+ }
+ catch (IdentityException e)
+ {
+ log.info("Cannot update password: " + user.getUserName() + "; ", e);
+
+ }
}
}
Attribute[] attrs = new Attribute[attributes.size()];
attrs = (Attribute[])attributes.toArray(attrs);
- am.addAttributes(user.getUserName(), attrs);
+
+ try
+ {
+ am.updateAttributes(user.getUserName(), attrs);
+ }
+ catch (IdentityException e)
+ {
+ log.info("Cannot update attributes for user: " + user.getUserName() + "; ", e);
+
+ }
+
}
public static User getPopulatedUser(String userName, IdentitySession session) throws Exception
{
+ Object u = null;
- if (session.getPersistenceManager().findUser(userName) == null)
+ try
{
+ u = session.getPersistenceManager().findUser(userName);
+ }
+ catch (IdentityException e)
+ {
+ log.info("Cannot obtain user: " + userName + "; ", e);
+
+ }
+
+ if (u == null)
+ {
return null;
}
@@ -419,8 +516,19 @@
AttributesManager am = session.getAttributesManager();
- Map<String, Attribute> attrs = am.getAttributes(user.getUserName());
+ Map<String, Attribute> attrs = null;
+ try
+ {
+ attrs = am.getAttributes(user.getUserName());
+ }
+ catch (IdentityException e)
+ {
+
+ log.info("Cannot obtain attributes for user: " + user.getUserName() + "; ", e);
+
+ }
+
if (attrs == null)
{
return;
Modified: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserProfileDAOImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserProfileDAOImpl.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserProfileDAOImpl.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -28,6 +28,8 @@
import org.picketlink.idm.api.Attribute;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.impl.api.SimpleAttribute;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
@@ -37,9 +39,15 @@
import java.util.Map;
import java.util.Set;
+
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public class UserProfileDAOImpl implements UserProfileHandler
{
+ private static Logger log = LoggerFactory.getLogger(UserProfileDAOImpl.class);
+
static private UserProfile NOT_FOUND = new UserProfileImpl();
private PicketLinkIDMService service_;
@@ -136,8 +144,18 @@
public UserProfile findUserProfileByName(String userName) throws Exception
{
- org.picketlink.idm.api.User foundUser = getIdentitySession().getPersistenceManager().findUser(userName);
+ org.picketlink.idm.api.User foundUser = null;
+ try
+ {
+ foundUser = getIdentitySession().getPersistenceManager().findUser(userName);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
+
if (foundUser == null)
{
return null;
@@ -214,13 +232,36 @@
public UserProfile getProfile(String userName) throws Exception
{
- if (getIdentitySession().getPersistenceManager().findUser(userName) == null)
+
+ Object u = null;
+
+ try
{
+ u = getIdentitySession().getPersistenceManager().findUser(userName);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
+
+ if (u == null)
+ {
return null;
}
- Map<String, Attribute> attrs = getIdentitySession().getAttributesManager().getAttributes(userName);
+ Map<String, Attribute> attrs = new HashMap();
+ try
+ {
+ attrs = getIdentitySession().getAttributesManager().getAttributes(userName);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
+
if (attrs == null || attrs.isEmpty())
{
return null;
@@ -264,7 +305,15 @@
Attribute[] attrArray = new Attribute[attrs.size()];
attrArray = attrs.toArray(attrArray);
- getIdentitySession().getAttributesManager().updateAttributes(userName, attrArray);
+ try
+ {
+ getIdentitySession().getAttributesManager().updateAttributes(userName, attrArray);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
}
@@ -276,7 +325,15 @@
attrKeys = profileAttrs.keySet().toArray(attrKeys);
- getIdentitySession().getAttributesManager().removeAttributes(userName, attrKeys);
+ try
+ {
+ getIdentitySession().getAttributesManager().removeAttributes(userName, attrKeys);
+ }
+ catch (Exception e)
+ {
+ //TODO:
+ log.info("Identity operation error: ", e);
+ }
}
private IdentitySession getIdentitySession() throws Exception
Modified: portal/trunk/component/identity/src/test/java/conf/portal/idm-configuration.xml
===================================================================
--- portal/trunk/component/identity/src/test/java/conf/portal/idm-configuration.xml 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/identity/src/test/java/conf/portal/idm-configuration.xml 2010-02-10 21:52:19 UTC (rev 1621)
@@ -51,18 +51,22 @@
<key><string>/</string></key>
<value><string>root_type</string></value>
</entry>
- <!--<entry>-->
- <!--<key><string>/platform</string></key>-->
- <!--<value><string>platform_type</string></value>-->
- <!--</entry>-->
- <!--<entry>-->
- <!--<key><string>/platform/users</string></key>-->
- <!--<value><string>users_type</string></value>-->
- <!--</entry>-->
- <!--<entry>-->
- <!--<key><string>/organization/acme/france</string></key>-->
- <!--<value><string>france_type</string></value>-->
- <!--</entry>-->
+ <entry>
+ <key><string>/platform/*</string></key>
+ <value><string>platform_type</string></value>
+ </entry>
+ <entry>
+ <key><string>/platform/users</string></key>
+ <value><string>users_type</string></value>
+ </entry>
+ <entry>
+ <key><string>/organization/acme/france</string></key>
+ <value><string>france_type</string></value>
+ </entry>
+ <entry>
+ <key><string>/toto/*</string></key>
+ <value><string>toto_type</string></value>
+ </entry>
</map>
</field>
<!-- If this option is used then each Membership created with MembrshipType that is
Added: portal/trunk/component/identity/src/test/java/org/exoplatform/services/organization/TestConfigOrganizationService.java
===================================================================
--- portal/trunk/component/identity/src/test/java/org/exoplatform/services/organization/TestConfigOrganizationService.java (rev 0)
+++ portal/trunk/component/identity/src/test/java/org/exoplatform/services/organization/TestConfigOrganizationService.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -0,0 +1,157 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2010, 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.exoplatform.services.organization;
+
+import org.exoplatform.commons.utils.PageList;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.component.ComponentRequestLifecycle;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.services.organization.idm.Config;
+import org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl;
+import org.exoplatform.test.BasicTestCase;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS Author : Hoa Pham hoapham@exoplatform.com,phamvuxuanhoa(a)yahoo.com
+ * Oct 27, 2005
+ */
+
+public class TestConfigOrganizationService extends BasicTestCase
+{
+
+ static String Group1 = "Group1";
+
+ static String Group2 = "Group2";
+
+ static String Group3 = "Group3";
+
+ static String Benj = "Benj";
+
+ static String Tuan = "Tuan";
+
+ OrganizationService service_;
+
+ UserHandler userHandler_;
+
+ UserProfileHandler profileHandler_;
+
+ GroupHandler groupHandler_;
+
+ MembershipTypeHandler mtHandler_;
+
+ MembershipHandler membershipHandler_;
+
+ boolean runtest = true;
+
+ private static final String USER = "test";
+
+ private static final List<String> USERS;
+
+ private static final int USERS_LIST_SIZE = 15;
+
+ private PortalContainer manager;
+
+ static
+ {
+ USERS = new ArrayList<String>(USERS_LIST_SIZE);
+ for (int i = 0; i < USERS_LIST_SIZE; i++)
+ USERS.add(USER + "_" + i);
+ }
+
+ public TestConfigOrganizationService(String s)
+ {
+ super(s);
+ }
+
+ public void setUp() throws Exception
+ {
+ if (!runtest)
+ return;
+
+ manager = PortalContainer.getInstance();
+ service_ = (OrganizationService)manager.getComponentInstanceOfType(OrganizationService.class);
+ userHandler_ = service_.getUserHandler();
+ profileHandler_ = service_.getUserProfileHandler();
+ groupHandler_ = service_.getGroupHandler();
+ mtHandler_ = service_.getMembershipTypeHandler();
+ membershipHandler_ = service_.getMembershipHandler();
+
+// ((ComponentRequestLifecycle)service_).startRequest(manager);
+ RequestLifeCycle.begin((ComponentRequestLifecycle)service_);
+
+ }
+
+ public void tearDown() throws Exception
+ {
+ Query query = new Query();
+ query.setUserName(USER + "*");
+ PageList users = userHandler_.findUsers(query);
+
+ List<User> allUsers = users.getAll();
+
+ for (int i = allUsers.size() - 1; i >= 0; i--)
+ {
+ String userName = allUsers.get(i).getUserName();
+ userHandler_.removeUser(userName, true);
+ }
+
+// ((ComponentRequestLifecycle)service_).endRequest(manager);
+ RequestLifeCycle.end();
+ }
+
+ public void testSimple() throws Exception
+ {
+ assertTrue(true);
+ Config config = ((PicketLinkIDMOrganizationServiceImpl)service_).getConfiguration();
+
+ assertNotNull(config);
+ assertNotNull(config.getGroupTypeMappings());
+ assertNotNull(config.getGroupTypeMappings().keySet());
+
+ assertEquals(config.getGroupTypeMappings().keySet().size(), 5);
+ assertEquals(config.getGroupTypeMappings().get("/"), "root_type");
+
+ assertEquals(config.getGroupType("/"), "root_type");
+ assertEquals(config.getGroupType(null), "root_type");
+ assertEquals(config.getGroupType("/platform"), "platform_type");
+ assertEquals(config.getGroupType("/platform/administrators"), "platform_type");
+ assertEquals(config.getGroupType("/platform/guests"), "platform_type");
+ assertEquals(config.getGroupType("/platform/users"), "users_type");
+ assertEquals(config.getGroupType("/platform/users/john"), "platform_type");
+ assertEquals(config.getGroupType("/organization/acme/france/offices"), ".organization.acme.france.offices");
+ assertEquals(config.getGroupType("/organization/acme/france/offices/paris"), ".organization.acme.france.offices.paris");
+ assertEquals(config.getGroupType("/organization/acme/france"), "france_type");
+ assertEquals(config.getGroupType("/organization/acme"), ".organization.acme");
+ assertEquals(config.getGroupType("/foo/bar"), ".foo.bar");
+ assertEquals(config.getGroupType("/foo"), ".foo");
+ assertEquals(config.getGroupType("/toto"), "toto_type");
+ assertEquals(config.getGroupType("/toto/lolo"), "toto_type");
+ assertEquals(config.getGroupType("/toto/lolo/tutu"), "toto_type");
+
+
+ }
+
+
+
+}
\ No newline at end of file
Added: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/filter/UserGroupFilter.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/filter/UserGroupFilter.java (rev 0)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/filter/UserGroupFilter.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -0,0 +1,185 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2010, Red Hat Middleware, 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.exoplatform.portal.filter;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.container.web.AbstractFilter;
+import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.UserPortalConfigService;
+import org.exoplatform.portal.config.model.Container;
+import org.exoplatform.portal.config.model.PageNavigation;
+import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.portal.config.model.PortalConfig;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.OrganizationService;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+
+/*
+ * This is mostly fork of the code from UserPortalConfigListener and GroupPortalConfigListener. If user was placed in
+ * the identity store externally it will lazy create portal objects
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
+public class UserGroupFilter extends AbstractFilter
+{
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+
+ HttpServletRequest httpRequest = (HttpServletRequest)request;
+ ExoContainer container = getContainer();
+
+
+
+ if (httpRequest.getRemoteUser() != null)
+ {
+ OrganizationService orgService = (OrganizationService)container.
+ getComponentInstanceOfType(OrganizationService.class);
+ UserPortalConfigService portalConfigService = (UserPortalConfigService)container.
+ getComponentInstanceOfType(UserPortalConfigService.class);
+ DataStorage dataStorage = (DataStorage)container.
+ getComponentInstanceOfType(DataStorage.class);
+
+ String userName = httpRequest.getRemoteUser();
+
+ try
+ {
+ try
+ {
+ RequestLifeCycle.begin(PortalContainer.getInstance());
+ checkUser(orgService, portalConfigService, dataStorage, userName);
+ checkUserGroups(orgService, portalConfigService, dataStorage, userName);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ finally
+ {
+ RequestLifeCycle.end();
+ }
+ }
+ catch (Exception e)
+ {
+ System.out.println("Error while checking user portal config and navigations");
+ e.printStackTrace();
+ }
+
+
+
+ }
+
+ chain.doFilter(request, response);
+
+ }
+
+ public void checkUser(OrganizationService orgService,
+ UserPortalConfigService portalConfigService,
+ DataStorage dataStorage,
+ String userName) throws Exception
+ {
+
+ PortalConfig config = dataStorage.getPortalConfig(PortalConfig.USER_TYPE, userName);
+
+ if (config == null)
+ {
+ System.out.println("Detected user without PortalConfig present: " + userName + "; lazy creation initiated.");
+
+ // Create the portal from the template
+ portalConfigService.createUserPortalConfig(PortalConfig.USER_TYPE, userName, "user");
+
+ // Need to insert the corresponding user site if needed
+ PortalConfig cfg = dataStorage.getPortalConfig(PortalConfig.USER_TYPE, userName);
+ if (cfg == null)
+ {
+ cfg = new PortalConfig(PortalConfig.USER_TYPE);
+ cfg.setPortalLayout(new Container());
+ cfg.setName(userName);
+ dataStorage.create(cfg);
+ }
+ }
+ // Create a blank navigation if needed
+ PageNavigation navigation = dataStorage.getPageNavigation(PortalConfig.USER_TYPE, userName);
+ if (navigation == null)
+ {
+ PageNavigation pageNav = new PageNavigation();
+ pageNav.setOwnerType(PortalConfig.USER_TYPE);
+ pageNav.setOwnerId(userName);
+ pageNav.setPriority(5);
+ pageNav.setNodes(new ArrayList<PageNode>());
+ portalConfigService.create(pageNav);
+ }
+
+ }
+
+ public void checkUserGroups(OrganizationService orgService,
+ UserPortalConfigService portalConfigService,
+ DataStorage dataStorage,
+ String userName) throws Exception
+ {
+
+ Collection<Group> groups = orgService.getGroupHandler().findGroupsOfUser(userName);
+
+ for (Group group : groups)
+ {
+ String groupId = group.getId();
+
+ if (dataStorage.getPortalConfig(PortalConfig.GROUP_TYPE, groupId) == null)
+ {
+ System.out.println("Detected group without PortalConfig present: " + groupId + "; lazy creation initiated.");
+
+
+ // Create the portal from the template
+ portalConfigService.createUserPortalConfig(PortalConfig.GROUP_TYPE, groupId, "group");
+
+ // Need to insert the corresponding group site
+ PortalConfig cfg = dataStorage.getPortalConfig(PortalConfig.GROUP_TYPE, groupId);
+ if (cfg == null)
+ {
+ cfg = new PortalConfig(PortalConfig.GROUP_TYPE);
+ cfg.setPortalLayout(new Container());
+ cfg.setName(groupId);
+ dataStorage.create(cfg);
+ }
+ }
+ }
+ }
+
+
+
+
+ public void destroy()
+ {
+
+ }
+}
Modified: portal/trunk/component/web/src/main/java/org/exoplatform/web/login/ClusteredSSOFilter.java
===================================================================
--- portal/trunk/component/web/src/main/java/org/exoplatform/web/login/ClusteredSSOFilter.java 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/component/web/src/main/java/org/exoplatform/web/login/ClusteredSSOFilter.java 2010-02-10 21:52:19 UTC (rev 1621)
@@ -39,6 +39,9 @@
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
+/*
+ * @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw Dawidowicz</a>
+ */
public class ClusteredSSOFilter extends AbstractFilter
{
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/pom.xml 2010-02-10 21:52:19 UTC (rev 1621)
@@ -47,7 +47,7 @@
<org.gatein.common.version>2.0.0-CR03</org.gatein.common.version>
<org.gatein.wci.version>2.0.0-CR02</org.gatein.wci.version>
<org.gatein.pc.version>2.1.0-CR02</org.gatein.pc.version>
- <org.picketlink.idm>1.1.0.Beta2</org.picketlink.idm>
+ <org.picketlink.idm>1.1.0.Beta3</org.picketlink.idm>
<org.gatein.wsrp.version>1.0.0-Beta06</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.0-Beta16</org.gatein.mop.version>
<org.slf4j.version>1.5.6</org.slf4j.version>
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml 2010-02-10 21:52:19 UTC (rev 1621)
@@ -57,6 +57,9 @@
<!--Sample LDAP config-->
<!--<value>war:/conf/organization/picketlink-idm/picketlink-idm-ldap-config.xml</value>-->
+
+ <!--ACME LDAP Example-->
+ <!--<value>war:/conf/organization/picketlink-idm/examples/picketlink-idm-ldap-acme-config.xml</value>-->
</value-param>
<value-param>
<name>portalRealm</name>
@@ -88,7 +91,7 @@
This option may be useful with LDAP config as it will make (if set to true) every entry
added to LDAP (not via GateIn management UI) appear in GateIn-->
<field name="forceMembershipOfMappedTypes">
- <boolean>false</boolean>
+ <boolean>true</boolean>
</field>
<!-- When 'userParentIdAsGroupType is set to true this value will be used to
replace all "/" chars in id. This is because "/" is not allowed to be
@@ -125,6 +128,19 @@
<value><string>organization_type</string></value>
</entry>
-->
+
+
+ <!-- Uncomment for ACME LDAP example -->
+ <!--
+ <entry>
+ <key><string>/acme/roles/*</string></key>
+ <value><string>acme_roles_type</string></value>
+ </entry>
+ <entry>
+ <key><string>/acme/organization_units/*</string></key>
+ <value><string>acme_ou_type</string></value>
+ </entry>
+ -->
</map>
</field>
<!-- If this option is used then each Membership created with MembrshipType that is
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/organization-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/organization-configuration.xml 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/organization-configuration.xml 2010-02-10 21:52:19 UTC (rev 1621)
@@ -35,7 +35,7 @@
<value-param>
<name>checkDatabaseAlgorithm</name>
<description>check database</description>
- <value>entry</value>
+ <value>empty</value>
</value-param>
<value-param>
<name>printInformation</name>
Added: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/examples/acme.ldif
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/examples/acme.ldif (rev 0)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/examples/acme.ldif 2010-02-10 21:52:19 UTC (rev 1621)
@@ -0,0 +1,151 @@
+dn: o=acme,dc=example,dc=com
+objectclass: top
+objectclass: dcObject
+objectclass: organization
+o: acme
+dc: acme
+
+dn: ou=People,o=acme,dc=example,dc=com
+objectclass: top
+objectclass: organizationalUnit
+ou: People
+
+
+dn: uid=admin,ou=People,o=acme,dc=example,dc=com
+objectclass: top
+objectclass: inetOrgPerson
+objectclass: person
+uid: admin
+cn: Administrator
+sn: Duke
+userPassword: admin
+mail: admin(a)acme.example.com
+
+dn: uid=user,ou=People,o=acme,dc=example,dc=com
+objectclass: top
+objectclass: inetOrgPerson
+objectclass: person
+uid: user
+cn: User
+sn: Sample
+userPassword: user
+mail: user(a)acme.example.com
+
+dn: uid=jduke,ou=People,o=acme,dc=example,dc=com
+objectclass: top
+objectclass: inetOrgPerson
+objectclass: person
+uid: jduke
+cn: Java
+sn: Duke
+userPassword: theduke
+mail: jduke(a)acme.example.com
+
+dn: uid=jduke1,ou=People,o=acme,dc=example,dc=com
+objectclass: top
+objectclass: inetOrgPerson
+objectclass: person
+uid: jduke1
+cn: Java 1
+sn: Duke1
+userPassword: theduke
+mail: jduke1(a)acme.example.com
+
+
+dn: uid=jduke2,ou=People,o=acme,dc=example,dc=com
+objectclass: top
+objectclass: inetOrgPerson
+objectclass: person
+uid: jduke2
+cn: Java 2
+sn: Duke2
+userPassword: theduke
+mail: jduke2(a)acme.example.com
+
+dn: uid=jduke3,ou=People,o=acme,dc=example,dc=com
+objectclass: top
+objectclass: inetOrgPerson
+objectclass: person
+uid: jduke3
+cn: Java 3
+sn: Duke3
+userPassword: theduke
+mail: jduke3(a)acme.example.com
+
+dn: uid=jduke4,ou=People,o=acme,dc=example,dc=com
+objectclass: top
+objectclass: inetOrgPerson
+objectclass: person
+uid: jduke4
+cn: Java 4
+sn: Duke4
+userPassword: theduke
+mail: jduke4(a)acme.example.com
+
+dn: ou=Roles,o=acme,dc=example,dc=com
+objectclass: top
+objectclass: organizationalUnit
+ou: Roles
+
+dn: cn=admins,ou=Roles,o=acme,dc=example,dc=com
+objectClass: top
+objectClass: groupOfNames
+cn: admins
+description: Portal admin role
+member: uid=admin,ou=People,o=acme,dc=example,dc=com
+
+dn: cn=employees,ou=Roles,o=acme,dc=example,dc=com
+objectClass: top
+objectClass: groupOfNames
+cn: employees
+description: ACME Employees
+member: uid=admin,ou=People,o=acme,dc=example,dc=com
+member: uid=user,ou=People,o=acme,dc=example,dc=com
+member: uid=jduke,ou=People,o=acme,dc=example,dc=com
+member: uid=jduke1,ou=People,o=acme,dc=example,dc=com
+member: uid=jduke2,ou=People,o=acme,dc=example,dc=com
+member: uid=jduke3,ou=People,o=acme,dc=example,dc=com
+member: uid=jduke4,ou=People,o=acme,dc=example,dc=com
+
+dn: cn=echo,ou=Roles,o=acme,dc=example,dc=com
+objectClass: top
+objectClass: groupOfNames
+cn: echo
+description: Echo role
+member: uid=jduke1,ou=People,o=acme,dc=example,dc=com
+member: uid=jduke3,ou=People,o=acme,dc=example,dc=com
+member: uid=jduke4,ou=People,o=acme,dc=example,dc=com
+
+dn: cn=echo1,ou=Roles,o=acme,dc=example,dc=com
+objectClass: top
+objectClass: groupOfNames
+cn: echo1
+description: Echo1 role
+member: uid=jduke2,ou=People,o=acme,dc=example,dc=com
+member: uid=jduke3,ou=People,o=acme,dc=example,dc=com
+
+dn: cn=theduke,ou=Roles,o=acme,dc=example,dc=com
+objectClass: groupOfNames
+objectClass: top
+cn: theduke
+description: TheDuke role
+member: uid=jduke,ou=People,o=acme,dc=example,dc=com
+
+dn: ou=OrganizationUnits,o=acme,dc=example,dc=com
+objectclass: top
+objectclass: organizationalUnit
+ou: OrganizationUnits
+
+dn: cn=foo,ou=OrganizationUnits,o=acme,dc=example,dc=com
+objectClass: top
+objectClass: groupOfNames
+cn: foo
+description: Foo organization unit
+
+
+dn: cn=bar,ou=OrganizationUnits,o=acme,dc=example,dc=com
+objectClass: top
+objectClass: groupOfNames
+cn: bar
+description: Bar organization
+
Added: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/examples/picketlink-idm-ldap-acme-config.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/examples/picketlink-idm-ldap-acme-config.xml (rev 0)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/picketlink-idm/examples/picketlink-idm-ldap-acme-config.xml 2010-02-10 21:52:19 UTC (rev 1621)
@@ -0,0 +1,381 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+
+<jboss-identity xmlns="urn:picketlink:idm:config:v1_0_0_ga"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:picketlink:idm:config:v1_0_0_ga identity-config.xsd">
+ <realms>
+ <realm>
+ <id>realm</id>
+ <repository-id-ref>PortalRepository</repository-id-ref>
+ <identity-type-mappings>
+ <user-mapping>USER</user-mapping>
+ </identity-type-mappings>
+ </realm>
+ <realm>
+ <id>realm_portal</id>
+ <repository-id-ref>PortalRepository</repository-id-ref>
+ <identity-type-mappings>
+ <user-mapping>USER</user-mapping>
+ </identity-type-mappings>
+ </realm>
+ <realm>
+ <id>realm_sample-portal</id>
+ <repository-id-ref>SamplePortalRepository</repository-id-ref>
+ <identity-type-mappings>
+ <user-mapping>USER</user-mapping>
+ </identity-type-mappings>
+ </realm>
+ </realms>
+ <repositories>
+ <repository>
+ <id>PortalRepository</id>
+ <class>org.picketlink.idm.impl.repository.FallbackIdentityStoreRepository</class>
+ <external-config/>
+ <default-identity-store-id>HibernateStore</default-identity-store-id>
+ <default-attribute-store-id>HibernateStore</default-attribute-store-id>
+ <identity-store-mappings>
+ <identity-store-mapping>
+ <identity-store-id>PortalLDAPStore</identity-store-id>
+ <identity-object-types>
+ <identity-object-type>USER</identity-object-type>
+ <identity-object-type>acme_roles_type</identity-object-type>
+ <identity-object-type>acme_ou_type</identity-object-type>
+ </identity-object-types>
+ <options>
+ <option>
+ <name>readOnly</name>
+ <value>true</value>
+ </option>
+ </options>
+ </identity-store-mapping>
+ </identity-store-mappings>
+ <options>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ </options>
+ </repository>
+ <repository>
+ <id>SamplePortalRepository</id>
+ <class>org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository</class>
+ <external-config/>
+ <default-identity-store-id>HibernateStore</default-identity-store-id>
+ <default-attribute-store-id>HibernateStore</default-attribute-store-id>
+ </repository>
+ </repositories>
+ <stores>
+ <attribute-stores/>
+ <identity-stores>
+ <identity-store>
+ <id>HibernateStore</id>
+ <class>org.picketlink.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+ <external-config/>
+ <supported-relationship-types>
+ <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
+ <relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
+ </supported-relationship-types>
+ <supported-identity-object-types>
+ <identity-object-type>
+ <name>USER</name>
+ <relationships/>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ </credentials>
+ <attributes/>
+ <options/>
+ </identity-object-type>
+ </supported-identity-object-types>
+ <options>
+ <option>
+ <name>hibernateSessionFactoryRegistryName</name>
+ <value>hibernateSessionFactory</value>
+ </option>
+ <option>
+ <name>populateRelationshipTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>populateIdentityObjectTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowNotDefinedIdentityObjectTypes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowNotDefinedAttributes</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>isRealmAware</name>
+ <value>true</value>
+ </option>
+ </options>
+ </identity-store>
+ <identity-store>
+ <id>PortalLDAPStore</id>
+ <class>org.picketlink.idm.impl.store.ldap.LDAPIdentityStoreImpl</class>
+ <external-config/>
+ <supported-relationship-types>
+ <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
+ </supported-relationship-types>
+ <supported-identity-object-types>
+ <identity-object-type>
+ <name>USER</name>
+ <relationships/>
+ <credentials>
+ <credential-type>PASSWORD</credential-type>
+ </credentials>
+ <attributes>
+ <attribute>
+ <name>firstName</name>
+ <mapping>cn</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ </attribute>
+ <attribute>
+ <name>lastName</name>
+ <mapping>sn</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ </attribute>
+ <attribute>
+ <name>email</name>
+ <mapping>mail</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ <isUnique>true</isUnique>
+ </attribute>
+ </attributes>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>uid</value>
+ </option>
+ <option>
+ <name>passwordAttributeName</name>
+ <value>userPassword</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+ <value>ou=People,o=acme,dc=example,dc=com</value>
+ </option>
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=inetOrgPerson</value>
+ <value>sn= </value>
+ <value>cn= </value>
+ </option>
+ </options>
+ </identity-object-type>
+ <identity-object-type>
+ <name>acme_roles_type</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>acme_roles_type</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes>
+ <attribute>
+ <name>label</name>
+ <mapping>cn</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>true</isReadOnly>
+ </attribute>
+ <attribute>
+ <name>description</name>
+ <mapping>description</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ </attribute>
+ <attribute>
+ <name>email</name>
+ <mapping>mail</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ <isUnique>true</isUnique>
+ </attribute>
+ </attributes>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+ <value>ou=Roles,o=acme,dc=example,dc=com</value>
+ </option>
+ <!--<option>-->
+ <!--<name>entrySearchFilter</name>-->
+ <!--<value></value>-->
+ <!--</option>-->
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>parentMembershipAttributeName</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>isParentMembershipAttributeDN</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowEmptyMemberships</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=groupOfNames</value>
+ </option>
+ </options>
+ </identity-object-type>
+ <identity-object-type>
+ <name>acme_ou_type</name>
+ <relationships>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>USER</identity-object-type-ref>
+ </relationship>
+ <relationship>
+ <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
+ <identity-object-type-ref>acme_ou_type</identity-object-type-ref>
+ </relationship>
+ </relationships>
+ <credentials/>
+ <attributes>
+ <attribute>
+ <name>label</name>
+ <mapping>cn</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>true</isReadOnly>
+ </attribute>
+ <attribute>
+ <name>description</name>
+ <mapping>description</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ </attribute>
+ <attribute>
+ <name>email</name>
+ <mapping>mail</mapping>
+ <type>text</type>
+ <isRequired>false</isRequired>
+ <isMultivalued>false</isMultivalued>
+ <isReadOnly>false</isReadOnly>
+ <isUnique>true</isUnique>
+ </attribute>
+ </attributes>
+ <options>
+ <option>
+ <name>idAttributeName</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>ctxDNs</name>
+ <value>ou=OrganizationUnits,o=acme,dc=example,dc=com</value>
+ </option>
+ <!--<option>-->
+ <!--<name>entrySearchFilter</name>-->
+ <!--<value></value>-->
+ <!--</option>-->
+ <option>
+ <name>allowCreateEntry</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>parentMembershipAttributeName</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>isParentMembershipAttributeDN</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>allowEmptyMemberships</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>createEntryAttributeValues</name>
+ <value>objectClass=top</value>
+ <value>objectClass=groupOfNames</value>
+ </option>
+ </options>
+ </identity-object-type>
+ </supported-identity-object-types>
+ <options>
+ <option>
+ <name>providerURL</name>
+ <value>ldap://localhost:1389</value>
+ </option>
+ <option>
+ <name>adminDN</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>adminPassword</name>
+ <value>password</value>
+ </option>
+ <option>
+ <name>searchTimeLimit</name>
+ <value>10000</value>
+ </option>
+ <option>
+ <name>createMissingContexts</name>
+ <value>true</value>
+ </option>
+ </options>
+ </identity-store>
+ </identity-stores>
+ </stores>
+</jboss-identity>
\ No newline at end of file
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2010-02-10 19:40:15 UTC (rev 1620)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2010-02-10 21:52:19 UTC (rev 1621)
@@ -86,6 +86,11 @@
<filter-class>org.exoplatform.web.login.ClusteredSSOFilter</filter-class>
</filter>
+ <filter>
+ <filter-name>UserGroupFilter</filter-name>
+ <filter-class>org.exoplatform.portal.filter.UserGroupFilter</filter-class>
+ </filter>
+
<filter-mapping>
<filter-name>ClusteredSSOFilter</filter-name>
<url-pattern>/*</url-pattern>
@@ -127,6 +132,11 @@
</filter-mapping>
<filter-mapping>
+ <filter-name>UserGroupFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <filter-mapping>
<filter-name>CacheUserProfileFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
14 years, 11 months
gatein SVN: r1620 - in portal/trunk: component/common and 7 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-02-10 14:40:15 -0500 (Wed, 10 Feb 2010)
New Revision: 1620
Modified:
portal/trunk/component/common/pom.xml
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateStatisticService.java
portal/trunk/component/web/src/main/java/org/exoplatform/web/login/PortalLoginController.java
portal/trunk/component/web/src/main/java/org/exoplatform/web/security/Token.java
portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/AbstractTokenService.java
portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java
portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/TransientTokenService.java
portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetToken.java
portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenContainer.java
portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenEntry.java
portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenInfoService.java
portal/trunk/pom.xml
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/ApplicationStatisticService.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStatisticService.java
Log:
- make a bit the token service to be more type safe
- use the @Impact annotations on the various managed operations
Modified: portal/trunk/component/common/pom.xml
===================================================================
--- portal/trunk/component/common/pom.xml 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/component/common/pom.xml 2010-02-10 19:40:15 UTC (rev 1620)
@@ -63,6 +63,10 @@
<groupId>org.chromattic</groupId>
<artifactId>chromattic.spi</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.rest.core</artifactId>
+ </dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -22,6 +22,8 @@
import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.commons.utils.Safe;
import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.management.annotations.Impact;
+import org.exoplatform.management.annotations.ImpactType;
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.annotations.ManagedName;
@@ -56,6 +58,7 @@
@NameTemplate({@Property(key = "view", value = "portal"), @Property(key = "service", value = "management"),
@Property(key = "type", value = "skin")})
@ManagedDescription("Skin service")
+// @Rest("skinservice")
public class SkinService implements Startable
{
@@ -563,6 +566,7 @@
@Managed
@ManagedDescription("Reload all skins")
+ @Impact(ImpactType.WRITE)
public void reloadSkins()
{
// remove all ltCache, rtCache
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -26,6 +26,8 @@
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.groovyscript.GroovyTemplate;
import org.exoplatform.groovyscript.GroovyTemplateEngine;
+import org.exoplatform.management.annotations.Impact;
+import org.exoplatform.management.annotations.ImpactType;
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.annotations.ManagedName;
@@ -36,6 +38,7 @@
import org.exoplatform.services.cache.ExoCache;
import java.io.InputStream;
+import java.util.ArrayList;
/**
* Created by The eXo Platform SAS Dec 26, 2005
@@ -44,6 +47,7 @@
@NameTemplate({@Property(key = "view", value = "portal"), @Property(key = "service", value = "management"),
@Property(key = "type", value = "template")})
@ManagedDescription("Template management service")
+// @Rest("templateservice")
public class TemplateService
{
@@ -172,6 +176,7 @@
*/
@Managed
@ManagedDescription("Clear the template cache for a specified template identifier")
+ @Impact(ImpactType.IDEMPOTENT_WRITE)
public void reloadTemplate(@ManagedDescription("The template id") @ManagedName("templateId") String name)
{
try
@@ -185,4 +190,25 @@
e.printStackTrace();
}
}
+
+ @Managed
+ @ManagedDescription("List the identifiers of the cached templates")
+ @Impact(ImpactType.READ)
+ public String[] listCachedTemplates()
+ {
+ try
+ {
+ ArrayList<String> list = new ArrayList<String>();
+ for (GroovyTemplate template : templatesCache_.getCachedObjects())
+ {
+ list.add(template.getId());
+ }
+ return list.toArray(new String[list.size()]);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
}
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateStatisticService.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateStatisticService.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateStatisticService.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -19,12 +19,15 @@
package org.exoplatform.groovyscript.text;
+import org.exoplatform.management.annotations.Impact;
+import org.exoplatform.management.annotations.ImpactType;
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.annotations.ManagedName;
import org.exoplatform.management.jmx.annotations.NameTemplate;
import org.exoplatform.management.jmx.annotations.Property;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -40,9 +43,12 @@
*/
@Managed
-@NameTemplate({@Property(key = "view", value = "portal"), @Property(key = "service", value = "statistic"),
- @Property(key = "type", value = "template")})
@ManagedDescription("Template statistic service")
+@NameTemplate({
+ @Property(key = "view", value = "portal"),
+ @Property(key = "service", value = "statistic"),
+ @Property(key = "type", value = "template")})
+// @Rest("templatestatistics")
public class TemplateStatisticService
{
@@ -95,6 +101,7 @@
*/
@Managed
@ManagedDescription("The maximum rendering time of a specified template in seconds")
+ @Impact(ImpactType.READ)
public double getMaxTime(@ManagedDescription("The template id") @ManagedName("templateId") String name)
{
TemplateStatistic app = apps.get(name);
@@ -106,6 +113,7 @@
*/
@Managed
@ManagedDescription("The minimum rendering time of a specified template in seconds")
+ @Impact(ImpactType.READ)
public double getMinTime(@ManagedDescription("The template id") @ManagedName("templateId") String name)
{
TemplateStatistic app = apps.get(name);
@@ -117,6 +125,7 @@
*/
@Managed
@ManagedDescription("The rendering count of a specified template")
+ @Impact(ImpactType.READ)
public long getExecutionCount(@ManagedDescription("The template id") @ManagedName("templateId") String name)
{
TemplateStatistic app = apps.get(name);
@@ -128,6 +137,7 @@
*/
@Managed
@ManagedDescription("The average rendering time of a specified template in seconds")
+ @Impact(ImpactType.READ)
public double getAverageTime(@ManagedDescription("The template id") @ManagedName("templateId") String name)
{
TemplateStatistic app = apps.get(name);
@@ -142,12 +152,10 @@
public String[] getSlowestTemplates()
{
- Map application = new HashMap();
- List<Object> list = new LinkedList<Object>(apps.entrySet());
- for (Iterator it = list.iterator(); it.hasNext();)
+ Map<String, Double> application = new HashMap<String, Double>();
+ for (Map.Entry<String, TemplateStatistic> entry : apps.entrySet())
{
- Map.Entry entry = (Map.Entry)it.next();
- String url = (String)entry.getKey();
+ String url = entry.getKey();
application.put(url, getAverageTime(url));
}
@@ -162,12 +170,10 @@
public String[] getMostExecutedTemplates()
{
- Map application = new HashMap();
- List<Object> list = new LinkedList<Object>(apps.entrySet());
- for (Iterator it = list.iterator(); it.hasNext();)
+ Map<String, Long> application = new HashMap<String, Long>();
+ for (Map.Entry<String, TemplateStatistic> entry : apps.entrySet())
{
- Map.Entry entry = (Map.Entry)it.next();
- String url = (String)entry.getKey();
+ String url = entry.getKey();
application.put(url, getExecutionCount(url));
}
@@ -182,74 +188,39 @@
public String[] getFastestTemplates()
{
- Map application = new HashMap();
- List<Object> list = new LinkedList<Object>(apps.entrySet());
- for (Iterator it = list.iterator(); it.hasNext();)
+ Map<String, Double> application = new HashMap<String, Double>();
+ for (Map.Entry<String, TemplateStatistic> entry : apps.entrySet())
{
- Map.Entry entry = (Map.Entry)it.next();
- String url = (String)entry.getKey();
+ String url = entry.getKey();
application.put(url, getAverageTime(url));
}
return sort(application, ASC);
}
- private String[] sort(Map source, String order)
+ private <T extends Comparable<T>> String[] sort(Map<String, T> source, final String order)
{
String[] app = new String[10];
- List<Object> list = new LinkedList<Object>(source.entrySet());
- if (order.equals(ASC))
+ List<Map.Entry<String, T>> list = new ArrayList<Map.Entry<String, T>>(source.entrySet());
+ Collections.sort(list, new Comparator<Map.Entry<String, T>>()
{
- Collections.sort(list, new Comparator<Object>()
+ public int compare(Map.Entry<String, T> o1, Map.Entry<String, T> o2)
{
- public int compare(Object o1, Object o2)
+ T value1 = o1.getValue();
+ T value2 = o2.getValue();
+ if (DESC.equals(order))
{
- double value1 = Double.parseDouble(((Map.Entry)(o1)).getValue().toString());
- double value2 = Double.parseDouble(((Map.Entry)(o2)).getValue().toString());
- if (value1 > value2)
- {
- return 1;
- }
- else if (value1 < value2)
- {
- return -1;
- }
- else
- {
- return 0;
- }
+ T tmp = value1;
+ value1 = value2;
+ value2 = tmp;
}
- });
- }
- else if (order.equals(DESC))
- {
- Collections.sort(list, new Comparator<Object>()
- {
- public int compare(Object o1, Object o2)
- {
- double value1 = Double.parseDouble(((Map.Entry)(o1)).getValue().toString());
- double value2 = Double.parseDouble(((Map.Entry)(o2)).getValue().toString());
- if (value2 > value1)
- {
- return 1;
- }
- else if (value2 < value1)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
- });
- }
-
+ return value1.compareTo(value2);
+ }
+ });
int index = 0;
- for (Iterator it = list.iterator(); it.hasNext();)
+ for (Map.Entry<String, T> entry : list)
{
- Map.Entry entry = (Map.Entry)it.next();
- app[index] = (String)entry.getKey();
+ app[index] = entry.getKey();
index++;
if (index >= app.length)
{
@@ -257,7 +228,6 @@
}
}
return app;
-
}
private double toSeconds(double value)
Modified: portal/trunk/component/web/src/main/java/org/exoplatform/web/login/PortalLoginController.java
===================================================================
--- portal/trunk/component/web/src/main/java/org/exoplatform/web/login/PortalLoginController.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/component/web/src/main/java/org/exoplatform/web/login/PortalLoginController.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -69,7 +69,7 @@
String cookieToken = tokenService.createToken(credentials);
Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, cookieToken);
cookie.setPath(req.getContextPath());
- cookie.setMaxAge((int)tokenService.getExpiredPeriodTime() / 1000);
+ cookie.setMaxAge((int)tokenService.getValidityTime() / 1000);
resp.addCookie(cookie);
}
}
Modified: portal/trunk/component/web/src/main/java/org/exoplatform/web/security/Token.java
===================================================================
--- portal/trunk/component/web/src/main/java/org/exoplatform/web/security/Token.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/component/web/src/main/java/org/exoplatform/web/security/Token.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -1,6 +1,32 @@
+/**
+ * Copyright (C) 2010 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.web.security;
+/**
+ * A token.
+ */
public interface Token
{
- public boolean isExpired();
+ boolean isExpired();
+
+ long getExpirationTimeMillis();
+
+ Credentials getPayload();
+
}
Modified: portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/AbstractTokenService.java
===================================================================
--- portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/AbstractTokenService.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/AbstractTokenService.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -21,14 +21,11 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.management.annotations.Managed;
-import org.exoplatform.management.annotations.ManagedDescription;
-import org.exoplatform.management.annotations.ManagedName;
+import org.exoplatform.management.annotations.*;
import org.exoplatform.management.jmx.annotations.NameTemplate;
import org.exoplatform.management.jmx.annotations.Property;
import org.exoplatform.web.login.InitiateLoginServlet;
import org.exoplatform.web.security.Credentials;
-import org.exoplatform.web.security.GateInToken;
import org.exoplatform.web.security.Token;
import org.exoplatform.web.security.TokenStore;
import org.picocontainer.Startable;
@@ -42,11 +39,21 @@
/**
* Created by The eXo Platform SAS Author : liem.nguyen ncliam(a)gmail.com Jun 5,
* 2009
+ *
+ * todo julien :
+ * - make delay configuration from init param and @Managed setter
+ * - start/stop expiration daemon
+ * - manually invoke the daemon via @Managed
+ *
+ * @param <T> the token type
+ * @param <K> the token key type
*/
@Managed
-@NameTemplate({@Property(key = "service", value = "TokenStore"), @Property(key = "name", value = "{Name}")})
@ManagedDescription("Token Store Service")
-public abstract class AbstractTokenService implements Startable, TokenStore
+@NameTemplate({
+ @Property(key = "service", value = "TokenStore"),
+ @Property(key = "name", value = "{Name}")})
+public abstract class AbstractTokenService<T extends Token, K> implements Startable, TokenStore
{
protected static final String SERVICE_CONFIG = "service.configuration";
@@ -94,14 +101,17 @@
return classType.cast(container.getComponentInstanceOfType(classType));
}
- public Credentials validateToken(String tokenKey, boolean remove)
+ public Credentials validateToken(String stringKey, boolean remove)
{
- if (tokenKey == null)
+ if (stringKey == null)
{
throw new NullPointerException();
}
- GateInToken token;
+ //
+ K tokenKey = decodeKey(stringKey);
+
+ T token;
try
{
if (remove)
@@ -135,49 +145,60 @@
@Managed
@ManagedDescription("Clean all tokens are expired")
+ @Impact(ImpactType.IDEMPOTENT_WRITE)
public void cleanExpiredTokens()
{
- String[] ids = getAllTokens();
- for (String s : ids)
+ K[] ids = getAllTokens();
+ for (K id : ids)
{
- GateInToken token = getToken(s);
+ T token = getToken(id);
if (token.isExpired())
{
- deleteToken(s);
+ deleteToken(id);
}
}
}
@Managed
- @ManagedDescription("Get period time of expired token")
- public long getExpiredPeriodTime()
+ @ManagedDescription("Get time for token expiration in seconds")
+ public long getValidityTime()
{
- return validityMillis;
+ return validityMillis / 1000;
}
@Managed
- @ManagedName("Name")
+ @ManagedDescription("The expiration daemon period time in seconds")
+ public long getPeriodTime()
+ {
+ return DELAY_TIME;
+ }
+
+ @Managed
@ManagedDescription("The token service name")
public String getName()
{
return name;
}
- @Managed
- @ManagedDescription("get a token by id")
- public abstract <T extends Token> T getToken(Object id);
+ public abstract T getToken(K id);
- @Managed
- @ManagedDescription("Delete a token by id")
- public abstract <T extends Token> T deleteToken(Object id);
+ public abstract T deleteToken(K id);
- @Managed
- @ManagedDescription("The list of all tokens")
- public abstract <T extends Object> T[] getAllTokens();
+ public abstract K[] getAllTokens();
+ /**
+ * Decode a key from its string representation.
+ *
+ * @param stringKey the key a s a string
+ * @return the typed key
+ */
+ protected abstract K decodeKey(String stringKey);
+
+ // We don't make it a property as retrieving the value can be an expensive operation
@Managed
@ManagedDescription("The number of tokens")
- public abstract long getNumberTokens() throws Exception;
+ @Impact(ImpactType.READ)
+ public abstract long size() throws Exception;
private enum TimeoutEnum {
SECOND(1000), MINUTE(1000 * 60), HOUR(1000 * 60 * 60), DAY(1000 * 60 * 60 * 24);
Modified: portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java
===================================================================
--- portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -35,7 +35,7 @@
* Created by The eXo Platform SAS Author : liem.nguyen ncliam(a)gmail.com Jun 5,
* 2009
*/
-public class CookieTokenService extends AbstractTokenService
+public class CookieTokenService extends AbstractTokenService<GateInToken, String>
{
/** . */
@@ -78,7 +78,7 @@
}
@Override
- public GateInToken getToken(final Object id)
+ public GateInToken getToken(final String id)
{
return new TokenTask<GateInToken>() {
@Override
@@ -90,7 +90,7 @@
}
@Override
- public GateInToken deleteToken(final Object id)
+ public GateInToken deleteToken(final String id)
{
return new TokenTask<GateInToken>() {
@Override
@@ -122,7 +122,7 @@
}
@Override
- public long getNumberTokens() throws Exception
+ public long size() throws Exception
{
return new TokenTask<Long>() {
@Override
@@ -135,6 +135,12 @@
}.executeWith(chromatticLifeCycle);
}
+ @Override
+ protected String decodeKey(String stringKey)
+ {
+ return stringKey;
+ }
+
/**
* Wraps token store logic conveniently.
*
Modified: portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/TransientTokenService.java
===================================================================
--- portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/TransientTokenService.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/component/web/src/main/java/org/exoplatform/web/security/security/TransientTokenService.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -29,7 +29,7 @@
* Created by The eXo Platform SAS Author : liem.nguyen ncliam(a)gmail.com Jun 5,
* 2009
*/
-public class TransientTokenService extends AbstractTokenService
+public class TransientTokenService extends AbstractTokenService<GateInToken, String>
{
protected final ConcurrentHashMap<String, GateInToken> tokens = new ConcurrentHashMap<String, GateInToken>();
@@ -56,14 +56,20 @@
}
@Override
- public GateInToken getToken(Object id)
+ public GateInToken getToken(String id)
{
return tokens.get(id);
}
@Override
- public GateInToken deleteToken(Object id)
+ protected String decodeKey(String stringKey)
{
+ return stringKey;
+ }
+
+ @Override
+ public GateInToken deleteToken(String id)
+ {
GateInToken token = tokens.get(id);
tokens.remove(id);
return token;
@@ -76,7 +82,7 @@
}
@Override
- public long getNumberTokens() throws Exception
+ public long size() throws Exception
{
return tokens.size();
}
Modified: portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetToken.java
===================================================================
--- portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetToken.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetToken.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -1,6 +1,7 @@
package org.exoplatform.portal.gadget.core;
import org.apache.shindig.gadgets.oauth.OAuthStore.TokenInfo;
+import org.exoplatform.web.security.Credentials;
import org.exoplatform.web.security.Token;
@@ -16,4 +17,15 @@
{
return false;
}
+
+ public long getExpirationTimeMillis()
+ {
+ return getTokenExpireMillis();
+ }
+
+ public Credentials getPayload()
+ {
+ // Should we return something ?
+ return null;
+ }
}
Modified: portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenContainer.java
===================================================================
--- portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenContainer.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenContainer.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -20,18 +20,10 @@
public GadgetToken getToken(BasicOAuthStoreTokenIndex tokenKey)
{
Map<String, GadgetTokenEntry> tokens = getGadgetTokens();
-
for (GadgetTokenEntry tokenEntry : tokens.values())
{
- {
- BasicOAuthStoreTokenIndex key = new BasicOAuthStoreTokenIndex();
- key.setGadgetUri(tokenEntry.getGadgetUri());
- key.setModuleId(tokenEntry.getModuleId());
- key.setServiceName(tokenEntry.getServiceName());
- key.setTokenName(tokenEntry.getTokenName());
- key.setUserId(tokenEntry.getUserId());
- if (tokenKey.equals(key)) return tokenEntry.getToken();
- }
+ BasicOAuthStoreTokenIndex key = tokenEntry.getKey();
+ if (tokenKey.equals(key)) return tokenEntry.getToken();
}
return null;
}
@@ -42,14 +34,10 @@
for (GadgetTokenEntry tokenEntry : tokens.values())
{
+ BasicOAuthStoreTokenIndex key = tokenEntry.getKey();
+ if (tokenKey.equals(key))
{
- BasicOAuthStoreTokenIndex key = new BasicOAuthStoreTokenIndex();
- key.setGadgetUri(tokenEntry.getGadgetUri());
- key.setModuleId(tokenEntry.getModuleId());
- key.setServiceName(tokenEntry.getServiceName());
- key.setTokenName(tokenEntry.getTokenName());
- key.setUserId(tokenEntry.getUserId());
- if (tokenKey.equals(key)) tokenEntry.remove();
+ tokenEntry.remove();
return tokenEntry.getToken();
}
}
@@ -62,17 +50,11 @@
GadgetTokenEntry entry = null;
for (GadgetTokenEntry item : tokens.values())
{
+ BasicOAuthStoreTokenIndex key = item.getKey();
+ if (tokenKey.equals(key))
{
- BasicOAuthStoreTokenIndex key = new BasicOAuthStoreTokenIndex();
- key.setGadgetUri(item.getGadgetUri());
- key.setModuleId(item.getModuleId());
- key.setServiceName(item.getServiceName());
- key.setTokenName(item.getTokenName());
- key.setUserId(item.getUserId());
- if (tokenKey.equals(key))
- entry = item;
+ entry = item;
}
-
}
if (entry == null)
{
Modified: portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenEntry.java
===================================================================
--- portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenEntry.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenEntry.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -1,5 +1,6 @@
package org.exoplatform.portal.gadget.core;
+import org.apache.shindig.gadgets.oauth.BasicOAuthStoreTokenIndex;
import org.chromattic.api.annotations.Destroy;
import org.chromattic.api.annotations.PrimaryType;
import org.chromattic.api.annotations.Property;
@@ -7,7 +8,18 @@
@PrimaryType(name = "lgn:gadgettoken")
public abstract class GadgetTokenEntry
{
-
+
+ public BasicOAuthStoreTokenIndex getKey()
+ {
+ BasicOAuthStoreTokenIndex key = new BasicOAuthStoreTokenIndex();
+ key.setGadgetUri(getGadgetUri());
+ key.setModuleId(getModuleId());
+ key.setServiceName(getServiceName());
+ key.setTokenName(getTokenName());
+ key.setUserId(getUserId());
+ return key;
+ }
+
@Property(name = "userId")
public abstract String getUserId();
Modified: portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenInfoService.java
===================================================================
--- portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenInfoService.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/GadgetTokenInfoService.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -32,7 +32,7 @@
import java.util.Collection;
-public class GadgetTokenInfoService extends AbstractTokenService
+public class GadgetTokenInfoService extends AbstractTokenService<GadgetToken, BasicOAuthStoreTokenIndex>
{
private ChromatticLifeCycle chromatticLifeCycle;
@@ -57,45 +57,45 @@
}
@Override
- public GadgetToken getToken(final Object key)
+ public GadgetToken getToken(final BasicOAuthStoreTokenIndex key)
{
return new TokenTask<GadgetToken>()
{
@Override
protected GadgetToken execute()
{
- return getGadgetTokenContainer().getToken((BasicOAuthStoreTokenIndex)key);
+ return getGadgetTokenContainer().getToken(key);
}
}.executeWith(chromatticLifeCycle);
}
@Override
- public GadgetToken deleteToken(final Object key)
+ public GadgetToken deleteToken(final BasicOAuthStoreTokenIndex key)
{
return new TokenTask<GadgetToken>()
{
@Override
protected GadgetToken execute()
{
- return getGadgetTokenContainer().removeToken((BasicOAuthStoreTokenIndex)key);
+ return getGadgetTokenContainer().removeToken(key);
}
}.executeWith(chromatticLifeCycle);
}
@Override
- public GadgetToken[] getAllTokens()
+ public BasicOAuthStoreTokenIndex[] getAllTokens()
{
- return new TokenTask<GadgetToken[]>()
+ return new TokenTask<BasicOAuthStoreTokenIndex[]>()
{
@Override
- protected GadgetToken[] execute()
+ protected BasicOAuthStoreTokenIndex[] execute()
{
GadgetTokenContainer container = getGadgetTokenContainer();
Collection<GadgetTokenEntry> tokens = container.getGadgetTokens().values();
- GadgetToken[] gadgetTokens = new GadgetToken[9];
+ BasicOAuthStoreTokenIndex[] gadgetTokens = new BasicOAuthStoreTokenIndex[9];
int count = 0;
for(GadgetTokenEntry tokenEntry : tokens) {
- gadgetTokens[count++] = tokenEntry.getToken();
+ gadgetTokens[count++] = tokenEntry.getKey();
}
return gadgetTokens;
}
@@ -103,7 +103,7 @@
}
@Override
- public long getNumberTokens() throws Exception
+ public long size() throws Exception
{
return new TokenTask<Long>()
{
@@ -123,6 +123,11 @@
return null;
}
+ @Override
+ protected BasicOAuthStoreTokenIndex decodeKey(String stringKey)
+ {
+ throw new UnsupportedOperationException();
+ }
/**
* Wraps token store logic conveniently.
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/pom.xml 2010-02-10 19:40:15 UTC (rev 1620)
@@ -176,6 +176,11 @@
<artifactId>exo.ws.frameworks.servlet</artifactId>
<version>${org.exoplatform.ws.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.rest.core</artifactId>
+ <version>${org.exoplatform.ws.version}</version>
+ </dependency>
<!-- GateIn components -->
<dependency>
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/ApplicationStatisticService.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/ApplicationStatisticService.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/ApplicationStatisticService.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -19,6 +19,8 @@
package org.exoplatform.portal.application;
+import org.exoplatform.management.annotations.Impact;
+import org.exoplatform.management.annotations.ImpactType;
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.annotations.ManagedName;
@@ -38,9 +40,12 @@
* @version $Revision$
*/
@Managed
-@NameTemplate({@Property(key = "view", value = "portal"), @Property(key = "service", value = "statistic"),
+@ManagedDescription("Application statistic service")
+@NameTemplate({
+ @Property(key = "view", value = "portal"),
+ @Property(key = "service", value = "statistic"),
@Property(key = "type", value = "application")})
-@ManagedDescription("Application statistic service")
+// @Rest("applicationstatistic")
public class ApplicationStatisticService implements Startable
{
@@ -66,8 +71,7 @@
/*
* get ApplicationStatistic by application id, if it isn't exits, create a new one
*/
- public ApplicationStatistic getApplicationStatistic(
- @ManagedDescription("The application id") @ManagedName("applicationId") String appId)
+ public ApplicationStatistic getApplicationStatistic(String appId)
{
ApplicationStatistic app = apps.get(appId);
if (app == null)
@@ -87,6 +91,7 @@
*/
@Managed
@ManagedDescription("The maximum execution time of a specified application in seconds")
+ @Impact(ImpactType.READ)
public double getMaxTime(@ManagedDescription("The application id") @ManagedName("applicationId") String appId)
{
ApplicationStatistic app = getApplicationStatistic(appId);
@@ -98,6 +103,7 @@
*/
@Managed
@ManagedDescription("The minimum execution time of a specified application in seconds")
+ @Impact(ImpactType.READ)
public double getMinTime(@ManagedDescription("The application id") @ManagedName("applicationId") String appId)
{
ApplicationStatistic app = getApplicationStatistic(appId);
@@ -109,6 +115,7 @@
*/
@Managed
@ManagedDescription("Return the average execution time of a specified application in seconds")
+ @Impact(ImpactType.READ)
public double getAverageTime(@ManagedDescription("The application id") @ManagedName("applicationId") String appId)
{
ApplicationStatistic app = getApplicationStatistic(appId);
@@ -120,6 +127,7 @@
*/
@Managed
@ManagedDescription("The execution count of a specified application")
+ @Impact(ImpactType.READ)
public long getExecutionCount(@ManagedDescription("The application id") @ManagedName("applicationId") String appId)
{
ApplicationStatistic app = getApplicationStatistic(appId);
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStatisticService.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStatisticService.java 2010-02-10 17:34:37 UTC (rev 1619)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStatisticService.java 2010-02-10 19:40:15 UTC (rev 1620)
@@ -19,6 +19,8 @@
package org.exoplatform.portal.application;
+import org.exoplatform.management.annotations.Impact;
+import org.exoplatform.management.annotations.ImpactType;
import org.exoplatform.management.annotations.Managed;
import org.exoplatform.management.annotations.ManagedDescription;
import org.exoplatform.management.annotations.ManagedName;
@@ -36,9 +38,12 @@
* @version $Revision$
*/
@Managed
-@NameTemplate({@Property(key = "view", value = "portal"), @Property(key = "service", value = "statistic"),
+@ManagedDescription("The portal statistic service")
+@NameTemplate({
+ @Property(key = "view", value = "portal"),
+ @Property(key = "service", value = "statistic"),
@Property(key = "type", value = "portal")})
-@ManagedDescription("The portal statistic service")
+// @Rest("portalstatistic")
public class PortalStatisticService implements Startable
{
@@ -94,6 +99,7 @@
*/
@Managed
@ManagedDescription("The maximum execution time of a specified portal in seconds")
+ @Impact(ImpactType.READ)
public double getMaxTime(@ManagedDescription("The portal id") @ManagedName("portalId") String id)
{
return toSeconds(getPortalStatistic(id).getMaxTime());
@@ -104,6 +110,7 @@
*/
@Managed
@ManagedDescription("The mininum execution time of a specified portal in seconds")
+ @Impact(ImpactType.READ)
public double getMinTime(@ManagedDescription("The portal id") @ManagedName("portalId") String id)
{
return toSeconds(getPortalStatistic(id).getMinTime());
@@ -114,6 +121,7 @@
*/
@Managed
@ManagedDescription("The average execution time of a specified portal in seconds")
+ @Impact(ImpactType.READ)
public double getAverageTime(@ManagedDescription("The portal id") @ManagedName("portalId") String id)
{
return toSeconds(getPortalStatistic(id).getAverageTime());
@@ -124,6 +132,7 @@
*/
@Managed
@ManagedDescription("The number of request per second of a specified portal")
+ @Impact(ImpactType.READ)
public double getThroughput(@ManagedDescription("The portal id") @ManagedName("portalId") String id)
{
return getPortalStatistic(id).getThroughput();
@@ -134,6 +143,7 @@
*/
@Managed
@ManagedDescription("The execution count of a specified portal")
+ @Impact(ImpactType.READ)
public long getExecutionCount(@ManagedDescription("The portal id") @ManagedName("portalId") String id)
{
return getPortalStatistic(id).viewCount();
14 years, 11 months
gatein SVN: r1619 - portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-02-10 12:34:37 -0500 (Wed, 10 Feb 2010)
New Revision: 1619
Modified:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/RegistrationMapping.java
Log:
- Do not create RegistrationPropertiesMapping if we already have one.
Modified: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/RegistrationMapping.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/RegistrationMapping.java 2010-02-10 13:47:07 UTC (rev 1618)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/state/producer/registrations/mapping/RegistrationMapping.java 2010-02-10 17:34:37 UTC (rev 1619)
@@ -1,24 +1,25 @@
/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+ * JBoss, a division of Red Hat
+ * Copyright 2010, 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.gatein.portal.wsrp.state.producer.registrations.mapping;
@@ -26,8 +27,8 @@
import org.chromattic.api.annotations.Id;
import org.chromattic.api.annotations.ManyToOne;
import org.chromattic.api.annotations.MappedBy;
+import org.chromattic.api.annotations.OneToOne;
import org.chromattic.api.annotations.PrimaryType;
-import org.chromattic.api.annotations.OneToOne;
import org.chromattic.api.annotations.Property;
import org.gatein.common.util.ParameterValidation;
import org.gatein.portal.wsrp.state.producer.registrations.JCRRegistrationPersistenceManager;
@@ -89,8 +90,12 @@
Map<QName, Object> properties = registration.getProperties();
if (ParameterValidation.existsAndIsNotEmpty(properties))
{
- RegistrationPropertiesMapping rpm = createProperties();
- setProperties(rpm);
+ RegistrationPropertiesMapping rpm = getProperties();
+ if (rpm == null)
+ {
+ rpm = createProperties();
+ setProperties(rpm);
+ }
rpm.initFrom(properties);
}
}
14 years, 11 months
gatein SVN: r1618 - portal/trunk/component/application-registry/src/test/java/conf.
by do-not-reply@jboss.org
Author: trong.tran
Date: 2010-02-10 08:47:07 -0500 (Wed, 10 Feb 2010)
New Revision: 1618
Modified:
portal/trunk/component/application-registry/src/test/java/conf/exo.portal.component.application-registry-configuration.xml
Log:
GTNPORTAL-598 update test configuration
Modified: portal/trunk/component/application-registry/src/test/java/conf/exo.portal.component.application-registry-configuration.xml
===================================================================
--- portal/trunk/component/application-registry/src/test/java/conf/exo.portal.component.application-registry-configuration.xml 2010-02-10 12:56:53 UTC (rev 1617)
+++ portal/trunk/component/application-registry/src/test/java/conf/exo.portal.component.application-registry-configuration.xml 2010-02-10 13:47:07 UTC (rev 1618)
@@ -299,6 +299,44 @@
<description>In the run method, use try catch or not (value is true/false)</description>
<value>true</value>
</value-param>
+ <value-param>
+ <name>page.templates.location</name>
+ <description>the path to the location that contains Page templates</description>
+ <value>classpath:/portal/template/pages</value>
+ </value-param>
+ <object-param>
+ <name>site.templates.location</name>
+ <description>description</description>
+ <object type="org.exoplatform.portal.config.SiteConfigTemplates">
+ <field name="location">
+ <string>classpath:/portal</string>
+ </field>
+ <field name="portalTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>classic</string>
+ </value>
+ <value>
+ <string>test</string>
+ </value>
+ </collection>
+ </field>
+ <field name="groupTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>group</string>
+ </value>
+ </collection>
+ </field>
+ <field name="userTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>user</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
<object-param>
<name>portal.configuration</name>
<description>description</description>
@@ -386,18 +424,6 @@
</field>
</object>
</object-param>
- <object-param>
- <name>page.templates</name>
- <description>List of page templates</description>
- <object type="org.exoplatform.portal.config.PageTemplateConfig">
- <field name="templates">
- <collection type="java.util.ArrayList"></collection>
- </field>
- <field name="location">
- <string>classpath:/portal/template/pages</string>
- </field>
- </object>
- </object-param>
</init-params>
</component-plugin>
</external-component-plugins>
14 years, 11 months
gatein SVN: r1617 - portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal.
by do-not-reply@jboss.org
Author: trong.tran
Date: 2010-02-10 07:56:53 -0500 (Wed, 10 Feb 2010)
New Revision: 1617
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
Log:
GTNPORTAL-598 update missing configuration
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2010-02-10 12:54:25 UTC (rev 1616)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/portal/portal-configuration.xml 2010-02-10 12:56:53 UTC (rev 1617)
@@ -109,10 +109,40 @@
<value>classic</value>
</value-param>
<value-param>
- <name>initializing.failure.ignore</name>
- <description>In the run method, use try catch or not (value is true/false)</description>
- <value>false</value>
+ <name>page.templates.location</name>
+ <description>the path to the location that contains Page templates</description>
+ <value>war:/conf/portal/template/pages</value>
</value-param>
+ <object-param>
+ <name>site.templates.location</name>
+ <description>description</description>
+ <object type="org.exoplatform.portal.config.SiteConfigTemplates">
+ <field name="location">
+ <string>war:/conf/portal</string>
+ </field>
+ <field name="portalTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>classic</string>
+ </value>
+ </collection>
+ </field>
+ <field name="groupTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>group</string>
+ </value>
+ </collection>
+ </field>
+ <field name="userTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>user</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
<object-param>
<name>portal.configuration</name>
<description>description</description>
@@ -159,16 +189,6 @@
<field name="templateLocation"><string>war:/conf/portal</string></field>
</object>
</object-param>
- <object-param>
- <name>page.templates</name>
- <description>List of page templates</description>
- <object type="org.exoplatform.portal.config.PageTemplateConfig">
- <field name="templates">
- <collection type="java.util.ArrayList"></collection>
- </field>
- <field name="location"><string>war:/conf/portal/template/pages</string></field>
- </object>
- </object-param>
</init-params>
</component-plugin>
</component-plugins>
14 years, 11 months
gatein SVN: r1616 - in portal/trunk/component/portal/src: test/java/conf and 1 other directories.
by do-not-reply@jboss.org
Author: trong.tran
Date: 2010-02-10 07:54:25 -0500 (Wed, 10 Feb 2010)
New Revision: 1616
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/SiteConfigTemplates.java
Removed:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/PageTemplateConfig.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfig.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration2.xml
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
Log:
GTNPORTAL-598 Add supporting to be able configuring portal templates from the extension
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfig.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfig.java 2010-02-10 10:55:19 UTC (rev 1615)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfig.java 2010-02-10 12:54:25 UTC (rev 1616)
@@ -33,8 +33,14 @@
private String ownerType;
- private String templateOwner;
+ private String templateName;
+ private String location;
+
+ /**
+ * @deprecated use the location instead
+ */
+ @Deprecated
private String templateLocation;
public NewPortalConfig()
@@ -45,10 +51,16 @@
{
this.ownerType = cfg.ownerType;
this.templateLocation = cfg.templateLocation;
- this.templateOwner = cfg.templateOwner;
+ this.location = cfg.location;
+ this.templateName = cfg.templateName;
this.predefinedOwner = new HashSet<String>(cfg.predefinedOwner);
}
+ public NewPortalConfig(String path)
+ {
+ this.location = path;
+ }
+
public HashSet<String> getPredefinedOwner()
{
return predefinedOwner;
@@ -59,24 +71,44 @@
this.predefinedOwner = s;
}
+ /**
+ * @return the location
+ */
+ public String getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * @param location the location to set
+ */
+ public void setLocation(String location)
+ {
+ this.location = location;
+ }
+
public String getTemplateLocation()
{
- return templateLocation;
+ if (location != null)
+ return location;
+ else
+ return templateLocation;
}
public void setTemplateLocation(String s)
{
+ this.location = s;
this.templateLocation = s;
}
- public String getTemplateOwner()
+ public String getTemplateName()
{
- return templateOwner;
+ return templateName;
}
- public void setTemplateOwner(String s)
+ public void setTemplateName(String s)
{
- this.templateOwner = s;
+ this.templateName = s;
}
public boolean isPredefinedOwner(String user)
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2010-02-10 10:55:19 UTC (rev 1615)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/NewPortalConfigListener.java 2010-02-10 12:54:25 UTC (rev 1616)
@@ -44,10 +44,10 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
/**
* Created by The eXo Platform SARL Author : Tuan Nguyen
@@ -61,10 +61,12 @@
private DataStorage dataStorage_;
- private volatile List<?> configs;
+ private volatile List<NewPortalConfig> configs;
- private PageTemplateConfig pageTemplateConfig_;
+ private List<SiteConfigTemplates> templateConfigs;
+ private String pageTemplatesLocation_;
+
private String defaultPortal;
private boolean isUseTryCatch;
@@ -77,18 +79,20 @@
cmanager_ = cmanager;
dataStorage_ = dataStorage;
- ObjectParameter objectParam = params.getObjectParam("page.templates");
- if (objectParam != null)
- pageTemplateConfig_ = (PageTemplateConfig)objectParam.getObject();
+ ValueParam valueParam = params.getValueParam("page.templates.location");
+ if (valueParam != null)
+ pageTemplatesLocation_ = valueParam.getValue();
defaultPortal = "classic";
- ValueParam valueParam = params.getValueParam("default.portal");
+ valueParam = params.getValueParam("default.portal");
if (valueParam != null)
defaultPortal = valueParam.getValue();
if (defaultPortal == null || defaultPortal.trim().length() == 0)
defaultPortal = "classic";
configs = params.getObjectParamValues(NewPortalConfig.class);
+ templateConfigs = params.getObjectParamValues(SiteConfigTemplates.class);
+
// get parameter
valueParam = params.getValueParam("initializing.failure.ignore");
// determine in the run function, is use try catch or not
@@ -105,66 +109,61 @@
public void run() throws Exception
{
- if (isInitedDB(defaultPortal))
+ if (dataStorage_.getPortalConfig(defaultPortal) != null)
return;
if (isUseTryCatch)
{
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
try
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPortletPreferencesDB(portalConfig);
+ initPortletPreferencesDB(ele);
}
catch (Exception e)
{
log.error("NewPortalConfig error: " + e.getMessage(), e);
}
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
try
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPortalConfigDB(portalConfig);
+ initPortalConfigDB(ele);
}
catch (Exception e)
{
log.error("NewPortalConfig error: " + e.getMessage(), e);
}
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
try
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPageDB(portalConfig);
+ initPageDB(ele);
}
catch (Exception e)
{
log.error("NewPortalConfig error: " + e.getMessage(), e);
}
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
try
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPageNavigationDB(portalConfig);
+ initPageNavigationDB(ele);
}
catch (Exception e)
{
log.error("NewPortalConfig error: " + e.getMessage(), e);
}
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
try
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- portalConfig.getPredefinedOwner().clear();
+ ele.getPredefinedOwner().clear();
}
catch (Exception e)
{
@@ -175,30 +174,25 @@
}
else
{
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPortletPreferencesDB(portalConfig);
+ initPortletPreferencesDB(ele);
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPortalConfigDB(portalConfig);
+ initPortalConfigDB(ele);
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPageDB(portalConfig);
+ initPageDB(ele);
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- initPageNavigationDB(portalConfig);
+ initPageNavigationDB(ele);
}
- for (Object ele : configs)
+ for (NewPortalConfig ele : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)ele;
- portalConfig.getPredefinedOwner().clear();
+ ele.getPredefinedOwner().clear();
}
}
}
@@ -213,13 +207,13 @@
* a copy of the original object.
*
* @param ownerType the owner type
+ * @param template
* @return the specified new portal config
*/
- NewPortalConfig getPortalConfig(String ownerType)
+ NewPortalConfig getPortalConfig(String ownerType, String template)
{
- for (Object object : configs)
+ for (NewPortalConfig portalConfig : configs)
{
- NewPortalConfig portalConfig = (NewPortalConfig)object;
if (portalConfig.getOwnerType().equals(ownerType))
{
// We are defensive, we make a deep copy
@@ -229,25 +223,35 @@
return null;
}
- @SuppressWarnings("unchecked")
- synchronized void addPortalConfigs(NewPortalConfigListener listener)
+ /**
+ * This is used to merge an other NewPortalConfigListener to this one
+ *
+ * @param other
+ */
+ public void mergePlugin(NewPortalConfigListener other)
{
+ this.defaultPortal = other.defaultPortal;
if (configs == null)
{
- this.configs = listener.configs;
+ this.configs = other.configs;
}
- else if (listener.configs != null && !listener.configs.isEmpty())
+ else if (other.configs != null && !other.configs.isEmpty())
{
- List result = new ArrayList(configs);
- result.addAll(listener.configs);
+ List<NewPortalConfig> result = new ArrayList<NewPortalConfig>(configs);
+ result.addAll(other.configs);
this.configs = Collections.unmodifiableList(result);
}
- }
- private boolean isInitedDB(String portalName) throws Exception
- {
- PortalConfig pconfig = dataStorage_.getPortalConfig(portalName);
- return pconfig != null;
+ if (templateConfigs == null)
+ {
+ this.templateConfigs = other.templateConfigs;
+ }
+ else if (other.templateConfigs != null && !other.templateConfigs.isEmpty())
+ {
+ List<SiteConfigTemplates> result = new ArrayList<SiteConfigTemplates>(templateConfigs);
+ result.addAll(other.templateConfigs);
+ this.templateConfigs = Collections.unmodifiableList(result);
+ }
}
public void initPortalConfigDB(NewPortalConfig config) throws Exception
@@ -285,19 +289,16 @@
}
}
- private void createPortalConfig(NewPortalConfig config, String owner) throws Exception
+ public void createPortalConfig(NewPortalConfig config, String owner) throws Exception
{
String type = config.getOwnerType();
- // get path of xml file, check if path in template folder and if path not in
- // template folder
- boolean notTemplate = (config.getTemplateOwner() == null || config.getTemplateOwner().trim().length() < 1);
- String path = getPathConfig(config, owner, type, notTemplate);
+ boolean isTemplate = (config.getTemplateName() != null && config.getTemplateName().trim().length() > 0);
+ String path = getPathConfig(config, owner, type, isTemplate);
- // get xml content and parse xml content
try
{
- String xml = getDefaultConfigIfExists(config.getTemplateLocation(), path);
+ String xml = getDefaultConfig(config.getTemplateLocation(), path);
if (xml == null)
{
@@ -314,7 +315,7 @@
}
return;
}
- if (!notTemplate)
+ if (isTemplate)
{
xml = StringUtils.replace(xml, "@owner@", owner);
}
@@ -346,15 +347,12 @@
}
}
- private void createPage(NewPortalConfig config, String owner) throws Exception
+ public void createPage(NewPortalConfig config, String owner) throws Exception
{
- // get path of xml file, check if path in template folder and if path not in
- // template folder
- boolean notTemplate = (config.getTemplateOwner() == null || config.getTemplateOwner().trim().length() < 1);
- String path = getPathConfig(config, owner, "pages", notTemplate);
+ boolean isTemplate = (config.getTemplateName() != null && config.getTemplateName().trim().length() > 0);
+ String path = getPathConfig(config, owner, "pages", isTemplate);
- // get xml content and parse xml content
try
{
String xml = getDefaultConfig(config.getTemplateLocation(), path);
@@ -363,7 +361,7 @@
return;
}
- if (!notTemplate)
+ if (isTemplate)
{
xml = StringUtils.replace(xml, "@owner@", owner);
}
@@ -382,14 +380,11 @@
}
}
- private void createPageNavigation(NewPortalConfig config, String owner) throws Exception
+ public void createPageNavigation(NewPortalConfig config, String owner) throws Exception
{
- // get path of xml file, check if path in template folder and if path not in
- // template folder
- boolean notTemplate = (config.getTemplateOwner() == null || config.getTemplateOwner().trim().length() < 1);
- String path = getPathConfig(config, owner, "navigation", notTemplate);
+ boolean isTemplate = (config.getTemplateName() != null && config.getTemplateName().trim().length() > 0);
+ String path = getPathConfig(config, owner, "navigation", isTemplate);
- // get xml content and parse xml content
try
{
String xml = getDefaultConfig(config.getTemplateLocation(), path);
@@ -398,7 +393,7 @@
return;
}
- if (!notTemplate)
+ if (isTemplate)
{
xml = StringUtils.replace(xml, "@owner@", owner);
}
@@ -421,14 +416,11 @@
}
}
- private void createPortletPreferences(NewPortalConfig config, String owner) throws Exception
+ public void createPortletPreferences(NewPortalConfig config, String owner) throws Exception
{
- // get path of xml file, check if path in template folder and if path not in
- // template folder
- boolean notTemplate = (config.getTemplateOwner() == null || config.getTemplateOwner().trim().length() < 1);
- String path = getPathConfig(config, owner, "portlet-preferences", notTemplate);
+ boolean isTemplate = (config.getTemplateName() != null && config.getTemplateName().trim().length() > 0);
+ String path = getPathConfig(config, owner, "portlet-preferences", isTemplate);
- // get xml content and parse xml content
try
{
String xml = getDefaultConfig(config.getTemplateLocation(), path);
@@ -437,7 +429,7 @@
return;
}
- if (!notTemplate)
+ if (isTemplate)
{
xml = StringUtils.replace(xml, "@owner@", owner);
}
@@ -456,18 +448,12 @@
}
}
- private String getDefaultConfigIfExists(String location, String path) throws Exception
- {
- URL url = cmanager_.getURL(location + path);
- return url == null ? null : IOUtil.getStreamContentAsString(url.openStream());
- }
-
private String getDefaultConfig(String location, String path) throws Exception
{
String s = location + path;
try
{
- return IOUtil.getStreamContentAsString(cmanager_.getInputStream(s));
+ return IOUtil.getStreamContentAsString(cmanager_.getInputStream(location + path));
}
catch (Exception ignore)
{
@@ -476,32 +462,39 @@
}
}
- private String getPathConfig(NewPortalConfig portalConfig, String owner, String dataType, boolean notTemplate)
+ private String getPathConfig(NewPortalConfig portalConfig, String owner, String fileName, boolean isTemplate)
{
String path = "";
- if (!notTemplate)
+ if (isTemplate)
{
String ownerType = portalConfig.getOwnerType();
- path = "/" + ownerType + "/template/" + portalConfig.getTemplateOwner() + "/" + dataType + ".xml";
+ path = "/" + ownerType + "/template/" + portalConfig.getTemplateName() + "/" + fileName + ".xml";
}
else
{
String ownerType = portalConfig.getOwnerType();
- path = "/" + ownerType + "/" + owner + "/" + dataType + ".xml";
+ path = "/" + ownerType + "/" + owner + "/" + fileName + ".xml";
}
return path;
}
public Page createPageFromTemplate(String ownerType, String owner, String temp) throws Exception
{
- return fromXML(ownerType, owner, getTemplateConfig(temp, "page"), Page.class);
+ String path = pageTemplatesLocation_ + "/" + temp + "/page.xml";
+ InputStream is = cmanager_.getInputStream(path);
+ String xml = IOUtil.getStreamContentAsString(is);
+ return fromXML(ownerType, owner, xml, Page.class);
}
- private String getTemplateConfig(String name, String dataType) throws Exception
+ public String getTemplateConfig(String type, String name)
{
- String path = pageTemplateConfig_.getLocation() + "/" + name + "/" + dataType + ".xml";
- InputStream is = cmanager_.getInputStream(path);
- return IOUtil.getStreamContentAsString(is);
+ for (SiteConfigTemplates tempConfig : templateConfigs)
+ {
+ Set<String> templates = tempConfig.getTemplates(type);
+ if (templates != null && templates.contains(name))
+ return tempConfig.getLocation();
+ }
+ return null;
}
// Deserializing code
Deleted: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/PageTemplateConfig.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/PageTemplateConfig.java 2010-02-10 10:55:19 UTC (rev 1615)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/PageTemplateConfig.java 2010-02-10 12:54:25 UTC (rev 1616)
@@ -1,69 +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.portal.config;
-
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS
- * Author : Pham Thanh Tung
- * thanhtungty(a)gmail.com
- * Mar 3, 2008
- */
-public class PageTemplateConfig
-{
-
- String location;
-
- List<String> templates;
-
- /**
- * @return the location
- */
- public String getLocation()
- {
- return location;
- }
-
- /**
- * @param location the location to set
- */
- public void setLocation(String location)
- {
- this.location = location;
- }
-
- /**
- * @return the templates
- */
- public List<String> getTemplates()
- {
- return templates;
- }
-
- /**
- * @param templates the templates to set
- */
- public void setTemplates(List<String> templates)
- {
- this.templates = templates;
- }
-
-}
Added: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/SiteConfigTemplates.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/SiteConfigTemplates.java (rev 0)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/SiteConfigTemplates.java 2010-02-10 12:54:25 UTC (rev 1616)
@@ -0,0 +1,74 @@
+/**
+ * Copyright (C) 2010 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.portal.config;
+
+import org.exoplatform.portal.config.model.PortalConfig;
+
+import java.util.Set;
+
+/**
+ * @author <a href="trong.tran(a)exoplatform.com">Trong Tran</a>
+ * @version $Revision$
+ */
+
+public class SiteConfigTemplates
+{
+ private String location;
+
+ private Set<String> portalTemplates;
+
+ private Set<String> groupTemplates;
+
+ private Set<String> userTemplates;
+
+ /**
+ * @return the location
+ */
+ public String getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * @param location the locationPath to set
+ */
+ public void setLocation(String locationPath)
+ {
+ this.location = locationPath;
+ }
+
+ /**
+ * @return the type
+ */
+ public Set<String> getTemplates(String type)
+ {
+ if (type.equals(PortalConfig.PORTAL_TYPE))
+ {
+ return portalTemplates;
+ }
+ else if (type.equals(PortalConfig.GROUP_TYPE))
+ {
+ return groupTemplates;
+ }
+ else
+ {
+ return userTemplates;
+ }
+ }
+}
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java
===================================================================
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2010-02-10 10:55:19 UTC (rev 1615)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/UserPortalConfigService.java 2010-02-10 12:54:25 UTC (rev 1616)
@@ -59,7 +59,7 @@
private OrganizationService orgService_;
private NewPortalConfigListener newPortalConfigListener_;
-
+
private Log log = ExoLogger.getLogger("Portal:UserPortalConfigService");
public UserPortalConfigService(
@@ -201,24 +201,25 @@
/**
* This method should create a the portal config, pages and navigation according to the template name.
*
- * @param portalName the portal name
+ * @param siteName the Site name
* @param template the template to use
* @throws Exception any exception
*/
- public void createUserPortalConfig(String ownerType, String portalName, String template) throws Exception
+ public void createUserPortalConfig(String ownerType, String siteName, String template) throws Exception
{
- NewPortalConfig portalConfig = newPortalConfigListener_.getPortalConfig(ownerType);
+ String templatePath = newPortalConfigListener_.getTemplateConfig(ownerType, template);
- //
- portalConfig.setTemplateOwner(template);
- portalConfig.getPredefinedOwner().clear();
- portalConfig.getPredefinedOwner().add(portalName);
+ NewPortalConfig portalConfig = new NewPortalConfig(templatePath);
+ portalConfig.setTemplateName(template);
+ portalConfig.setOwnerType(ownerType);
- //
- newPortalConfigListener_.initPortletPreferencesDB(portalConfig);
- newPortalConfigListener_.initPortalConfigDB(portalConfig);
- newPortalConfigListener_.initPageDB(portalConfig);
- newPortalConfigListener_.initPageNavigationDB(portalConfig);
+ if (!portalConfig.getOwnerType().equals(PortalConfig.USER_TYPE))
+ {
+ newPortalConfigListener_.createPortletPreferences(portalConfig, siteName);
+ }
+ newPortalConfigListener_.createPortalConfig(portalConfig, siteName);
+ newPortalConfigListener_.createPage(portalConfig, siteName);
+ newPortalConfigListener_.createPageNavigation(portalConfig, siteName);
}
/**
@@ -229,7 +230,7 @@
*/
public void removeUserPortalConfig(String portalName) throws Exception
{
- removeUserPortalConfig("portal", portalName);
+ removeUserPortalConfig(PortalConfig.PORTAL_TYPE, portalName);
}
/**
@@ -497,7 +498,7 @@
public List<String> getAllPortalNames() throws Exception
{
List<String> list = new ArrayList<String>();
- Query<PortalConfig> query = new Query<PortalConfig>("portal", null, null, null, PortalConfig.class);
+ Query<PortalConfig> query = new Query<PortalConfig>(PortalConfig.PORTAL_TYPE, null, null, null, PortalConfig.class);
PageList<PortalConfig> pageList = storage_.find(query);
List<PortalConfig> configs = pageList.getAll();
for (PortalConfig ele : configs)
@@ -558,7 +559,7 @@
}
else
{
- newPortalConfigListener_.addPortalConfigs((NewPortalConfigListener)listener);
+ newPortalConfigListener_.mergePlugin((NewPortalConfigListener)listener);
}
}
}
@@ -576,7 +577,6 @@
//
RequestLifeCycle.begin(PortalContainer.getInstance());
- //
newPortalConfigListener_.run();
}
catch (Exception e)
Modified: portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration2.xml
===================================================================
--- portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration2.xml 2010-02-10 10:55:19 UTC (rev 1615)
+++ portal/trunk/component/portal/src/test/java/conf/exo.portal.component.portal-configuration2.xml 2010-02-10 12:54:25 UTC (rev 1616)
@@ -42,6 +42,44 @@
<description>In the run method, use try catch or not (value is true/false)</description>
<value>true</value>
</value-param>
+ <value-param>
+ <name>page.templates.location</name>
+ <description>the path to the location that contains Page templates</description>
+ <value>classpath:/portal/template/pages</value>
+ </value-param>
+ <object-param>
+ <name>site.templates.location</name>
+ <description>description</description>
+ <object type="org.exoplatform.portal.config.SiteConfigTemplates">
+ <field name="location">
+ <string>classpath:/portal</string>
+ </field>
+ <field name="portalTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>classic</string>
+ </value>
+ <value>
+ <string>test</string>
+ </value>
+ </collection>
+ </field>
+ <field name="groupTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>group</string>
+ </value>
+ </collection>
+ </field>
+ <field name="userTemplates">
+ <collection type="java.util.HashSet">
+ <value>
+ <string>user</string>
+ </value>
+ </collection>
+ </field>
+ </object>
+ </object-param>
<object-param>
<name>portal.configuration</name>
<description>description</description>
@@ -129,18 +167,6 @@
</field>
</object>
</object-param>
- <object-param>
- <name>page.templates</name>
- <description>List of page templates</description>
- <object type="org.exoplatform.portal.config.PageTemplateConfig">
- <field name="templates">
- <collection type="java.util.ArrayList"></collection>
- </field>
- <field name="location">
- <string>classpath:/portal/template/pages</string>
- </field>
- </object>
- </object-param>
</init-params>
</component-plugin>
</external-component-plugins>
Modified: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2010-02-10 10:55:19 UTC (rev 1615)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java 2010-02-10 12:54:25 UTC (rev 1616)
@@ -40,6 +40,8 @@
import org.exoplatform.services.listener.Event;
import org.exoplatform.services.listener.Listener;
import org.exoplatform.services.listener.ListenerService;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.GroupHandler;
import org.exoplatform.services.organization.OrganizationService;
import org.exoplatform.services.organization.User;
import org.exoplatform.services.organization.UserHandler;
@@ -816,6 +818,36 @@
}.execute(null);
}
+ public void testGroupTemplate()
+ {
+ new UnitTest()
+ {
+ public void execute() throws Exception
+ {
+ String groupName = "groupTest";
+ assertNull(storage_.getPortalConfig(PortalConfig.GROUP_TYPE, groupName));
+
+ //
+ GroupHandler groupHandler = orgService_.getGroupHandler();
+ Group group = groupHandler.createGroupInstance();
+ group.setGroupName(groupName);
+ group.setDescription("this is a group for test");
+ groupHandler.addChild(null, group, true);
+
+ //
+ PortalConfig cfg = storage_.getPortalConfig(PortalConfig.GROUP_TYPE, "/" + groupName);
+ assertNotNull(cfg);
+ Container container = cfg.getPortalLayout();
+ assertNotNull(container);
+ assertEquals(4, container.getChildren().size());
+ assertTrue(container.getChildren().get(2) instanceof PageBody);
+ assertTrue(((Application)container.getChildren().get(1)).getType() == ApplicationType.PORTLET);
+
+ groupHandler.removeGroup(group, true);
+ }
+ }.execute(null);
+ }
+
public void testCacheUserPortalConfig()
{
new UnitTest()
14 years, 11 months
gatein SVN: r1615 - portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal.
by do-not-reply@jboss.org
Author: tuancn
Date: 2010-02-10 05:55:19 -0500 (Wed, 10 Feb 2010)
New Revision: 1615
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties
Log:
GTNPORTAL-569: NoSuchDataException when delete page in Manage page
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties 2010-02-10 10:54:54 UTC (rev 1614)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_vi.properties 2010-02-10 10:55:19 UTC (rev 1615)
@@ -462,6 +462,7 @@
UIPageForm.tab.label.PermissionSetting=Phân quyền sử dụng
UIPageForm.tab.label.UIPageTemplateOptions=Trình bày trang
UIPageForm.msg.sameName=Tên của trang này đang tồn tại!
+UIPageForm.msg.notExistOrDeleted=Trang này không tồn tại hoặc đã bị xóa.
UIOwnerIdSelector.title.OwnerIdSelector=Tùy chọn mã chủ sở hữu
UIPopupGroupSelector.title.UIGroupSelector=Tùy chọn nhóm
UIPopupGroupSelector.title.GroupSelector=Chọn nhóm
14 years, 11 months
gatein SVN: r1614 - portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal.
by do-not-reply@jboss.org
Author: tuancn
Date: 2010-02-10 05:54:54 -0500 (Wed, 10 Feb 2010)
New Revision: 1614
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
Log:
GTNPORTAL-569: NoSuchDataException when delete page in Manage page
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-02-10 10:53:27 UTC (rev 1613)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-02-10 10:54:54 UTC (rev 1614)
@@ -484,6 +484,7 @@
UIPageForm.tab.label.PermissionSetting=Permission Setting
UIPageForm.tab.label.UIPageTemplateOptions=Page Layout
UIPageForm.msg.sameName=This page name already exists.
+UIPageForm.msg.notExistOrDeleted=This page doesn't exist or has been deleted.
UIOwnerIdSelector.title.OwnerIdSelector=Owner Id Selector
UIPopupGroupSelector.title.UIGroupSelector=Group Selector
UIPopupGroupSelector.title.GroupSelector=Select Group
14 years, 11 months
gatein SVN: r1613 - portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page.
by do-not-reply@jboss.org
Author: tuancn
Date: 2010-02-10 05:53:27 -0500 (Wed, 10 Feb 2010)
New Revision: 1613
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
Log:
GTNPORTAL-569: NoSuchDataException when delete page in Manage page
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2010-02-10 10:52:33 UTC (rev 1612)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2010-02-10 10:53:27 UTC (rev 1613)
@@ -23,6 +23,7 @@
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
+import org.exoplatform.portal.config.NoSuchDataException;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.UserPortalConfig;
import org.exoplatform.portal.config.UserPortalConfigService;
@@ -31,12 +32,15 @@
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.container.UIContainer;
+import org.exoplatform.portal.webui.portal.UIPortalComponent;
+import org.exoplatform.portal.webui.portal.UIPortalComposer;
import org.exoplatform.portal.webui.util.PortalDataMapper;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIMaskWorkspace;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.portal.webui.workspace.UIPortalToolPanel;
import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
+import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.InitParams;
import org.exoplatform.webui.config.Param;
@@ -353,7 +357,17 @@
page.setChildren(children);
uiPage.getChildren().clear();
- PortalDataMapper.toUIPage(uiPage, page);
+ try{
+ PortalDataMapper.toUIPage(uiPage, page);
+ } catch(NoSuchDataException de){
+ uiPortalApp.addMessage(new ApplicationMessage("UIPageForm.msg.notExistOrDeleted", null, ApplicationMessage.ERROR));
+ UIPortalComposer uiPortalComposer = (UIPortalComposer)uiPortalApp.findComponentById("UIPageEditor");
+ if(uiPortalComposer != null){
+ Event aboutEvent = new Event<UIPortalComposer>(uiPortalComposer, "Abort", event.getRequestContext());
+ uiPortalComposer.broadcast(aboutEvent, event.getExecutionPhase());
+ }
+ }
+
uiPage.setStorageId(storageId);
// if(page.getTemplate() == null) page.setTemplate(uiPage.getTemplate()) ;
if (page.getChildren() == null)
14 years, 11 months