Search in sources :

Example 46 with ObjectReport

use of org.hisp.dhis.feedback.ObjectReport in project dhis2-core by dhis2.

the class UserController method inviteUser.

/**
 * Creates a user invitation and invites the user.
 *
 * @param user user object parsed from the POST request.
 */
private ObjectReport inviteUser(User user, User currentUser, HttpServletRequest request) {
    RestoreOptions restoreOptions = user.getUsername() == null || user.getUsername().isEmpty() ? RestoreOptions.INVITE_WITH_USERNAME_CHOICE : RestoreOptions.INVITE_WITH_DEFINED_USERNAME;
    securityService.prepareUserForInvite(user);
    ImportReport importReport = createUser(user, currentUser);
    ObjectReport objectReport = getObjectReport(importReport);
    if (importReport.getStatus() == Status.OK && importReport.getStats().getCreated() == 1 && objectReport != null) {
        securityService.sendRestoreOrInviteMessage(user, ContextUtils.getContextPath(request), restoreOptions);
        log.info(String.format("An invite email was successfully sent to: %s", user.getEmail()));
    }
    return objectReport;
}
Also used : RestoreOptions(org.hisp.dhis.security.RestoreOptions) ImportReport(org.hisp.dhis.dxf2.metadata.feedback.ImportReport) ObjectReport(org.hisp.dhis.feedback.ObjectReport)

Aggregations

ObjectReport (org.hisp.dhis.feedback.ObjectReport)46 TypeReport (org.hisp.dhis.feedback.TypeReport)29 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)22 ErrorReport (org.hisp.dhis.feedback.ErrorReport)22 ArrayList (java.util.ArrayList)15 PreheatErrorReport (org.hisp.dhis.preheat.PreheatErrorReport)13 User (org.hisp.dhis.user.User)9 Schema (org.hisp.dhis.schema.Schema)7 List (java.util.List)6 AttributeValue (org.hisp.dhis.attribute.AttributeValue)6 Test (org.junit.jupiter.api.Test)6 IdentifiableObjectManager (org.hisp.dhis.common.IdentifiableObjectManager)5 ImportReport (org.hisp.dhis.dxf2.metadata.feedback.ImportReport)5 SchemaService (org.hisp.dhis.schema.SchemaService)5 Service (org.springframework.stereotype.Service)5 HashMap (java.util.HashMap)4 MetadataImportParams (org.hisp.dhis.dxf2.metadata.MetadataImportParams)4 WebMessage (org.hisp.dhis.dxf2.webmessage.WebMessage)4 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3