Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Jan 25, 2019
2 parents c1a6c7a + d186319 commit 16e3951
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 12 deletions.
Expand Up @@ -359,8 +359,8 @@ protected boolean processDeputyAssignments(boolean previewOnly) {
boolean isAnythingChanged = false;
for (AssignmentEditorDto dto : delegationsModel.getObject()) {
if (!UserDtoStatus.MODIFY.equals(dto.getStatus())) {
UserType user = dto.getDelegationOwner();
if (!previewOnly) {
UserType user = dto.getDelegationOwner();
saveDelegationToUser(user.asPrismObject(), dto);
}
isAnythingChanged = true;
Expand Down Expand Up @@ -401,6 +401,7 @@ protected void processAdditionalFocalObjectsForPreview(Map<PrismObject<UserType>
private void saveDelegationToUser(PrismObject<UserType> user, AssignmentEditorDto assignmentDto) {
OperationResult result = new OperationResult(OPERATION_SAVE);
try {
getPrismContext().adopt(user);
Collection<ObjectDelta<? extends ObjectType>> deltas = prepareDelegationDelta(user, assignmentDto);
getModelService().executeChanges(deltas, getOptions(false), createSimpleTask(OPERATION_SAVE), result);

Expand Down
Expand Up @@ -312,6 +312,10 @@ private void savePerformed(AjaxRequestTarget target, boolean approved) {
}
}
ObjectDelta delta = getWorkItemPanel().getDeltaFromForm();
if (delta != null) {
//noinspection unchecked
getPrismContext().adopt(delta);
}
try {
assumePowerOfAttorneyIfRequested(result);
getWorkflowService().completeWorkItem(dto.getWorkItemId(), approved, dto.getApproverComment(), delta, result);
Expand Down
Expand Up @@ -1012,6 +1012,27 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="attachment" type="tns:NotificationMessageAttachmentType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Message attachment(s) to be sent out.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.0</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="attachmentExpression" type="tns:ExpressionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
An expression that returns message attachment(s) to be sent out. Returned objects should be
of type NotificationMessageAttachmentType.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.0</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="watchAuxiliaryAttributes" type="xsd:boolean" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -1362,7 +1383,54 @@
<xsd:element name="subject" type="xsd:string" minOccurs="0" />
<xsd:element name="body" type="xsd:string" minOccurs="0" />
<xsd:element name="contentType" type="xsd:string" minOccurs="0" />
<xsd:element name="attachment" type="tns:NotificationMessageAttachmentType" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="NotificationMessageAttachmentType">
<xsd:annotation>
<xsd:documentation>
Message attachment for notifications. The content might be provided either directly (as arbitrary object)
or by referencing a file.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.0</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="contentType" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Content type for the attachment, e.g. image/png or text/html.
It is required.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:choice>
<xsd:element name="content" type="xsd:anyType">
<xsd:annotation>
<xsd:documentation>
Content of the attachment.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="contentFromFile" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Name of the file that provides the content for this attachment.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<!-- TODO some other option like referencing a library of objects? -->
</xsd:choice>
<xsd:element name="fileName" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
File name for the attachment. E.g. in the case of the mail transport it should be put into Content-Disposition header field.
If omitted and if contentFromFile is used, it should be derived from the name of that file.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Expand Up @@ -18,6 +18,7 @@

import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationMessageAttachmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationMessageType;
import org.jetbrains.annotations.NotNull;

Expand All @@ -36,6 +37,7 @@ public class Message implements DebugDumpable {
private String subject;
private String body; // todo
private String contentType;
@NotNull private List<NotificationMessageAttachmentType> attachments = new ArrayList<>();

public Message() {
}
Expand All @@ -48,6 +50,7 @@ public Message(NotificationMessageType message) {
subject = message.getSubject();
body = message.getBody();
contentType = message.getContentType();
attachments.addAll(message.getAttachment());
}

public String getBody() {
Expand Down Expand Up @@ -109,7 +112,12 @@ public void setFrom(String from) {
this.from = from;
}

@Override
@NotNull
public List<NotificationMessageAttachmentType> getAttachments() {
return attachments;
}

@Override
public String toString() {
return "Message{" +
"to='" + to + '\'' +
Expand All @@ -119,6 +127,7 @@ public String toString() {
", subject='" + subject + '\'' +
", contentType='" + contentType + '\'' +
", body='" + body + '\'' +
", attachments: " + attachments.size() + // TODO provide a short information here (the same as in debugDump below)
'}';
}

Expand Down Expand Up @@ -152,6 +161,8 @@ public String debugDump(int indent) {
rv.append("\n");

DebugUtil.debugDumpWithLabel(rv, "Body", DebugUtil.fixIndentInMultiline(indent+1, DebugDumpable.INDENT_STRING, body), indent+1);

// TODO attachments (instead of content provide only information about e.g. its size in case of byte[] or length in case of String)
return rv.toString();
}
}
Expand Up @@ -307,14 +307,6 @@ public PrismObject<ShadowType> getShadow(String oid, PrismObject<ShadowType> rep

resourceManager.modifyResourceAvailabilityStatus(resource.asPrismObject(),
AvailabilityStatusType.UP, parentResult);
// try to apply changes to the account only if the resource if UP
if (isCompensate(rootOptions) && repositoryShadow.asObjectable().getObjectChange() != null
&& repositoryShadow.asObjectable().getFailedOperationType() != null
&& resource.getOperationalState() != null && resource.getOperationalState()
.getLastAvailabilityStatus() == AvailabilityStatusType.UP) {
throw new GenericConnectorException(
"Found changes that have been not applied to the resource object yet. Trying to apply them now.");
}

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Shadow from repository:\n{}", repositoryShadow.debugDump(1));
Expand Down
Expand Up @@ -113,7 +113,7 @@ public abstract class AbstractDummyTest extends AbstractProvisioningIntegrationT
protected static final File ACCOUNT_LECHUCK_FILE = new File(TEST_DIR, "account-lechuck.xml");
protected static final String ACCOUNT_LECHUCK_OID = "c0c010c0-d34d-b44f-f11d-444400009aa9";
protected static final String ACCOUNT_LECHUCK_NAME = "lechuck";

protected static final File GROUP_PIRATES_FILE = new File(TEST_DIR, "group-pirates.xml");
protected static final String GROUP_PIRATES_OID = "c0c010c0-d34d-b44f-f11d-3332eeee0000";
protected static final String GROUP_PIRATES_NAME = "pirates";
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum
* Copyright (c) 2010-2019 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -94,6 +94,11 @@ public class TestDummyConsistency extends AbstractDummyTest {
private static final String ACCOUNT_BETTY_FULLNAME = "Betty Rubble";
private static final String ACCOUNT_ELIZABETH2_FULLNAME = "Her Majesty Queen Elizabeth II";

protected static final File ACCOUNT_SHADOW_MURRAY_LEGACY_FILE = new File(TEST_DIR, "account-shadow-murray-legacy.xml");
protected static final String ACCOUNT_SHADOW_MURRAY_LEGACY_OID = "34132742-2085-11e9-a956-17770b09881b";
private static final String ACCOUNT_MURRAY_USERNAME = "murray";
private static final String ACCOUNT_MURRAY_FULL_NAME = "Murray";

private XMLGregorianCalendar lastRequestStartTs;
private XMLGregorianCalendar lastRequestEndTs;
private XMLGregorianCalendar lastAttemptStartTs;
Expand Down Expand Up @@ -2124,6 +2129,38 @@ public void test816AddAccountElizabethAfterDeathAlreadyExists() throws Exception

// TODO: test no discovery options

/**
* Legacy consistency items.
* MID-5076
*/
@Test
public void test900GetAccountMurrayLegacy() throws Exception {
final String TEST_NAME = "test900GetAccountMurrayLegacy";
displayTestTitle(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
dummyResource.resetBreakMode();

dummyResourceCtl.addAccount(ACCOUNT_MURRAY_USERNAME, ACCOUNT_MURRAY_FULL_NAME);
repoAddObjectFromFile(ACCOUNT_SHADOW_MURRAY_LEGACY_FILE, result);

// WHEN
displayWhen(TEST_NAME);
PrismObject<ShadowType> accountMurray = provisioningService.getObject(ShadowType.class, ACCOUNT_SHADOW_MURRAY_LEGACY_OID, null, task, result);

// THEN
displayThen(TEST_NAME);
display("Result", result);
assertSuccess(result);
accountMurray.checkConsistence();

// TODO: assert Murray

assertSteadyResources();
}

private void assertUncreatedMorgan(int expectedAttemptNumber) throws Exception {

assertRepoShadow(shadowMorganOid)
Expand Down
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!-- MID-5076 -->
<account oid="34132742-2085-11e9-a956-17770b09881b"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance/ef2bc95b-76e0-59e2-86d6-9999dddddddd">
<name>murray</name>
<resourceRef oid="ef2bc95b-76e0-59e2-86d6-9999dddddddd" />
<objectClass>ri:AccountObjectClass</objectClass>
<kind>account</kind>

<!-- Legacy consistency items -->
<objectChange>
<t:changeType>modify</t:changeType>
<t:objectType>c:ShadowType</t:objectType>
<t:oid>34132742-2085-11e9-a956-17770b09881b</t:oid>
<t:itemDelta>
<t:modificationType>add</t:modificationType>
<t:path>c:attributes/ri:fullname</t:path>
<t:value xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xsd:string">Evil Devil Murray</t:value>
</t:itemDelta>
</objectChange>
<attemptNumber>0</attemptNumber>
<failedOperationType>modify</failedOperationType>

<attributes>
<icfs:name>murray</icfs:name>
<icfs:uid>murray</icfs:uid>
</attributes>
</account>

0 comments on commit 16e3951

Please sign in to comment.