Permalink
Browse files

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

  • Loading branch information...
1 parent f3aa970 commit d344ad01b9c5512a381b9da77ece0ac753c8c7da Quentin Lamerand committed Apr 11, 2011
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>
@@ -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;
+ }
+
}
@@ -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;
+ }
+
}
@@ -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";
/**
@@ -49,6 +50,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
*
@@ -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();
}
@@ -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;
+ }
+}
@@ -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
@@ -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>
@@ -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
@@ -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
@@ -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>
@@ -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>
Oops, something went wrong.

0 comments on commit d344ad0

Please sign in to comment.