use of org.alfresco.repo.client.config.ClientAppNotFoundException in project alfresco-repository by Alfresco.
the class ResetPasswordServiceImpl method getClientAppConfig.
@Override
public ClientApp getClientAppConfig(String clientName) {
ParameterCheck.mandatoryString("clientName", clientName);
ClientApp clientApp = clientAppConfig.getClient(clientName);
if (clientApp == null) {
throw new ClientAppNotFoundException("Client was not found [" + clientName + "]");
}
return clientApp;
}
use of org.alfresco.repo.client.config.ClientAppNotFoundException in project alfresco-repository by Alfresco.
the class QuickShareServiceImpl method sendEmailNotification.
@Override
public void sendEmailNotification(final QuickShareEmailRequest emailRequest) {
ParameterCheck.mandatory("emailRequest", emailRequest);
emailRequest.validate();
ClientApp clientApp = clientAppConfig.getClient(emailRequest.getClient());
if (clientApp == null) {
throw new ClientAppNotFoundException("Client was not found [" + emailRequest.getClient() + "]");
}
// Set the details of the person sending the email
final String authenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser();
final NodeRef senderNodeRef = personService.getPerson(authenticatedUser, false);
final Map<QName, Serializable> senderProps = nodeService.getProperties(senderNodeRef);
final String senderFirstName = (String) senderProps.get(ContentModel.PROP_FIRSTNAME);
final String senderLastName = (String) senderProps.get(ContentModel.PROP_LASTNAME);
final String senderFullName = ((senderFirstName != null ? senderFirstName + " " : "") + (senderLastName != null ? senderLastName : "")).trim();
// Set the default model information
Map<String, Serializable> templateModel = new HashMap<>(6);
templateModel.put(FTL_SENDER_FIRST_NAME, senderFirstName);
templateModel.put(FTL_SENDER_LAST_NAME, senderLastName);
final String sharedNodeUrl = getUrl(clientApp.getProperty(CONFIG_SHARED_LINK_BASE_URL), CONFIG_SHARED_LINK_BASE_URL) + '/' + emailRequest.getSharedId();
templateModel.put(FTL_SHARED_NODE_URL, sharedNodeUrl);
templateModel.put(FTL_SHARED_NODE_NAME, emailRequest.getSharedNodeName());
templateModel.put(FTL_SENDER_MESSAGE, emailRequest.getSenderMessage());
final String templateAssetsUrl = getUrl(clientApp.getTemplateAssetsUrl(), ClientAppConfig.PROP_TEMPLATE_ASSETS_URL);
templateModel.put(FTL_TEMPLATE_ASSETS_URL, templateAssetsUrl);
// Set the email details
Map<String, Serializable> actionParams = new HashMap<>();
// Email sender. By default the current-user's email address will not be used to send this mail.
// However, current-user's first and lastname will be used as the personal name.
actionParams.put(MailActionExecuter.PARAM_FROM, this.defaultEmailSender);
actionParams.put(MailActionExecuter.PARAM_FROM_PERSONAL_NAME, senderFullName);
actionParams.put(MailActionExecuter.PARAM_SUBJECT, DEFAULT_EMAIL_SUBJECT);
actionParams.put(MailActionExecuter.PARAM_SUBJECT_PARAMS, new Object[] { senderFirstName, senderLastName, emailRequest.getSharedNodeName() });
actionParams.put(MailActionExecuter.PARAM_IGNORE_SEND_FAILURE, emailRequest.isIgnoreSendFailure());
// Pick the template
final String templatePath = emailHelper.getEmailTemplate(clientApp.getName(), getSharedLinkEmailTemplatePath(clientApp), EMAIL_TEMPLATE_REF);
actionParams.put(MailActionExecuter.PARAM_TEMPLATE, templatePath);
actionParams.put(MailActionExecuter.PARAM_TEMPLATE_MODEL, (Serializable) templateModel);
actionParams.put(MailActionExecuter.PARAM_LOCALE, getDefaultIfNull(emailHelper.getUserLocaleOrDefault(authenticatedUser), emailRequest.getLocale()));
for (String to : emailRequest.getToEmails()) {
Map<String, Serializable> params = new HashMap<>(actionParams);
params.put(MailActionExecuter.PARAM_TO, to);
Action mailAction = actionService.createAction(MailActionExecuter.NAME, params);
actionService.executeAction(mailAction, null, false, true);
}
}
Aggregations