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);
});
}
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;
}
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);
}
}
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);
}
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));
}
Aggregations