Search in sources :

Example 16 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm in project perun by CESNET.

the class RegistrarBaseIntegrationTest method testAddFormItem_multipleEmbeddedGroupsItems.

@Test
public void testAddFormItem_multipleEmbeddedGroupsItems() throws PerunException {
    ApplicationForm form = registrarManager.getFormForVo(vo);
    // create 2 embedded groups form items
    ApplicationFormItem embeddedGroupsItem = new ApplicationFormItem();
    embeddedGroupsItem.setType(ApplicationFormItem.Type.EMBEDDED_GROUP_APPLICATION);
    embeddedGroupsItem.setShortname("embeddedGroups");
    registrarManager.addFormItem(session, form, embeddedGroupsItem);
    ApplicationFormItem embeddedGroupsItem2 = new ApplicationFormItem();
    embeddedGroupsItem2.setType(ApplicationFormItem.Type.EMBEDDED_GROUP_APPLICATION);
    embeddedGroupsItem2.setShortname("embeddedGroups2");
    assertThrows(MultipleApplicationFormItemsException.class, () -> {
        registrarManager.addFormItem(session, form, embeddedGroupsItem2);
    });
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) ApplicationFormItem(cz.metacentrum.perun.registrar.model.ApplicationFormItem) Test(org.junit.Test)

Example 17 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm in project perun by CESNET.

the class MailManagerImpl method getInvitationMessage.

/**
 * Initialize MimeMessage for invitation, that will be sent to user. Initialization takes care of following:
 * - set FROM, set TO, set TEXT, set SUBJECT
 */
private MimeMessage getInvitationMessage(Vo vo, Group group, String language, String to, Application app, String name, User user) throws FormNotExistsException, RegistrarException, MessagingException {
    if (language == null) {
        language = LANG_EN;
        language = getLanguageFromVoAndGroupAttrs(vo, group, language);
    }
    ApplicationForm form = getForm(vo, group);
    ApplicationMail mail = getMail(form, AppType.INITIAL, MailType.USER_INVITE);
    MimeMessage message = mailSender.createMimeMessage();
    setFromMailAddress(message, app);
    setRecipient(message, to);
    // get language
    Locale lang = new Locale(language);
    // get localized subject and text
    String mailText = getMailTextInvitation(mail, lang, vo, group, user, name);
    message.setText(mailText);
    String mailSubject = getMailSubjectInvitation(mail, lang, vo, group, user, name);
    message.setSubject(mailSubject);
    return message;
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) MimeMessage(javax.mail.internet.MimeMessage) ApplicationMail(cz.metacentrum.perun.registrar.model.ApplicationMail)

Example 18 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm in project perun by CESNET.

the class MailManagerImpl method copyMailsFromVoToGroup.

@Override
public void copyMailsFromVoToGroup(PerunSession sess, Vo fromVo, Group toGroup, boolean reverse) throws PerunException {
    perun.getVosManagerBl().checkVoExists(sess, fromVo);
    perun.getGroupsManagerBl().checkGroupExists(sess, toGroup);
    // Authorization
    if (!AuthzResolver.authorizedInternal(sess, "copyMailsFromVoToGroup_Vo_Group_boolean_policy", fromVo) || !AuthzResolver.authorizedInternal(sess, "copyMailsFromVoToGroup_Vo_Group_boolean_policy", toGroup)) {
        throw new PrivilegeException(sess, "copyMailsFromVoToGroup");
    }
    if (reverse) {
        // copy notifications from Group to VO
        ApplicationForm voForm = registrarManager.getFormForVo(fromVo);
        ApplicationForm groupForm = registrarManager.getFormForGroup(toGroup);
        copyApplicationMails(sess, groupForm, voForm);
    } else {
        // copy notifications from VO to Group
        ApplicationForm voForm = registrarManager.getFormForVo(fromVo);
        ApplicationForm groupForm = registrarManager.getFormForGroup(toGroup);
        copyApplicationMails(sess, voForm, groupForm);
    }
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm)

Example 19 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm in project perun by CESNET.

the class MailManagerImpl method copyMailsFromVoToVo.

