Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class MtaArchiveHelper {

// Attribute names:
private static final String ATTR_CREATED_BY = "Created-By";
public static final String ATTR_MTA_RESOURCE = "MTA-Resource";
public static final String ATTR_MTA_REQUIRES_DEPENDENCY = "MTA-Requires";
public static final String ATTR_MTA_MODULE = "MTA-Module";
Expand All @@ -23,6 +24,10 @@ public class MtaArchiveHelper {

private Map<String, String> mtaArchiveResources;
private Map<String, String> mtaArchiveModules;

public String getCreatedBy() {
return this.manifest.getMainAttributes().getValue(ATTR_CREATED_BY);
}
private Map<String, String> mtaArchiveRequiresDependencies;

public MtaArchiveHelper(Manifest manifest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

class MtaArchiveHelperTest {

Expand Down Expand Up @@ -65,11 +66,7 @@ void testGetResourceFileAttributes() throws IOException {
helper = new MtaArchiveHelper(manifest);
Map<String, List<String>> result = helper.getResourceFileAttributes();
assertEquals(Map.of("config.json", List.of("parameters-service", "parameters-service-2")), result);
}

private Manifest getManifest() throws IOException {
InputStream fileInputStream = getClass().getResourceAsStream("mta-archive-helper-manifest.txt");
return new Manifest(fileInputStream);
assertNull(helper.getCreatedBy());
}

@Test
Expand All @@ -78,6 +75,14 @@ void getRequiresDependenciesFileAttributes() throws IOException {
helper = new MtaArchiveHelper(manifest);
Map<String, List<String>> result = helper.getRequiresDependenciesFileAttributes();
assertEquals(Map.of("config-bind.json", List.of("anatz/my-required-application", "anatz/my-required-application-2")), result);
assertNull(helper.getCreatedBy());
}

@Test
void getCreatedByAttribute() throws IOException {
Manifest manifest = getManifestWithCreatedBy();
helper = new MtaArchiveHelper(manifest);
assertEquals("SAP Application Archive Builder 1.2.34", helper.getCreatedBy());
}

private void initializeParameters(String mtarLocation, String deploymentDescriptorLocation) {
Expand All @@ -91,6 +96,17 @@ private void initializeParameters(String mtarLocation, String deploymentDescript
helper.init();
}


private Manifest getManifest() throws IOException {
InputStream fileInputStream = getClass().getResourceAsStream("mta-archive-helper-manifest.txt");
return new Manifest(fileInputStream);
}

private Manifest getManifestWithCreatedBy() throws IOException {
InputStream fileInputStream = getClass().getResourceAsStream("mta-archive-helper-manifest-with-created-by.txt");
return new Manifest(fileInputStream);
}

private Set<String> getResourcesNamesFromDescriptor() {
return descriptor.getResources()
.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0
Created-By: SAP Application Archive Builder 1.2.34
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cloudfoundry.multiapps.controller.process.dynatrace;

import org.cloudfoundry.multiapps.common.Nullable;
import org.immutables.value.Value;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
Expand All @@ -12,6 +13,9 @@ public abstract class DynatraceProcessEvent implements DyntraceProcessEntity {

public abstract EventType getEventType();

@Nullable
public abstract String getCreatedBy();

public enum EventType {

STARTED, FINISHED, FAILED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private void publishDynatraceEvent(DelegateExecution execution, ProcessType proc
.processId(VariableHandling.get(execution,
Variables.CORRELATION_ID))
.mtaId(VariableHandling.get(execution, Variables.MTA_ID))
.createdBy(VariableHandling.get(execution, Variables.MTA_ARCHIVE_CREATED_BY))
.spaceId(VariableHandling.get(execution, Variables.SPACE_GUID))
.eventType(DynatraceProcessEvent.EventType.FINISHED)
.processType(processType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void processApplicationArchive(ProcessContext context, String appArchive
context.getRequiredVariable(Variables.SPACE_GUID), appArchiveId);
context.setVariable(Variables.ARCHIVE_ENTRIES_POSITIONS, archiveEntriesWithStreamPositions);
MtaArchiveHelper helper = createMtaArchiveHelperFromManifest(context, appArchiveId, archiveEntriesWithStreamPositions);

context.setVariable(Variables.MTA_ARCHIVE_CREATED_BY, helper.getCreatedBy());
DeploymentDescriptor deploymentDescriptor = extractDeploymentDescriptor(context, appArchiveId, archiveEntriesWithStreamPositions);

if (context.getVariable(Variables.SHOULD_BACKUP_PREVIOUS_VERSION)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ public interface Variables {
.type(Variable.typeReference(MtaArchiveElements.class))
.defaultValue(new MtaArchiveElements())
.build();
Variable<String> MTA_ARCHIVE_CREATED_BY = ImmutableSimpleVariable.<String> builder()
.name("mtaArchiveCreatedBy")
.defaultValue(null)
.build();
Variable<CloudServiceInstanceExtended> SERVICE_TO_PROCESS = ImmutableJsonStringVariable.<CloudServiceInstanceExtended> builder()
.name("serviceToProcess")
.type(Variable.typeReference(
Expand Down
Loading