Skip to content

Commit

Permalink
Merge branch 'support-4.0' of https://github.com/Evolveum/midpoint in…
Browse files Browse the repository at this point in the history
…to support-4.0
  • Loading branch information
KaterynaHonchar committed Apr 20, 2020
2 parents b2585f4 + d5b2b88 commit 0765fa1
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 30 deletions.
Expand Up @@ -523,6 +523,9 @@ public static void save(Collection<ObjectDelta<? extends ObjectType>> deltas, Mo

page.getModelService().executeChanges(deltas, options, task, result);
} catch (Exception ex) {
if (ex instanceof CommonException) {
subResult.setUserFriendlyMessage(((CommonException) ex).getUserFriendlyMessage());
}
subResult.recordFatalError(ex.getMessage());
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save object", ex);
} finally {
Expand Down
Expand Up @@ -355,8 +355,14 @@ public OperationResult run() {
LOGGER.trace("Registration for user {} was successfull.", getUserModel().getObject());

} else {
String message;
if (result.getUserFriendlyMessage() != null) {
message = WebModelServiceUtils.translateMessage(result, this);
} else {
message = result.getMessage();
}
getSession().error(
createStringResource("PageSelfRegistration.registration.error", result.getMessage())
createStringResource("PageSelfRegistration.registration.error", message)
.getString());
// removePassword(target);
updateCaptcha(target);
Expand Down
Expand Up @@ -160,13 +160,15 @@ public void setResult(OperationResult result) {
this.result = result;
}

ScriptExpressionEvaluationContext setupThreadLocal() {
@SuppressWarnings("WeakerAccess") // Can be used e.g. from the overlay code
public ScriptExpressionEvaluationContext setupThreadLocal() {
ScriptExpressionEvaluationContext oldContext = THREAD_LOCAL_CONTEXT.get();
THREAD_LOCAL_CONTEXT.set(this);
return oldContext;
}

void cleanupThreadLocal(ScriptExpressionEvaluationContext oldContext) {
@SuppressWarnings("WeakerAccess") // Can be used e.g. from the overlay code
public void cleanupThreadLocal(ScriptExpressionEvaluationContext oldContext) {
THREAD_LOCAL_CONTEXT.set(oldContext);
}

Expand Down
Expand Up @@ -316,30 +316,34 @@ public String getContentType() {

mimeMessage.setContent(multipart);
javax.mail.Transport t = session.getTransport("smtp");
if (StringUtils.isNotEmpty(mailServerConfigurationType.getUsername())) {
ProtectedStringType passwordProtected = mailServerConfigurationType.getPassword();
String password = null;
if (passwordProtected != null) {
try {
password = protector.decryptString(passwordProtected);
} catch (EncryptionException e) {
String msg = "Couldn't send mail message to " + mailMessage.getTo() + " via " + host + ", because the plaintext password value couldn't be obtained. Trying another mail server, if there is any.";
LoggingUtils.logException(LOGGER, msg, e);
resultForServer.recordFatalError(msg, e);
continue;
try {
if (StringUtils.isNotEmpty(mailServerConfigurationType.getUsername())) {
ProtectedStringType passwordProtected = mailServerConfigurationType.getPassword();
String password = null;
if (passwordProtected != null) {
try {
password = protector.decryptString(passwordProtected);
} catch (EncryptionException e) {
String msg = "Couldn't send mail message to " + mailMessage.getTo() + " via " + host + ", because the plaintext password value couldn't be obtained. Trying another mail server, if there is any.";
LoggingUtils.logException(LOGGER, msg, e);
resultForServer.recordFatalError(msg, e);
continue;
}
}
t.connect(mailServerConfigurationType.getUsername(), password);
} else {
t.connect();
}
t.connect(mailServerConfigurationType.getUsername(), password);
} else {
t.connect();
t.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
LOGGER.info("Message sent successfully to " + mailMessage.getTo() + " via server " + host + ".");
resultForServer.recordSuccess();
result.recordSuccess();
long duration = System.currentTimeMillis() - start;
task.recordState("Notification mail sent successfully via " + host + ", in " + duration + " ms overall.");
task.recordNotificationOperation(NAME, true, duration);
} finally {
t.close();
}
t.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
LOGGER.info("Message sent successfully to " + mailMessage.getTo() + " via server " + host + ".");
resultForServer.recordSuccess();
result.recordSuccess();
long duration = System.currentTimeMillis() - start;
task.recordState("Notification mail sent successfully via " + host + ", in " + duration + " ms overall.");
task.recordNotificationOperation(NAME, true, duration);
return;
} catch (MessagingException e) {
String msg = "Couldn't send mail message to " + mailMessage.getTo() + " via " + host + ", trying another mail server, if there is any";
Expand Down
Expand Up @@ -236,14 +236,16 @@ public boolean hasContentToShow(boolean watchAuxiliaryAttributes) {
ObjectDelta<? extends ObjectType> summarizedDelta;
try {
summarizedDelta = getSummarizedFocusDeltas();
if (!summarizedDelta.isModify()) {
if (summarizedDelta == null) {
return false;
} else if (summarizedDelta.isAdd() || summarizedDelta.isDelete()) {
return true;
} else if (!getTextFormatter().containsVisibleModifiedItems(summarizedDelta.getModifications(),
} else if (getTextFormatter().containsVisibleModifiedItems(summarizedDelta.getModifications(),
false, watchAuxiliaryAttributes)) {
return true;
} else {
LOGGER.trace("No relevant attributes in modify delta (watchAux={})", watchAuxiliaryAttributes);
return false;
} else {
return true;
}
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Unable to check if there's content to show; focus context = {}", t, focusContext.debugDump());
Expand All @@ -255,7 +257,9 @@ public boolean hasContentToShow(boolean watchAuxiliaryAttributes) {
public String getContentAsFormattedList(boolean showAuxiliaryAttributes) {
try {
ObjectDelta<? extends ObjectType> summarizedDelta = getSummarizedFocusDeltas();
if (summarizedDelta.isAdd()) {
if (summarizedDelta == null) {
return ""; // should not happen
} else if (summarizedDelta.isAdd()) {
return getTextFormatter().formatObject(summarizedDelta.getObjectToAdd(), false, showAuxiliaryAttributes);
} else if (summarizedDelta.isModify()) {
ModelElementContext<?> focusContext = modelContext.getFocusContext();
Expand Down
Expand Up @@ -18,6 +18,9 @@ public enum RTaskWaitingReason implements SchemaEnum<TaskWaitingReasonType> {

OTHER_TASKS(TaskWaitingReasonType.OTHER_TASKS),

// See MID-6117.
PLACEHOLDER(null),

OTHER(TaskWaitingReasonType.OTHER);

private TaskWaitingReasonType reason;
Expand Down
Expand Up @@ -317,8 +317,9 @@ public static <T extends SchemaEnum> T getRepoEnumValue(Object object, Class<T>
}
Object[] values = type.getEnumConstants();
for (Object value : values) {
//noinspection unchecked
T schemaEnum = (T) value;
if (schemaEnum.getSchemaValue().equals(object)) {
if (object.equals(schemaEnum.getSchemaValue())) {
return schemaEnum;
}
}
Expand Down

0 comments on commit 0765fa1

Please sign in to comment.