Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

NXP-6499 : Add request list in Admin Center with accept/reject actions.

  • Loading branch information...
commit d344ad01b9c5512a381b9da77ece0ac753c8c7da 1 parent f3aa970
Quentin Lamerand authored
Showing with 387 additions and 1 deletion.
  1. +12 −0 pom.xml
  2. +38 −0 src/main/java/org/nuxeo/ecm/user/registration/UserRegistrationComponent.java
  3. +7 −0 src/main/java/org/nuxeo/ecm/user/registration/UserRegistrationConfiguration.java
  4. +10 −0 src/main/java/org/nuxeo/ecm/user/registration/UserRegistrationService.java
  5. +79 −0 src/main/java/org/nuxeo/ecm/user/registration/actions/UserRegistrationActions.java
  6. +4 −1 src/main/resources/META-INF/MANIFEST.MF
  7. +25 −0 src/main/resources/OSGI-INF/deployment-fragment.xml
  8. +5 −0 src/main/resources/OSGI-INF/l10n/messages_en.properties
  9. +5 −0 src/main/resources/OSGI-INF/l10n/messages_fr.properties
  10. +21 −0 src/main/resources/OSGI-INF/user-registration-actions-contrib.xml
  11. +35 −0 src/main/resources/OSGI-INF/user-registration-contentviews-contrib.xml
  12. +116 −0 src/main/resources/OSGI-INF/user-registration-layouts-contrib.xml
  13. +7 −0 src/main/resources/OSGI-INF/user-registration-lifecycle-contrib.xml
  14. 0  src/main/resources/seam.properties
  15. +7 −0 src/main/resources/web/nuxeo.war/incl/userregistration/requests.xhtml
  16. +8 −0 src/main/resources/web/nuxeo.war/widgets/user_request_accept_widget_template.xhtml
  17. +8 −0 src/main/resources/web/nuxeo.war/widgets/user_request_reject_widget_template.xhtml
