Skip to content

Commit

Permalink
PA-10660 add ContributingDeveloperAudit (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
SOOS-JAlvarez committed Aug 15, 2023
1 parent 8e7f769 commit 70af280
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.soos</groupId>
<artifactId>sca</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>

<name>SOOS Integrations core</name>
<description>Core package used on all our java integrations development.</description>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/io/soos/integration/commons/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class Constants {
public static final String SOOS_BUILD_URI = "SOOS_BUILD_URI";
public static final String SOOS_OPERATING_ENVIRONMENT = "SOOS_OPERATING_ENVIRONMENT";
public static final String SOOS_INTEGRATION_NAME = "SOOS_INTEGRATION_NAME";
public static final String SOOS_CONTRIBUTING_DEVELOPER = "SOOS_CONTRIBUTING_DEVELOPER";
public static final String SOOS_CONTRIBUTING_DEVELOPER_ENV = "SOOS_CONTRIBUTING_DEVELOPER_ENV";

// Params Arguments
public static final String PARAM_ON_FAILURE_KEY = "of";
Expand All @@ -84,6 +86,8 @@ public class Constants {
public static final String PARAM_OPERATING_ENVIRONMENT_KEY = "oe";
public static final String PARAM_INTEGRATION_NAME_KEY = "intn";
public static final String PARAM_PACKAGE_MANAGERS_KEY = "pkgm";
public static final String PARAM_CONTRIBUTING_DEVELOPER_KEY = "cdev";
public static final String PARAM_CONTRIBUTING_DEVELOPER_ENV_KEY = "cdeve";

public static final String MAP_PARAM_CLIENT_ID_KEY = "clientId";
public static final String MAP_PARAM_API_KEY = "apiKey";
Expand All @@ -104,6 +108,8 @@ public class Constants {
public static final String MAP_PARAM_OPERATING_ENVIRONMENT_KEY = "operatingEnvironment";
public static final String MAP_PARAM_INTEGRATION_NAME_KEY = "integrationName";
public static final String MAP_PARAM_PACKAGE_MANAGERS_KEY = "packageManagers";
public static final String MAP_PARAM_CONTRIBUTING_DEVELOPER_KEY = "contributingDeveloper";
public static final String MAP_PARAM_CONTRIBUTING_DEVELOPER_ENV_KEY = "contributingDeveloperEnv";

// Report Status
public static final String REPORT_STATUS_FINISHED = "Finished";
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/io/soos/integration/commons/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public static Map<String, String> parseArgs() {
params.put(Constants.MAP_PARAM_OPERATING_ENVIRONMENT_KEY, System.getProperty(Constants.PARAM_OPERATING_ENVIRONMENT_KEY));
params.put(Constants.MAP_PARAM_INTEGRATION_NAME_KEY, System.getProperty(Constants.PARAM_INTEGRATION_NAME_KEY));
params.put(Constants.MAP_PARAM_PACKAGE_MANAGERS_KEY, System.getProperty(Constants.PARAM_PACKAGE_MANAGERS_KEY));
params.put(Constants.MAP_PARAM_CONTRIBUTING_DEVELOPER_KEY, System.getProperty(Constants.PARAM_CONTRIBUTING_DEVELOPER_KEY));
params.put(Constants.MAP_PARAM_CONTRIBUTING_DEVELOPER_ENV_KEY, System.getProperty(Constants.PARAM_CONTRIBUTING_DEVELOPER_ENV_KEY));

return params;
}
Expand All @@ -210,6 +212,8 @@ public static Map<String, String> parseEnvVariables() {
envVariables.put(Constants.MAP_PARAM_INTEGRATION_NAME_KEY, System.getenv(Constants.SOOS_INTEGRATION_NAME));
envVariables.put(Constants.MAP_PARAM_CLIENT_ID_KEY, System.getenv(Constants.SOOS_CLIENT_ID));
envVariables.put(Constants.MAP_PARAM_API_KEY, System.getenv(Constants.SOOS_API_KEY));
envVariables.put(Constants.MAP_PARAM_CONTRIBUTING_DEVELOPER_KEY, System.getenv(Constants.SOOS_CONTRIBUTING_DEVELOPER));
envVariables.put(Constants.MAP_PARAM_CONTRIBUTING_DEVELOPER_ENV_KEY, System.getenv(Constants.SOOS_CONTRIBUTING_DEVELOPER_ENV));

return envVariables;
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/io/soos/integration/domain/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Properties;

Expand All @@ -28,6 +29,9 @@ public class Context {
protected String integrationName;
protected String integrationType;
protected String scriptVersion;
protected String contributingDeveloper;
protected String contributingDeveloperEnv;
protected ArrayList<ContributingDeveloperAudit> contributingDeveloperAudit;
protected int analysisResultMaxWait;
protected int analysisResultPoolInterval;

Expand Down Expand Up @@ -168,6 +172,8 @@ public void setScriptVersion(String scriptVersion) {
this.scriptVersion = scriptVersion;
}

public ArrayList<ContributingDeveloperAudit> getContributingDeveloperAudit() { return contributingDeveloperAudit; }

private void reset() {
this.baseURI = Constants.SOOS_DEFAULT_API_URL;
this.sourceCodePath = null;
Expand Down Expand Up @@ -226,8 +232,19 @@ private void loadPropsFromParams() {
this.integrationName = this.loadProperty(this.integrationName, Constants.MAP_PARAM_INTEGRATION_NAME_KEY);
this.analysisResultMaxWait = this.loadIntProperty(this.analysisResultMaxWait, Constants.MAP_PARAM_ANALYSIS_RESULT_MAX_WAIT_KEY);
this.analysisResultPoolInterval = this.loadIntProperty(this.analysisResultPoolInterval, Constants.MAP_PARAM_ANALYSIS_RESULT_POLLING_INTERVAL_KEY);
this.contributingDeveloper = this.loadProperty(this.contributingDeveloper, Constants.MAP_PARAM_CONTRIBUTING_DEVELOPER_KEY);
this.contributingDeveloperEnv = this.loadProperty(this.contributingDeveloperEnv, Constants.MAP_PARAM_CONTRIBUTING_DEVELOPER_ENV_KEY);

if (StringUtils.isNotBlank(this.contributingDeveloper) && StringUtils.isNotBlank(this.contributingDeveloperEnv)) {
if (this.contributingDeveloperAudit == null) {
this.contributingDeveloperAudit = new ArrayList<>();
}
ContributingDeveloperAudit audit = new ContributingDeveloperAudit("EnvironmentVariable", this.contributingDeveloperEnv, this.contributingDeveloper);
this.contributingDeveloperAudit.add(audit);
}
}


private String loadProperty(String property, String paramMapKey) {
String paramValue = this.params.get(paramMapKey);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.soos.integration.domain;

public class ContributingDeveloperAudit {
protected String source;
protected String sourceName;
protected String contributingDeveloperId;

public ContributingDeveloperAudit(String source, String sourceName, String contributingDeveloperId) {
this.source = source;
this.sourceName = sourceName;
this.contributingDeveloperId = contributingDeveloperId;
}

public String getSource() {
return source;
}

public String getSourceName() {
return sourceName;
}

public String getContributingDeveloperId() {
return contributingDeveloperId;
}

public void setSource(String source) {
this.source = source;
}

public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}

public void setContributingDeveloperId(String contributingDeveloperId) {
this.contributingDeveloperId = contributingDeveloperId;
}
}
2 changes: 0 additions & 2 deletions src/main/java/io/soos/integration/domain/scan/Scan.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import io.soos.integration.builders.CreateScanURIBuilder;
import io.soos.integration.builders.StructureURIBuilder;
import io.soos.integration.commons.Utils;
import io.soos.integration.domain.Context;
import io.soos.integration.domain.RequestParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.soos.integration.domain.scan;

import io.soos.integration.domain.Context;
import io.soos.integration.domain.ContributingDeveloperAudit;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class ScanAPIRequestBody {
Expand All @@ -21,6 +23,7 @@ public class ScanAPIRequestBody {
private String integrationName;
private String scriptVersion;
private String toolName;
private ArrayList<ContributingDeveloperAudit> contributingDeveloperAudit;


public ScanAPIRequestBody(Context context) {
Expand All @@ -32,6 +35,7 @@ public ScanAPIRequestBody(Context context) {
this.projectName = context.getProjectName();
this.integrationType = context.getIntegrationType();
this.scriptVersion = context.getScriptVersion();
this.integrationName = context.getIntegrationName();
this.initialize(context);
}

Expand Down Expand Up @@ -66,6 +70,10 @@ private void initialize(Context context) {
if(StringUtils.isNotEmpty(context.getIntegrationName())) {
this.setIntegrationName(context.getIntegrationName());
}

if(context.getContributingDeveloperAudit() != null) {
this.setContributingDeveloperAudit(context.getContributingDeveloperAudit());
}
}

public String getProject() {
Expand Down Expand Up @@ -170,6 +178,14 @@ public void setToolName(String toolName) {
this.toolName = toolName;
}

public ArrayList<ContributingDeveloperAudit> getContributingDeveloperAudit() {
return contributingDeveloperAudit;
}

public void setContributingDeveloperAudit (ArrayList<ContributingDeveloperAudit> contributingDeveloperAudit) {
this.contributingDeveloperAudit = contributingDeveloperAudit;
}

@Override
public String toString() {
return new ToStringBuilder(this)
Expand All @@ -186,6 +202,7 @@ public String toString() {
.append("integrationName", integrationName)
.append("scriptVersion", scriptVersion)
.append("toolName", toolName)
.append("contributingDeveloperAudit", contributingDeveloperAudit)
.toString();
}
}

0 comments on commit 70af280

Please sign in to comment.