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 String REGISTRATION_CONFIGURATION_NAME = "configurationName"; 034 035 String REGISTRATION_DATA_DOC = "registrationDoc"; 036 037 String REGISTRATION_DATA_USER = "registeredUser"; 038 039 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 String submitRegistrationRequest(DocumentModel userRegistrationModel, Map<String, Serializable> additionnalInfo, 056 ValidationMethod validationMethod, boolean autoAccept) throws UserRegistrationException; 057 058 /** 059 * accept the registration request 060 */ 061 void acceptRegistrationRequest(String requestId, Map<String, Serializable> additionnalInfo) throws 062 UserRegistrationException; 063 064 /** 065 * reject the registration request 066 */ 067 void rejectRegistrationRequest(String requestId, Map<String, Serializable> additionnalInfo) throws 068 UserRegistrationException; 069 070 /** 071 * Validate a registration request and generate the target User 072 */ 073 Map<String, Serializable> validateRegistration(String requestId, Map<String, Serializable> additionnalInfo); 074 075 /** 076 * Validate a registration request and generate the target User 077 */ 078 Map<String, Serializable> validateRegistrationAndSendEmail(String requestId, 079 Map<String, Serializable> additionnalInfo) throws UserRegistrationException; 080 081 NuxeoPrincipal createUser(CoreSession session, DocumentModel registrationDoc) throws 082 UserRegistrationException; 083 084 /** 085 * Send a mail to the invited user to revive his invitation If an error occured while sending an email, it logs it 086 * and continue. 087 * 088 * @since 5.6 089 */ 090 void reviveRegistrationRequests(CoreSession session, List<DocumentModel> registrationDocs); 091 092 /** 093 * Delete a registration document 094 * 095 * @since 5.6 096 */ 097 void deleteRegistrationRequests(CoreSession session, List<DocumentModel> registrationDoc); 098 099 UserRegistrationConfiguration getConfiguration(); 100 101 /** 102 * Retrieve registrations for a document givent the username 103 * 104 * @since 5.6 105 */ 106 DocumentModelList getRegistrationsForUser(String docId, String username, String configurationName); 107 108 /** 109 * Return specific configuration for the specified name 110 * 111 * @param name configuration name 112 * @since 5.6 113 */ 114 UserRegistrationConfiguration getConfiguration(String name); 115 116 /** 117 * @since 5.6 118 */ 119 UserRegistrationConfiguration getConfiguration(DocumentModel requestDoc); 120 121 /** 122 * Get documentmodel that stores request configuration using RegistrationConfiguration facet. 123 */ 124 DocumentModel getRegistrationRulesDocument(CoreSession session, String configurationName); 125 126 /** 127 * Stores a resgitration request like submitRegistrationRequest with Document information 128 * 129 * @return a unique ID for it 130 * @since 5.6 131 */ 132 String submitRegistrationRequest(String configurationName, DocumentModel userRegistrationModel, 133 Map<String, Serializable> additionnalInfo, ValidationMethod validationMethod, boolean autoAccept) 134 throws UserRegistrationException; 135 136 /** 137 * Get registration rules adapter 138 * 139 * @since 5.6 140 */ 141 RegistrationRules getRegistrationRules(String configurationName); 142 143 /** 144 * List all registered onfiguration name 145 */ 146 Set<String> getConfigurationsName(); 147 148 /** 149 * The method checks if the request id is a valid one. 150 * 151 * @param requestId The value of the request id. 152 * @since 5.9.3 153 */ 154 void checkRequestId(String requestId) throws UserRegistrationException; 155 156 /** 157 * @return The name of the event when the registration is submitted. 158 * @since 5.9.3 159 */ 160 String getNameEventRegistrationSubmitted(); 161 162 /** 163 * @return The name of the event when the registration is accepted. 164 * @since 5.9.3 165 */ 166 String getNameEventRegistrationAccepted(); 167 168 /** 169 * @return The name of the event when the registration is rejected. 170 * @since 5.9.3 171 */ 172 String getNameEventRegistrationRejected(); 173 174 /** 175 * @return The name of the event when the registration is validated. 176 * @since 5.9.3 177 */ 178 String getNameEventRegistrationValidated(); 179 180}