@Override
public void copyMailsFromVoToVo(PerunSession sess, Vo fromVo, Vo toVo) throws PerunException {
    perun.getVosManagerBl().checkVoExists(sess, fromVo);
    perun.getVosManagerBl().checkVoExists(sess, toVo);
    // Authorization
    if (!AuthzResolver.authorizedInternal(sess, "copyMailsFromVoToVo_Vo_Vo_policy", fromVo) || !AuthzResolver.authorizedInternal(sess, "copyMailsFromVoToVo_Vo_Vo_policy", toVo)) {
        throw new PrivilegeException(sess, "copyMailsFromVoToVo");
    }
    ApplicationForm formFrom = registrarManager.getFormForVo(fromVo);
    ApplicationForm formTo = registrarManager.getFormForVo(toVo);
    copyApplicationMails(sess, formFrom, formTo);
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm)

Example 20 with ApplicationForm

use of cz.metacentrum.perun.registrar.model.ApplicationForm in project perun by CESNET.

the class AppAutoRejectionSchedulerTest method voAdminIgnoredCustomMessageByPreferredLangFromApplication.

@Test
public void voAdminIgnoredCustomMessageByPreferredLangFromApplication() throws Exception {
    System.out.println(CLASS_NAME + "voAdminIgnoredCustomMessageByPreferredLangFromApplication");
    ApplicationForm voform = registrarManager.getFormForVo(vo);
    registrarManager.addFormItem(session, voform, new ApplicationFormItem(-1, "lang", true, ApplicationFormItem.Type.TEXTFIELD, null, null, A_U_D_PREF_LANG, ""));
    setUpAndSubmitAppForPotentialAutoRejection(70, null, VO_APP_EXP_RULES, "cs", null);
    String messageTemplate = "Vase zadost do %vo_name% byla zamitnuta";
    String expectedReason = "Vase zadost do " + vo.getName() + " byla zamitnuta";
    setVoMessagesAttribute("ignoredByAdmin-cs", messageTemplate);
    ReflectionTestUtils.invokeMethod(spyScheduler, "voApplicationsAutoRejection", List.of(vo));
    verify(mockMailManager).sendMessage(any(), any(), eq(expectedReason), eq(null));
}
Also used : ApplicationForm(cz.metacentrum.perun.registrar.model.ApplicationForm) ApplicationFormItem(cz.metacentrum.perun.registrar.model.ApplicationFormItem) Test(org.junit.Test)

Aggregations

ApplicationForm (cz.metacentrum.perun.registrar.model.ApplicationForm)22 Test (org.junit.Test)13 ApplicationFormItem (cz.metacentrum.perun.registrar.model.ApplicationFormItem)11 Group (cz.metacentrum.perun.core.api.Group)8 ApplicationFormItemData (cz.metacentrum.perun.registrar.model.ApplicationFormItemData)7 User (cz.metacentrum.perun.core.api.User)6 Application (cz.metacentrum.perun.registrar.model.Application)6 GroupsManager (cz.metacentrum.perun.core.api.GroupsManager)5 RichApplication (cz.metacentrum.perun.registrar.model.RichApplication)5 ApplicationMail (cz.metacentrum.perun.registrar.model.ApplicationMail)4 ExtSource (cz.metacentrum.perun.core.api.ExtSource)2 Vo (cz.metacentrum.perun.core.api.Vo)2 ApplicationMailNotExistsException (cz.metacentrum.perun.registrar.exceptions.ApplicationMailNotExistsException)2 RegistrarException (cz.metacentrum.perun.registrar.exceptions.RegistrarException)2 MailText (cz.metacentrum.perun.registrar.model.ApplicationMail.MailText)2 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)2 EmptyResultDataAccessException (org.springframework.dao.EmptyResultDataAccessException)2 MailForGroupIdUpdated (cz.metacentrum.perun.audit.events.MailManagerEvents.MailForGroupIdUpdated)1 MailForVoIdUpdated (cz.metacentrum.perun.audit.events.MailManagerEvents.MailForVoIdUpdated)1 MailSentForApplication (cz.metacentrum.perun.audit.events.MailManagerEvents.MailSentForApplication)1