Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Implementation for the report goal.

* Renaming of various stuff.
  • Loading branch information...
commit d08b575a95896271a8ca3132998a7284748baef2 1 parent 0277055
@tomshapira tomshapira authored
Showing with 269 additions and 149 deletions.
  1. +6 −4 .../main/java/{com/wss/agent/constants/AgentConstants.java → org/whitesource/agent/api/APIConstants.java}
  2. +1 −1  ...t-domain/src/main/java/{com/wss/agent/exception → org/whitesource/agent/api}/JsonParsingException.java
  3. +1 −2  ...parent/wss-agent-domain/src/main/java/{com/wss/agent/utils → org/whitesource/agent/api}/JsonUtils.java
  4. +1 −1  ...s-agent-domain/src/main/java/{com/wss/agent/api → org/whitesource/agent/api/dispatch}/BaseRequest.java
  5. +1 −1  ...t-domain/src/main/java/{com/wss/agent/api → org/whitesource/agent/api/dispatch}/PropertiesRequest.java
  6. +4 −3 ...nt-domain/src/main/java/{com/wss/agent/api → org/whitesource/agent/api/dispatch}/PropertiesResult.java
  7. +3 −2 ...s-agent-domain/src/main/java/{com/wss/agent/api → org/whitesource/agent/api/dispatch}/RequestType.java
  8. +6 −5 ...gent-domain/src/main/java/{com/wss/agent/api → org/whitesource/agent/api/dispatch}/ResultEnvelope.java
  9. +1 −1  ...gent-domain/src/main/java/{com/wss/agent/api → org/whitesource/agent/api/dispatch}/ServiceRequest.java
  10. +3 −2 ...ain/src/main/java/{com/wss/agent/api → org/whitesource/agent/api/dispatch}/UpdateInventoryRequest.java
  11. +15 −3 ...main/src/main/java/{com/wss/agent/api → org/whitesource/agent/api/dispatch}/UpdateInventoryResult.java
  12. +1 −1  ...wss-agent-domain/src/main/java/{com/wss/agent → org/whitesource/agent/api}/model/AgentProjectInfo.java
  13. +1 −1  ...rent/wss-agent-domain/src/main/java/{com/wss/agent → org/whitesource/agent/api}/model/Coordinates.java
  14. +53 −20 ...t/wss-agent-domain/src/main/java/{com/wss/agent → org/whitesource/agent/api}/model/DependencyInfo.java
  15. +1 −1  ...nt/wss-agent-domain/src/main/java/{com/wss/agent → org/whitesource/agent/api}/model/ExclusionInfo.java
  16. +0 −18 ...ent-parent/wss-agent-mavenplugin/src/main/java/com/wss/agent/maven/plugin/update/service/UpdateService.java
  17. +22 −13 .../src/main/java/{com/wss/agent/maven/plugin/update → org/whitesource/agent/maven/plugin}/Constants.java
  18. +59 −0 ...-parent/wss-agent-mavenplugin/src/main/java/org/whitesource/agent/maven/plugin/service/ServiceProvider.java
  19. +42 −25 .../service/UpdateServiceImpl.java → org/whitesource/agent/maven/plugin/service/ServiceProviderImpl.java}
  20. +25 −23 ...-agent-mavenplugin/src/main/java/{com/wss → org/whitesource}/agent/maven/plugin/update/UpdateMojo.java
  21. +2 −2 ...wss-agent-mavenplugin/src/main/java/{com/wss → org/whitesource}/agent/maven/plugin/update/Updater.java
  22. +21 −20 ...agent-mavenplugin/src/main/java/{com/wss → org/whitesource}/agent/maven/plugin/update/UpdaterImpl.java
