Skip to content

Commit

Permalink
MID-8842 ninja - file transport processor, "notificationConfiguration…
Browse files Browse the repository at this point in the history
…/file" marked deprecated (type was already deprecated
  • Loading branch information
1azyman committed Jul 25, 2023
1 parent ed2d45b commit dc29ef4
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2010-2023 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.schema.validator.processor;

import java.util.List;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.validator.UpgradeObjectProcessor;
import com.evolveum.midpoint.schema.validator.UpgradePhase;
import com.evolveum.midpoint.schema.validator.UpgradePriority;
import com.evolveum.midpoint.schema.validator.UpgradeType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

@SuppressWarnings("unused")
public class FileTransportProcessor implements UpgradeObjectProcessor<SystemConfigurationType> {

@Override
public UpgradePhase getPhase() {
return UpgradePhase.BEFORE;
}

@Override
public UpgradePriority getPriority() {
return UpgradePriority.OPTIONAL;
}

@Override
public UpgradeType getType() {
return UpgradeType.SEAMLESS;
}

@Override
public boolean isApplicable(PrismObject<?> object, ItemPath path) {
return matchParentTypeAndItemName(object, path, NotificationConfigurationType.class, NotificationConfigurationType.F_FILE);
}

@Override
public boolean process(PrismObject<SystemConfigurationType> object, ItemPath path) throws Exception {
SystemConfigurationType config = object.asObjectable();
NotificationConfigurationType notificationConfig = config.getNotificationConfiguration();

List<FileConfigurationType> files = notificationConfig.getFile();
if (files == null || files.isEmpty()) {
return false;
}

MessageTransportConfigurationType messageTransport = config.getMessageTransportConfiguration();
if (messageTransport == null) {
messageTransport = new MessageTransportConfigurationType();
config.setMessageTransportConfiguration(messageTransport);
}

for (FileConfigurationType transport : files) {
FileTransportConfigurationType ft = new FileTransportConfigurationType();
ft.setFile(transport.getFile());

copyTransport(transport, ft);

messageTransport.getFile().add(ft);
}

files.clear();

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@
<a:displayName>FileConfigurationType.details</a:displayName>
<a:deprecated>true</a:deprecated>
<a:deprecatedSince>4.5</a:deprecatedSince>
<a:plannedRemoval>4.7</a:plannedRemoval>
<a:plannedRemoval>5.0</a:plannedRemoval>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
Expand Down Expand Up @@ -808,9 +808,9 @@
<xsd:annotation>
<xsd:appinfo>
<!-- TODO: not deprecated yet because it breaks old GUI, see comments in NotificationConfigTabPanel -->
<!--<a:deprecated>true</a:deprecated>-->
<!--<a:deprecatedSince>4.5</a:deprecatedSince>-->
<!--<a:plannedRemoval>4.6</a:plannedRemoval>-->
<a:deprecated>true</a:deprecated>
<a:deprecatedSince>4.5</a:deprecatedSince>
<a:plannedRemoval>5.0</a:plannedRemoval>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private String getProcessorIdentifier(Class<?> processorClass) {
@Test
public void test30TestSystemConfig() throws Exception {
testUpgradeValidator("system-configuration.xml", result -> {
Assertions.assertThat(result.getItems()).hasSize(10);
Assertions.assertThat(result.getItems()).hasSize(11);

UpgradeValidationItem item = assertGetItem(result, getProcessorIdentifier(RoleCatalogCollectionsProcessor.class));
Assertions.assertThat(item.getDelta().getModifiedItems()).hasSize(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@


<messageTransportConfiguration>
<file>
<name>f1</name>
<file>a.csv</file>
<redirectToFile>redirect.csv</redirectToFile>
<debug>true</debug>
<whiteList>asdf</whiteList>
<blackList>jklo</blackList>
<recipientFilterExpression>
<script>
<code>
return null
</code>
</script>
</recipientFilterExpression>
</file>
<sms>
<name>s1</name>
<gateway>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@
<transport>custom1</transport>
</simpleUserNotifier>
</handler>
<file name="f1">
<file>a.csv</file>
<redirectToFile>redirect.csv</redirectToFile>
<debug>true</debug>
<whiteList>asdf</whiteList>
<blackList>jklo</blackList>
<recipientFilterExpression>
<script>
<code>
return null
</code>
</script>
</recipientFilterExpression>
</file>
<sms name="s1">
<gateway>
<urlExpression>
Expand Down

0 comments on commit dc29ef4

Please sign in to comment.