001/* 002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * Contributors: 016 * Nuxeo - initial API and implementation 017 */ 018 019package org.nuxeo.ecm.user.invite; 020 021import java.io.Serializable; 022import java.util.List; 023import java.util.Map; 024import java.util.Set; 025 026import org.nuxeo.ecm.core.api.CoreSession; 027import org.nuxeo.ecm.core.api.DocumentModel; 028import org.nuxeo.ecm.core.api.DocumentModelList; 029import org.nuxeo.ecm.core.api.NuxeoPrincipal; 030 031public interface UserInvitationService { 032 033 public static final String REGISTRATION_CONFIGURATION_NAME = "configurationName"; 034 035 public static final String REGISTRATION_DATA_DOC = "registrationDoc"; 036 037 public static final String REGISTRATION_DATA_USER = "registeredUser"; 038 039 public enum ValidationMethod { 040 EMAIL, NONE 041 } 042 043 /** 044 * Create a document model for the UserRegistration doctype. 045 * 046 * @param configurationName The name of the configuration. 047 * @return The document model 048 * @since 5.9.3 049 */ 050 DocumentModel getUserRegistrationModel(String configurationName); 051 052 /** 053 * Stores a registration request and return a unique ID for it 054 * 055 * @return 056 */ 057 String submitRegistrationRequest(DocumentModel userRegistrationModel, Map<String, Serializable> additionnalInfo, 058 ValidationMethod validationMethod, boolean autoAccept) throws UserRegistrationException; 059 060 /** 061 * accept the registration request 062 * 063 * @param requestId 064 */ 065 void acceptRegistrationRequest(String requestId, Map<String, Serializable> additionnalInfo) throws 066 UserRegistrationException; 067 068 /** 069 * reject the registration request 070 * 071 * @param requestId 072 */ 073 void rejectRegistrationRequest(String requestId, Map<String, Serializable> additionnalInfo) throws 074 UserRegistrationException; 075 076 /** 077 * Validate a registration request and generate the target User 078 * 079 * @param requestId 080 */ 081 Map<String, Serializable> validateRegistration(String requestId, Map<String, Serializable> additionnalInfo); 082 083 /** 084 * Validate a registration request and generate the target User 085 * 086 * @param requestId 087 */ 088 Map<String, Serializable> validateRegistrationAndSendEmail(String requestId, 089 Map<String, Serializable> additionnalInfo) throws UserRegistrationException; 090 091 NuxeoPrincipal createUser(CoreSession session, DocumentModel registrationDoc) throws 092 UserRegistrationException; 093 094 /** 095 * Send a mail to the invited user to revive his invitation If an error occured while sending an email, it logs it 096 * and continue. 097 * 098 * @since 5.6 099 */ 100 void reviveRegistrationRequests(CoreSession session, List<DocumentModel> registrationDocs); 101 102 /** 103 * Delete a registration document 104 * 105 * @since 5.6 106 */ 107 void deleteRegistrationRequests(CoreSession session, List<DocumentModel> registrationDoc); 108 109 UserRegistrationConfiguration getConfiguration(); 110 111 /** 112 * Retrieve registrations for a document givent the username 113 * 114 * @since 5.6 115 */ 116 DocumentModelList getRegistrationsForUser(String docId, String username, String configurationName); 117 118 /** 119 * Return specific configuration for the specified name 120 * 121 * @param name configuration name 122 * @since 5.6 123 */ 124 UserRegistrationConfiguration getConfiguration(String name); 125 126 /** 127 * @since 5.6 128 */ 129 UserRegistrationConfiguration getConfiguration(DocumentModel requestDoc); 130 131 /** 132 * Get documentmodel that stores request configuration using RegistrationConfiguration facet. 133 * 134 * @param session 135 * @return 136 */ 137 DocumentModel getRegistrationRulesDocument(CoreSession session, String configurationName); 138 139 /** 140 * Stores a resgitration request like submitRegistrationRequest with Document information 141 * 142 * @return a unique ID for it 143 * @since 5.6 144 */ 145 String submitRegistrationRequest(String configurationName, DocumentModel userRegistrationModel, 146 Map<String, Serializable> additionnalInfo, ValidationMethod validationMethod, boolean autoAccept) 147 throws UserRegistrationException; 148 149 /** 150 * Get registration rules adapter 151 * 152 * @since 5.6 153 */ 154 RegistrationRules getRegistrationRules(String configurationName); 155 156 /** 157 * List all registered onfiguration name 158 */ 159 Set<String> getConfigurationsName(); 160 161 /** 162 * The method checks if the request id is a valid one. 163 * 164 * @param requestId The value of the request id. 165 * @since 5.9.3 166 */ 167 void checkRequestId(String requestId) throws UserRegistrationException; 168 169 /** 170 * @return The name of the event when the registration is submitted. 171 * @since 5.9.3 172 */ 173 String getNameEventRegistrationSubmitted(); 174 175 /** 176 * @return The name of the event when the registration is accepted. 177 * @since 5.9.3 178 */ 179 String getNameEventRegistrationAccepted(); 180 181 /** 182 * @return The name of the event when the registration is rejected. 183 * @since 5.9.3 184 */ 185 String getNameEventRegistrationRejected(); 186 187 /** 188 * @return The name of the event when the registration is validated. 189 * @since 5.9.3 190 */ 191 String getNameEventRegistrationValidated(); 192 193}