View
10 .../java/com/wss/agent/constants/AgentConstants.java → .../java/org/whitesource/agent/api/APIConstants.java
@@ -1,11 +1,11 @@
-package com.wss.agent.constants;
+package org.whitesource.agent.api;
/**
* A class to hold constant values used in WhiteSource agents.
*
* @author tom.shapira
*/
-public final class AgentConstants {
+public final class APIConstants {
public static final String API_VERSION = "1.0";
@@ -19,6 +19,8 @@
public static final String PARAM_DIFF = "diff";
+ public static final String PARAM_DEPENDENCIES = "dependencies";
+
public static final String PARAM_AGENT_VERSION = "agentVersion";
public static final String PARAM_REQUEST_TYPE = "type";
@@ -40,8 +42,8 @@
/**
* Private default constructor
*/
- private AgentConstants() {
+ private APIConstants() {
// avoid instantiation
}
-}
+}
View
2  ...com/wss/agent/exception/JsonParsingException.java → ...g/whitesource/agent/api/JsonParsingException.java
@@ -1,4 +1,4 @@
-package com.wss.agent.exception;
+package org.whitesource.agent.api;
/**
* Exception thrown when an error occurs during JSON parsing.
View
3  .../src/main/java/com/wss/agent/utils/JsonUtils.java → ...ain/java/org/whitesource/agent/api/JsonUtils.java
@@ -1,4 +1,4 @@
-package com.wss.agent.utils;
+package org.whitesource.agent.api;
import java.io.IOException;
@@ -7,7 +7,6 @@
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
-import com.wss.agent.exception.JsonParsingException;
/**
* Utility class for JSON conversion.
View
2  .../src/main/java/com/wss/agent/api/BaseRequest.java → ...g/whitesource/agent/api/dispatch/BaseRequest.java
@@ -1,4 +1,4 @@
-package com.wss.agent.api;
+package org.whitesource.agent.api.dispatch;
public class BaseRequest<R> implements ServiceRequest<R> {
View
2  ...ain/java/com/wss/agent/api/PropertiesRequest.java → ...esource/agent/api/dispatch/PropertiesRequest.java
@@ -1,4 +1,4 @@
-package com.wss.agent.api;
+package org.whitesource.agent.api.dispatch;
/**
* Request for service properties.
View
7 ...main/java/com/wss/agent/api/PropertiesResult.java → ...tesource/agent/api/dispatch/PropertiesResult.java
@@ -1,9 +1,10 @@
-package com.wss.agent.api;
+package org.whitesource.agent.api.dispatch;
import java.util.Properties;
-import com.wss.agent.exception.JsonParsingException;
-import com.wss.agent.utils.JsonUtils;
+import org.whitesource.agent.api.JsonParsingException;
+import org.whitesource.agent.api.JsonUtils;
+
/**
* Result of the properties operation.
View
5 .../src/main/java/com/wss/agent/api/RequestType.java → ...g/whitesource/agent/api/dispatch/RequestType.java
@@ -1,4 +1,4 @@
-package com.wss.agent.api;
+package org.whitesource.agent.api.dispatch;
/**
* Enumeration of the service available methods.
@@ -8,6 +8,7 @@
public enum RequestType {
PROPERTIES,
- UPDATE;
+ UPDATE,
+ REPORT;
}
View
11 ...c/main/java/com/wss/agent/api/ResultEnvelope.java → ...hitesource/agent/api/dispatch/ResultEnvelope.java
@@ -1,10 +1,11 @@
-package com.wss.agent.api;
+package org.whitesource.agent.api.dispatch;
import java.io.Serializable;
-import com.wss.agent.constants.AgentConstants;
-import com.wss.agent.exception.JsonParsingException;
-import com.wss.agent.utils.JsonUtils;
+import org.whitesource.agent.api.APIConstants;
+import org.whitesource.agent.api.JsonParsingException;
+import org.whitesource.agent.api.JsonUtils;
+
/**
* Wrapper for any response form the White Source service.
@@ -27,7 +28,7 @@
/* --- Members --- */
- private String envelopeVersion = AgentConstants.API_VERSION;
+ private String envelopeVersion = APIConstants.API_VERSION;
/** Status code of the operation. */
private int status;
View
2  ...c/main/java/com/wss/agent/api/ServiceRequest.java → ...hitesource/agent/api/dispatch/ServiceRequest.java
@@ -1,4 +1,4 @@
-package com.wss.agent.api;
+package org.whitesource.agent.api.dispatch;
import java.io.Serializable;
View
5 ...ava/com/wss/agent/api/UpdateInventoryRequest.java → ...ce/agent/api/dispatch/UpdateInventoryRequest.java
@@ -1,9 +1,10 @@
-package com.wss.agent.api;
+package org.whitesource.agent.api.dispatch;
import java.util.ArrayList;
import java.util.Collection;
-import com.wss.agent.model.AgentProjectInfo;
+import org.whitesource.agent.api.model.AgentProjectInfo;
+
/**
* Request to update organization inventory.
View
18 ...java/com/wss/agent/api/UpdateInventoryResult.java → ...rce/agent/api/dispatch/UpdateInventoryResult.java
@@ -1,10 +1,11 @@
-package com.wss.agent.api;
+package org.whitesource.agent.api.dispatch;
import java.util.ArrayList;
import java.util.Collection;
-import com.wss.agent.exception.JsonParsingException;
-import com.wss.agent.utils.JsonUtils;
+import org.whitesource.agent.api.JsonParsingException;
+import org.whitesource.agent.api.JsonUtils;
+
/**
* Result of the update inventory operation.
@@ -19,6 +20,8 @@
private Collection<String> updatedProjects;
+ private Collection<String> createdProjects;
+
/* --- Constructors --- */
/**
@@ -27,6 +30,7 @@
*/
public UpdateInventoryResult() {
updatedProjects = new ArrayList<String>();
+ createdProjects = new ArrayList<String>();
}
/**
@@ -63,4 +67,12 @@ public void setUpdatedProjects(Collection<String> updatedProjects) {
this.updatedProjects = updatedProjects;
}
+ public Collection<String> getCreatedProjects() {
+ return createdProjects;
+ }
+
+ public void setCreatedProjects(Collection<String> createdProjects) {
+ this.createdProjects = createdProjects;
+ }
+
}
View
2  ...in/java/com/wss/agent/model/AgentProjectInfo.java → ...whitesource/agent/api/model/AgentProjectInfo.java
@@ -1,4 +1,4 @@
-package com.wss.agent.model;
+package org.whitesource.agent.api.model;
import java.io.Serializable;
import java.util.ArrayList;
View
2  ...rc/main/java/com/wss/agent/model/Coordinates.java → .../org/whitesource/agent/api/model/Coordinates.java
@@ -1,4 +1,4 @@
-package com.wss.agent.model;
+package org.whitesource.agent.api.model;
import java.io.Serializable;
View
73 ...main/java/com/wss/agent/model/DependencyInfo.java → ...g/whitesource/agent/api/model/DependencyInfo.java
@@ -1,4 +1,4 @@
-package com.wss.agent.model;
+package org.whitesource.agent.api.model;
import java.io.Serializable;
import java.util.ArrayList;
@@ -11,58 +11,91 @@
*
*/
public class DependencyInfo implements Serializable {
-
+
/* --- Static members --- */
-
+
private static final long serialVersionUID = -6212622409560068635L;
/* --- Members --- */
-
+
private String groupId;
-
+
private String artifactId;
-
+
private String version;
-
+
private String type;
-
+
private String classifier;
-
+
private String scope;
-
+
private String systemPath;
-
+
private Collection<ExclusionInfo> exclusions;
-
+
private boolean optional;
-
+
/* --- Constructors --- */
-
+
/**
* Default constructor
*/
public DependencyInfo() {
exclusions = new ArrayList<ExclusionInfo>();
}
-
+
/* --- Overridden methods --- */
-
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
-
+
sb.append("DependencyInfo@").append(Integer.toHexString(hashCode()))
.append("[")
.append("groupId= ").append(groupId).append(",")
.append("artifactId= ").append(artifactId).append(",")
.append("version= ").append(version)
.append(" ]");
-
+
return sb.toString();
}
-
+
+ @Override
+ public int hashCode() {
+ final int multiplier = 23;
+
+ int code = 133;
+ code = multiplier * code + ((groupId == null) ? 0 : groupId.hashCode());
+ code = multiplier * code + ((artifactId == null) ? 0 : artifactId.hashCode());
+ code = multiplier * code + ((version == null) ? 0 : version.hashCode());
+
+ return code;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+ if (obj.getClass() != getClass()) {
+ return false;
+ }
+
+ DependencyInfo other = (DependencyInfo) obj;
+
+ boolean isEqual = (groupId == null) ? (other.groupId == null) : groupId.equals(other.groupId);
+ isEqual = isEqual && ((artifactId == null) ? (other.artifactId == null) : artifactId.equals(other.artifactId));
+ isEqual = isEqual && ((version == null) ? (other.version == null) : version.equals(other.version));
+
+ return isEqual;
+ }
+
/* --- Getters / Setters --- */
-
+
public String getGroupId() {
return groupId;
}
View
2  .../main/java/com/wss/agent/model/ExclusionInfo.java → ...rg/whitesource/agent/api/model/ExclusionInfo.java
@@ -1,4 +1,4 @@
-package com.wss.agent.model;
+package org.whitesource.agent.api.model;
import java.io.Serializable;
View
18 ...-parent/wss-agent-mavenplugin/src/main/java/com/wss/agent/maven/plugin/update/service/UpdateService.java
@@ -1,18 +0,0 @@
-package com.wss.agent.maven.plugin.update.service;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
-
-import com.wss.agent.api.PropertiesRequest;
-import com.wss.agent.api.PropertiesResult;
-import com.wss.agent.api.UpdateInventoryRequest;
-import com.wss.agent.api.UpdateInventoryResult;
-
-public interface UpdateService {
-
- PropertiesResult getProperties(PropertiesRequest request) throws MojoExecutionException;
-
- UpdateInventoryResult updateInventory(UpdateInventoryRequest request) throws MojoExecutionException;
-
- void setLog(Log log);
-}
View
35 .../com/wss/agent/maven/plugin/update/Constants.java → ...org/whitesource/agent/maven/plugin/Constants.java
@@ -1,7 +1,7 @@
-package com.wss.agent.maven.plugin.update;
+package org.whitesource.agent.maven.plugin;
/**
- * Constants used by {@link UpdateMojo}
+ * Constants used by plugins.
*
* @author tom.shapira
*
@@ -19,18 +19,10 @@
/* --- Servlet info --- */
// TODO change
- public static final String SERVICE_ENDPOINT_URL = "http://localhost:8888/agent/update";
+ public static final String SERVICE_ENDPOINT_URL = "http://localhost:8888/agent";
public static final String APPLICATION_JSON = "application/json";
- /* --- Stand alone pom --- */
-
- public static final String STANDALONE_POM_GROUP_ID = "org.apache.maven";
-
- public static final String STANDALONE_POM_ARTIFACT_ID = "standalone-pom";
-
- public static final String STANDALONE_POM_VERSION = "1";
-
/* --- Error messages --- */
public static final String ERROR_NOT_PROJECT_FOLDER = "Not a project folder";
@@ -51,11 +43,27 @@
public static final String INFO_PROJECTS_UPDATED = "The following projects have been updated: ";
+ public static final String INFO_PROJECTS_CREATED = "The following projects have been created: ";
+
public static final String INFO_NO_PROJECTS_UPDATED = "No projects were updated";
public static final String INFO_EMAIL_MESSAGE = "Each project admin will receive an email once the update process has been completed";
- public static final String SKIP_UPDATE = "Skipping White Source update";
+ public static final String INFO_NO_RESULTS = "No results found";
+
+ public static final String INFO_NO_DEPENDENCIES = "No dependencies were found";
+
+ public static final String INFO_LICENSE_ANALYSIS = "White Source License Report:";
+
+ public static final String INFO_CONTACT = "For more information visit www.whitesourcesoftware.com";
+
+ public static final String INFO_NEWER_VERSIONS_FORMAT = "Found {0} libraries that have newer versions.";
+
+ public static final String INFO_REPORT_DIRECTORY = "White Source report directory: ";
+
+ public static final String INFO_SKIP_UPDATE = "Skipping White Source update";
+
+ public static final String INFO_SKIP_LICENSES = "Skipping White Source license report";
public static final String DEBUG_REQUEST_BUILT = "Request created successfully";
@@ -69,6 +77,7 @@
public static final String DEBUG_UPDATE_SUCCESS = "Update successful";
+
/* --- Constructors --- */
/**
@@ -78,4 +87,4 @@ private Constants() {
// avoid instantiation
}
-}
+}
View
59 ...rent/wss-agent-mavenplugin/src/main/java/org/whitesource/agent/maven/plugin/service/ServiceProvider.java
@@ -0,0 +1,59 @@
+package org.whitesource.agent.maven.plugin.service;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.whitesource.agent.api.dispatch.PropertiesRequest;
+import org.whitesource.agent.api.dispatch.PropertiesResult;
+import org.whitesource.agent.api.dispatch.ReportRequest;
+import org.whitesource.agent.api.dispatch.ReportResult;
+import org.whitesource.agent.api.dispatch.UpdateInventoryRequest;
+import org.whitesource.agent.api.dispatch.UpdateInventoryResult;
+
+/**
+ * The interface describes the functionality exposed by the wrapper to the WhiteSource agent service.
+ *
+ * @author tom.shapira
+ *
+ */
+public interface ServiceProvider {
+
+ /**
+ * The method calls the WhiteSource service for properties.
+ *
+ * @param request Properties request.
+ *
+ * @return Properties result.
+ *
+ * @throws MojoExecutionException In case an error occurred during the call to White Source server.
+ */
+ PropertiesResult getProperties(PropertiesRequest request) throws MojoExecutionException;
+
+ /**
+ * The method calls the WhiteSource service for inventory update.
+ *
+ * @param request Inventory update request.
+ *
+ * @return Inventory update result.
+ *
+ * @throws MojoExecutionException In case an error occurred during the call to White Source server.
+ */
+ UpdateInventoryResult updateInventory(UpdateInventoryRequest request) throws MojoExecutionException;
+
+ /**
+ * The method calls the WhiteSource service for dependency analysis report.
+ *
+ * @param request Report request.
+ *
+ * @return Report result.
+ *
+ * @throws MojoExecutionException In case an error occurred during the call to White Source server.
+ */
+ ReportResult getReport(ReportRequest request) throws MojoExecutionException;
+
+ /**
+ * Sets the log.
+ *
+ * @param log Log.
+ */
+ void setLog(Log log);
+}
View
67 ...aven/plugin/update/service/UpdateServiceImpl.java → ...ent/maven/plugin/service/ServiceProviderImpl.java
@@ -1,4 +1,4 @@
-package com.wss.agent.maven.plugin.update.service;
+package org.whitesource.agent.maven.plugin.service;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -19,39 +19,41 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.IOUtil;
+import org.whitesource.agent.api.APIConstants;
+import org.whitesource.agent.api.JsonParsingException;
+import org.whitesource.agent.api.JsonUtils;
+import org.whitesource.agent.api.dispatch.PropertiesRequest;
+import org.whitesource.agent.api.dispatch.PropertiesResult;
+import org.whitesource.agent.api.dispatch.ReportRequest;
+import org.whitesource.agent.api.dispatch.ReportResult;
+import org.whitesource.agent.api.dispatch.RequestType;
+import org.whitesource.agent.api.dispatch.ResultEnvelope;
+import org.whitesource.agent.api.dispatch.ServiceRequest;
+import org.whitesource.agent.api.dispatch.UpdateInventoryRequest;
+import org.whitesource.agent.api.dispatch.UpdateInventoryResult;
+import org.whitesource.agent.maven.plugin.Constants;
-import com.wss.agent.api.PropertiesRequest;
-import com.wss.agent.api.PropertiesResult;
-import com.wss.agent.api.RequestType;
-import com.wss.agent.api.ResultEnvelope;
-import com.wss.agent.api.ServiceRequest;
-import com.wss.agent.api.UpdateInventoryRequest;
-import com.wss.agent.api.UpdateInventoryResult;
-import com.wss.agent.constants.AgentConstants;
-import com.wss.agent.exception.JsonParsingException;
-import com.wss.agent.maven.plugin.update.Constants;
-import com.wss.agent.utils.JsonUtils;
/**
- * Implementation class for {@link UpdateService}
+ * Implementation class for {@link ServiceProvider}
*
* @author tom.shapira
*/
-public final class UpdateServiceImpl implements UpdateService {
+public final class ServiceProviderImpl implements ServiceProvider {
/* --- Members --- */
private Log log;
- private static final UpdateService INSTANCE = new UpdateServiceImpl();
+ private static final ServiceProvider INSTANCE = new ServiceProviderImpl();
/* --- Singleton --- */
- private UpdateServiceImpl() {
+ private ServiceProviderImpl() {
}
- public static UpdateService getInstance() {
+ public static ServiceProvider getInstance() {
return INSTANCE;
}
@@ -64,6 +66,10 @@ public PropertiesResult getProperties(PropertiesRequest request) throws MojoExec
public UpdateInventoryResult updateInventory(UpdateInventoryRequest request) throws MojoExecutionException {
return service(request);
}
+
+ public ReportResult getReport(ReportRequest request) throws MojoExecutionException {
+ return service(request);
+ }
/* --- Private methods --- */
@@ -101,6 +107,9 @@ public UpdateInventoryResult updateInventory(UpdateInventoryRequest request) thr
case UPDATE:
result = (R) UpdateInventoryResult.fromJSON(data);
break;
+ case REPORT:
+ result = (R) ReportResult.fromJSON(data);
+ break;
default:
throw new IllegalStateException("Unsupporeted request type.");
}
@@ -127,17 +136,25 @@ public UpdateInventoryResult updateInventory(UpdateInventoryRequest request) thr
private <R> HttpRequestBase createHttpRequest(ServiceRequest<R> request)
throws UnsupportedEncodingException, JsonParsingException {
HttpPost httpRequest = new HttpPost(Constants.SERVICE_ENDPOINT_URL);
-
httpRequest.setHeader("Accept", Constants.APPLICATION_JSON);
+ RequestType type = request.getType();
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
- nvps.add(new BasicNameValuePair(AgentConstants.PARAM_AGENT_VERSION, Constants.AGENT_VERSION));
- nvps.add(new BasicNameValuePair(AgentConstants.PARAM_REQUEST_TYPE, request.getType().toString()));
- nvps.add(new BasicNameValuePair(AgentConstants.PARAM_TOKEN, request.getOrgToken()));
+ nvps.add(new BasicNameValuePair(APIConstants.PARAM_AGENT_VERSION, Constants.AGENT_VERSION));
+ nvps.add(new BasicNameValuePair(APIConstants.PARAM_REQUEST_TYPE, type.toString()));
+ nvps.add(new BasicNameValuePair(APIConstants.PARAM_TOKEN, request.getOrgToken()));
- if (RequestType.UPDATE.equals(request.getType())) {
- nvps.add(new BasicNameValuePair(AgentConstants.PARAM_TIME_STAMP, String.valueOf(request.getTimeStamp())));
- nvps.add(new BasicNameValuePair(AgentConstants.PARAM_DIFF, JsonUtils.toJson(((UpdateInventoryRequest) request).getProjects())));
+ switch (type) {
+ case UPDATE:
+ nvps.add(new BasicNameValuePair(APIConstants.PARAM_TIME_STAMP, String.valueOf(request.getTimeStamp())));
+ nvps.add(new BasicNameValuePair(APIConstants.PARAM_DIFF, JsonUtils.toJson(((UpdateInventoryRequest) request).getProjects())));
+ break;
+ case REPORT:
+ nvps.add(new BasicNameValuePair(APIConstants.PARAM_TIME_STAMP, String.valueOf(request.getTimeStamp())));
+ nvps.add(new BasicNameValuePair(APIConstants.PARAM_DEPENDENCIES, JsonUtils.toJson(((ReportRequest) request).getDependencies())));
+ break;
+ default:
+ break;
}
httpRequest.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
@@ -243,4 +260,4 @@ private void logDebug(String message) {
public void setLog(Log log) {
this.log = log;
}
-}
+}
View
48 ...com/wss/agent/maven/plugin/update/UpdateMojo.java → ...esource/agent/maven/plugin/update/UpdateMojo.java
@@ -1,16 +1,18 @@
-package com.wss.agent.maven.plugin.update;
+package org.whitesource.agent.maven.plugin.update;
import java.util.Collection;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
+import org.whitesource.agent.api.dispatch.PropertiesRequest;
+import org.whitesource.agent.api.dispatch.PropertiesResult;
+import org.whitesource.agent.api.dispatch.UpdateInventoryResult;
+import org.whitesource.agent.maven.plugin.Constants;
+import org.whitesource.agent.maven.plugin.InputValidator;
+import org.whitesource.agent.maven.plugin.service.ServiceProvider;
+import org.whitesource.agent.maven.plugin.service.ServiceProviderImpl;
-import com.wss.agent.api.PropertiesRequest;
-import com.wss.agent.api.PropertiesResult;
-import com.wss.agent.api.UpdateInventoryResult;
-import com.wss.agent.maven.plugin.update.service.UpdateService;
-import com.wss.agent.maven.plugin.update.service.UpdateServiceImpl;
/**
* Sends an update request to White Source.
@@ -62,7 +64,7 @@
public void execute() throws MojoExecutionException {
if (skip) {
- getLog().info(Constants.SKIP_UPDATE);
+ getLog().info(Constants.INFO_SKIP_UPDATE);
} else {
try {
doExecute();
@@ -89,7 +91,7 @@ private void doExecute() throws MojoExecutionException {
* @throws MojoExecutionException
*/
private void update() throws MojoExecutionException {
- UpdateService service = UpdateServiceImpl.getInstance();
+ ServiceProvider service = ServiceProviderImpl.getInstance();
service.setLog(getLog());
// get properties
@@ -114,6 +116,7 @@ private void logResult(UpdateInventoryResult result) {
getLog().info("");
getLog().info(Constants.INFO_DOMAIN + result.getOrganization());
+ // log updated projects
Collection<String> updatedProjects = result.getUpdatedProjects();
if (updatedProjects.isEmpty()) {
getLog().info(Constants.INFO_NO_PROJECTS_UPDATED);
@@ -125,6 +128,17 @@ private void logResult(UpdateInventoryResult result) {
}
getLog().info("");
getLog().info(Constants.INFO_EMAIL_MESSAGE);
+ getLog().info("");
+ }
+
+ // log created projects
+ Collection<String> createdProjects = result.getCreatedProjects();
+ if (!createdProjects.isEmpty()) {
+ getLog().info(Constants.INFO_PROJECTS_CREATED);
+ getLog().info("");
+ for (String projectName : createdProjects) {
+ getLog().info(projectName);
+ }
}
}
@@ -140,7 +154,7 @@ private void validateInputs(MavenProject project, String token) throws MojoExecu
}
// check if plugin was run from folder without POM file
- if (isStandAlonePom(project)) {
+ if (InputValidator.isStandAlonePom(project)) {
throw new MojoExecutionException(Constants.ERROR_NOT_PROJECT_FOLDER);
}
@@ -151,18 +165,6 @@ private void validateInputs(MavenProject project, String token) throws MojoExecu
}
/**
- * Checks if the plugin was run in folder without pom file.
- *
- * @param project The maven project.
- * @return True if the folder is not a maven project folder, false o/w
- */
- private boolean isStandAlonePom(MavenProject project) {
- return project.getArtifactId().equals(Constants.STANDALONE_POM_ARTIFACT_ID) &&
- project.getGroupId().equals(Constants.STANDALONE_POM_GROUP_ID) &&
- project.getVersion().equals(Constants.STANDALONE_POM_VERSION);
- }
-
- /**
* Handle error according to failOnError property.
*
* @param e Exception thrown
@@ -172,10 +174,10 @@ private void handleError(Exception e) throws MojoExecutionException {
String message = e.getMessage();
if (failOnError) {
- throw new MojoExecutionException(message);
+ throw new MojoExecutionException(message, e);
} else {
getLog().warn(message);
getLog().debug(e);
}
}
-}
+}
View
4 ...va/com/wss/agent/maven/plugin/update/Updater.java → ...hitesource/agent/maven/plugin/update/Updater.java
@@ -1,9 +1,9 @@
-package com.wss.agent.maven.plugin.update;
+package org.whitesource.agent.maven.plugin.update;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
+import org.whitesource.agent.api.dispatch.UpdateInventoryResult;
-import com.wss.agent.api.UpdateInventoryResult;
/**
* The interface describe the functionality to be exposed by a maven project updater to the white source service.
View
41 ...om/wss/agent/maven/plugin/update/UpdaterImpl.java → ...source/agent/maven/plugin/update/UpdaterImpl.java
@@ -1,4 +1,4 @@
-package com.wss.agent.maven.plugin.update;
+package org.whitesource.agent.maven.plugin.update;
import java.util.ArrayList;
import java.util.Collection;
@@ -12,15 +12,16 @@
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.whitesource.agent.api.dispatch.UpdateInventoryRequest;
+import org.whitesource.agent.api.dispatch.UpdateInventoryResult;
+import org.whitesource.agent.api.model.AgentProjectInfo;
+import org.whitesource.agent.api.model.Coordinates;
+import org.whitesource.agent.api.model.DependencyInfo;
+import org.whitesource.agent.api.model.ExclusionInfo;
+import org.whitesource.agent.maven.plugin.Constants;
+import org.whitesource.agent.maven.plugin.service.ServiceProvider;
+import org.whitesource.agent.maven.plugin.service.ServiceProviderImpl;
-import com.wss.agent.api.UpdateInventoryRequest;
-import com.wss.agent.api.UpdateInventoryResult;
-import com.wss.agent.maven.plugin.update.service.UpdateService;
-import com.wss.agent.maven.plugin.update.service.UpdateServiceImpl;
-import com.wss.agent.model.AgentProjectInfo;
-import com.wss.agent.model.Coordinates;
-import com.wss.agent.model.DependencyInfo;
-import com.wss.agent.model.ExclusionInfo;
/**
* Implementation class of {@link Updater}
@@ -40,7 +41,7 @@
private MavenProject project;
- private UpdateService service;
+ private ServiceProvider service;
/* --- Constructors --- */
@@ -68,7 +69,7 @@ public UpdateInventoryResult update() throws MojoExecutionException {
logDebug(Constants.DEBUG_REQUEST_BUILT);
// send request
- service = UpdateServiceImpl.getInstance();
+ service = ServiceProviderImpl.getInstance();
result = service.updateInventory(request);
return result;
@@ -172,20 +173,20 @@ private void populateCoordinates(AgentProjectInfo projectInfo, MavenProject proj
private void populateDependencies(AgentProjectInfo projectInfo, MavenProject project) {
Collection<DependencyInfo> dependencyInfos = projectInfo.getDependencies();
for (Dependency dependency : project.getDependencies()) {
- dependencyInfos.add(extractDependencyInfo(dependency));
+ dependencyInfos.add(getDependencyInfo(dependency));
}
}
-
+
/**
- * The method extract the info model from the given dependency.
+ * The method builds the info model from the given dependency.
*
* @param dependency Source maven dependency.
*
* @return Extracted info model.
*/
- private DependencyInfo extractDependencyInfo(Dependency dependency) {
+ public static DependencyInfo getDependencyInfo(Dependency dependency) {
DependencyInfo info = new DependencyInfo();
-
+
// dependency data
info.setGroupId(dependency.getGroupId());
info.setArtifactId(dependency.getArtifactId());
@@ -195,16 +196,16 @@ private DependencyInfo extractDependencyInfo(Dependency dependency) {
info.setOptional(dependency.isOptional());
info.setType(dependency.getType());
info.setSystemPath(dependency.getSystemPath());
-
+
// exclusions
Collection<ExclusionInfo> exclusions = info.getExclusions();
for (Exclusion exclusion : dependency.getExclusions()) {
exclusions.add(new ExclusionInfo(exclusion.getGroupId(), exclusion.getArtifactId()));
}
-
+
return info;
}
-
+
/**
* The method extract the gav from the given maven project.
*
@@ -229,4 +230,4 @@ private void logDebug(String message) {
}
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.