View
12 pom.xml
@@ -29,6 +29,14 @@
<groupId>org.nuxeo.ecm.core</groupId>
<artifactId>nuxeo-core-event</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-ui-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-webapp-base</artifactId>
+ </dependency>
<dependency>
<groupId>commons-lang</groupId>
@@ -38,5 +46,9 @@
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>jboss-seam</artifactId>
+ </dependency>
</dependencies>
</project>
View
38 src/main/java/org/nuxeo/ecm/user/registration/UserRegistrationComponent.java
@@ -210,6 +210,32 @@ public void run() throws ClientException {
}
}
+ protected class RegistrationRejector extends UnrestrictedSessionRunner {
+
+ protected String uuid;
+ protected Map<String, Serializable> additionnalInfo;
+
+ public RegistrationRejector(String registrationUuid, Map<String, Serializable> additionnalInfo) {
+ super(getTargetRepositoryName());
+ this.uuid=registrationUuid;
+ this.additionnalInfo=additionnalInfo;
+ }
+
+ @Override
+ public void run() throws ClientException {
+
+ DocumentModel doc = session.getDocument(new IdRef(uuid));
+
+ doc.setPropertyValue("registration:accepted", false);
+ if (doc.getAllowedStateTransitions().contains("reject")) {
+ doc.followTransition("reject");
+ }
+ doc = session.saveDocument(doc);
+ session.save();
+
+ sendEvent(session, doc, UserRegistrationService.REGISTRATION_REJECTED_EVENT);
+ }
+ }
protected class RegistrationValidator extends UnrestrictedSessionRunner {
@@ -354,6 +380,13 @@ public void acceptRegistrationRequest(String requestId, Map<String, Serializable
}
+ public void rejectRegistrationRequest(String requestId, Map<String, Serializable> additionnalInfo) throws ClientException, UserRegistrationException {
+
+ RegistrationRejector rejector = new RegistrationRejector(requestId, additionnalInfo);
+ rejector.runUnrestricted();
+
+ }
+
public Map<String, Serializable> validateRegistration(String requestId) throws ClientException, UserRegistrationException {
RegistrationValidator validator = new RegistrationValidator(requestId);
@@ -425,4 +458,9 @@ public NuxeoPrincipal createUser(CoreSession session,
return factory.createUser(session, registrationDoc);
}
+ @Override
+ public UserRegistrationConfiguration getConfiguration() {
+ return configuration;
+ }
+
}
View
7 src/main/java/org/nuxeo/ecm/user/registration/UserRegistrationConfiguration.java
@@ -52,6 +52,9 @@
@XNode("registrationUserFactory")
private Class<? extends RegistrationUserFactory> registrationUserFactory;
+ @XNode("validationRelUrl")
+ private String validationRelUrl;
+
public String getRequestDocType() {
return requestDocType;
}
@@ -92,4 +95,8 @@ public String getSuccessEmailTemplate() {
return registrationUserFactory;
}
+ public String getValidationRelUrl() {
+ return validationRelUrl;
+ }
+
}
View
10 src/main/java/org/nuxeo/ecm/user/registration/UserRegistrationService.java
@@ -33,6 +33,7 @@
// events fired by the service impl
public static final String REGISTRATION_SUBMITTED_EVENT = "registrationSubmitted";
public static final String REGISTRATION_ACCEPTED_EVENT = "registrationAccepted";
+ public static final String REGISTRATION_REJECTED_EVENT = "registrationRejected";
public static final String REGISTRATION_VALIDATED_EVENT = "registrationValidated";
/**
@@ -50,6 +51,13 @@
void acceptRegistrationRequest(String requestId, Map<String, Serializable> additionnalInfo) throws ClientException, UserRegistrationException ;
/**
+ * reject the registration request
+ *
+ * @param requestId
+ */
+ void rejectRegistrationRequest(String requestId, Map<String, Serializable> additionnalInfo) throws ClientException, UserRegistrationException ;
+
+ /**
* Validate a registration request and generate the target User
*
* @param requestId
@@ -64,4 +72,6 @@
Map<String, Serializable> validateRegistrationAndSendEmail(String requestId, Map<String, Serializable> additionnalInfo) throws ClientException, UserRegistrationException ;
NuxeoPrincipal createUser(CoreSession session, DocumentModel registrationDoc) throws ClientException, UserRegistrationException;
+
+ UserRegistrationConfiguration getConfiguration();
}
View
79 src/main/java/org/nuxeo/ecm/user/registration/actions/UserRegistrationActions.java
@@ -0,0 +1,79 @@
+/*
+ * (C) Copyright 2011 Nuxeo SAS (http://nuxeo.com/) and contributors.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser General Public License
+ * (LGPL) version 2.1 which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * This library 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.
+ * Contributors:
+ * Nuxeo - initial API and implementation
+ */
+
+package org.nuxeo.ecm.user.registration.actions;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.nuxeo.ecm.core.api.ClientException;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.platform.ui.web.util.BaseURL;
+import org.nuxeo.ecm.user.registration.UserRegistrationException;
+import org.nuxeo.ecm.user.registration.UserRegistrationService;
+import org.nuxeo.ecm.webapp.helpers.EventManager;
+import org.nuxeo.runtime.api.Framework;
+
+@Name("userRegistrationActions")
+@Scope(ScopeType.CONVERSATION)
+public class UserRegistrationActions {
+
+ protected UserRegistrationService userRegistrationService;
+
+ public String getDocType() throws ClientException {
+ return getUserRegistrationService().getConfiguration().getRequestDocType();
+ }
+
+ public String getValidationBaseUrl() throws ClientException {
+ return BaseURL.getBaseURL()
+ + getUserRegistrationService().getConfiguration().getValidationRelUrl();
+ }
+
+ public void acceptRegistrationRequest(DocumentModel request)
+ throws UserRegistrationException, ClientException {
+ Map<String, Serializable> additionalInfo = new HashMap<String, Serializable>();
+ additionalInfo.put("validationBaseURL", getValidationBaseUrl());
+ getUserRegistrationService().acceptRegistrationRequest(request.getId(),
+ additionalInfo);
+ EventManager.raiseEventsOnDocumentChange(request);
+ }
+
+ public void rejectRegistrationRequest(DocumentModel request)
+ throws UserRegistrationException, ClientException {
+ Map<String, Serializable> additionalInfo = new HashMap<String, Serializable>();
+ additionalInfo.put("validationBaseURL", getValidationBaseUrl());
+ getUserRegistrationService().rejectRegistrationRequest(request.getId(),
+ additionalInfo);
+ EventManager.raiseEventsOnDocumentChange(request);
+ }
+
+ protected UserRegistrationService getUserRegistrationService()
+ throws ClientException {
+ if (userRegistrationService == null) {
+ try {
+ userRegistrationService = Framework.getService(UserRegistrationService.class);
+ } catch (Exception e) {
+ throw new ClientException(
+ "Failed to get UserRegistrationService", e);
+ }
+ }
+ return userRegistrationService;
+ }
+}
View
5 src/main/resources/META-INF/MANIFEST.MF
@@ -7,4 +7,7 @@ Bundle-Version: 1.0.0
Nuxeo-Component: OSGI-INF/user-registration-core-types-contrib.xml,
OSGI-INF/user-registration-lifecycle-contrib.xml,
OSGI-INF/user-registration-service-framework.xml,
- OSGI-INF/user-registration-listener-contrib.xml
+ OSGI-INF/user-registration-listener-contrib.xml,
+ OSGI-INF/user-registration-actions-contrib.xml,
+ OSGI-INF/user-registration-layouts-contrib.xml,
+ OSGI-INF/user-registration-contentviews-contrib.xml
View
25 src/main/resources/OSGI-INF/deployment-fragment.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<fragment version="1">
+
+ <require>org.nuxeo.ecm.platform.lang</require>
+ <require>org.nuxeo.ecm.webapp.core</require>
+
+ <install>
+ <!-- unzip the war template -->
+ <unzip from="${bundle.fileName}" to="/" prefix="web">
+ <include>web/nuxeo.war/**</include>
+ </unzip>
+
+ <delete path="${bundle.fileName}.tmp" />
+ <mkdir path="${bundle.fileName}.tmp" />
+ <unzip from="${bundle.fileName}" to="${bundle.fileName}.tmp" />
+
+ <append from="${bundle.fileName}.tmp/OSGI-INF/l10n/messages_en.properties"
+ to="nuxeo.war/WEB-INF/classes/messages_en.properties" addNewLine="true" />
+ <append from="${bundle.fileName}.tmp/OSGI-INF/l10n/messages_fr.properties"
+ to="nuxeo.war/WEB-INF/classes/messages_fr.properties" addNewLine="true" />
+ <delete path="${bundle.fileName}.tmp" />
+
+ </install>
+
+</fragment>
View
5 src/main/resources/OSGI-INF/l10n/messages_en.properties
@@ -0,0 +1,5 @@
+admcommand.userregistration=User Registration
+tab.userregistration.requests=User registration requests
+label.userinfo.username=User name
+command.userrequest.accept=Accept
+command.userrequest.reject=Reject
View
5 src/main/resources/OSGI-INF/l10n/messages_fr.properties
@@ -0,0 +1,5 @@
+admcommand.userregistration=Enregistrement d'utilisateurs
+tab.userregistration.requests=Demandes d'enregistrement d'utilisateurs
+label.userinfo.username=Nom d'utilisateur
+command.userrequest.accept=Accepter
+command.userrequest.reject=Refuser
View
21 src/main/resources/OSGI-INF/user-registration-actions-contrib.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<component name="org.nuxeo.ecm.user.registration.actions.contrib">
+
+ <extension target="org.nuxeo.ecm.platform.actions.ActionService"
+ point="actions">
+
+ <action id="UserRegistration" link="view_admin-fragment.xhtml" label="admcommand.userregistration"
+ order="55">
+ <category>NUXEO_ADMIN</category>
+ <filter-id>only_for_manager</filter-id>
+ </action>
+
+ <action id="UserRegistrationRequests" link="/incl/userregistration/requests.xhtml"
+ label="tab.userregistration.requests" order="10">
+ <category>NUXEO_ADMIN_UserRegistration</category>
+ <filter-id>only_for_manager</filter-id>
+ </action>
+
+ </extension>
+
+</component>
View
35 src/main/resources/OSGI-INF/user-registration-contentviews-contrib.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<component name="org.nuxeo.ecm.user.registration.contentviews.contrib">
+
+ <extension target="org.nuxeo.ecm.platform.ui.web.ContentViewService"
+ point="contentViews">
+
+ <contentView name="user_requests_view">
+
+ <coreQueryPageProvider>
+ <property name="coreSession">#{documentManager}</property>
+ <pattern>
+ SELECT * FROM Document WHERE ecm:primaryType = ? AND ecm:isCheckedInVersion = 0
+ </pattern>
+ <parameter>#{userRegistrationActions.docType}</parameter>
+ <pageSize>20</pageSize>
+ </coreQueryPageProvider>
+
+ <refresh>
+ <event>documentChanged</event>
+ <event>documentChildrenChanged</event>
+ </refresh>
+ <cacheKey>only_one_cache</cacheKey>
+ <cacheSize>1</cacheSize>
+
+ <resultLayouts>
+ <layout name="user_requests_listing_layout" title="document_listing"
+ translateTitle="true" iconPath="/icons/document_listing_icon.png" />
+ </resultLayouts>
+
+ </contentView>
+
+ </extension>
+
+
+</component>
View
116 src/main/resources/OSGI-INF/user-registration-layouts-contrib.xml
@@ -0,0 +1,116 @@
+<?xml version="1.0"?>
+<component name="org.nuxeo.ecm.user.registration.layouts.contrib">
+
+ <require>org.nuxeo.ecm.platform.forms.layouts.webapp.base</require>
+
+ <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
+ point="layouts">
+
+ <layout name="user_requests_listing_layout">
+ <properties mode="any">
+ <property name="showListingHeader">true</property>
+ <property name="showRowEvenOddClass">true</property>
+ </properties>
+ <templates>
+ <template mode="any">/layouts/layout_listing_ajax_template.xhtml</template>
+ </templates>
+ <columns>
+ <column>
+ <properties mode="any">
+ <property name="useFirstWidgetLabelAsColumnHeader">true</property>
+ <property name="sortPropertyName">userinfo:username</property>
+ </properties>
+ <widget>user_request_username</widget>
+ </column>
+
+ <column name="creation_date">
+ <properties mode="any">
+ <property name="useFirstWidgetLabelAsColumnHeader">true</property>
+ <property name="sortPropertyName">dc:created</property>
+ <property name="label">label.dublincore.created</property>
+ </properties>
+ <properties mode="edit_sort_infos">
+ <property name="showInSortInfoSelection">true</property>
+ </properties>
+ <properties mode="edit_sort_infos_map">
+ <property name="showInSortInfoSelection">true</property>
+ </properties>
+ <widget>listing_creation_date</widget>
+ </column>
+
+ <column name="lifecycle">
+ <properties mode="any">
+ <property name="useFirstWidgetLabelAsColumnHeader">true</property>
+ <property name="sortPropertyName">
+ ecm:currentLifeCycleState
+ </property>
+ <property name="label">
+ label.content.header.currentLifecycleState
+ </property>
+ </properties>
+ <properties mode="edit_sort_infos">
+ <property name="showInSortInfoSelection">true</property>
+ </properties>
+ <widget>listing_lifecycle</widget>
+ </column>
+
+ <column>
+ <properties mode="any">
+ <property name="useFirstWidgetLabelAsColumnHeader">false</property>
+ </properties>
+ <widget>user_request_accept</widget>
+ </column>
+
+ <column>
+ <properties mode="any">
+ <property name="useFirstWidgetLabelAsColumnHeader">false</property>
+ </properties>
+ <widget>user_request_reject</widget>
+ </column>
+ </columns>
+ </layout>
+
+ </extension>
+
+ <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
+ point="widgets">
+
+ <widget name="user_request_username" type="text">
+ <labels>
+ <label mode="any">label.userinfo.username</label>
+ </labels>
+ <fields>
+ <field>data.userinfo.username</field>
+ </fields>
+ <widgetModes>
+ <mode value="any">view</mode>
+ </widgetModes>
+ </widget>
+
+ <widget name="user_request_accept" type="template">
+ <labels>
+ <label mode="any">command.userrequest.accept</label>
+ </labels>
+ <fields>
+ <field>data</field>
+ </fields>
+ <properties mode="any">
+ <property name="template">/widgets/user_request_accept_widget_template.xhtml</property>
+ </properties>
+ </widget>
+
+ <widget name="user_request_reject" type="template">
+ <labels>
+ <label mode="any">command.userrequest.reject</label>
+ </labels>
+ <fields>
+ <field>data</field>
+ </fields>
+ <properties mode="any">
+ <property name="template">/widgets/user_request_reject_widget_template.xhtml</property>
+ </properties>
+ </widget>
+
+ </extension>
+
+</component>
View
7 src/main/resources/OSGI-INF/user-registration-lifecycle-contrib.xml
@@ -9,6 +9,9 @@
<transition name="accept" destinationState="accepted">
<description>Accept the registration request</description>
</transition>
+ <transition name="reject" destinationState="rejected">
+ <description>Reject the registration request</description>
+ </transition>
<transition name="validate" destinationState="validated">
<description>Validate the registration request</description>
</transition>
@@ -20,6 +23,7 @@
<state name="created" description="Default state" initial="true">
<transitions>
<transition>accept</transition>
+ <transition>reject</transition>
</transitions>
</state>
<state name="accepted" description="Registration has been accepted">
@@ -27,6 +31,9 @@
<transition>validate</transition>
</transitions>
</state>
+ <state name="rejected" description="Registration has been rejected">
+ <transitions></transitions>
+ </state>
<state name="validated" description="Registration has been validated">
<transitions>
<transition>process</transition>
View
0  src/main/resources/seam.properties
No changes.
View
7 src/main/resources/web/nuxeo.war/incl/userregistration/requests.xhtml
@@ -0,0 +1,7 @@
+<div xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:nxu="http://nuxeo.org/nxweb/util">
+<nxu:set var="contentViewName" value="user_requests_view">
+ <ui:decorate template="/incl/content_view.xhtml" />
+</nxu:set>
+</div>
View
8 src/main/resources/web/nuxeo.war/widgets/user_request_accept_widget_template.xhtml
@@ -0,0 +1,8 @@
+<div xmlns:h="http://java.sun.com/jsf/html">
+
+ <h:commandLink
+ value="#{messages['command.userrequest.accept']}"
+ action="#{userRegistrationActions.acceptRegistrationRequest(field_0)}"
+ rendered="#{field_0.currentLifeCycleState == 'created'}" />
+
+</div>
View
8 src/main/resources/web/nuxeo.war/widgets/user_request_reject_widget_template.xhtml
@@ -0,0 +1,8 @@
+<div xmlns:h="http://java.sun.com/jsf/html">
+
+ <h:commandLink
+ value="#{messages['command.userrequest.reject']}"
+ action="#{userRegistrationActions.rejectRegistrationRequest(field_0)}"
+ rendered="#{field_0.currentLifeCycleState == 'created'}" />
+
+</div>
Please sign in to comment.
Something went wrong with that request. Please try again.