- * Filters the contents of an unzipped feed file
- *
- *
- * @param filterRequest
- * Consists of all the parameters that are required for filtering.
- *
- * In case of filtering by level two or level three categories, it is mandatory to pass
- *
+ * Filters the contents of an unzipped feed file
+ *
+ *
+ * @param filterRequest
+ * Consists of all the parameters that are required for filtering.
+ *
+ * In case of filtering by level two or level three categories, it is
+ * mandatory to pass
+ *
- * Unzip downloaded feed file and create a new file
- *
- *
- * @param filePath The absolute path to the gzipped feed file
- * @return Response Response
- */
- public Response unzip(String filePath);
+ /**
+ *
+ * Unzip downloaded feed file and create a new file
+ *
+ *
+ * @param filePath The absolute path to the gzipped feed file
+ * @return Response Response
+ */
+ public Response unzip(String filePath);
+ /**
+ *
+ * Downloads the feed file as specified by the parameters in the request.
+ * Based on the feedRequest values, if a file is available, then it is
+ * downloaded and the method returns the file path.
+ *
+ * If the file is not available, then the error details are returned.
+ *
+ *
+ * @param feedRequest Container for capturing parameters for downloading
+ * feed file
+ * @param downloadDirectory The local directory where the file should be
+ * downloaded. Default location is the current working directory
+ * @return GetFeedResponse GetFeedResponse
+ */
+ public GetFeedResponse get(FeedRequest feedRequest, String downloadDirectory);
- /**
- *
- * Downloads the feed file as specified by the parameters in the request. Based on the feedRequest
- * values, if a file is available, then it is downloaded and the method returns the file path.
- *
- * If the file is not available, then the error details are returned.
- *
- *
- * @param feedRequest Container for capturing parameters for downloading feed file
- * @param downloadDirectory The local directory where the file should be downloaded. Default location is
- * the current working directory
- * @return GetFeedResponse GetFeedResponse
- */
- public GetFeedResponse get(FeedRequest feedRequest, String downloadDirectory);
+ /**
+ *
+ * Downloads the feed file as specified by the parameters in the
+ * request.Based on the feedRequest values, if a file is available, then it
+ * is downloaded and the method returns the file path. If the file is not
+ * available, then the error details are returned.
+ *
+ *
+ * @param feedRequest Container for capturing parameters for downloading
+ * feed file
+ * @param downloadDirectory The local directory where the file should be
+ * downloaded. Default location is the current working directory
+ * @param credentialConfigFilePath credentials file absolute path, required
+ * for token refresh on the fly to support resume capability. Default
+ * location is the current working directory
+ * @return GetFeedResponse GetFeedResponse
+ */
+ public GetFeedResponse get(FeedRequest feedRequest, String downloadDirectory, String credentialConfigFilePath);
- /**
- *
- * Given a config file, this method parses the input, and performs necessary actions,
- * as specified in the config file.
- *
- * The config file should consist of json and follow the structure :-
- * {
- *
- * "requests": [
- * {
- * "feedRequest": {
- *
- * },
- * "filterRequest": {
- *
- * }
- * }
- *
- * ]
- * }
- *
- *
- * If the original file is already downloaded, then the feedRequest becomes optional,
- * and the unzipped file path can be provided in the 'inputFilePath' field in the
- * filter request,
- * along with the other filter characteristics.
- *
- * If the entire workflow needs to be performed i.e - download, unzip and filter,
- * then both feedRequest and filterRequest are required.
- * The inputFilePath can be omitted in this case.
- *
- *
- * @param configFile The absolute path of the file, which consists of a list of feed request or filter
- * request or both
- * @param token The oAuth token with the appropriate scope Eg - Bearer vxxx
- * @return List of type Response
- */
- public List processConfigFile(
- String configFile, String token);
+ /**
+ *
+ * Given a config file, this method parses the input, and performs necessary actions,
+ * as specified in the config file.
+ *
+ * The config file should consist of json and follow the structure :-
+ * {
+ *
+ * "requests": [
+ * {
+ * "feedRequest": {
+ *
+ * },
+ * "filterRequest": {
+ *
+ * }
+ * }
+ *
+ * ]
+ * }
+ *
+ *
+ * If the original file is already downloaded, then the feedRequest becomes optional,
+ * and the unzipped file path can be provided in the 'inputFilePath' field in the
+ * filter request,
+ * along with the other filter characteristics.
+ *
+ * If the entire workflow needs to be performed i.e - download, unzip and filter,
+ * then both feedRequest and filterRequest are required.
+ * The inputFilePath can be omitted in this case.
+ *
+ *
+ * @param configFile The absolute path of the file, which consists of a list
+ * of feed request or filter request or both
+ * @param token The oAuth token with the appropriate scope Eg - Bearer vxxx
+ * @return List of type Response
+ */
+ public List processConfigFile(
+ String configFile, String token);
}
diff --git a/src/main/java/com/ebay/feed/api/FeedImpl.java b/src/main/java/com/ebay/feed/api/FeedImpl.java
index 6d22fc9..516b6c3 100755
--- a/src/main/java/com/ebay/feed/api/FeedImpl.java
+++ b/src/main/java/com/ebay/feed/api/FeedImpl.java
@@ -11,10 +11,10 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
-
package com.ebay.feed.api;
+import com.ebay.api.client.auth.oauth2.model.AccessToken;
+import com.ebay.feed.auth.CredentialLoader;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -33,7 +33,6 @@
import okhttp3.Request;
import okhttp3.Response;
-
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,472 +44,581 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.internal.InvokeResponse;
+import com.ebay.feed.model.oauth.AuthRequest;
import com.ebay.feed.util.FeedUtil;
import com.ebay.feed.util.FilterUtil;
import com.ebay.feed.validator.FeedValidator;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import java.util.Date;
/**
*
- * Concrete implementation which consists of the core capabilities of the SDK.
+ * Concrete implementation which consists of the core capabilities of the
+ * SDK.
*
*
get - To download the feed files
*
unzip - To unzip the gzipped files filter
- *
filter - To apply filters to the unzipped file and create a new file with the filtered
- * contents
+ *
filter - To apply filters to the unzipped file and create a new file with
+ * the filtered contents
+ * Downloads the feed file as specified by the parameters in the
+ * request.Based on the feedRequest values, if a file is available, then it
+ * is downloaded and the method returns the file path. If the file is not
+ * available, then the error details are returned.
+ *
+ *
+ * @param feedRequest Container for capturing parameters for downloading
+ * feed file
+ * @param downloadDirectory The local directory where the file should be
+ * downloaded. Default location is the current working directory
+ * @param credentialConfigFilePath credentials file absolute path, required
+ * for token refresh on the fly to support resume capability while
+ * downloading feeds. Default location is the current working directory
+ * @return GetFeedResponse GetFeedResponse
+ */
+ @Override
+ public GetFeedResponse get(FeedRequest feedRequest, String downloadDirectory, String credentialConfigFilePath) {
+
+ if (null == credentialConfigFilePath || credentialConfigFilePath.isEmpty()) {
+ LOGGER.debug("********* using default credentialFilePath = {}", credentialFilePath);
+ credentialConfigFilePath = credentialFilePath;
+ }
+ LOGGER.debug("********* Begin Feed.get()");
- if (feedRequest == null) {
- return new GetFeedResponse(-1, "feedRequest is null.Aborting..", null, null);
- }
+ GetFeedResponse response = null;
+ Path downloadDirectoryPath = null;
- // if null, then take default path - current directory
- if (downloadDirectory == null) {
- downloadDirectoryPath = Paths.get(".").toAbsolutePath().normalize();
- } else {
- downloadDirectoryPath = Paths.get(downloadDirectory);
- }
+ if (feedRequest == null) {
+ return new GetFeedResponse(-1, "feedRequest is null.Aborting..", null, null);
+ }
- LOGGER.debug("feedRequest params = {}", feedRequest.toString());
+ // if null, then take default path - current directory
+ if (downloadDirectory == null) {
+ downloadDirectoryPath = Paths.get(".").toAbsolutePath().normalize();
+ } else {
+ downloadDirectoryPath = Paths.get(downloadDirectory);
+ }
- try {
- response = process(feedRequest, downloadDirectoryPath);
+ LOGGER.debug("feedRequest params = {}", feedRequest.toString());
- } catch (Exception e) {
- LOGGER.error("Exception in Feed.get()", e);
- e.printStackTrace();
- response = new GetFeedResponse(Constants.FAILURE_CODE, e.getMessage(), null, null);
- }
+ try {
+ response = process(feedRequest, downloadDirectoryPath, credentialConfigFilePath);
- LOGGER.debug("Exiting Feed.get() {}", response.getFilePath());
- return response;
- }
+ } catch (Exception e) {
+ LOGGER.error("Exception in Feed.get()", e);
+ e.printStackTrace();
+ response = new GetFeedResponse(Constants.FAILURE_CODE, e.getMessage(), null, null);
+ }
- /**
- *
- * The process method performs pre requisite functions, before calling the feed API - Adds
- * additional headers including range - Creates default file/folder path and cleansup if already
- * present
- *
- *
- * @param feedRequest
- * @param downloadDirectory Optional local directory where files can be downloaded. Default is
- * current working directory
- * @return
- * @throws IOException
- */
- private GetFeedResponse process(FeedRequest feedRequest, Path downloadDirectory)
- throws IOException {
-
- LOGGER.debug("Entering Feed.process()");
-
- if (feedRequest.getToken() == null || feedRequest.getType() == null
- || feedRequest.getCategoryId() == null || feedRequest.getMarketplaceId() == null) {
- return new GetFeedResponse(-1, "Mandatory feedRequest parameters are null. Aborting..", null,
- null);
+ LOGGER.debug("Exiting Feed.get() {}", response.getFilePath());
+ return response;
}
- Request.Builder requestBuilder = new Request.Builder();
+ /**
+ *
+ * The process method performs pre requisite functions, before calling the
+ * feed API - Adds additional headers including range - Creates default
+ * file/folder path and cleansup if already present
+ *
+ *
+ * @param feedRequest
+ * @param downloadDirectory Optional local directory where files can be
+ * downloaded. Default is current working directory
+ * @return
+ * @throws IOException
+ */
+ private GetFeedResponse process(FeedRequest feedRequest, Path downloadDirectory, String credentialConfigFilePath)
+ throws IOException {
+
+ LOGGER.debug("Entering Feed.process()");
+
+ if (feedRequest.getToken() == null || feedRequest.getType() == null
+ || feedRequest.getCategoryId() == null || feedRequest.getMarketplaceId() == null) {
+ return new GetFeedResponse(-1, "Mandatory feedRequest parameters are null. Aborting..", null,
+ null);
+ }
- Path pathToFile =
- Paths.get(downloadDirectory.toString() + "/" + feedUtils.generateFileName(feedRequest));
- LOGGER.debug("Path to store file = {}", pathToFile);
+ // checking if date format is valid and date is within valid range
+ if (!feedValidator.isValidDateFormatAndRange(feedRequest)) {
+ LOGGER.debug("Date format is not valid or Date is not within valid range. Cannot get feed. Aborting...");
+ return new GetFeedResponse(-1, "Date format is not valid or Date is not within valid range. Cannot get feed. Aborting...",
+ null, null);
+ }
- if (Files.exists(pathToFile)) {
- Files.delete(pathToFile);
- } else {
- Files.createDirectories(pathToFile.getParent());
- }
+ Request.Builder requestBuilder = new Request.Builder();
- Path path = Files.createFile(pathToFile);
+ Path pathToFile
+ = Paths.get(downloadDirectory.toString() + "/" + feedUtils.generateFileName(feedRequest));
+ LOGGER.debug("Path to store file = {}", pathToFile);
- // generate static request
- requestBuilder = feedUtils.generateRequest(feedRequest, requestBuilder);
+ if (Files.exists(pathToFile)) {
+ Files.delete(pathToFile);
+ } else {
+ Files.createDirectories(pathToFile.getParent());
+ }
- // generate dynamic header
- Long chunkSizeLimit = feedUtils.getChunkSizeLimit(feedRequest);
- requestBuilder.addHeader(Constants.RANGE_HEADER, Constants.RANGE_PREFIX + chunkSizeLimit);
+ Path path = Files.createFile(pathToFile);
- // invoke request
- return invoker(requestBuilder, path, true, chunkSizeLimit);
- }
+ // generate static request
+ requestBuilder = feedUtils.generateRequest(feedRequest, requestBuilder);
- /**
- *
- * Invokes the feed API with the max range value of 100 MB. If the file is lesser than 100 MB,
- * then it returns the downloaded file path along with the status.
- *
- * If the file is greater than 100 MB - Iteratively calls feed API, with incrementing range
- * headers - Appends content to file - Downloads entire content and returns with downloaded file
- * path.
- *
- *
- *
- * @param request The API request
- * @param path Path of the downloaded or partially downloading file, where contents need to be
- * appended
- * @param isStart - THe first request sets this parameter to true. If subsequent requests are
- * required in case of 206, then this is set to false.
- * @param chunkSizeLimit - This indicates the max chunkSize limit. For prod, it is 100 MB and for sandbox, it is 10MB.
- * @return
- */
- private GetFeedResponse invoker(Request.Builder requestBuilder, Path path, boolean isStart, Long chunkSizeLimit) {
+ // generate dynamic header
+ Long chunkSizeLimit = feedUtils.getChunkSizeLimit(feedRequest);
+ requestBuilder.addHeader(Constants.RANGE_HEADER, Constants.RANGE_PREFIX + chunkSizeLimit);
- LOGGER.debug("Entering Feed.invoker()");
+ // invoke request
+ return invoker(requestBuilder, path, true, chunkSizeLimit, feedRequest, credentialConfigFilePath);
+ }
- Request request = requestBuilder.build();
+ /**
+ *
+ * Invokes the feed API with the max range value of 100 MB. If the file is
+ * lesser than 100 MB, then it returns the downloaded file path along with
+ * the status.
+ *
+ * If the file is greater than 100 MB - Iteratively calls feed API, with
+ * incrementing range headers - Appends content to file - Downloads entire
+ * content and returns with downloaded file path.
+ *
+ *
+ *
+ * @param request The API request
+ * @param path Path of the downloaded or partially downloading file, where
+ * contents need to be appended
+ * @param isStart - THe first request sets this parameter to true. If
+ * subsequent requests are required in case of 206, then this is set to
+ * false.
+ * @param chunkSizeLimit - This indicates the max chunkSize limit. For prod,
+ * it is 100 MB and for sandbox, it is 10MB.
+ * @return
+ */
+ private GetFeedResponse invoker(Request.Builder requestBuilder, Path path, boolean isStart, Long chunkSizeLimit, FeedRequest feedRequest, String credentialConfigFilePath) {
+
+ LOGGER.debug("Entering Feed.invoker()");
+
+ Request request = requestBuilder.build();
+
+ LOGGER.debug("API request = {}", request.toString());
+
+ InvokeResponse responseFlag = invokeIteratively(request, path);
+
+ LOGGER.debug("First API Response = {}", responseFlag.toString());
+
+ if (responseFlag.getStatusCode() == 200) {
+ LOGGER.debug("First API Response is 200. All done..");
+ return new GetFeedResponse(Constants.SUCCESS_CODE, Constants.SUCCESS, fixFilePath(path, responseFlag), null);
+
+ } else if (responseFlag.getStatusCode() == 206) {
+
+ LOGGER.debug("First API Response is 206. Performing iterations...");
+
+ long requestRangeUpperLimit
+ = Long.valueOf(requestBuilder.build().header("Range").split("-")[1]) + 1;
+ long responseRangeUpperLimit = Long.valueOf(responseFlag.getContentRange().split("/")[1]);
+
+ boolean isCredentialLoaded = false;
+ //config file path for loading credentials
+ AuthRequest authRequest = new AuthRequest(credentialConfigFilePath, null);
+ CredentialLoader credentialLoader = new CredentialLoader(authRequest);
+ AccessToken accessToken = null;
+ try {
+ credentialLoader.loadCredentials();
+ //Getting access using credentials file as we have to use this for resume capability
+ accessToken = updateAccessTokenOnTheFly(credentialLoader, feedRequest, requestBuilder);
+ isCredentialLoaded = true;
+ } catch (Exception e) {
+ }
+ while (requestRangeUpperLimit <= responseRangeUpperLimit) {
- LOGGER.debug("API request = {}", request.toString());
+ long newUpperLimit = requestRangeUpperLimit + chunkSizeLimit;
+ String val = "bytes=" + requestRangeUpperLimit + "-" + newUpperLimit;
- InvokeResponse responseFlag = invokeIteratively(request, path);
+ requestBuilder.removeHeader(Constants.RANGE_HEADER);
+ requestBuilder.addHeader(Constants.RANGE_HEADER, val);
- LOGGER.debug("First API Response = {}", responseFlag.toString());
+ //this block will not execute if token passed direcrly. Backward compatibile
+ if (isCredentialLoaded) {
+ if (checkTokenExpiry(accessToken, credentialLoader, feedRequest, requestBuilder)) {
+ return new GetFeedResponse(Constants.FAILURE_CODE, Constants.FAILURE, null, null);
+ }
+ }
- if (responseFlag.getStatusCode() == 200) {
- LOGGER.debug("First API Response is 200. All done..");
- return new GetFeedResponse(Constants.SUCCESS_CODE, Constants.SUCCESS, fixFilePath(path,responseFlag), null);
+ responseFlag = invokeIteratively(requestBuilder.build(), path);
+ //Showing download progess
+ LOGGER.debug("First API Response = {}", responseFlag.toString());
- } else if (responseFlag.getStatusCode() == 206) {
+ if (responseFlag == null) {
+ return new GetFeedResponse(-1, "Internal error. Please check the logs..", null, null);
+ }
- LOGGER.debug("First API Response is 206. Performing iterations...");
+ requestRangeUpperLimit
+ = Long.valueOf(requestBuilder.build().header(Constants.RANGE_HEADER).split("-")[1]) + 1;
+ responseRangeUpperLimit = Long.valueOf(responseFlag.getContentRange().split("/")[1]);
- long requestRangeUpperLimit =
- Long.valueOf(requestBuilder.build().header("Range").split("-")[1]) + 1;
- long responseRangeUpperLimit = Long.valueOf(responseFlag.getContentRange().split("/")[1]);
+ }
+ return new GetFeedResponse(Constants.SUCCESS_CODE, Constants.SUCCESS, fixFilePath(path, responseFlag), null);
+ } else {
+ LOGGER.debug("First API Response is error. Aborting...");
+ return new GetFeedResponse(Constants.FAILURE_CODE, Constants.FAILURE, null, null);
+ }
+ }
- while (requestRangeUpperLimit <= responseRangeUpperLimit) {
+ /**
+ *
+ * @param accessToken
+ * @param credentialLoader
+ * @param feedRequest
+ * @param requestBuilder
+ * @return
+ */
+ private boolean checkTokenExpiry(AccessToken accessToken, CredentialLoader credentialLoader, FeedRequest feedRequest, Request.Builder requestBuilder) {
+ try {
+ Date currentTime = new Date();
+ //token refresh on the fly from config file to support resume capability.
+ if (accessToken.getExpiresOn().before(currentTime)) {
+ LOGGER.debug("Old Token expiry time = {}", accessToken.getExpiresOn());
+ accessToken = updateAccessTokenOnTheFly(credentialLoader, feedRequest, requestBuilder);
+ LOGGER.info("Got refresh token on the fly and New Token Expiry time = {}", accessToken.getExpiresOn());
+ }
+ } catch (Exception e) {
+ LOGGER.info("Exception in fetching the new access token " + e.getMessage());
+ return true;
+ }
+ return false;
+ }
- long newUpperLimit = requestRangeUpperLimit + chunkSizeLimit;
- String val = "bytes=" + requestRangeUpperLimit + "-" + newUpperLimit;
+ /**
+ *
+ * Since date is optional param for getting bootstrap feed, filePath will
+ * have null value(item_bootstrap-11116-null-EBAY_US.gz) This method helps
+ * to rename the null value with LastModified api response header
+ *
+ * Invoked, only if the file size is greater than max chunk size
+ *
+ *
+ * @param request The API request
+ * @param path Path of the downloaded or partially downloading file, where
+ * contents need to be appended
+ * @return
+ */
+ private InvokeResponse invokeIteratively(Request request, Path path) {
+
+ InvokeResponse responseFlag = null;
+
+ try (Response response = client.newCall(request).execute()) {
+
+ if (!response.isSuccessful()) {
+ LOGGER.debug("Error in API response - status = {}, body = {}", response.code(), response
+ .body().string());
+ return new InvokeResponse(null, response.code());
+ }
- responseFlag = invokeIteratively(requestBuilder.build(), path);
+ InputStream is = response.body().byteStream();
- if (responseFlag == null) {
- return new GetFeedResponse(-1, "Internal error. Please check the logs..", null, null);
- }
+ OutputStream outStream = new FileOutputStream(path.toString(), true);
+ byte[] buffer = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = is.read(buffer)) != -1) {
+ outStream.write(buffer, 0, bytesRead);
+ }
+ outStream.flush();
+ outStream.close();
+ is.close();
+
+ String lastModifiedHeader = response.header(Constants.LAST_MODIFIED_DATE_HEADER);
+ String lastModifiedDate = null;
+ if (!StringUtils.isEmpty(lastModifiedHeader)) {
+ LocalDate localDate = LocalDate.parse(lastModifiedHeader, DateTimeFormatter.RFC_1123_DATE_TIME);
+ lastModifiedDate = localDate.format(DateTimeFormatter.BASIC_ISO_DATE);
+ }
- requestRangeUpperLimit =
- Long.valueOf(requestBuilder.build().header(Constants.RANGE_HEADER).split("-")[1]) + 1;
- responseRangeUpperLimit = Long.valueOf(responseFlag.getContentRange().split("/")[1]);
+ responseFlag
+ = new InvokeResponse(response.header(Constants.CONTENT_RANGE_HEADER), response.code(), lastModifiedDate);
- }
- return new GetFeedResponse(Constants.SUCCESS_CODE, Constants.SUCCESS, fixFilePath(path,responseFlag), null);
- } else {
- LOGGER.debug("First API Response is error. Aborting...");
- return new GetFeedResponse(Constants.FAILURE_CODE, Constants.FAILURE, null, null);
- }
- }
-
- /**
- *
- * Since date is optional param for getting bootstrap feed, filePath will have null value(item_bootstrap-11116-null-EBAY_US.gz)
- * This method helps to rename the null value with LastModified api response header
- *
+ * Returns a new instance of response, based on the provided inputs
+ *
+ *
+ * @param statusCode
+ * @param message
+ * @param filePath
+ * @param appliedFilters
+ * @return
+ */
+ private com.ebay.feed.model.feed.operation.filter.Response createResponse(Integer statusCode,
+ String message, String filePath, FeedFilterRequest appliedFilters) {
+
+ LOGGER.debug("Returning response status code = {}, message = {}", statusCode, message);
+ LOGGER.debug("Filtered file = {}, appliedFilters = {}", filePath,
+ appliedFilters != null ? appliedFilters.toString() : null);
+
+ return new com.ebay.feed.model.feed.operation.filter.Response(statusCode, message, filePath,
+ appliedFilters);
+ }
+
+ /**
+ * Getting accessToken on the fly using credential file to support resume
+ * capability
+ *
+ * @param credentialLoader
+ * @param environment
+ * @param feedRequest
+ * @param requestBuilder
+ * @return
+ */
+ private AccessToken updateAccessTokenOnTheFly(CredentialLoader credentialLoader, FeedRequest feedRequest, Request.Builder requestBuilder) throws IOException {
+ AccessToken accessToken = credentialLoader.getOauthResponse(feedRequest.getEnv()).getAccessToken().get();
+ //using token which generated from credentials file as we don't know the expiry time of directly passed token
+ if (!accessToken.getToken().equalsIgnoreCase(feedRequest.getToken())) {
+ String token = Constants.TOKEN_BEARER_PREFIX + accessToken.getToken();
+ requestBuilder.removeHeader(Constants.AUTHORIZATION_HEADER);
+ requestBuilder.addHeader(Constants.AUTHORIZATION_HEADER, token);
+ }
+ return accessToken;
+ }
}
diff --git a/src/main/java/com/ebay/feed/api/Taxonomy.java b/src/main/java/com/ebay/feed/api/Taxonomy.java
index bb0c721..8222e52 100644
--- a/src/main/java/com/ebay/feed/api/Taxonomy.java
+++ b/src/main/java/com/ebay/feed/api/Taxonomy.java
@@ -14,7 +14,6 @@
package com.ebay.feed.api;
-import java.io.IOException;
import com.ebay.feed.model.feed.operation.taxonomy.CategoryResponse;
diff --git a/src/main/java/com/ebay/feed/auth/CredentialLoader.java b/src/main/java/com/ebay/feed/auth/CredentialLoader.java
index 26ab827..5f8cac9 100644
--- a/src/main/java/com/ebay/feed/auth/CredentialLoader.java
+++ b/src/main/java/com/ebay/feed/auth/CredentialLoader.java
@@ -11,14 +11,12 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.auth;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import com.ebay.feed.example.CombiningFilters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ebay.api.client.auth.oauth2.CredentialUtil;
@@ -30,70 +28,95 @@
/**
*
* Responsible for loading consumer credentials and generating token.
- *
+ *
* In order to generate token, the {@link #loadCredentials() loadCredentials} method needs to be
* invoked, which loads the credentials from the provided config file.
- *
+ *
* Once the credentials are loaded, the token can be obtained by invoking the
* {@link #getOauthResponse() getOauthResponse}
- *
+ *
*
- * Loads the credentials provided in the config file
- *
- *
- * @throws Exception Thrown if file is not found or credentials are invalid
- */
- public void loadCredentials() throws Exception {
+ /**
+ *
+ * Loads the credentials provided in the config file
+ *
+ *
+ * @throws Exception Thrown if file is not found or credentials are invalid
+ */
+ public void loadCredentials() throws Exception {
if (authRequest == null)
- throw new Exception("null AuthRequest");
+ throw new Exception("null AuthRequest");
+
+ LOGGER.debug("****** Begin loadCredentials with configPath = {}",
+ authRequest.getConfigFilePath());
+ try {
+
+ File f = new File(authRequest.getConfigFilePath());
+ FileInputStream fs = new FileInputStream(f);
+ CredentialUtil.load(fs);
- LOGGER.debug("****** Begin loadCredentials with configPath = {}",
- authRequest.getConfigFilePath());
- try {
+ } catch (Exception e) {
+ LOGGER.debug("Exception in loadCredentials", e);
+ throw new Exception("Could not load credentials");
+ }
+ }
+
+ /**
+ *
+ * Generates oauth token, based on the loaded credentials
+ *
+ *
+ * @return Returns the OAuthResponse which contains the token
+ * @throws IOException Thrown if file is not found
+ */
+ public OAuthResponse getOauthResponse() throws IOException {
+
+ LOGGER.debug("****** Begin getOauthResponse with configPath = {}",
+ authRequest.getConfigFilePath());
+ OAuth2Api api = new OAuth2Api();
+ OAuthResponse res = api.getApplicationToken(Environment.PRODUCTION, authRequest.getScopes());
+ return res;
+
+ }
- File f = new File(authRequest.getConfigFilePath());
- FileInputStream fs = new FileInputStream(f);
- CredentialUtil.load(fs);
+ /**
+ *
+ * Generates oauth token, based on the loaded credentials
+ *
+ *
+ * @param environment
+ * @return Returns the OAuthResponse which contains the token
+ * @throws IOException Thrown if file is not found
+ */
+ public OAuthResponse getOauthResponse(String environment) throws IOException {
+
+ LOGGER.debug("****** Begin getOauthResponse with configPath = {}",
+ authRequest.getConfigFilePath());
+ OAuth2Api api = new OAuth2Api();
+ OAuthResponse res = null;
+ //checking environment for token
+ if (environment.equalsIgnoreCase("SANDBOX")) {
+ res = api.getApplicationToken(Environment.SANDBOX, authRequest.getScopes());
+ } else {
+ res = api.getApplicationToken(Environment.PRODUCTION, authRequest.getScopes());
+ }
+ return res;
- } catch (Exception e) {
- LOGGER.debug("Exception in loadCredentials", e);
- throw new Exception("Could not load credentials");
}
- }
-
- /**
- *
- * Generates oauth token, based on the loaded credentials
- *
- *
- * @return Returns the OAuthResponse which contains the token
- * @throws IOException Thrown if file is not found
- */
- public OAuthResponse getOauthResponse() throws IOException {
-
- LOGGER.debug("****** Begin getOauthResponse with configPath = {}",
- authRequest.getConfigFilePath());
- OAuth2Api api = new OAuth2Api();
- OAuthResponse res = api.getApplicationToken(Environment.PRODUCTION, authRequest.getScopes());
- return res;
-
- }
}
diff --git a/src/main/java/com/ebay/feed/cli/FeedCli.java b/src/main/java/com/ebay/feed/cli/FeedCli.java
index ba041ed..2210ae3 100644
--- a/src/main/java/com/ebay/feed/cli/FeedCli.java
+++ b/src/main/java/com/ebay/feed/cli/FeedCli.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.cli;
import java.util.ArrayList;
@@ -31,8 +30,6 @@
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
import com.ebay.feed.auth.CredentialLoader;
-import com.ebay.feed.enums.EnvTypeEnum;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -40,283 +37,307 @@
import com.ebay.feed.model.feed.operation.filter.Response;
import com.ebay.feed.model.oauth.AuthRequest;
-
/**
*
* Wrapper for exposing feed sdk capabilities using CLI
*
- *
+ *
* @author shanganesh
*
*/
public class FeedCli {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(FeedCli.class);
-
- public static void main(String[] args) throws Exception {
-
- // ***Definition Stage***
-
- // create Options object
- Options options = new Options();
-
- options.addOption("help", false, "display help");
-
- /***
- * options for downloading the file
- */
- // date
- options.addOption("dt", true, "the date when feed file was generated");
-
- // l1 category
- options.addOption("c1", true, "the l1 category id of the feed file");
-
- // scope
- options.addOption("scope", true,
- "the feed scope. Available scopes are ALL_ACTIVE or NEWLY_LISTED");
-
- // marketplace
- options.addOption("mkt", true,
- "the marketplace id for which feed is being request. For example - EBAY_US");
-
- // token
- options.addOption("token", true, "the oauth token for the consumer. Omit the word 'Bearer'");
-
- // env
- options.addOption("env", true, "Supported environment types are SANDBOX, PRODUCTION");
-
- /**
- * options for filtering the files
- */
-
- Option filterL2 =
- new Option("c2f", true, "list of l2 categories which are used to filter the feed");
- filterL2.hasArgs();
- filterL2.setArgs(Option.UNLIMITED_VALUES);
- options.addOption(filterL2);
-
- Option filterL3 =
- new Option("c3f", true, "list of l3 categories which are used to filter the feed");
- filterL3.hasArgs();
- filterL3.setArgs(Option.UNLIMITED_VALUES);
- options.addOption(filterL3);
-
- Option filterLeaf =
- new Option("lf", true, "list of leaf categories which are used to filter the feed");
- filterLeaf.hasArgs();
- filterLeaf.setArgs(Option.UNLIMITED_VALUES);
- options.addOption(filterLeaf);
-
- Option filterSeller =
- new Option("sellerf", true, "list of seller names which are used to filter the feed");
- filterSeller.hasArgs();
- filterSeller.setArgs(Option.UNLIMITED_VALUES);
- options.addOption(filterSeller);
-
- Option filterLocation =
- new Option("locf", true, "list of item locations which are used to filter the feed");
- filterLocation.hasArgs();
- filterLocation.setArgs(Option.UNLIMITED_VALUES);
- options.addOption(filterLocation);
-
- options.addOption("pricelf", true, "lower limit of the price range for items in the feed");
-
- options.addOption("priceuf", true, "upper limit of the price range for items in the feed");
-
-
- Option filterEpid =
- new Option("epidf", true, "list of epids which are used to filter the feed");
- filterEpid.hasArgs();
- filterEpid.setArgs(Option.UNLIMITED_VALUES);
- options.addOption(filterEpid);
-
- Option filterInferredEpid =
- new Option("iepidf", true, "list of inferred epids which are used to filter the feed");
- filterInferredEpid.hasArgs();
- filterInferredEpid.setArgs(Option.UNLIMITED_VALUES);
- options.addOption(filterInferredEpid);
-
- Option filterGtin =
- new Option("gtinf", true, "list of gtins which are used to filter the feed");
- filterGtin.hasArgs();
- filterGtin.setArgs(Option.UNLIMITED_VALUES);
- options.addOption(filterGtin);
-
- Option filterItem =
- new Option("itemf", true, "list of item ids which are used to filter the feed");
- filterItem.hasArgs();
- filterItem.setArgs(Option.UNLIMITED_VALUES);
- options.addOption(filterItem);
-
- /**
- * Overrides for file locations
- */
-
- // file location
- options.addOption("dl", "downloadlocation", true,
- "override for changing the directory where files are downloaded");
-
- // oauth related
- options.addOption("cl", "credentiallocation", true,
- "directory where the credentials file is located");
-
- options.addOption("authscopes", "oauthscopes", true, "list of scopes");
-
- // ***Parsing Stage***
- // Create a parser
- CommandLineParser parser = new DefaultParser();
- // parse the options passed as command line arguments
- CommandLine cmd = parser.parse(options, args);
+ private static final Logger LOGGER = LoggerFactory.getLogger(FeedCli.class);
- // ***Interrogation Stage***
- // hasOptions checks if option is present or not
+ public static void main(String[] args) throws Exception {
- // populate feed request
- FeedRequestBuilder builder = new FeedRequestBuilder();
+ // ***Definition Stage***
+ // create Options object
+ Options options = new Options();
- if (cmd.hasOption("dt"))
- builder.date(cmd.getOptionValue("dt"));
+ options.addOption("help", false, "display help");
- if (cmd.hasOption("c1"))
- builder.categoryId(cmd.getOptionValue("c1"));
-
- if (cmd.hasOption("mkt"))
- builder.siteId(cmd.getOptionValue("mkt"));
-
- if (cmd.hasOption("scope"))
- builder.feedScope(cmd.getOptionValue("scope"));
+ /***
+ * options for downloading the file
+ */
+ // date
+ options.addOption("dt", true, "the date when feed file was generated");
+
+ // snapshot_date
+ options.addOption("sdt", true, "the snapshot_date when feed file was generated");
+
+ // l1 category
+ options.addOption("c1", true, "the l1 category id of the feed file");
+
+ // scope
+ options.addOption("scope", true,
+ "the feed scope. Available scopes are ALL_ACTIVE or NEWLY_LISTED");
+
+ // marketplace
+ options.addOption("mkt", true,
+ "the marketplace id for which feed is being request. For example - EBAY_US");
+
+ // token
+ options.addOption("token", true, "the oauth token for the consumer. Omit the word 'Bearer'");
+
+ // env
+ options.addOption("env", true, "Supported environment types are SANDBOX, PRODUCTION");
+
+ // type
+ options.addOption("type", true, "Supported feed types are ITEM, ITEM_SNAPSHOT");
+
+ /**
+ * options for filtering the files
+ */
+ Option filterL2
+ = new Option("c2f", true, "list of l2 categories which are used to filter the feed");
+ filterL2.hasArgs();
+ filterL2.setArgs(Option.UNLIMITED_VALUES);
+ options.addOption(filterL2);
+
+ Option filterL3
+ = new Option("c3f", true, "list of l3 categories which are used to filter the feed");
+ filterL3.hasArgs();
+ filterL3.setArgs(Option.UNLIMITED_VALUES);
+ options.addOption(filterL3);
+
+ Option filterLeaf
+ = new Option("lf", true, "list of leaf categories which are used to filter the feed");
+ filterLeaf.hasArgs();
+ filterLeaf.setArgs(Option.UNLIMITED_VALUES);
+ options.addOption(filterLeaf);
+
+ Option filterSeller
+ = new Option("sellerf", true, "list of seller names which are used to filter the feed");
+ filterSeller.hasArgs();
+ filterSeller.setArgs(Option.UNLIMITED_VALUES);
+ options.addOption(filterSeller);
+
+ Option filterLocation
+ = new Option("locf", true, "list of item locations which are used to filter the feed");
+ filterLocation.hasArgs();
+ filterLocation.setArgs(Option.UNLIMITED_VALUES);
+ options.addOption(filterLocation);
+
+ options.addOption("pricelf", true, "lower limit of the price range for items in the feed");
+
+ options.addOption("priceuf", true, "upper limit of the price range for items in the feed");
+
+ Option filterEpid
+ = new Option("epidf", true, "list of epids which are used to filter the feed");
+ filterEpid.hasArgs();
+ filterEpid.setArgs(Option.UNLIMITED_VALUES);
+ options.addOption(filterEpid);
+
+ Option filterInferredEpid
+ = new Option("iepidf", true, "list of inferred epids which are used to filter the feed");
+ filterInferredEpid.hasArgs();
+ filterInferredEpid.setArgs(Option.UNLIMITED_VALUES);
+ options.addOption(filterInferredEpid);
+
+ Option filterGtin
+ = new Option("gtinf", true, "list of gtins which are used to filter the feed");
+ filterGtin.hasArgs();
+ filterGtin.setArgs(Option.UNLIMITED_VALUES);
+ options.addOption(filterGtin);
+
+ Option filterItem
+ = new Option("itemf", true, "list of item ids which are used to filter the feed");
+ filterItem.hasArgs();
+ filterItem.setArgs(Option.UNLIMITED_VALUES);
+ options.addOption(filterItem);
+
+ /**
+ * Overrides for file locations
+ */
+ // file location
+ options.addOption("dl", "downloadlocation", true,
+ "override for changing the directory where files are downloaded");
+
+ // oauth related
+ options.addOption("cl", "credentiallocation", true,
+ "directory where the credentials file is located");
+
+ options.addOption("authscopes", "oauthscopes", true, "list of scopes");
+
+ // ***Parsing Stage***
+ // Create a parser
+ CommandLineParser parser = new DefaultParser();
+
+ // parse the options passed as command line arguments
+ CommandLine cmd = parser.parse(options, args);
+
+ // ***Interrogation Stage***
+ // hasOptions checks if option is present or not
+ // populate feed request
+ FeedRequestBuilder builder = new FeedRequestBuilder();
+
+ if (cmd.hasOption("dt"))
+ builder.date(cmd.getOptionValue("dt"));
+
+ if (cmd.hasOption("sdt"))
+ builder.snapshotDate(cmd.getOptionValue("sdt"));
+
+ if (cmd.hasOption("c1"))
+ builder.categoryId(cmd.getOptionValue("c1"));
+
+ if (cmd.hasOption("mkt"))
+ builder.siteId(cmd.getOptionValue("mkt"));
+
+ if (cmd.hasOption("scope"))
+ builder.feedScope(cmd.getOptionValue("scope"));
+
+ if (cmd.hasOption("token"))
+ builder.token("Bearer " + cmd.getOptionValue("token"));
- if (cmd.hasOption("token"))
- builder.token("Bearer " + cmd.getOptionValue("token"));
-
if (cmd.hasOption("env")){
- builder.env(cmd.getOptionValue("env"));
+ builder.env(cmd.getOptionValue("env"));
}
-
- // TODO : Hardcoded item
- builder.type(FeedTypeEnum.ITEM);
- FeedRequest feedRequest = builder.build();
-
- // populate filter request if available
- FeedFilterRequest filterRequest = new FeedFilterRequest();
-
- // populate auth request if available
- String credentialFile = null;
- String optionalDownloadPath = null;
- List scopes = null;
-
- System.out.println(cmd.getOptionValue("lf"));
+
+ if (cmd.hasOption("type")) {
+ builder.type(cmd.getOptionValue("type"));
+ } else {
+ // Hardcoded item for backword compatibilty
+ builder.type("item");
+ }
+ FeedRequest feedRequest = builder.build();
+
+ // populate filter request if available
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+
+ // populate auth request if available
+ String credentialFile = null;
+ String optionalDownloadPath = null;
+ List scopes = null;
+
+ System.out.println(cmd.getOptionValue("lf"));
if (cmd.hasOption("lf"))
- filterRequest
- .setLeafCategoryIds(new HashSet(Arrays.asList(cmd.getOptionValues("lf"))));
+ filterRequest
+ .setLeafCategoryIds(new HashSet(Arrays.asList(cmd.getOptionValues("lf"))));
if (cmd.hasOption("c3f"))
- filterRequest.setLevelThreeCategories(new HashSet(Arrays.asList(cmd
- .getOptionValues("c3f"))));
-
- if (cmd.hasOption("c2f"))
- filterRequest.setLevelTwoCategories(new HashSet(Arrays.asList(cmd
- .getOptionValues("c3f"))));
-
- if (cmd.hasOption("sellerf"))
- filterRequest.setSellerNames(new HashSet(
- Arrays.asList(cmd.getOptionValues("sellerf"))));
-
- if (cmd.hasOption("locf"))
- filterRequest.setItemLocationCountries(new HashSet(Arrays.asList(cmd
- .getOptionValues("locf"))));
-
- if (cmd.hasOption("pricelf"))
- filterRequest.setPriceLowerLimit(Double.valueOf(cmd.getOptionValue("pricelf")));
-
- if (cmd.hasOption("priceuf"))
- filterRequest.setPriceUpperLimit(Double.valueOf(cmd.getOptionValue("priceuf")));
-
- if (cmd.hasOption("epidf"))
- filterRequest.setEpids(new HashSet(Arrays.asList(cmd.getOptionValues("epidf"))));
-
- if (cmd.hasOption("iepidf"))
- filterRequest.setInferredEpids(new HashSet(Arrays.asList(cmd
- .getOptionValues("iepidf"))));
-
- if (cmd.hasOption("gtinf"))
- filterRequest.setGtins(new HashSet(Arrays.asList(cmd.getOptionValues("gtinf"))));
-
- if (cmd.hasOption("itemf"))
- filterRequest.setItemIds(new HashSet(Arrays.asList(cmd.getOptionValues("itemf"))));
-
- if (cmd.hasOption("c1"))
- filterRequest.setLevelOneCategory(cmd.getOptionValue("c1"));
-
- if (cmd.hasOption("token"))
- filterRequest.setToken("Bearer " + cmd.getOptionValue("token"));
+ filterRequest.setLevelThreeCategories(new HashSet(Arrays.asList(cmd
+ .getOptionValues("c3f"))));
+
+ if (cmd.hasOption("c2f")) {
+ filterRequest.setLevelTwoCategories(new HashSet(Arrays.asList(cmd
+ .getOptionValues("c3f"))));
+ }
+
+ if (cmd.hasOption("sellerf")) {
+ filterRequest.setSellerNames(new HashSet(
+ Arrays.asList(cmd.getOptionValues("sellerf"))));
+ }
+
+ if (cmd.hasOption("locf")) {
+ filterRequest.setItemLocationCountries(new HashSet(Arrays.asList(cmd
+ .getOptionValues("locf"))));
+ }
+
+ if (cmd.hasOption("pricelf")) {
+ filterRequest.setPriceLowerLimit(Double.valueOf(cmd.getOptionValue("pricelf")));
+ }
+
+ if (cmd.hasOption("priceuf")) {
+ filterRequest.setPriceUpperLimit(Double.valueOf(cmd.getOptionValue("priceuf")));
+ }
+
+ if (cmd.hasOption("epidf")) {
+ filterRequest.setEpids(new HashSet(Arrays.asList(cmd.getOptionValues("epidf"))));
+ }
+
+ if (cmd.hasOption("iepidf")) {
+ filterRequest.setInferredEpids(new HashSet(Arrays.asList(cmd
+ .getOptionValues("iepidf"))));
+ }
+
+ if (cmd.hasOption("gtinf")) {
+ filterRequest.setGtins(new HashSet(Arrays.asList(cmd.getOptionValues("gtinf"))));
+ }
+
+ if (cmd.hasOption("itemf")) {
+ filterRequest.setItemIds(new HashSet(Arrays.asList(cmd.getOptionValues("itemf"))));
+ }
+
+ if (cmd.hasOption("c1")) {
+ filterRequest.setLevelOneCategory(cmd.getOptionValue("c1"));
+ }
+
+ if (cmd.hasOption("token")) {
+ filterRequest.setToken("Bearer " + cmd.getOptionValue("token"));
+ }
+
+ if (cmd.hasOption("mkt")) {
+ filterRequest.setMarketplace(cmd.getOptionValue("mkt"));
+ }
+
+ if (cmd.hasOption("cl")) {
+ credentialFile = cmd.getOptionValue("cl");
+ }
+
+ if (cmd.hasOption("dl")) {
+ optionalDownloadPath = cmd.getOptionValue("dl");
+ }
+
+ if (cmd.hasOption("authscopes")) {
+ scopes = new ArrayList(Arrays.asList(cmd.getOptionValues("authscopes")));
+ }
+
+ if (cmd.hasOption("help")) {
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.setOptionComparator(null);
+ formatter.printHelp("Feed SDK CLI", options);
+ } else if (cmd.getOptions().length > 0) {
+
+ // create auth request
+ AuthRequest authRequest = new AuthRequest(credentialFile, scopes);
+
+ // start processing
+ start(feedRequest, filterRequest, authRequest, optionalDownloadPath);
+ }
+ }
- if (cmd.hasOption("mkt"))
- filterRequest.setMarketplace(cmd.getOptionValue("mkt"));
+ /**
+ *
+ * Begin the process of downloading and filtering feed based on the input
+ * parameters
+ *
+ *
+ * @param feedRequest
+ * @param filterRequest
+ * @throws Exception
+ */
+ private static void start(FeedRequest feedRequest, FeedFilterRequest filterRequest,
+ AuthRequest authRequest, String optionalDownloadPath) throws Exception {
- if (cmd.hasOption("cl"))
- credentialFile = cmd.getOptionValue("cl");
+ Feed feed = new FeedImpl();
- if (cmd.hasOption("dl"))
- optionalDownloadPath = cmd.getOptionValue("dl");
+ // if token is null, then retrieve from oauth lib and set in request
+ if (feedRequest.getToken() == null) {
+ CredentialLoader credentialLoader = new CredentialLoader(authRequest);
+ credentialLoader.loadCredentials();
+ feedRequest.setToken(credentialLoader.getOauthResponse().getAccessToken().get().getToken());
+ filterRequest.setToken(credentialLoader.getOauthResponse().getAccessToken().get().getToken());
+ }
- if (cmd.hasOption("authscopes"))
- scopes = new ArrayList(Arrays.asList(cmd.getOptionValues("authscopes")));
+ // download feed
+ GetFeedResponse getFeedResponse = feed.get(feedRequest, optionalDownloadPath);
- if (cmd.hasOption("help")) {
- HelpFormatter formatter = new HelpFormatter();
- formatter.setOptionComparator(null);
- formatter.printHelp("Feed SDK CLI", options);
- } else if (cmd.getOptions().length > 0) {
+ if (getFeedResponse.getStatusCode() != 0) {
+ return;
+ }
+ // unzip
+ Response unzipResponse = feed.unzip(getFeedResponse.getFilePath());
- // create auth request
- AuthRequest authRequest = new AuthRequest(credentialFile, scopes);
+ if (unzipResponse.getStatusCode() != 0) {
+ return;
+ }
- // start processing
- start(feedRequest, filterRequest, authRequest, optionalDownloadPath);
- }
- }
-
- /**
- *
- * Begin the process of downloading and filtering feed based on the input parameters
- *
- *
- * @param feedRequest
- * @param filterRequest
- * @throws Exception
- */
- private static void start(FeedRequest feedRequest, FeedFilterRequest filterRequest,
- AuthRequest authRequest, String optionalDownloadPath) throws Exception {
-
- Feed feed = new FeedImpl();
-
- // if token is null, then retrieve from oauth lib and set in request
- if (feedRequest.getToken() == null) {
- CredentialLoader credentialLoader = new CredentialLoader(authRequest);
- credentialLoader.loadCredentials();
- feedRequest.setToken(credentialLoader.getOauthResponse().getAccessToken().get().getToken());
- filterRequest.setToken(credentialLoader.getOauthResponse().getAccessToken().get().getToken());
+ // filter
+ filterRequest.setInputFilePath(unzipResponse.getFilePath());
+ Response filterResponse = feed.filter(filterRequest);
+ System.out.println("Filter response = " + filterResponse.toString());
}
- // download feed
- GetFeedResponse getFeedResponse = feed.get(feedRequest, optionalDownloadPath);
-
- if (getFeedResponse.getStatusCode() != 0)
- return;
-
- // unzip
- Response unzipResponse = feed.unzip(getFeedResponse.getFilePath());
-
- if (unzipResponse.getStatusCode() != 0)
- return;
-
- // filter
- filterRequest.setInputFilePath(unzipResponse.getFilePath());
- Response filterResponse = feed.filter(filterRequest);
- System.out.println("Filter response = " + filterResponse.toString());
- }
-
}
diff --git a/src/main/java/com/ebay/feed/constants/Constants.java b/src/main/java/com/ebay/feed/constants/Constants.java
index 126fb28..430d211 100755
--- a/src/main/java/com/ebay/feed/constants/Constants.java
+++ b/src/main/java/com/ebay/feed/constants/Constants.java
@@ -11,60 +11,69 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.constants;
public class Constants {
- /**
- * Base path for the feed api
- */
- public static final String FEED_API_PROD_BASE = "https://api.ebay.com/buy/feed/v1_beta/";
-
- public static final String FEED_API_SANDBOX_BASE = "https://api.sandbox.ebay.com/buy/feed/v1_beta/";
-
- // max content that can be downloaded in one request, in bytes
- public static final Long PROD_CHUNK_SIZE = 104857600L;
- public static final Long SANDBOX_CHUNK_SIZE = 10485760L;
-
- // timeout for http client
- public static final Integer TIMEOUT = 30;
+ /**
+ * Base path for the feed api
+ */
+ public static final String FEED_API_PROD_BASE = "https://api.ebay.com/buy/feed/v1_beta/";
+
+ public static final String FEED_API_SANDBOX_BASE = "https://api.sandbox.ebay.com/buy/feed/v1_beta/";
+
+ // max content that can be downloaded in one request, in bytes
+ public static final Long PROD_CHUNK_SIZE = 104857600L;
+ public static final Long SANDBOX_CHUNK_SIZE = 10485760L;
+
+ // timeout for http client
+ public static final Integer TIMEOUT = 30;
+
+ // api related constants
+ public static final String AUTHORIZATION_HEADER = "Authorization";
+
+ // taxonomy
+ public static final String TAXONOMY_DEFAULT
+ = "https://api.ebay.com/commerce/taxonomy/v1_beta/get_default_category_tree_id?marketplace_id=";
+
+ public static final String TAXONOMY_CATEGORY_SUBTREE_BASE = "https://api.ebay.com/commerce/taxonomy/v1_beta/category_tree/";
+ public static final String TAXONOMY_CATEGORY_SUBTREE_QUERY = "/get_category_subtree?category_id=";
+
+ // status and util related constants
+ public static final String SUCCESS = "Success";
+ public static final Integer SUCCESS_CODE = 0;
+ public static final String FAILURE = "Failure";
+ public static final Integer FAILURE_CODE = -1;
+ public static final String RANGE_PREFIX = "bytes=0-";
+ public static final String RANGE_HEADER = "Range";
+ public static final String CONTENT_RANGE_HEADER = "Content-Range";
+ public static final String LAST_MODIFIED_DATE_HEADER = "Last-Modified";
+ public static final String TOKEN_BEARER_PREFIX = "Bearer ";
+ public static final String TRUE = "true";
+ public static final String FALSE = "false";
+ public static final String ITEM_RESOURCE_SCOPE = "item?feed_scope=";
+ public static final String ITEM_SNAPSHOT_RESOURCE = "item_snapshot?";
+ public static final String QUERY_PARAM_SEPARATOR = "&";
+ public static final String QUERY_CATEGORY_ID = "category_id=";
+ public static final String QUERY_DATE = "date=";
+ public static final String QUERY_SNAPSHOT_DATE = "snapshot_date=";
+ public static final String QUERY_DATE_FORMAT = "yyyyMMdd";
+ public static final String QUERY_SNAPSHOT_DATE_FORMAT = "yyyy-MM-dd'T'HH:00:00.000'Z'";
+ public static final String MARKETPLACE_HEADER = "X-EBAY-C-MARKETPLACE-ID";
+ public static final String CONTENT_TYPE_HEADER = "Content-type";
+ public static final String ACCEPT_HEADER = "Accept";
+
+ public static final String ALL_ACTIVE = "ALL_ACTIVE";
+ public static final String NEWLY_LISTED = "NEWLY_LISTED";
+ public static final Integer NEWLY_LISTED_AVAILABILITY_START_DAY = -14;
+ public static final Integer NEWLY_LISTED_AVAILABILITY_END_DAY = -2;
+
+ public static final Integer ITEM_SNAPSHOT_AVAILABILITY_START_DAY = -7;
+ public static final Integer ITEM_SNAPSHOT_AVAILABILITY_END_HOUR = -2;
- // api related constants
- public static final String AUTHORIZATION_HEADER = "Authorization";
-
- // taxonomy
- public static final String TAXONOMY_DEFAULT =
- "https://api.ebay.com/commerce/taxonomy/v1_beta/get_default_category_tree_id?marketplace_id=";
-
- public static final String TAXONOMY_CATEGORY_SUBTREE_BASE = "https://api.ebay.com/commerce/taxonomy/v1_beta/category_tree/";
- public static final String TAXONOMY_CATEGORY_SUBTREE_QUERY = "/get_category_subtree?category_id=";
-
- // status and util related constants
- public static final String SUCCESS = "Success";
- public static final Integer SUCCESS_CODE = 0;
- public static final String FAILURE = "Failure";
- public static final Integer FAILURE_CODE = -1;
- public static final String RANGE_PREFIX = "bytes=0-";
- public static final String RANGE_HEADER = "Range";
- public static final String CONTENT_RANGE_HEADER = "Content-Range";
- public static final String LAST_MODIFIED_DATE_HEADER = "Last-Modified";
- public static final String TOKEN_BEARER_PREFIX = "Bearer ";
- public static final String TRUE = "true";
- public static final String FALSE = "false";
- public static final String ITEM_RESOURCE_SCOPE = "item?feed_scope=";
- public static final String QUERY_PARAM_SEPARATOR = "&";
- public static final String QUERY_CATEGORY_ID = "category_id=";
- public static final String QUERY_DATE = "date=";
- public static final String MARKETPLACE_HEADER = "X-EBAY-C-MARKETPLACE-ID";
- public static final String CONTENT_TYPE_HEADER = "Content-type";
- public static final String ACCEPT_HEADER = "Accept";
+ public static final String BOOTSTRAP = "bootstrap";
+ public static final String DAILY = "daily";
+ public static final String SEPARATOR = "\\t";
+ public static final String ITEM_ID = "ItemId";
- public static final String ALL_ACTIVE = "ALL_ACTIVE";
-
- public static final String BOOTSTRAP = "bootstrap";
- public static final String DAILY = "daily";
- public static final String SEPARATOR = "\\t";
- public static final String ITEM_ID = "ItemId";
-
}
diff --git a/src/main/java/com/ebay/feed/enums/FeedTypeEnum.java b/src/main/java/com/ebay/feed/enums/FeedTypeEnum.java
index b37ff03..aac0cba 100644
--- a/src/main/java/com/ebay/feed/enums/FeedTypeEnum.java
+++ b/src/main/java/com/ebay/feed/enums/FeedTypeEnum.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.enums;
/**
@@ -23,5 +22,14 @@
*/
public enum FeedTypeEnum {
- ITEM
+ ITEM, ITEM_SNAPSHOT;
+
+ public static FeedTypeEnum getFeedEnum(String name) {
+ for (FeedTypeEnum feedEnum : FeedTypeEnum.values()) {
+ if (feedEnum.name().equalsIgnoreCase(name)) {
+ return feedEnum;
+ }
+ }
+ return null;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/CombiningFilters.java b/src/main/java/com/ebay/feed/example/CombiningFilters.java
index 385a904..0ffd291 100644
--- a/src/main/java/com/ebay/feed/example/CombiningFilters.java
+++ b/src/main/java/com/ebay/feed/example/CombiningFilters.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -19,7 +18,6 @@
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
import com.ebay.feed.constants.Constants;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -28,10 +26,11 @@
/**
*
- * Example showing how to download and filter feed files based on a combination of filter criteria
- * The download location is default - current working directory
- * This example downloads the bootstrap feed file for L1 category : 1 (Collectibles) and filters on
- * :-
+ * Example showing how to download and filter feed files based on a combination
+ * of filter criteria The download location is default - current working
+ * directory
+ * This example downloads the bootstrap feed file for L1 category : 1
+ * (Collectibles) and filters on :-
* - leaf categories
* - price
* - item location
@@ -41,93 +40,93 @@
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class CombiningFilters {
- // oauth token with Bearer prefix
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#I^3....";
-
- // init feed
- static Feed feed = new FeedImpl();
-
- private static final String CATEGORY = "1";
-
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180805";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
-
- public static void main(String[] args) {
-
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FeedTypeEnum.ITEM);
-
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
-
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
+ // oauth token with Bearer prefix
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#I^3....";
+
+ // init feed
+ static Feed feed = new FeedImpl();
+
+ private static final String CATEGORY = "1";
+
+ private static final String DATE = "20180805";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
+
+ public static void main(String[] args) {
+
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(FEEDTYPE);
+
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
+ }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+
+ // filter for leaf category ids
+ filterRequest.setLeafCategoryIds(getLeafCategorySet());
+
+ // filter for price
+ filterRequest.setPriceLowerLimit(10.0);
+ filterRequest.setPriceUpperLimit(50.0);
+
+ // filter for item location
+ filterRequest.setItemLocationCountries(getItemLocationSet());
+
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
-
- // filter for leaf category ids
- filterRequest.setLeafCategoryIds(getLeafCategorySet());
-
- // filter for price
- filterRequest.setPriceLowerLimit(10.0);
- filterRequest.setPriceUpperLimit(50.0);
-
- // filter for item location
- filterRequest.setItemLocationCountries(getItemLocationSet());
-
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
-
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
- }
-
- /**
- * Get the set of leaf category ids to filter on
- *
- * @return
- */
- private static Set getLeafCategorySet() {
- Set leafCategorySet = new HashSet<>();
- leafCategorySet.add("11675");
- leafCategorySet.add("3226");
- return leafCategorySet;
- }
-
- /**
- * Get the set of item locations to filter on
- *
- * @return
- */
- private static Set getItemLocationSet() {
- Set itemLocationSet = new HashSet<>();
- itemLocationSet.add("CN");
- return itemLocationSet;
- }
+ /**
+ * Get the set of leaf category ids to filter on
+ *
+ * @return
+ */
+ private static Set getLeafCategorySet() {
+ Set leafCategorySet = new HashSet<>();
+ leafCategorySet.add("11675");
+ leafCategorySet.add("3226");
+ return leafCategorySet;
+ }
+
+ /**
+ * Get the set of item locations to filter on
+ *
+ * @return
+ */
+ private static Set getItemLocationSet() {
+ Set itemLocationSet = new HashSet<>();
+ itemLocationSet.add("CN");
+ return itemLocationSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java b/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
index e22f08f..2cc3915 100644
--- a/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
+++ b/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.List;
@@ -23,13 +22,13 @@
public class ConfigFileBasedExample {
- // credentials file absolute path
- static String credentialFilePath = "credentials.yaml";
+ // credentials file absolute path
+ static String credentialFilePath = "credentials.yaml";
- // init feed
- static Feed feed = new FeedImpl();
+ // init feed
+ static Feed feed = new FeedImpl();
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) throws Exception {
// null scopes result in default values being used
AuthRequest authRequest = new AuthRequest(credentialFilePath, null);
@@ -39,14 +38,14 @@ public static void main(String[] args) throws Exception {
credentialLoader.loadCredentials();
String token = credentialLoader.getOauthResponse().getAccessToken().get().getToken();
- // expects path to the config file. The config file should be a json with the
- // structure mirroring the pojo ConfigFileBasedRequest.java
- String configFilePath = "sample-config/config-file-download-unzip-filter";
- List responses = feed.processConfigFile(configFilePath, token);
-
- for (Response response : responses) {
- System.out.println(response.toString());
+ // expects path to the config file. The config file should be a json with the
+ // structure mirroring the pojo ConfigFileBasedRequest.java
+ String configFilePath = "sample-config/config-file-download-unzip-filter";
+ List responses = feed.processConfigFile(configFilePath, token);
+
+ for (Response response : responses) {
+ System.out.println(response.toString());
+ }
}
- }
}
diff --git a/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java b/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
new file mode 100644
index 0000000..6b8d8e2
--- /dev/null
+++ b/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2018 eBay Inc.
+ *
+ * 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.
+ */
+package com.ebay.feed.example;
+
+import java.util.HashSet;
+import java.util.Set;
+import com.ebay.feed.api.Feed;
+import com.ebay.feed.api.FeedImpl;
+import com.ebay.feed.constants.Constants;
+import com.ebay.feed.enums.EnvTypeEnum;
+import com.ebay.feed.model.feed.download.GetFeedResponse;
+import com.ebay.feed.model.feed.operation.feed.FeedRequest;
+import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
+import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
+import com.ebay.feed.model.feed.operation.filter.Response;
+
+/**
+ *
+ * Example showing how to download and filter item_snapshot feed files based on
+ * itemIds. The download location is default - current working directory
+ * This example downloads the item_snapshot feed file for L1 category : 1
+ * (Collectibles) and filters on itemIds.
+ * The filtering is performed on the unzipped file.
+ * So the sequence of events that are followed is :-
+ * - Download feed file
+ * - Unzip feed file
+ * - Filter feed file
+ *
+ *
+ *
+ */
+public class FeedTypeItemSnapShot {
+
+ // oauth token - Bearer xxx
+ static String token
+ = Constants.TOKEN_BEARER_PREFIX
+ + "v^1.1#i^1#f...";
+
+ // init feed
+ static Feed feed = new FeedImpl();
+
+ private static final String CATEGORY = "625";
+ private static final String SNAPSHOT_DATE = "2021-01-29T02:00:00.000Z";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item_snapshot";
+
+ public static void main(String[] args) {
+
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+
+ builder.categoryId(CATEGORY).snapshotDate(SNAPSHOT_DATE).siteId(MKT).token(token)
+ .type(FEEDTYPE).env(EnvTypeEnum.SANDBOX.name());
+
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ // set price lower and upper limit
+ filterRequest.setPriceLowerLimit(10.0);
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
+
+ }
+
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getItemIds() {
+ Set itemIdSet = new HashSet<>();
+ itemIdSet.add("132029430107");
+ itemIdSet.add("132676918161");
+ itemIdSet.add("14270967132");
+ return itemIdSet;
+ }
+
+}
diff --git a/src/main/java/com/ebay/feed/example/FilterByEnv.java b/src/main/java/com/ebay/feed/example/FilterByEnv.java
index b112730..157da90 100644
--- a/src/main/java/com/ebay/feed/example/FilterByEnv.java
+++ b/src/main/java/com/ebay/feed/example/FilterByEnv.java
@@ -18,7 +18,6 @@
import com.ebay.feed.api.FeedImpl;
import com.ebay.feed.constants.Constants;
import com.ebay.feed.enums.EnvTypeEnum;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -54,13 +53,14 @@ public class FilterByEnv {
private static final String DATE = "20181005";
private static final String SCOPE = "ALL_ACTIVE";
private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FeedTypeEnum.ITEM).env(EnvTypeEnum.SANDBOX.name());
+ .type(FEEDTYPE).env(EnvTypeEnum.SANDBOX.name());
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
diff --git a/src/main/java/com/ebay/feed/example/FilterByEpids.java b/src/main/java/com/ebay/feed/example/FilterByEpids.java
index 6a9ceb8..21e4233 100644
--- a/src/main/java/com/ebay/feed/example/FilterByEpids.java
+++ b/src/main/java/com/ebay/feed/example/FilterByEpids.java
@@ -19,7 +19,6 @@
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
import com.ebay.feed.constants.Constants;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -56,13 +55,14 @@ public class FilterByEpids {
private static final String DATE = "20180805";
private static final String SCOPE = "ALL_ACTIVE";
private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT)
- .token(token).type(FeedTypeEnum.ITEM);
+ .token(token).type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
diff --git a/src/main/java/com/ebay/feed/example/FilterByItemIds.java b/src/main/java/com/ebay/feed/example/FilterByItemIds.java
index 2252e6c..eccece9 100644
--- a/src/main/java/com/ebay/feed/example/FilterByItemIds.java
+++ b/src/main/java/com/ebay/feed/example/FilterByItemIds.java
@@ -19,7 +19,6 @@
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
import com.ebay.feed.constants.Constants;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -54,17 +53,17 @@ public class FilterByItemIds {
private static final String CATEGORY = "1281";
- // TODO : Check if the date is within 14 days, before making the call
private static final String DATE = "20180805";
private static final String SCOPE = "ALL_ACTIVE";
private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FeedTypeEnum.ITEM);
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
diff --git a/src/main/java/com/ebay/feed/example/FilterByItemLocation.java b/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
index 60f65b1..57dd2c3 100644
--- a/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
+++ b/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
@@ -19,7 +19,6 @@
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
import com.ebay.feed.constants.Constants;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -54,13 +53,14 @@ public class FilterByItemLocation {
private static final String DATE = "20180708";
private static final String SCOPE = "ALL_ACTIVE";
private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FeedTypeEnum.ITEM);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
diff --git a/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java b/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
index 7fae317..32ed26a 100644
--- a/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
+++ b/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -19,7 +18,6 @@
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
import com.ebay.feed.constants.Constants;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -28,79 +26,79 @@
/**
*
- * Example showing how to download and filter feed files based on leaf category ids. The download
- * location is default - current working directory
+ * Example showing how to download and filter feed files based on leaf category
+ * ids. The download location is default - current working directory
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByLeafCategories {
- // oauth token
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#I^3...";
+ // oauth token
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#I^3...";
- // init feed
- static Feed feed = new FeedImpl();
+ // init feed
+ static Feed feed = new FeedImpl();
- private static final String CATEGORY = "1281";
+ private static final String CATEGORY = "1281";
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180805";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
+ private static final String DATE = "20180805";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- public static void main(String[] args) {
+ public static void main(String[] args) {
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FeedTypeEnum.ITEM);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(FEEDTYPE);
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setLeafCategoryIds(getLeafCategorySet());
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setLeafCategoryIds(getLeafCategorySet());
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
- }
-
- /**
- * Get the set of leaf category ids to filter on
- *
- * @return
- */
- private static Set getLeafCategorySet() {
- Set leafCategorySet = new HashSet<>();
- leafCategorySet.add("146242");
- leafCategorySet.add("134792");
- leafCategorySet.add("117432");
- return leafCategorySet;
- }
+ /**
+ * Get the set of leaf category ids to filter on
+ *
+ * @return
+ */
+ private static Set getLeafCategorySet() {
+ Set leafCategorySet = new HashSet<>();
+ leafCategorySet.add("146242");
+ leafCategorySet.add("134792");
+ leafCategorySet.add("117432");
+ return leafCategorySet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java b/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
index f3a6d7b..f66d6e3 100644
--- a/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
+++ b/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -21,7 +20,6 @@
import com.ebay.feed.api.Taxonomy;
import com.ebay.feed.api.TaxonomyImpl;
import com.ebay.feed.constants.Constants;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -30,106 +28,108 @@
/**
*
- * Example showing how to download and filter feed files based on L3 category ids. The download
- * location is default - current working directory
- *
- * To filter on L3 category, the mapping between L3 to leaf category ids needs to be loaded. Once
- * the mapping is loaded, the operation translates to actually filtering the feed files on leaf
- * category ids, which belong to the L3 category id.
- *
+ * Example showing how to download and filter feed files based on L3 category
+ * ids. The download location is default - current working directory
+ *
+ * To filter on L3 category, the mapping between L3 to leaf category ids needs
+ * to be loaded. Once the mapping is loaded, the operation translates to
+ * actually filtering the feed files on leaf category ids, which belong to the
+ * L3 category id.
+ *
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByLevelThreeCategory {
- // oauth token : Bearer xxx
- /**
- * For filtering on level two or level three categories, the token scope should include
- * feed_scope and api_scope.
- *
- * Filtering on level two and level three categories requires an additional call
- * to taxonomy api
- */
- static String TOKEN =
- Constants.TOKEN_BEARER_PREFIX
- + "v^1.1#i^1#r^0#I^3...";
+ // oauth token : Bearer xxx
+ /**
+ * For filtering on level two or level three categories, the token scope
+ * should include feed_scope and api_scope.
+ *
+ * Filtering on level two and level three categories requires an additional
+ * call to taxonomy api
+ */
+ static String TOKEN
+ = Constants.TOKEN_BEARER_PREFIX
+ + "v^1.1#i^1#r^0#I^3...";
- // init feed
- static Feed feed = new FeedImpl();
+ // init feed
+ static Feed feed = new FeedImpl();
- private static final String CATEGORY = "1";
+ private static final String CATEGORY = "1";
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180708";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20180708";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- // init taxonomy
- static Taxonomy taxonomy = new TaxonomyImpl();
+ // init taxonomy
+ static Taxonomy taxonomy = new TaxonomyImpl();
- public static void main(String[] args) {
+ public static void main(String[] args) {
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FeedTypeEnum.ITEM);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
+ .type(FEEDTYPE);
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
+ }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
- }
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
- // set input file
- filterRequest.setToken(TOKEN);
- filterRequest.setMarketplace(MKT);
+ // set input file
+ filterRequest.setToken(TOKEN);
+ filterRequest.setMarketplace(MKT);
- // level three
- filterRequest.setLevelThreeCategories(getLevelThreeCats());
+ // level three
+ filterRequest.setLevelThreeCategories(getLevelThreeCats());
- // level two
- filterRequest.setLevelTwoCategories(getLevelTwoCats());
- filterRequest.setLevelOneCategory(CATEGORY);
+ // level two
+ filterRequest.setLevelTwoCategories(getLevelTwoCats());
+ filterRequest.setLevelOneCategory(CATEGORY);
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
- Response response = feed.filter(filterRequest);
+ Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
- }
+ }
- static Set getLevelThreeCats() {
- Set levelThreeSet = new HashSet<>();
- levelThreeSet.add("1313");
- levelThreeSet.add("13583");
- return levelThreeSet;
- }
+ static Set getLevelThreeCats() {
+ Set levelThreeSet = new HashSet<>();
+ levelThreeSet.add("1313");
+ levelThreeSet.add("13583");
+ return levelThreeSet;
+ }
- static Set getLevelTwoCats() {
- Set levelThreeSet = new HashSet<>();
- levelThreeSet.add("34");
- return levelThreeSet;
- }
+ static Set getLevelTwoCats() {
+ Set levelThreeSet = new HashSet<>();
+ levelThreeSet.add("34");
+ return levelThreeSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByPrice.java b/src/main/java/com/ebay/feed/example/FilterByPrice.java
index 3127daf..f3a6e05 100644
--- a/src/main/java/com/ebay/feed/example/FilterByPrice.java
+++ b/src/main/java/com/ebay/feed/example/FilterByPrice.java
@@ -11,13 +11,11 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
import com.ebay.feed.constants.Constants;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -26,70 +24,70 @@
/**
*
- * Example showing how to download and filter feed files based on item price. The download location
- * is default - current working directory
+ * Example showing how to download and filter feed files based on item price.
+ * The download location is default - current working directory
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByPrice {
+ // oauth token
+ static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#r^0#I^3...";
- // oauth token
- static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#r^0#I^3...";
+ // init feed
+ static Feed feed = new FeedImpl();
- // init feed
- static Feed feed = new FeedImpl();
+ private static final String CATEGORY = "1281";
- private static final String CATEGORY = "1281";
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20180708";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180708";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
-
- public static void main(String[] args) {
+ public static void main(String[] args) {
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FeedTypeEnum.ITEM);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
+ .type(FEEDTYPE);
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+
+ // set price lower and upper lomit
+ filterRequest.setPriceLowerLimit(10.0);
+ filterRequest.setPriceUpperLimit(20.0);
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
-
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
-
- // set price lower and upper lomit
- filterRequest.setPriceLowerLimit(10.0);
- filterRequest.setPriceLowerLimit(20.0);
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
- }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java b/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
index 466f9a3..01ae3fa 100644
--- a/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
+++ b/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -19,7 +18,6 @@
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
import com.ebay.feed.constants.Constants;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -28,83 +26,83 @@
/**
*
- * Example showing how to download and filter feed files based on seller user names. The download
- * location is default - current working directory
- * This example downloads the bootstrap feed file for L1 category : 1 (Collectibles) and filters on
- * seller user names.
+ * Example showing how to download and filter feed files based on seller user
+ * names. The download location is default - current working directory
+ * This example downloads the bootstrap feed file for L1 category : 1
+ * (Collectibles) and filters on seller user names.
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterBySellerUserNames {
- // oauth token
+ // oauth token
static String TOKEN =
Constants.TOKEN_BEARER_PREFIX
- + "v^1.1#i^1#r^0#I^3...";
+ + "v^1.1#i^1#r^0#I^3...";
- // init feed
- static Feed feed = new FeedImpl();
+ // init feed
+ static Feed feed = new FeedImpl();
- private static final String CATEGORY = "1281";
+ private static final String CATEGORY = "1281";
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180708";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20180708";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
+ public static void main(String[] args) {
- public static void main(String[] args) {
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
+ .type(FEEDTYPE);
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FeedTypeEnum.ITEM);
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setSellerNames(getSellerNameSet());
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setSellerNames(getSellerNameSet());
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
- }
-
- /**
- * Get the set of seller user names to filter on
- *
- * @return
- */
- private static Set getSellerNameSet() {
- Set sellerNameSet = new HashSet<>();
- sellerNameSet.add("pro-sports1021");
- sellerNameSet.add("cbpetz");
- return sellerNameSet;
- }
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getSellerNameSet() {
+ Set sellerNameSet = new HashSet<>();
+ sellerNameSet.add("pro-sports1021");
+ sellerNameSet.add("cbpetz");
+ return sellerNameSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/UsingCredentialFile.java b/src/main/java/com/ebay/feed/example/UsingCredentialFile.java
index a63d2e1..a6b6922 100644
--- a/src/main/java/com/ebay/feed/example/UsingCredentialFile.java
+++ b/src/main/java/com/ebay/feed/example/UsingCredentialFile.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -19,7 +18,6 @@
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
import com.ebay.feed.auth.CredentialLoader;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
@@ -29,89 +27,88 @@
/**
*
- * Example showing how to download and filter feed files based on item location. The download
- * location is default - current working directory
+ * Example showing how to download and filter feed files based on item location.
+ * The download location is default - current working directory
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class UsingCredentialFile {
- // credentials file absolute path
- static String credentialFilePath = "sample-credentials/credentials.yaml";
-
- // init feed
- static Feed feed = new FeedImpl();
+ // credentials file absolute path
+ static String credentialFilePath = "sample-credentials/credentials.yaml";
- private static final String CATEGORY = "11116";
+ // init feed
+ static Feed feed = new FeedImpl();
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180708";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
+ private static final String CATEGORY = "11116";
- public static void main(String[] args) throws Exception {
+ private static final String DATE = "20180708";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- // null scopes result in default values being used
- AuthRequest authRequest = new AuthRequest(credentialFilePath, null);
+ public static void main(String[] args) throws Exception {
- // load credentials and generate token
- CredentialLoader credentialLoader = new CredentialLoader(authRequest);
- credentialLoader.loadCredentials();
- String token = credentialLoader.getOauthResponse().getAccessToken().get().getToken();
+ // null scopes result in default values being used
+ AuthRequest authRequest = new AuthRequest(credentialFilePath, null);
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FeedTypeEnum.ITEM);
+ // load credentials and generate token
+ CredentialLoader credentialLoader = new CredentialLoader(authRequest);
+ credentialLoader.loadCredentials();
+ String token = credentialLoader.getOauthResponse().getAccessToken().get().getToken();
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(FEEDTYPE);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
- }
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setToken(token);
- filterRequest.setItemLocationCountries(getItemLocationSet());
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setToken(token);
+ filterRequest.setItemLocationCountries(getItemLocationSet());
- Response response = feed.filter(filterRequest);
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ Response response = feed.filter(filterRequest);
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
- }
+ }
- /**
- * Get the set of item locations to filter on
- *
- * @return
- */
- private static Set getItemLocationSet() {
- Set itemLocationSet = new HashSet<>();
- itemLocationSet.add("CN");
- return itemLocationSet;
- }
+ /**
+ * Get the set of item locations to filter on
+ *
+ * @return
+ */
+ private static Set getItemLocationSet() {
+ Set itemLocationSet = new HashSet<>();
+ itemLocationSet.add("CN");
+ return itemLocationSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/UsingCredentialFileForSandBoxEnv.java b/src/main/java/com/ebay/feed/example/UsingCredentialFileForSandBoxEnv.java
new file mode 100644
index 0000000..eb783a4
--- /dev/null
+++ b/src/main/java/com/ebay/feed/example/UsingCredentialFileForSandBoxEnv.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2018 eBay Inc.
+ *
+ * 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.
+ */
+package com.ebay.feed.example;
+
+import java.util.HashSet;
+import java.util.Set;
+import com.ebay.feed.api.Feed;
+import com.ebay.feed.api.FeedImpl;
+import com.ebay.feed.auth.CredentialLoader;
+import com.ebay.feed.enums.EnvTypeEnum;
+import com.ebay.feed.model.feed.download.GetFeedResponse;
+import com.ebay.feed.model.feed.operation.feed.FeedRequest;
+import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
+import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
+import com.ebay.feed.model.feed.operation.filter.Response;
+import com.ebay.feed.model.oauth.AuthRequest;
+
+/**
+ *
+ * Example showing how to download and filter feed files based on item location.
+ * The download location is default - current working directory
+ * The filtering is performed on the unzipped file.
+ * So the sequence of events that are followed is :-
+ * - Download feed file
+ * - Unzip feed file
+ * - Filter feed file
+ *
+ *
+ *
+ */
+public class UsingCredentialFileForSandBoxEnv {
+
+ // credentials file absolute path
+ static String credentialFilePath = "credentials.yaml";
+
+ // init feed
+ static Feed feed = new FeedImpl();
+
+ // private static final String CATEGORY = "11116";
+ private static final String CATEGORY = "1";
+
+ private static final String DATE = "20210125";
+ private static final String SCOPE = "NEWLY_LISTED";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
+
+ public static void main(String[] args) throws Exception {
+
+ // null scopes result in default values being used
+ AuthRequest authRequest = new AuthRequest(credentialFilePath, null);
+
+ // load credentials and generate token
+ CredentialLoader credentialLoader = new CredentialLoader(authRequest);
+ credentialLoader.loadCredentials();
+ String token = credentialLoader.getOauthResponse(EnvTypeEnum.SANDBOX.name()).getAccessToken().get().getToken();
+
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(FEEDTYPE).env(EnvTypeEnum.SANDBOX.name());
+
+ // using null for download directory - defaults to current working directory
+ // passing credentialFilePath as required for token refresh on the fly to support resume capability while downloading feed
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null,credentialFilePath);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setToken(token);
+ filterRequest.setItemLocationCountries(getItemLocationSet());
+
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
+
+ }
+
+ /**
+ * Get the set of item locations to filter on
+ *
+ * @return
+ */
+ private static Set getItemLocationSet() {
+ Set itemLocationSet = new HashSet<>();
+ itemLocationSet.add("CN");
+ return itemLocationSet;
+ }
+
+}
diff --git a/src/main/java/com/ebay/feed/example/UsingMutliThread.java b/src/main/java/com/ebay/feed/example/UsingMutliThread.java
new file mode 100644
index 0000000..7346a95
--- /dev/null
+++ b/src/main/java/com/ebay/feed/example/UsingMutliThread.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2018 eBay Inc.
+ *
+ * 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.
+ */
+package com.ebay.feed.example;
+
+import java.util.HashSet;
+import java.util.Set;
+import com.ebay.feed.api.Feed;
+import com.ebay.feed.api.FeedImpl;
+import com.ebay.feed.constants.Constants;
+import com.ebay.feed.enums.EnvTypeEnum;
+import com.ebay.feed.model.feed.download.GetFeedResponse;
+import com.ebay.feed.model.feed.operation.feed.FeedRequest;
+import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
+import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
+import com.ebay.feed.model.feed.operation.filter.Response;
+
+/**
+ *
+ * Example showing how to download and filter feed files based on seller user
+ * names. The download location is default - current working directory
+ * This example downloads the bootstrap feed file for L1 category : 1
+ * (Collectibles) and filters on seller user names.
+ * The filtering is performed on the unzipped file.
+ * So the sequence of events that are followed is :-
+ * - Download feed file
+ * - Unzip feed file
+ * - Filter feed file
+ *
+ *
+ *
+ */
+public class UsingMutliThread {
+
+ // oauth token - Bearer xxx
+ static String token
+ = Constants.TOKEN_BEARER_PREFIX
+ + "v^1.1#i^1#f...";
+
+ // init feed
+ static Feed feed = new FeedImpl();
+
+ private static final String CATEGORY = "625";
+ private static final String DATE = "20210125";
+ private static final String SNAPSHOT_DATE = "2021-01-29T02:00:00.000Z";
+ private static final String SCOPE = "NEWLY_LISTED";
+ private static final String MKT = "EBAY_US";
+
+ public static void main(String[] args) {
+
+ new Thread(() -> {
+ String feedType = "item";
+ getUnzipAndFilterFeed(feedType);
+ }).start();
+
+ new Thread(() -> {
+ String feedType = "item_snapshot";
+ getUnzipAndFilterFeed(feedType);
+ }).start();
+ }
+
+ private static void getUnzipAndFilterFeed(String feedType) {
+ System.out.println("starting thread for feedType: " + feedType);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ if (feedType.equalsIgnoreCase("item_snapshot")) {
+ builder.categoryId(CATEGORY).snapshotDate(SNAPSHOT_DATE).siteId(MKT).token(token)
+ .type(feedType).env(EnvTypeEnum.SANDBOX.name());
+ } else {
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(feedType).env(EnvTypeEnum.SANDBOX.name());
+ }
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setItemIds(getItemIds());
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
+ System.out.println("finished first thread");
+ }
+
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getItemIds() {
+ Set itemIdSet = new HashSet<>();
+ itemIdSet.add("132029430107");
+ itemIdSet.add("132676918161");
+ itemIdSet.add("14270967132");
+ return itemIdSet;
+ }
+
+}
diff --git a/src/main/java/com/ebay/feed/model/feed/operation/feed/FeedRequest.java b/src/main/java/com/ebay/feed/model/feed/operation/feed/FeedRequest.java
index baa0af8..8219eaf 100755
--- a/src/main/java/com/ebay/feed/model/feed/operation/feed/FeedRequest.java
+++ b/src/main/java/com/ebay/feed/model/feed/operation/feed/FeedRequest.java
@@ -11,12 +11,9 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
-
package com.ebay.feed.model.feed.operation.feed;
import com.ebay.feed.constants.Constants;
-import com.ebay.feed.enums.FeedTypeEnum;
/**
*
+ * Generates a file name based on the input parameters
+ *
+ * @param feedRequest Container for capturing parameters related to
+ * downloading and unzipping feed files
+ * @return string Generates a filename based on the feed type, scope,
+ * category, marketplace and date
+ */
+ public String generateFileName(FeedRequest feedRequest) {
+
+ String fileType
+ = Constants.ALL_ACTIVE.equalsIgnoreCase(feedRequest.getFeedScope()) ? Constants.BOOTSTRAP
+ : Constants.DAILY;
+
+ FeedTypeEnum type = FeedTypeEnum.getFeedEnum(feedRequest.getType());
+
+ // switch (feedRequest.getType()) {
+ switch (type) {
+ case ITEM:
+ return "item_" + fileType + "-" + feedRequest.getCategoryId() + "-" + feedRequest.getDate()
+ + "-" + feedRequest.getMarketplaceId() + ".gz";
+ case ITEM_SNAPSHOT:
+ return "item_snapshot-" + feedRequest.getCategoryId() + "-" + feedRequest.getSnapshotDate().replaceAll(":", "")
+ + "-" + feedRequest.getMarketplaceId() + ".gz";
+ default:
+ return null;
+ }
}
- }
- /**
- *
- * Unzips a file and creates a new file and returns the path Returns null in case of errors
- *
- * @param path Path to the downloaded compressed feed file
- * @return string Path to the unzipped file
- * @throws Exception Exception
- */
- public String unzip(Path path) throws Exception {
+ /**
+ *
+ * Unzips a file and creates a new file and returns the path Returns null in
+ * case of errors
+ *
+ *
+ * @param path Path to the downloaded compressed feed file
+ * @return string Path to the unzipped file
+ * @throws Exception Exception
+ */
+ public String unzip(Path path) throws Exception {
- if (path == null)
- return null;
+ if (path == null) {
+ return null;
+ }
- byte[] buffer = new byte[1024];
+ byte[] buffer = new byte[1024];
- try {
+ try {
- LOGGER.debug("Starting unzipping operation for = {}", path.toString());
- String newFilePath = (path.toString().substring(0, path.toString().length() - 3));
+ LOGGER.debug("Starting unzipping operation for = {}", path.toString());
+ String newFilePath = (path.toString().substring(0, path.toString().length() - 3));
- GZIPInputStream gzis = new GZIPInputStream(new FileInputStream(path.toFile()));
+ GZIPInputStream gzis = new GZIPInputStream(new FileInputStream(path.toFile()));
- FileOutputStream out = new FileOutputStream(newFilePath);
+ FileOutputStream out = new FileOutputStream(newFilePath);
- int len;
- while ((len = gzis.read(buffer)) > 0) {
- out.write(buffer, 0, len);
- }
+ int len;
+ while ((len = gzis.read(buffer)) > 0) {
+ out.write(buffer, 0, len);
+ }
- gzis.close();
- out.close();
+ gzis.close();
+ out.close();
- LOGGER.debug("Completed unzipping operation. Unzipped file = {}", newFilePath);
- return newFilePath;
+ LOGGER.debug("Completed unzipping operation. Unzipped file = {}", newFilePath);
+ return newFilePath;
- } catch (IOException ex) {
- LOGGER.debug("Exception in unzip()", ex);
- ex.printStackTrace();
+ } catch (IOException ex) {
+ LOGGER.debug("Exception in unzip()", ex);
+ ex.printStackTrace();
+ }
+ return null;
}
- return null;
- }
}
diff --git a/src/main/java/com/ebay/feed/validator/FeedValidator.java b/src/main/java/com/ebay/feed/validator/FeedValidator.java
index 7f15d26..118b187 100644
--- a/src/main/java/com/ebay/feed/validator/FeedValidator.java
+++ b/src/main/java/com/ebay/feed/validator/FeedValidator.java
@@ -11,92 +11,213 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.validator;
+import com.ebay.feed.constants.Constants;
+import com.ebay.feed.enums.FeedTypeEnum;
+import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
* Class responsible for validating feed and filter requests
*
- *
+ *
* @author shanganesh
*
*/
public class FeedValidator {
- /**
- * Check path validity
- *
- * @param filePath Checks if the file exists on the specified path
- * @return boolean Indicates whether the file was found on the specified path
- */
- public boolean isValidPath(String filePath) {
-
- if (filePath == null || filePath.isEmpty())
- return false;
-
- Path path = Paths.get(filePath);
-
- return Files.exists(path);
- }
-
- /**
- *
- * Check feed filter request
- *
- *
- * @param filterRequest Container for capturing parameters related to filtering the feed files
- * @return boolean Indicates whether all the mandatory parameters are present
- */
- public boolean isValidFilterRequest(FeedFilterRequest filterRequest) {
-
- if (filterRequest == null)
- return false;
+ private static final Logger LOGGER = LoggerFactory.getLogger(FeedValidator.class);
+ SimpleDateFormat sdf;
+ Calendar calendar;
- if (filterRequest.getInputFilePath() == null || filterRequest.getInputFilePath().isEmpty())
- return false;
+ /**
+ * Check path validity
+ *
+ * @param filePath Checks if the file exists on the specified path
+ * @return boolean Indicates whether the file was found on the specified
+ * path
+ */
+ public boolean isValidPath(String filePath) {
- Path path = Paths.get(filterRequest.getInputFilePath());
+ if (filePath == null || filePath.isEmpty()) {
+ return false;
+ }
- if (!Files.exists(path))
- return false;
-
- if (filterRequest.isEmpty())
- return false;
-
- if (!isValidLevelNRequest(filterRequest))
- return false;
-
- return true;
- }
+ Path path = Paths.get(filePath);
+ return Files.exists(path);
+ }
- /**
- * Check that the mandatory parameters are present, in case filtering on level 'n' is requested
- *
- * @return
- */
- private boolean isValidLevelNRequest(FeedFilterRequest filterRequest) {
+ /**
+ *
+ * Check feed filter request
+ *
+ *
+ * @param filterRequest Container for capturing parameters related to
+ * filtering the feed files
+ * @return boolean Indicates whether all the mandatory parameters are
+ * present
+ */
+ public boolean isValidFilterRequest(FeedFilterRequest filterRequest) {
+
+ if (filterRequest == null) {
+ return false;
+ }
+
+ if (filterRequest.getInputFilePath() == null || filterRequest.getInputFilePath().isEmpty()) {
+ return false;
+ }
+
+ Path path = Paths.get(filterRequest.getInputFilePath());
+
+ if (!Files.exists(path)) {
+ return false;
+ }
+
+ if (filterRequest.isEmpty()) {
+ return false;
+ }
+
+ if (!isValidLevelNRequest(filterRequest)) {
+ return false;
+ }
+
+ return true;
+ }
- boolean isValid = true;
- // check if level 'n' categories are present.
- if ((filterRequest.getLevelTwoCategories() != null && !filterRequest.getLevelTwoCategories()
- .isEmpty())
- || (filterRequest.getLevelThreeCategories() != null && !filterRequest
- .getLevelThreeCategories().isEmpty())) {
+ /**
+ * Check that the mandatory parameters are present, in case filtering on
+ * level 'n' is requested
+ *
+ * @return
+ */
+ private boolean isValidLevelNRequest(FeedFilterRequest filterRequest) {
+
+ boolean isValid = true;
+ // check if level 'n' categories are present.
+ if ((filterRequest.getLevelTwoCategories() != null && !filterRequest.getLevelTwoCategories()
+ .isEmpty())
+ || (filterRequest.getLevelThreeCategories() != null && !filterRequest
+ .getLevelThreeCategories().isEmpty())) {
+
+ if (filterRequest.getToken() == null || filterRequest.getMarketplace() == null
+ || filterRequest.getLevelOneCategory() == null) {
+ isValid = false;
+ }
+
+ }
+ return isValid;
+ }
- if (filterRequest.getToken() == null || filterRequest.getMarketplace() == null
- || filterRequest.getLevelOneCategory() == null)
- isValid = false;
+ /**
+ * Check that the date format is valid and date is within valid range for
+ * selected feed type
+ *
+ * Feed Type Item date format is yyyyMMdd and range would be within previous
+ * 3-14 days
+ *
+ * Feed Type ItemSnapshot date format is yyyy-MM-dd'T'HH:00:00.000'Z' and
+ * range would be within previous 7 days
+ *
+ * @param feedRequest
+ * @return
+ */
+ public boolean isValidDateFormatAndRange(FeedRequest feedRequest) {
+ boolean isValid = true;
+ FeedTypeEnum type = FeedTypeEnum.getFeedEnum(feedRequest.getType());
+
+ switch (type) {
+ case ITEM:
+ if (Constants.NEWLY_LISTED.equalsIgnoreCase(feedRequest.getFeedScope())) {
+ try {
+ sdf = new SimpleDateFormat(Constants.QUERY_DATE_FORMAT);
+ Date feedItemRequestDate = sdf.parse(feedRequest.getDate());
+ LOGGER.debug("feedItemRequestDate : {}", feedItemRequestDate);
+
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+ calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ LOGGER.debug("Current Time in GMT Time Zone : {}", calendar.getTime());
+// Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.DAY_OF_MONTH, Constants.NEWLY_LISTED_AVAILABILITY_START_DAY);
+ Date feedItemAvailabilityStartDate = sdf.parse(sdf.format(calendar.getTime()));
+ LOGGER.debug("feedItemAvailabilityStartDate : {}", feedItemAvailabilityStartDate);
+
+ calendar = Calendar.getInstance();
+ calendar.add(Calendar.DAY_OF_MONTH, Constants.NEWLY_LISTED_AVAILABILITY_END_DAY);
+ Date feedItemAvailabilityEndDate = sdf.parse(sdf.format(calendar.getTime()));
+ LOGGER.debug("feedItemAvailabilityEndDate : {}", feedItemAvailabilityEndDate);
+
+ if (!isWithinRange(feedItemRequestDate, feedItemAvailabilityStartDate, feedItemAvailabilityEndDate)) {
+ isValid = false;
+ }
+ // good format and within valid range
+ } catch (ParseException ex) {
+ isValid = false;
+ LOGGER.error("Item Date format is not valid. Cannot get feed. Aborting...", ex);
+ }
+ }
+
+ break;
+
+ case ITEM_SNAPSHOT:
+ try {
+ sdf = new SimpleDateFormat(Constants.QUERY_SNAPSHOT_DATE_FORMAT);
+ Date feedItemSnapshotRequestDate = sdf.parse(feedRequest.getSnapshotDate());
+ LOGGER.debug("feedItemSnapshotRequestDate : {}", feedItemSnapshotRequestDate);
+
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+ calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ LOGGER.debug("Current Time in GMT Time Zone : {}", calendar.getTime());
+ //Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.DAY_OF_MONTH, Constants.ITEM_SNAPSHOT_AVAILABILITY_START_DAY);
+ Date feedItemSnapshotAvailabilitStartDate = sdf.parse(sdf.format(calendar.getTime()));
+ LOGGER.debug("feedItemSnapshotAvailabilitStartDate : {}", feedItemSnapshotAvailabilitStartDate);
+
+ calendar = Calendar.getInstance();
+ calendar.add(Calendar.HOUR_OF_DAY, Constants.ITEM_SNAPSHOT_AVAILABILITY_END_HOUR);
+ Date feedItemSnapshotAvailabilitEndDate = sdf.parse(sdf.format(calendar.getTime()));
+ LOGGER.debug("feedItemSnapshotAvailabilitEndDate : {}", feedItemSnapshotAvailabilitEndDate);
+
+ if (!isWithinRange(feedItemSnapshotRequestDate, feedItemSnapshotAvailabilitStartDate, feedItemSnapshotAvailabilitEndDate)) {
+ isValid = false;
+ }
+ // good format and within valid range
+ } catch (ParseException ex) {
+ isValid = false;
+ LOGGER.error("Item Snapshot Date format is not valid. Cannot get feed. Aborting...", ex);
+ }
+ break;
+
+ default:
+ break;
+ }
+ return isValid;
}
- return isValid;
- }
-
+ /**
+ * Feed Type Item date range would be within previous 3-14 days
+ *
+ * Feed Type ItemSnapshot date range would be within previous 7 days
+ *
+ * @param queryRequestDate
+ * @param startDate
+ * @param endDate
+ * @return
+ */
+ private boolean isWithinRange(Date queryRequestDate, Date startDate, Date endDate) {
+ return !(queryRequestDate.before(startDate) || queryRequestDate.after(endDate));
+ }
}
diff --git a/src/test/java/com/ebay/feed/util/FeedUtilTest.java b/src/test/java/com/ebay/feed/util/FeedUtilTest.java
index 42870e4..edd6078 100644
--- a/src/test/java/com/ebay/feed/util/FeedUtilTest.java
+++ b/src/test/java/com/ebay/feed/util/FeedUtilTest.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.util;
import okhttp3.Request;
@@ -21,100 +20,132 @@
import com.ebay.feed.constants.Constants;
import com.ebay.feed.enums.EnvTypeEnum;
-import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
public class FeedUtilTest {
- FeedUtil feedUtil = new FeedUtil();
-
- @Test
- public void getFinalUrlInvalidTypeTest() {
-
- String expectedUrl =
- Constants.FEED_API_PROD_BASE + Constants.ITEM_RESOURCE_SCOPE + "ALL_ACTIVE"
- + Constants.QUERY_PARAM_SEPARATOR + Constants.QUERY_CATEGORY_ID + "1"
- + Constants.QUERY_PARAM_SEPARATOR + Constants.QUERY_DATE + "20180101";
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.type(FeedTypeEnum.ITEM);
- builder.categoryId("1");
- builder.feedScope("ALL_ACTIVE");
- builder.date("20180101");
-
- Assert.assertEquals(expectedUrl, feedUtil.getFinalUrl(builder.build()));
- }
-
- @Test
- public void generateRequestTest() {
-
- Request.Builder requestBuilder = new Request.Builder();
-
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.type(FeedTypeEnum.ITEM);
- builder.categoryId("1");
- builder.feedScope("ALL_ACTIVE");
- builder.date("20180101");
- builder.token(Constants.TOKEN_BEARER_PREFIX + "v1...");
- builder.siteId("EBAY_US");
-
- feedUtil.generateRequest(builder.build(), requestBuilder);
-
- Request request = requestBuilder.build();
- Assert.assertNotNull(request.header(Constants.AUTHORIZATION_HEADER));
- Assert.assertNotNull(request.header(Constants.MARKETPLACE_HEADER));
- Assert.assertNotNull(request.header(Constants.CONTENT_TYPE_HEADER));
- Assert.assertNotNull(request.header(Constants.ACCEPT_HEADER));
- }
-
- @Test
- public void generateFileNameTest() {
-
- String expectedFileName = "item_daily-1-20180101-EBAY_US.gz";
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.type(FeedTypeEnum.ITEM);
- builder.categoryId("1");
- builder.feedScope("NEWLY_LISTED");
- builder.date("20180101");
- builder.siteId("EBAY_US");
- Assert.assertEquals(expectedFileName, feedUtil.generateFileName(builder.build()));
- }
-
- @Test
- public void generateFileNameBootstrapTest() {
-
- String expectedFileName = "item_bootstrap-1-20180101-EBAY_US.gz";
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.type(FeedTypeEnum.ITEM);
- builder.categoryId("1");
- builder.feedScope("ALL_ACTIVE");
- builder.date("20180101");
- builder.siteId("EBAY_US");
- Assert.assertEquals(expectedFileName, feedUtil.generateFileName(builder.build()));
- }
-
- @Test
- public void getChunkSizeLimitTest() {
- // Prod
- Long expectedChunkSize =
- Constants.PROD_CHUNK_SIZE;
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.type(FeedTypeEnum.ITEM);
- builder.categoryId("1");
- builder.feedScope("ALL_ACTIVE");
- builder.date("20180101");
-
- Assert.assertEquals(expectedChunkSize, feedUtil.getChunkSizeLimit(builder.build()));
-
- // Sandbox
- expectedChunkSize =
- Constants.SANDBOX_CHUNK_SIZE;
- builder = new FeedRequestBuilder();
- builder.type(FeedTypeEnum.ITEM);
- builder.categoryId("1");
- builder.feedScope("ALL_ACTIVE");
- builder.date("20180101");
- builder.env(EnvTypeEnum.SANDBOX.name());
- Assert.assertEquals(expectedChunkSize, feedUtil.getChunkSizeLimit(builder.build()));
- }
+ FeedUtil feedUtil = new FeedUtil();
+
+ @Test
+ public void getFinalUrlInvalidTypeTest() {
+
+ String expectedUrl
+ = Constants.FEED_API_PROD_BASE + Constants.ITEM_RESOURCE_SCOPE + "ALL_ACTIVE"
+ + Constants.QUERY_PARAM_SEPARATOR + Constants.QUERY_CATEGORY_ID + "1"
+ + Constants.QUERY_PARAM_SEPARATOR + Constants.QUERY_DATE + "20180101";
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.type("item");
+ builder.categoryId("1");
+ builder.feedScope("ALL_ACTIVE");
+ builder.date("20180101");
+
+ Assert.assertEquals(expectedUrl, feedUtil.getFinalUrl(builder.build()));
+ }
+
+ @Test
+ public void generateRequestTest() {
+
+ Request.Builder requestBuilder = new Request.Builder();
+
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.type("item");
+ builder.categoryId("1");
+ builder.feedScope("ALL_ACTIVE");
+ builder.date("20180101");
+ builder.token(Constants.TOKEN_BEARER_PREFIX + "v1...");
+ builder.siteId("EBAY_US");
+
+ feedUtil.generateRequest(builder.build(), requestBuilder);
+
+ Request request = requestBuilder.build();
+ Assert.assertNotNull(request.header(Constants.AUTHORIZATION_HEADER));
+ Assert.assertNotNull(request.header(Constants.MARKETPLACE_HEADER));
+ Assert.assertNotNull(request.header(Constants.CONTENT_TYPE_HEADER));
+ Assert.assertNotNull(request.header(Constants.ACCEPT_HEADER));
+ }
+
+ @Test
+ public void generateItemSnapshotRequestTest() {
+
+ Request.Builder requestBuilder = new Request.Builder();
+
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.type("ITEM_SNAPSHOT");
+ builder.categoryId("1");
+ builder.snapshotDate("2018-08-05T02:00:00.000Z");
+ builder.token(Constants.TOKEN_BEARER_PREFIX + "v1...");
+ builder.siteId("EBAY_US");
+
+ feedUtil.generateRequest(builder.build(), requestBuilder);
+
+ Request request = requestBuilder.build();
+ Assert.assertNotNull(request.header(Constants.AUTHORIZATION_HEADER));
+ Assert.assertNotNull(request.header(Constants.MARKETPLACE_HEADER));
+ Assert.assertNotNull(request.header(Constants.CONTENT_TYPE_HEADER));
+ Assert.assertNotNull(request.header(Constants.ACCEPT_HEADER));
+ }
+
+ @Test
+ public void generateFileNameSnapshotTest() {
+
+ String expectedFileName = "item_snapshot-1281-2018-08-05T020000.000Z-EBAY_US.gz";
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.type("item_snapshot");
+ builder.categoryId("1281");
+ builder.snapshotDate("2018-08-05T020000.000Z");
+ builder.siteId("EBAY_US");
+ Assert.assertEquals(expectedFileName, feedUtil.generateFileName(builder.build()));
+ }
+
+ @Test
+ public void generateFileNameTest() {
+
+ String expectedFileName = "item_daily-1-20180101-EBAY_US.gz";
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.type("item");
+ builder.categoryId("1");
+ builder.feedScope("NEWLY_LISTED");
+ builder.date("20180101");
+ builder.siteId("EBAY_US");
+ Assert.assertEquals(expectedFileName, feedUtil.generateFileName(builder.build()));
+ }
+
+ @Test
+ public void generateFileNameBootstrapTest() {
+
+ String expectedFileName = "item_bootstrap-1-20180101-EBAY_US.gz";
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.type("item");
+ builder.categoryId("1");
+ builder.feedScope("ALL_ACTIVE");
+ builder.date("20180101");
+ builder.siteId("EBAY_US");
+ Assert.assertEquals(expectedFileName, feedUtil.generateFileName(builder.build()));
+ }
+
+ @Test
+ public void getChunkSizeLimitTest() {
+ // Prod
+ Long expectedChunkSize
+ = Constants.PROD_CHUNK_SIZE;
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.type("item");
+ builder.categoryId("1");
+ builder.feedScope("ALL_ACTIVE");
+ builder.date("20180101");
+
+ Assert.assertEquals(expectedChunkSize, feedUtil.getChunkSizeLimit(builder.build()));
+
+ // Sandbox
+ expectedChunkSize
+ = Constants.SANDBOX_CHUNK_SIZE;
+ builder = new FeedRequestBuilder();
+ builder.type("item");
+ builder.categoryId("1");
+ builder.feedScope("ALL_ACTIVE");
+ builder.date("20180101");
+ builder.env(EnvTypeEnum.SANDBOX.name());
+ Assert.assertEquals(expectedChunkSize, feedUtil.getChunkSizeLimit(builder.build()));
+ }
}
diff --git a/src/test/java/com/ebay/feed/validator/FeedValidatorTest.java b/src/test/java/com/ebay/feed/validator/FeedValidatorTest.java
index 04ed7c8..bc62615 100644
--- a/src/test/java/com/ebay/feed/validator/FeedValidatorTest.java
+++ b/src/test/java/com/ebay/feed/validator/FeedValidatorTest.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.validator;
import java.util.HashSet;
@@ -19,76 +18,150 @@
import org.junit.Assert;
import org.junit.Test;
import com.ebay.feed.constants.Constants;
+import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
+import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.TimeZone;
public class FeedValidatorTest {
- FeedValidator feedValidator = new FeedValidator();
-
- @Test
- public void isValidPathNullTest() {
- Assert.assertFalse(feedValidator.isValidPath(null));
- }
-
- @Test
- public void isValidPathBlankTrimTest() {
- Assert.assertFalse(feedValidator.isValidPath(""));
- }
-
- //@Test
- public void isValidPathBlankTest() {
- Assert.assertFalse(feedValidator.isValidPath(" "));
- }
-
- // TODO : this may fail if folder is not present
- @Test
- public void isValidPathTest() {
- Assert.assertTrue(feedValidator.isValidPath("/tmp"));
- }
-
- @Test
- public void isValidFilterRequestNullTest() {
- Assert.assertFalse(feedValidator.isValidFilterRequest(null));
- }
-
- @Test
- public void isValidFilterRequestEmptyTest() {
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- Assert.assertFalse(feedValidator.isValidFilterRequest(filterRequest));
- }
-
- @Test
- public void isValidFilterRequestInvalidInputPathTest() {
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setInputFilePath("test");
- Assert.assertFalse(feedValidator.isValidFilterRequest(filterRequest));
- }
-
- @Test
- public void isValidFilterRequestInvalidLevelNTest() {
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setInputFilePath("/tmp");
-
- Set levelThreeCats = new HashSet<>();
- levelThreeCats.add("1");
- filterRequest.setLevelThreeCategories(levelThreeCats);
-
- Assert.assertFalse(feedValidator.isValidFilterRequest(filterRequest));
- }
-
- @Test
- public void isValidFilterRequestValidLevelNTest() {
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setInputFilePath("/tmp");
-
- Set levelThreeCats = new HashSet<>();
- levelThreeCats.add("1");
- filterRequest.setLevelThreeCategories(levelThreeCats);
-
- filterRequest.setToken(Constants.TOKEN_BEARER_PREFIX + "v1...");
- filterRequest.setMarketplace("EBAY_US");
- filterRequest.setLevelOneCategory("1");
-
- Assert.assertTrue(feedValidator.isValidFilterRequest(filterRequest));
- }
+ FeedValidator feedValidator = new FeedValidator();
+
+ @Test
+ public void isValidPathNullTest() {
+ Assert.assertFalse(feedValidator.isValidPath(null));
+ }
+
+ @Test
+ public void isValidPathBlankTrimTest() {
+ Assert.assertFalse(feedValidator.isValidPath(""));
+ }
+
+ //@Test
+ public void isValidPathBlankTest() {
+ Assert.assertFalse(feedValidator.isValidPath(" "));
+ }
+
+ // TODO : this may fail if folder is not present
+ @Test
+ public void isValidPathTest() {
+ //Assert.assertTrue(feedValidator.isValidPath("/tmp"));
+ String path = Paths.get("").toAbsolutePath().toString();
+ Assert.assertTrue(feedValidator.isValidPath(path));
+ }
+
+ @Test
+ public void isValidFilterRequestNullTest() {
+ Assert.assertFalse(feedValidator.isValidFilterRequest(null));
+ }
+
+ @Test
+ public void isValidFilterRequestEmptyTest() {
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ Assert.assertFalse(feedValidator.isValidFilterRequest(filterRequest));
+ }
+
+ @Test
+ public void isValidFilterRequestInvalidInputPathTest() {
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setInputFilePath("test");
+ Assert.assertFalse(feedValidator.isValidFilterRequest(filterRequest));
+ }
+
+ @Test
+ public void isValidFilterRequestInvalidLevelNTest() {
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setInputFilePath("/tmp");
+
+ Set levelThreeCats = new HashSet<>();
+ levelThreeCats.add("1");
+ filterRequest.setLevelThreeCategories(levelThreeCats);
+
+ Assert.assertFalse(feedValidator.isValidFilterRequest(filterRequest));
+ }
+
+ @Test
+ public void isValidFilterRequestValidLevelNTest() {
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ //filterRequest.setInputFilePath("/tmp");
+ String path = Paths.get("").toAbsolutePath().toString();
+ filterRequest.setInputFilePath(path);
+
+ Set levelThreeCats = new HashSet<>();
+ levelThreeCats.add("1");
+ filterRequest.setLevelThreeCategories(levelThreeCats);
+
+ filterRequest.setToken(Constants.TOKEN_BEARER_PREFIX + "v1...");
+ filterRequest.setMarketplace("EBAY_US");
+ filterRequest.setLevelOneCategory("1");
+
+ Assert.assertTrue(feedValidator.isValidFilterRequest(filterRequest));
+ }
+
+ @Test
+ public void isValidDateFormatAndRangeFeedItemScopeALLACTIVETest() {
+
+ FeedRequest.FeedRequestBuilder builder = new FeedRequest.FeedRequestBuilder();
+ builder.type("item");
+ builder.feedScope("ALL_ACTIVE");
+ builder.date("20180101");
+ Assert.assertTrue(feedValidator.isValidDateFormatAndRange(builder.build()));
+ }
+
+ @Test
+ public void isValidDateFormatAndRangeFeedItemScopeNEWLYLISTEDTest() {
+
+ FeedRequest.FeedRequestBuilder builder = new FeedRequest.FeedRequestBuilder();
+ builder.type("item");
+ builder.feedScope("NEWLY_LISTED");
+ //builder.date("20210121");
+ builder.date(getFeedDate("item"));
+ Assert.assertTrue(feedValidator.isValidDateFormatAndRange(builder.build()));
+ }
+
+ private String getFeedDate(String feedType) {
+ SimpleDateFormat sdf;
+ if (feedType.equalsIgnoreCase("item")) {
+ sdf = new SimpleDateFormat(Constants.QUERY_DATE_FORMAT);
+ } else {
+ sdf = new SimpleDateFormat(Constants.QUERY_SNAPSHOT_DATE_FORMAT);
+ }
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+ Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ calendar.add(Calendar.DAY_OF_MONTH, -5);
+ String date = sdf.format(calendar.getTime());
+
+ return date;
+ }
+
+ @Test
+ public void isValidDateFormatAndRangeFeedItemSnapshotTest() {
+
+ FeedRequest.FeedRequestBuilder builder = new FeedRequest.FeedRequestBuilder();
+ builder.type("item_snapshot");
+ //builder.snapshotDate("2021-01-26T12:00:00.000Z");
+ builder.snapshotDate(getFeedDate("item_snapshot"));
+ Assert.assertTrue(feedValidator.isValidDateFormatAndRange(builder.build()));
+ }
+
+ @Test
+ public void isValidDateFormatAndRangeFeedItemScopeNEWLYLISTEDInvalidDateTest() {
+
+ FeedRequest.FeedRequestBuilder builder = new FeedRequest.FeedRequestBuilder();
+ builder.type("item");
+ builder.feedScope("NEWLY_LISTED");
+ builder.date("20180101");
+ Assert.assertFalse(feedValidator.isValidDateFormatAndRange(builder.build()));
+ }
+
+ @Test
+ public void isValidDateFormatAndRangeFeedItemSnapshotInvalidSnapshotDateTest() {
+
+ FeedRequest.FeedRequestBuilder builder = new FeedRequest.FeedRequestBuilder();
+ builder.type("item_snapshot");
+ builder.snapshotDate("2018-08-05T02:00:00.000Z");
+ Assert.assertFalse(feedValidator.isValidDateFormatAndRange(builder.build()));
+ }
}
From 60e1ccd5ccdef5c0ae266eac7778fc6f701a650d Mon Sep 17 00:00:00 2001
From: babar-shzd <76955251+babar-shzd@users.noreply.github.com>
Date: Mon, 15 Feb 2021 17:45:12 +0500
Subject: [PATCH 02/17] Update credentials.yaml
---
credentials.yaml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/credentials.yaml b/credentials.yaml
index 570924a..74d40c8 100644
--- a/credentials.yaml
+++ b/credentials.yaml
@@ -1,7 +1,7 @@
name:
-api.sandbox.ebay.com:
- appid: BabarSha-feedsdke-SBX-ad4a886f5-0880f10f
- certid: SBX-d4a886f5cd39-bc5a-4498-8a9f-c87f
- devid: e8abc2fb-3967-41e8-ab8b-e9004e839b50
+api.ebay.com:
+ appid:
+ certid:
+ devid:
redirecturi:
From e1f2a6710c87bfdb11b1a4e84a07b829823a9995 Mon Sep 17 00:00:00 2001
From: babar-shzd <76955251+babar-shzd@users.noreply.github.com>
Date: Mon, 15 Feb 2021 19:07:34 +0500
Subject: [PATCH 03/17] Update README.md
updated example links
---
README.md | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/README.md b/README.md
index bf61255..8a0b256 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ You are most welcome to collaborate and enhance the existing code base.
## Add as maven dependency
```
-
+
com.ebay.apifeed-sdk
@@ -339,11 +339,11 @@ The structure of the config file
```
An example of using the SDK through a config file is located at
-[Config file based approach example - ConfigFileBasedExample.java](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java)
+[Config file based approach example - ConfigFileBasedExample.java](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java)
-[Example config file - 1](https://github.com/eBay/FeedSDK/blob/master/sample-config/config-file-download-unzip-filter)
+[Example config file - 1](https://github.com/babar-shzd/FeedSDK/tree/incorporation-snapshot-feed-sdk/sample-config/config-file-download-unzip-filter)
-[Example config file - 2](https://github.com/eBay/FeedSDK/blob/master/sample-config/config-file-filter)
+[Example config file - 2](https://github.com/babar-shzd/FeedSDK/tree/incorporation-snapshot-feed-sdk/sample-config/config-file-filter)
### Using java method calls
@@ -351,21 +351,21 @@ Samples showing the usage of available operations and filters.
#### Examples
-All the examples are located [__here__](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example)
-
-* [Filter by item location](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/FilterByItemLocation.java)
-* [Filter by leaf categories](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java)
-* [Filter by price](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/FilterByPrice.java)
-* [Filter by seller user names](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java)
-* [Combining multiple filters](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/CombiningFilters.java)
-* [Filter on level three category](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java)
-* [Filter on EPID](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/FilterByEpids.java)
-* [Filter on GTIN](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/FilterByGtins.java)
-* [Filter on item IDs](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/FilterByItemIds.java)
-* [Filter by 'env'](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/FilterByEnv.java)
-* [Feed type 'item_snapshot'](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java)
-* [Multithreading usage 'MutliThreading'](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/UsingMutliThread.java)
-* [Credential file usage 'Credential'](https://github.com/eBay/FeedSDK/tree/master/src/main/java/com/ebay/feed/example/UsingCredentialFileForSandBoxEnv.java)
+All the examples are located [__here__](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example)
+
+* [Filter by item location](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByItemLocation.java)
+* [Filter by leaf categories](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java)
+* [Filter by price](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByPrice.java)
+* [Filter by seller user names](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java)
+* [Combining multiple filters](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/CombiningFilters.java)
+* [Filter on level three category](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java)
+* [Filter on EPID](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByEpids.java)
+* [Filter on GTIN](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByGtins.java)
+* [Filter on item IDs](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByItemIds.java)
+* [Filter by env](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByEnv.java)
+* [Feed type item_snapshot](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java)
+* [Multithreading usage MutliThreading](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/UsingMutliThread.java)
+* [Credential file usage 'Credential'](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/UsingCredentialFileForSandBoxEnv.java)
---
From 10e0b677daa66222bb16c0f11c43a48eeaf96b05 Mon Sep 17 00:00:00 2001
From: Babar Shahzad
Date: Wed, 24 Mar 2021 17:40:17 +0500
Subject: [PATCH 04/17] Replace sout with Logger
Formatted all the code using NetBeans IDE Source formatting
---
src/main/java/com/ebay/feed/api/FeedImpl.java | 46 +-
src/main/java/com/ebay/feed/api/Taxonomy.java | 65 +--
.../java/com/ebay/feed/api/TaxonomyImpl.java | 408 +++++++++---------
.../com/ebay/feed/auth/CredentialLoader.java | 12 +-
src/main/java/com/ebay/feed/cli/FeedCli.java | 37 +-
.../ebay/feed/example/CombiningFilters.java | 15 +-
.../feed/example/ConfigFileBasedExample.java | 22 +-
.../feed/example/FeedTypeItemSnapShot.java | 12 +-
.../com/ebay/feed/example/FilterByEnv.java | 96 +++--
.../com/ebay/feed/example/FilterByEpids.java | 113 ++---
.../com/ebay/feed/example/FilterByGtins.java | 63 +--
.../ebay/feed/example/FilterByItemIds.java | 119 ++---
.../feed/example/FilterByItemLocation.java | 116 ++---
.../feed/example/FilterByLeafCategories.java | 14 +-
.../example/FilterByLevelThreeCategory.java | 14 +-
.../com/ebay/feed/example/FilterByPrice.java | 14 +-
.../feed/example/FilterBySellerUserNames.java | 18 +-
.../feed/example/UsingCredentialFile.java | 12 +-
.../UsingCredentialFileForSandBoxEnv.java | 14 +-
.../ebay/feed/example/UsingMutliThread.java | 16 +-
.../model/feed/operation/filter/Response.java | 111 +++--
.../ebay/feed/model/oauth/AuthRequest.java | 4 +-
src/main/resources/logback.xml | 82 ++--
.../com/ebay/feed/util/FilterUtilTest.java | 51 ++-
24 files changed, 769 insertions(+), 705 deletions(-)
diff --git a/src/main/java/com/ebay/feed/api/FeedImpl.java b/src/main/java/com/ebay/feed/api/FeedImpl.java
index 516b6c3..e880d1b 100755
--- a/src/main/java/com/ebay/feed/api/FeedImpl.java
+++ b/src/main/java/com/ebay/feed/api/FeedImpl.java
@@ -51,6 +51,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.Date;
+import java.util.logging.Level;
/**
*
@@ -348,11 +349,28 @@ private GetFeedResponse invoker(Request.Builder requestBuilder, Path path, boole
//this block will not execute if token passed direcrly. Backward compatibile
if (isCredentialLoaded) {
- if (checkTokenExpiry(accessToken, credentialLoader, feedRequest, requestBuilder)) {
+ try {
+ Date currentTime = new Date();
+ //token refresh on the fly from config file to support resume capability.
+ if (accessToken.getExpiresOn().before(currentTime)) {
+ LOGGER.debug("Old Token expiry time = {}", accessToken.getExpiresOn());
+ accessToken = updateAccessTokenOnTheFly(credentialLoader, feedRequest, requestBuilder);
+ LOGGER.info("Got refresh token on the fly and New Token Expiry time = {}", accessToken.getExpiresOn());
+ }
+ } catch (Exception e) {
+ LOGGER.error("Exception in fetching the new access token " + e.getMessage());
return new GetFeedResponse(Constants.FAILURE_CODE, Constants.FAILURE, null, null);
}
}
+ try {
+ LOGGER.debug("Sleeping Thread for One Hour to test Resume Capability");
+ Thread.sleep(3600000);
+ LOGGER.debug("Thread awaked after One Hour");
+ } catch (InterruptedException ex) {
+ LOGGER.error("ERROR while sleeping ", ex);
+ }
+
responseFlag = invokeIteratively(requestBuilder.build(), path);
//Showing download progess
LOGGER.debug("First API Response = {}", responseFlag.toString());
@@ -373,30 +391,6 @@ private GetFeedResponse invoker(Request.Builder requestBuilder, Path path, boole
}
}
- /**
- *
- * @param accessToken
- * @param credentialLoader
- * @param feedRequest
- * @param requestBuilder
- * @return
- */
- private boolean checkTokenExpiry(AccessToken accessToken, CredentialLoader credentialLoader, FeedRequest feedRequest, Request.Builder requestBuilder) {
- try {
- Date currentTime = new Date();
- //token refresh on the fly from config file to support resume capability.
- if (accessToken.getExpiresOn().before(currentTime)) {
- LOGGER.debug("Old Token expiry time = {}", accessToken.getExpiresOn());
- accessToken = updateAccessTokenOnTheFly(credentialLoader, feedRequest, requestBuilder);
- LOGGER.info("Got refresh token on the fly and New Token Expiry time = {}", accessToken.getExpiresOn());
- }
- } catch (Exception e) {
- LOGGER.info("Exception in fetching the new access token " + e.getMessage());
- return true;
- }
- return false;
- }
-
/**
*
* Since date is optional param for getting bootstrap feed, filePath will
@@ -436,7 +430,7 @@ private InvokeResponse invokeIteratively(Request request, Path path) {
InvokeResponse responseFlag = null;
- try (Response response = client.newCall(request).execute()) {
+ try ( Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) {
LOGGER.debug("Error in API response - status = {}, body = {}", response.code(), response
diff --git a/src/main/java/com/ebay/feed/api/Taxonomy.java b/src/main/java/com/ebay/feed/api/Taxonomy.java
index 8222e52..35eea1f 100644
--- a/src/main/java/com/ebay/feed/api/Taxonomy.java
+++ b/src/main/java/com/ebay/feed/api/Taxonomy.java
@@ -11,57 +11,58 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.api;
+import java.io.IOException;
import com.ebay.feed.model.feed.operation.taxonomy.CategoryResponse;
-
/**
*
* Taxonomy interface which consists of the following capabilities
*
*
- * getCategoryTreeId - Get the category tree id for the marketplace. For EBAY_US, it returns 0
+ * getCategoryTreeId - Get the category tree id for the marketplace. For
+ * EBAY_US, it returns 0
*
*
- * loadLeafCategories - Creates a map between level two categories to leaf categories,
- * and level three categories to leaf categories. Useful when filtering on level two or level three
- * categories
+ * loadLeafCategories - Creates a map between level two categories to
+ * leaf categories, and level three categories to leaf categories. Useful when
+ * filtering on level two or level three categories
*
- * Returns the category tree id for the marketplace
- *
- *
- *
- * @param token OAUth token
- * @param marketplaceId A string representing the marketplace : EBAY_US
- * @return string The category tree id for the marketplace
- */
- public String getCategoryTreeId(String token, String marketplaceId);
+ /**
+ *
+ * Returns the category tree id for the marketplace
+ *
+ *
+ *
+ * @param token OAUth token
+ * @param marketplaceId A string representing the marketplace : EBAY_US
+ * @return string The category tree id for the marketplace
+ */
+ public String getCategoryTreeId(String token, String marketplaceId);
- /**
- *
- *
- * Loads the mapping between all level 'n' categories to leaf categories.
- * Currently supported values for 'n' are 2,3
- *
- *
- *
- * @param token OAUth token
- * @param categoryTreeId The category tree id for the marketplace
- * @param categoryId - Level one category id
- * @return The category response for the marketplace and category id
- */
- public CategoryResponse loadLeafCategories(String token, String categoryTreeId, String categoryId);
+ /**
+ *
+ *
+ * Loads the mapping between all level 'n' categories to leaf categories.
+ * Currently supported values for 'n' are 2,3
+ *
+ *
+ *
+ * @param token OAUth token
+ * @param categoryTreeId The category tree id for the marketplace
+ * @param categoryId - Level one category id
+ * @return The category response for the marketplace and category id
+ */
+ public CategoryResponse loadLeafCategories(String token, String categoryTreeId, String categoryId);
}
diff --git a/src/main/java/com/ebay/feed/api/TaxonomyImpl.java b/src/main/java/com/ebay/feed/api/TaxonomyImpl.java
index 774574e..47d2d1c 100644
--- a/src/main/java/com/ebay/feed/api/TaxonomyImpl.java
+++ b/src/main/java/com/ebay/feed/api/TaxonomyImpl.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.api;
import java.util.HashMap;
@@ -37,239 +36,246 @@
* Taxonomy implementation which consists of the following capabilities
*
*
- * getCategoryTreeId - Get the category tree id for the marketplace. For EBAY_US, it returns
- * 0
+ * getCategoryTreeId - Get the category tree id for the marketplace. For
+ * EBAY_US, it returns 0
*
- * loadLeafCategories - Creates a map between level two categories to leaf categories, and
- * level three categories to leaf categories. Useful when filtering on level two or level three
- * categories
- *
+ * loadLeafCategories - Creates a map between level two categories to
+ * leaf categories, and level three categories to leaf categories. Useful when
+ * filtering on level two or level three categories
+ *
*
* Responsible for loading consumer credentials and generating token.
*
- * In order to generate token, the {@link #loadCredentials() loadCredentials} method needs to be
- * invoked, which loads the credentials from the provided config file.
+ * In order to generate token, the {@link #loadCredentials() loadCredentials}
+ * method needs to be invoked, which loads the credentials from the provided
+ * config file.
*
* Once the credentials are loaded, the token can be obtained by invoking the
* {@link #getOauthResponse() getOauthResponse}
@@ -60,8 +61,9 @@ public CredentialLoader(AuthRequest authRequest) {
*/
public void loadCredentials() throws Exception {
- if (authRequest == null)
+ if (authRequest == null) {
throw new Exception("null AuthRequest");
+ }
LOGGER.debug("****** Begin loadCredentials with configPath = {}",
authRequest.getConfigFilePath());
@@ -100,7 +102,7 @@ public OAuthResponse getOauthResponse() throws IOException {
* Generates oauth token, based on the loaded credentials
*
*
- * @param environment
+ * @param environment
* @return Returns the OAuthResponse which contains the token
* @throws IOException Thrown if file is not found
*/
@@ -112,7 +114,7 @@ public OAuthResponse getOauthResponse(String environment) throws IOException {
OAuthResponse res = null;
//checking environment for token
if (environment.equalsIgnoreCase("SANDBOX")) {
- res = api.getApplicationToken(Environment.SANDBOX, authRequest.getScopes());
+ res = api.getApplicationToken(Environment.SANDBOX, authRequest.getScopes());
} else {
res = api.getApplicationToken(Environment.PRODUCTION, authRequest.getScopes());
}
diff --git a/src/main/java/com/ebay/feed/cli/FeedCli.java b/src/main/java/com/ebay/feed/cli/FeedCli.java
index 2210ae3..506ae52 100644
--- a/src/main/java/com/ebay/feed/cli/FeedCli.java
+++ b/src/main/java/com/ebay/feed/cli/FeedCli.java
@@ -57,7 +57,8 @@ public static void main(String[] args) throws Exception {
options.addOption("help", false, "display help");
- /***
+ /**
+ * *
* options for downloading the file
*/
// date
@@ -172,28 +173,34 @@ public static void main(String[] args) throws Exception {
// populate feed request
FeedRequestBuilder builder = new FeedRequestBuilder();
- if (cmd.hasOption("dt"))
+ if (cmd.hasOption("dt")) {
builder.date(cmd.getOptionValue("dt"));
+ }
- if (cmd.hasOption("sdt"))
+ if (cmd.hasOption("sdt")) {
builder.snapshotDate(cmd.getOptionValue("sdt"));
+ }
- if (cmd.hasOption("c1"))
+ if (cmd.hasOption("c1")) {
builder.categoryId(cmd.getOptionValue("c1"));
+ }
- if (cmd.hasOption("mkt"))
+ if (cmd.hasOption("mkt")) {
builder.siteId(cmd.getOptionValue("mkt"));
+ }
- if (cmd.hasOption("scope"))
+ if (cmd.hasOption("scope")) {
builder.feedScope(cmd.getOptionValue("scope"));
+ }
- if (cmd.hasOption("token"))
+ if (cmd.hasOption("token")) {
builder.token("Bearer " + cmd.getOptionValue("token"));
+ }
- if (cmd.hasOption("env")){
+ if (cmd.hasOption("env")) {
builder.env(cmd.getOptionValue("env"));
- }
-
+ }
+
if (cmd.hasOption("type")) {
builder.type(cmd.getOptionValue("type"));
} else {
@@ -210,14 +217,16 @@ public static void main(String[] args) throws Exception {
String optionalDownloadPath = null;
List scopes = null;
- System.out.println(cmd.getOptionValue("lf"));
- if (cmd.hasOption("lf"))
+ LOGGER.info(cmd.getOptionValue("lf"));
+ if (cmd.hasOption("lf")) {
filterRequest
.setLeafCategoryIds(new HashSet(Arrays.asList(cmd.getOptionValues("lf"))));
+ }
- if (cmd.hasOption("c3f"))
+ if (cmd.hasOption("c3f")) {
filterRequest.setLevelThreeCategories(new HashSet(Arrays.asList(cmd
.getOptionValues("c3f"))));
+ }
if (cmd.hasOption("c2f")) {
filterRequest.setLevelTwoCategories(new HashSet(Arrays.asList(cmd
@@ -337,7 +346,7 @@ private static void start(FeedRequest feedRequest, FeedFilterRequest filterReque
// filter
filterRequest.setInputFilePath(unzipResponse.getFilePath());
Response filterResponse = feed.filter(filterRequest);
- System.out.println("Filter response = " + filterResponse.toString());
+ LOGGER.info("Filter response = " + filterResponse.toString());
}
}
diff --git a/src/main/java/com/ebay/feed/example/CombiningFilters.java b/src/main/java/com/ebay/feed/example/CombiningFilters.java
index 0ffd291..b8a1229 100644
--- a/src/main/java/com/ebay/feed/example/CombiningFilters.java
+++ b/src/main/java/com/ebay/feed/example/CombiningFilters.java
@@ -17,12 +17,15 @@
import java.util.Set;
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
+import com.ebay.feed.cli.FeedCli;
import com.ebay.feed.constants.Constants;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -46,6 +49,8 @@
*/
public class CombiningFilters {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CombiningFilters.class);
+
// oauth token with Bearer prefix
static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#I^3....";
@@ -64,14 +69,14 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
@@ -79,7 +84,7 @@ public static void main(String[] args) {
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -101,8 +106,8 @@ public static void main(String[] args) {
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java b/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
index 2cc3915..9ae5098 100644
--- a/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
+++ b/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
@@ -19,9 +19,13 @@
import com.ebay.feed.auth.CredentialLoader;
import com.ebay.feed.model.feed.operation.filter.Response;
import com.ebay.feed.model.oauth.AuthRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ConfigFileBasedExample {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConfigFileBasedExample.class);
+
// credentials file absolute path
static String credentialFilePath = "credentials.yaml";
@@ -30,21 +34,21 @@ public class ConfigFileBasedExample {
public static void main(String[] args) throws Exception {
- // null scopes result in default values being used
- AuthRequest authRequest = new AuthRequest(credentialFilePath, null);
-
- // load credentials and generate token
- CredentialLoader credentialLoader = new CredentialLoader(authRequest);
- credentialLoader.loadCredentials();
- String token = credentialLoader.getOauthResponse().getAccessToken().get().getToken();
-
+ // null scopes result in default values being used
+ AuthRequest authRequest = new AuthRequest(credentialFilePath, null);
+
+ // load credentials and generate token
+ CredentialLoader credentialLoader = new CredentialLoader(authRequest);
+ credentialLoader.loadCredentials();
+ String token = credentialLoader.getOauthResponse().getAccessToken().get().getToken();
+
// expects path to the config file. The config file should be a json with the
// structure mirroring the pojo ConfigFileBasedRequest.java
String configFilePath = "sample-config/config-file-download-unzip-filter";
List responses = feed.processConfigFile(configFilePath, token);
for (Response response : responses) {
- System.out.println(response.toString());
+ LOGGER.info(response.toString());
}
}
diff --git a/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java b/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
index 6b8d8e2..c9d16b2 100644
--- a/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
+++ b/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
@@ -24,6 +24,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -42,6 +44,8 @@
*/
public class FeedTypeItemSnapShot {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FeedTypeItemSnapShot.class);
+
// oauth token - Bearer xxx
static String token
= Constants.TOKEN_BEARER_PREFIX
@@ -68,14 +72,14 @@ public static void main(String[] args) {
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -87,8 +91,8 @@ public static void main(String[] args) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByEnv.java b/src/main/java/com/ebay/feed/example/FilterByEnv.java
index 157da90..b5115ef 100644
--- a/src/main/java/com/ebay/feed/example/FilterByEnv.java
+++ b/src/main/java/com/ebay/feed/example/FilterByEnv.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import com.ebay.feed.api.Feed;
@@ -23,74 +22,77 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on environment. The download location
- * is default - current working directory
+ * Example showing how to download and filter feed files based on environment.
+ * The download location is default - current working directory
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByEnv {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByEnv.class);
- // oauth token
- static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#r^0#I...";
+ // oauth token
+ static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#r^0#I...";
- // init feed
- static Feed feed = new FeedImpl();
+ // init feed
+ static Feed feed = new FeedImpl();
- private static final String CATEGORY = "15032";
+ private static final String CATEGORY = "15032";
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20181005";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
- private static final String FEEDTYPE = "item";
-
- public static void main(String[] args) {
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20181005";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FEEDTYPE).env(EnvTypeEnum.SANDBOX.name());
+ public static void main(String[] args) {
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
+ .type(FEEDTYPE).env(EnvTypeEnum.SANDBOX.name());
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+
+ // set price lower and upper lomit
+ filterRequest.setPriceLowerLimit(10.0);
+ filterRequest.setPriceLowerLimit(20.0);
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
-
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
-
- // set price lower and upper lomit
- filterRequest.setPriceLowerLimit(10.0);
- filterRequest.setPriceLowerLimit(20.0);
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
- }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByEpids.java b/src/main/java/com/ebay/feed/example/FilterByEpids.java
index 21e4233..d2ca812 100644
--- a/src/main/java/com/ebay/feed/example/FilterByEpids.java
+++ b/src/main/java/com/ebay/feed/example/FilterByEpids.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -24,83 +23,87 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on seller user names. The download
- * location is default - current working directory
- * This example downloads the bootstrap feed file for L1 category : 1 (Collectibles) and filters on
- * seller user names.
+ * Example showing how to download and filter feed files based on seller user
+ * names. The download location is default - current working directory
+ * This example downloads the bootstrap feed file for L1 category : 1
+ * (Collectibles) and filters on seller user names.
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByEpids {
- // oauth token
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^...";
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByEpids.class);
- // init feed
- static Feed feed = new FeedImpl();
+ // oauth token
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^...";
- private static final String CATEGORY = "1281";
+ // init feed
+ static Feed feed = new FeedImpl();
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180805";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
- private static final String FEEDTYPE = "item";
+ private static final String CATEGORY = "1281";
- public static void main(String[] args) {
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20180805";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT)
- .token(token).type(FEEDTYPE);
+ public static void main(String[] args) {
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT)
+ .token(token).type(FEEDTYPE);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setEpids(getEpids());
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setEpids(getEpids());
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
- }
-
- /**
- * Get the set of seller user names to filter on
- *
- * @return
- */
- private static Set getEpids() {
- Set epidSet = new HashSet<>();
- epidSet.add("710154699");
- return epidSet;
- }
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getEpids() {
+ Set epidSet = new HashSet<>();
+ epidSet.add("710154699");
+ return epidSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByGtins.java b/src/main/java/com/ebay/feed/example/FilterByGtins.java
index 24df20d..b9e90fa 100644
--- a/src/main/java/com/ebay/feed/example/FilterByGtins.java
+++ b/src/main/java/com/ebay/feed/example/FilterByGtins.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -21,50 +20,54 @@
import com.ebay.feed.constants.Constants;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
- * Simple example of applying a filter on an already downlaoded file
+ * Simple example of applying a filter on an already downlaoded file
*
* The filtering is performed on the unzipped file.
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByGtins {
- // oauth token
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#...";
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByGtins.class);
+
+ // oauth token
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#...";
+
+ // init feed
+ static Feed feed = new FeedImpl();
- // init feed
- static Feed feed = new FeedImpl();
-
- public static void main(String[] args) {
+ public static void main(String[] args) {
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setGtins(getGtins());
- // set input file
- // absolute path to the unzipped file
- filterRequest
- .setInputFilePath("item_bootstrap-1281-20180708-EBAY_US");
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setGtins(getGtins());
+ // set input file
+ // absolute path to the unzipped file
+ filterRequest
+ .setInputFilePath("item_bootstrap-1281-20180708-EBAY_US");
- Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ Response response = feed.filter(filterRequest);
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
- }
+ }
- /**
- * Get the set of seller user names to filter on
- *
- * @return
- */
- private static Set getGtins() {
- Set gtinSet = new HashSet<>();
- gtinSet.add("647369501375");
- return gtinSet;
- }
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getGtins() {
+ Set gtinSet = new HashSet<>();
+ gtinSet.add("647369501375");
+ return gtinSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByItemIds.java b/src/main/java/com/ebay/feed/example/FilterByItemIds.java
index eccece9..69ddc45 100644
--- a/src/main/java/com/ebay/feed/example/FilterByItemIds.java
+++ b/src/main/java/com/ebay/feed/example/FilterByItemIds.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -24,86 +23,90 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on seller user names. The download
- * location is default - current working directory
- * This example downloads the bootstrap feed file for L1 category : 1 (Collectibles) and filters on
- * seller user names.
+ * Example showing how to download and filter feed files based on seller user
+ * names. The download location is default - current working directory
+ * This example downloads the bootstrap feed file for L1 category : 1
+ * (Collectibles) and filters on seller user names.
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByItemIds {
- // oauth token - Bearer xxx
- static String token =
- Constants.TOKEN_BEARER_PREFIX
- + "v^1.1#i^1#f...";
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByItemIds.class);
- // init feed
- static Feed feed = new FeedImpl();
+ // oauth token - Bearer xxx
+ static String token
+ = Constants.TOKEN_BEARER_PREFIX
+ + "v^1.1#i^1#f...";
- private static final String CATEGORY = "1281";
+ // init feed
+ static Feed feed = new FeedImpl();
- private static final String DATE = "20180805";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
- private static final String FEEDTYPE = "item";
+ private static final String CATEGORY = "1281";
- public static void main(String[] args) {
+ private static final String DATE = "20180805";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
+ public static void main(String[] args) {
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(FEEDTYPE);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setItemIds(getItemIds());
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setItemIds(getItemIds());
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
- }
-
- /**
- * Get the set of seller user names to filter on
- *
- * @return
- */
- private static Set getItemIds() {
- Set itemIdSet = new HashSet<>();
- itemIdSet.add("132029430107");
- itemIdSet.add("132676918161");
- itemIdSet.add("14270967132");
- return itemIdSet;
- }
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getItemIds() {
+ Set itemIdSet = new HashSet<>();
+ itemIdSet.add("132029430107");
+ itemIdSet.add("132676918161");
+ itemIdSet.add("14270967132");
+ return itemIdSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByItemLocation.java b/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
index 57dd2c3..f46879b 100644
--- a/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
+++ b/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -24,85 +23,88 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on item location. The download
- * location is default - current working directory
+ * Example showing how to download and filter feed files based on item location.
+ * The download location is default - current working directory
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByItemLocation {
- // oauth token - Bearer xxx
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#..";
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByItemLocation.class);
- // init feed
- static Feed feed = new FeedImpl();
+ // oauth token - Bearer xxx
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#..";
- private static final String CATEGORY = "11116";
+ // init feed
+ static Feed feed = new FeedImpl();
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180708";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
+ private static final String CATEGORY = "11116";
+
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20180708";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
private static final String FEEDTYPE = "item";
-
- public static void main(String[] args) {
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
+ public static void main(String[] args) {
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(FEEDTYPE);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setToken(token);
+ filterRequest.setItemLocationCountries(getItemLocationSet());
+
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setToken(token);
- filterRequest.setItemLocationCountries(getItemLocationSet());
-
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
-
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
-
- }
-
- /**
- * Get the set of item locations to filter on
- *
- * @return
- */
- private static Set getItemLocationSet() {
- Set itemLocationSet = new HashSet<>();
- itemLocationSet.add("CN");
- return itemLocationSet;
- }
+ /**
+ * Get the set of item locations to filter on
+ *
+ * @return
+ */
+ private static Set getItemLocationSet() {
+ Set itemLocationSet = new HashSet<>();
+ itemLocationSet.add("CN");
+ return itemLocationSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java b/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
index 32ed26a..b1cd7c0 100644
--- a/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
+++ b/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
@@ -23,6 +23,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -40,6 +42,8 @@
*/
public class FilterByLeafCategories {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByLeafCategories.class);
+
// oauth token
static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#I^3...";
@@ -58,21 +62,21 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -83,8 +87,8 @@ public static void main(String[] args) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java b/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
index f66d6e3..b5817b5 100644
--- a/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
+++ b/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
@@ -25,6 +25,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -48,6 +50,8 @@
*/
public class FilterByLevelThreeCategory {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByLevelThreeCategory.class);
+
// oauth token : Bearer xxx
/**
* For filtering on level two or level three categories, the token scope
@@ -79,13 +83,13 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
@@ -93,7 +97,7 @@ public static void main(String[] args) {
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -115,8 +119,8 @@ public static void main(String[] args) {
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByPrice.java b/src/main/java/com/ebay/feed/example/FilterByPrice.java
index f3a6e05..011e629 100644
--- a/src/main/java/com/ebay/feed/example/FilterByPrice.java
+++ b/src/main/java/com/ebay/feed/example/FilterByPrice.java
@@ -21,6 +21,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -38,6 +40,8 @@
*/
public class FilterByPrice {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByPrice.class);
+
// oauth token
static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#r^0#I^3...";
@@ -57,21 +61,21 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -85,8 +89,8 @@ public static void main(String[] args) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java b/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
index 01ae3fa..59ecfa1 100644
--- a/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
+++ b/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
@@ -23,6 +23,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
null - Failure non null value - Path of the file that was created as a result of this operation
+ *
null - Failure non null value - Path of the file that was created as a
+ * result of this operation
*
*
* appliedFilters - List of all the filters that were applied
- *
+ *
*
- *
+ *
* @author shanganesh
*
*/
public class Response {
- private FeedFilterRequest appliedFilters;
- private Integer statusCode;
- private String message;
- private String filePath;
+ private FeedFilterRequest appliedFilters;
+ private Integer statusCode;
+ private String message;
+ private String filePath;
- public Integer getStatusCode() {
- return statusCode;
- }
+ public Integer getStatusCode() {
+ return statusCode;
+ }
- public void setStatusCode(Integer statusCode) {
- this.statusCode = statusCode;
- }
+ public void setStatusCode(Integer statusCode) {
+ this.statusCode = statusCode;
+ }
- public String getFilePath() {
- return filePath;
- }
+ public String getFilePath() {
+ return filePath;
+ }
- public void setFilePath(String filePath) {
- this.filePath = filePath;
- }
+ public void setFilePath(String filePath) {
+ this.filePath = filePath;
+ }
- public String getMessage() {
- return message;
- }
+ public String getMessage() {
+ return message;
+ }
- public void setMessage(String message) {
- this.message = message;
- }
+ public void setMessage(String message) {
+ this.message = message;
+ }
- public FeedFilterRequest getAppliedFilters() {
- return appliedFilters;
- }
+ public FeedFilterRequest getAppliedFilters() {
+ return appliedFilters;
+ }
- public void setAppliedFilters(FeedFilterRequest appliedFilters) {
- this.appliedFilters = appliedFilters;
- }
+ public void setAppliedFilters(FeedFilterRequest appliedFilters) {
+ this.appliedFilters = appliedFilters;
+ }
- /**
- *
- * @param statusCode 0 success
- * @param message Detailed message regarding the error
- * @param filePath In case of success, the path to the resulting file
- * @param appliedFilters Applied filters
- */
- public Response(Integer statusCode, String message, String filePath,
- FeedFilterRequest appliedFilters) {
- super();
- this.appliedFilters = appliedFilters;
- this.statusCode = statusCode;
- this.message = message;
- this.filePath = filePath;
- }
+ /**
+ *
+ * @param statusCode 0 success
+ * @param message Detailed message regarding the error
+ * @param filePath In case of success, the path to the resulting file
+ * @param appliedFilters Applied filters
+ */
+ public Response(Integer statusCode, String message, String filePath,
+ FeedFilterRequest appliedFilters) {
+ super();
+ this.appliedFilters = appliedFilters;
+ this.statusCode = statusCode;
+ this.message = message;
+ this.filePath = filePath;
+ }
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("Response [appliedFilters=").append(appliedFilters).append(", statusCode=")
- .append(statusCode).append(", message=").append(message).append(", filePath=")
- .append(filePath).append("]");
- return builder.toString();
- }
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Response [appliedFilters=").append(appliedFilters).append(", statusCode=")
+ .append(statusCode).append(", message=").append(message).append(", filePath=")
+ .append(filePath).append("]");
+ return builder.toString();
+ }
}
diff --git a/src/main/java/com/ebay/feed/model/oauth/AuthRequest.java b/src/main/java/com/ebay/feed/model/oauth/AuthRequest.java
index 9740aa0..9a1c96e 100644
--- a/src/main/java/com/ebay/feed/model/oauth/AuthRequest.java
+++ b/src/main/java/com/ebay/feed/model/oauth/AuthRequest.java
@@ -44,8 +44,8 @@ public void setScopes(List scopes) {
public AuthRequest(String configFilePath, List scopes) {
super();
- this.configFilePath = configFilePath;
-
+ this.configFilePath = configFilePath;
+
if (scopes == null) {
List defaultScopes = new ArrayList<>();
defaultScopes.add("https://api.ebay.com/oauth/api_scope");
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index ac7aff9..f509dd0 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -1,48 +1,48 @@
+~ /**
+~ * Copyright (c) 2018 eBay Inc.
+~ *
+~ * 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.
+~ **/
+-->
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
-
- ${LOG_HOME:-.}/feed-sdk-log.log
-
- feedsdk-log.%d{yyyy-MM-dd}.log
-
- 7
- 100MB
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
+
+ ${LOG_HOME:-.}/feed-sdk-log.log
+
+ feedsdk-log.%d{yyyy-MM-dd}.log
+
+ 7
+ 100MB
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
-
-
-
-
-
+
+
+
+
+
diff --git a/src/test/java/com/ebay/feed/util/FilterUtilTest.java b/src/test/java/com/ebay/feed/util/FilterUtilTest.java
index 3f57b7a..d99ffa2 100644
--- a/src/test/java/com/ebay/feed/util/FilterUtilTest.java
+++ b/src/test/java/com/ebay/feed/util/FilterUtilTest.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.util;
import java.util.HashSet;
@@ -22,40 +21,40 @@
public class FilterUtilTest {
- FilterUtil filterUtil = new FilterUtil();
+ FilterUtil filterUtil = new FilterUtil();
- @Test
- public void evaluateNegativeTest() {
+ @Test
+ public void evaluateNegativeTest() {
- FeedFilterRequest request = new FeedFilterRequest();
- request.setLeafCategoryIds(getFilterSet());;
- Assert.assertTrue(filterUtil.evaluate(getLine("123"), request));
+ FeedFilterRequest request = new FeedFilterRequest();
+ request.setLeafCategoryIds(getFilterSet());;
+ Assert.assertTrue(filterUtil.evaluate(getLine("123"), request));
- }
-
- @Test
- public void evaluatePositiveTest() {
+ }
- FeedFilterRequest request = new FeedFilterRequest();
- request.setLeafCategoryIds(getFilterSet());;
- Assert.assertFalse(filterUtil.evaluate(getLine("456"), request));
+ @Test
+ public void evaluatePositiveTest() {
- }
+ FeedFilterRequest request = new FeedFilterRequest();
+ request.setLeafCategoryIds(getFilterSet());;
+ Assert.assertFalse(filterUtil.evaluate(getLine("456"), request));
- private Set getFilterSet() {
- Set filterSet = new HashSet<>();
- filterSet.add("123");
- return filterSet;
- }
+ }
+
+ private Set getFilterSet() {
+ Set filterSet = new HashSet<>();
+ filterSet.add("123");
+ return filterSet;
+ }
- private String[] getLine(String filterValue) {
+ private String[] getLine(String filterValue) {
- String[] arr = new String[50];
+ String[] arr = new String[50];
- for (int i = 0; i < 50; i++) {
- arr[i] = filterValue;
+ for (int i = 0; i < 50; i++) {
+ arr[i] = filterValue;
+ }
+ return arr;
}
- return arr;
- }
}
From d06f846c3ca0bf7537f6e5d984beb4377aeee0ec Mon Sep 17 00:00:00 2001
From: Babar Shahzad
Date: Wed, 24 Mar 2021 17:54:39 +0500
Subject: [PATCH 05/17] Revert "Replace sout with Logger"
This reverts commit 10e0b677daa66222bb16c0f11c43a48eeaf96b05.
---
src/main/java/com/ebay/feed/api/FeedImpl.java | 46 +-
src/main/java/com/ebay/feed/api/Taxonomy.java | 65 ++-
.../java/com/ebay/feed/api/TaxonomyImpl.java | 408 +++++++++---------
.../com/ebay/feed/auth/CredentialLoader.java | 12 +-
src/main/java/com/ebay/feed/cli/FeedCli.java | 37 +-
.../ebay/feed/example/CombiningFilters.java | 15 +-
.../feed/example/ConfigFileBasedExample.java | 22 +-
.../feed/example/FeedTypeItemSnapShot.java | 12 +-
.../com/ebay/feed/example/FilterByEnv.java | 96 ++---
.../com/ebay/feed/example/FilterByEpids.java | 113 +++--
.../com/ebay/feed/example/FilterByGtins.java | 63 ++-
.../ebay/feed/example/FilterByItemIds.java | 119 +++--
.../feed/example/FilterByItemLocation.java | 116 +++--
.../feed/example/FilterByLeafCategories.java | 14 +-
.../example/FilterByLevelThreeCategory.java | 14 +-
.../com/ebay/feed/example/FilterByPrice.java | 14 +-
.../feed/example/FilterBySellerUserNames.java | 18 +-
.../feed/example/UsingCredentialFile.java | 12 +-
.../UsingCredentialFileForSandBoxEnv.java | 14 +-
.../ebay/feed/example/UsingMutliThread.java | 16 +-
.../model/feed/operation/filter/Response.java | 111 ++---
.../ebay/feed/model/oauth/AuthRequest.java | 4 +-
src/main/resources/logback.xml | 82 ++--
.../com/ebay/feed/util/FilterUtilTest.java | 51 +--
24 files changed, 705 insertions(+), 769 deletions(-)
diff --git a/src/main/java/com/ebay/feed/api/FeedImpl.java b/src/main/java/com/ebay/feed/api/FeedImpl.java
index e880d1b..516b6c3 100755
--- a/src/main/java/com/ebay/feed/api/FeedImpl.java
+++ b/src/main/java/com/ebay/feed/api/FeedImpl.java
@@ -51,7 +51,6 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.Date;
-import java.util.logging.Level;
/**
*
@@ -349,28 +348,11 @@ private GetFeedResponse invoker(Request.Builder requestBuilder, Path path, boole
//this block will not execute if token passed direcrly. Backward compatibile
if (isCredentialLoaded) {
- try {
- Date currentTime = new Date();
- //token refresh on the fly from config file to support resume capability.
- if (accessToken.getExpiresOn().before(currentTime)) {
- LOGGER.debug("Old Token expiry time = {}", accessToken.getExpiresOn());
- accessToken = updateAccessTokenOnTheFly(credentialLoader, feedRequest, requestBuilder);
- LOGGER.info("Got refresh token on the fly and New Token Expiry time = {}", accessToken.getExpiresOn());
- }
- } catch (Exception e) {
- LOGGER.error("Exception in fetching the new access token " + e.getMessage());
+ if (checkTokenExpiry(accessToken, credentialLoader, feedRequest, requestBuilder)) {
return new GetFeedResponse(Constants.FAILURE_CODE, Constants.FAILURE, null, null);
}
}
- try {
- LOGGER.debug("Sleeping Thread for One Hour to test Resume Capability");
- Thread.sleep(3600000);
- LOGGER.debug("Thread awaked after One Hour");
- } catch (InterruptedException ex) {
- LOGGER.error("ERROR while sleeping ", ex);
- }
-
responseFlag = invokeIteratively(requestBuilder.build(), path);
//Showing download progess
LOGGER.debug("First API Response = {}", responseFlag.toString());
@@ -391,6 +373,30 @@ private GetFeedResponse invoker(Request.Builder requestBuilder, Path path, boole
}
}
+ /**
+ *
+ * @param accessToken
+ * @param credentialLoader
+ * @param feedRequest
+ * @param requestBuilder
+ * @return
+ */
+ private boolean checkTokenExpiry(AccessToken accessToken, CredentialLoader credentialLoader, FeedRequest feedRequest, Request.Builder requestBuilder) {
+ try {
+ Date currentTime = new Date();
+ //token refresh on the fly from config file to support resume capability.
+ if (accessToken.getExpiresOn().before(currentTime)) {
+ LOGGER.debug("Old Token expiry time = {}", accessToken.getExpiresOn());
+ accessToken = updateAccessTokenOnTheFly(credentialLoader, feedRequest, requestBuilder);
+ LOGGER.info("Got refresh token on the fly and New Token Expiry time = {}", accessToken.getExpiresOn());
+ }
+ } catch (Exception e) {
+ LOGGER.info("Exception in fetching the new access token " + e.getMessage());
+ return true;
+ }
+ return false;
+ }
+
/**
*
* Since date is optional param for getting bootstrap feed, filePath will
@@ -430,7 +436,7 @@ private InvokeResponse invokeIteratively(Request request, Path path) {
InvokeResponse responseFlag = null;
- try ( Response response = client.newCall(request).execute()) {
+ try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) {
LOGGER.debug("Error in API response - status = {}, body = {}", response.code(), response
diff --git a/src/main/java/com/ebay/feed/api/Taxonomy.java b/src/main/java/com/ebay/feed/api/Taxonomy.java
index 35eea1f..8222e52 100644
--- a/src/main/java/com/ebay/feed/api/Taxonomy.java
+++ b/src/main/java/com/ebay/feed/api/Taxonomy.java
@@ -11,58 +11,57 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package com.ebay.feed.api;
-import java.io.IOException;
import com.ebay.feed.model.feed.operation.taxonomy.CategoryResponse;
+
/**
*
* Taxonomy interface which consists of the following capabilities
*
*
- * getCategoryTreeId - Get the category tree id for the marketplace. For
- * EBAY_US, it returns 0
+ * getCategoryTreeId - Get the category tree id for the marketplace. For EBAY_US, it returns 0
*
*
- * loadLeafCategories - Creates a map between level two categories to
- * leaf categories, and level three categories to leaf categories. Useful when
- * filtering on level two or level three categories
+ * loadLeafCategories - Creates a map between level two categories to leaf categories,
+ * and level three categories to leaf categories. Useful when filtering on level two or level three
+ * categories
*
- * Returns the category tree id for the marketplace
- *
- *
- *
- * @param token OAUth token
- * @param marketplaceId A string representing the marketplace : EBAY_US
- * @return string The category tree id for the marketplace
- */
- public String getCategoryTreeId(String token, String marketplaceId);
+ /**
+ *
+ * Returns the category tree id for the marketplace
+ *
+ *
+ *
+ * @param token OAUth token
+ * @param marketplaceId A string representing the marketplace : EBAY_US
+ * @return string The category tree id for the marketplace
+ */
+ public String getCategoryTreeId(String token, String marketplaceId);
- /**
- *
- *
- * Loads the mapping between all level 'n' categories to leaf categories.
- * Currently supported values for 'n' are 2,3
- *
- *
- *
- * @param token OAUth token
- * @param categoryTreeId The category tree id for the marketplace
- * @param categoryId - Level one category id
- * @return The category response for the marketplace and category id
- */
- public CategoryResponse loadLeafCategories(String token, String categoryTreeId, String categoryId);
+ /**
+ *
+ *
+ * Loads the mapping between all level 'n' categories to leaf categories.
+ * Currently supported values for 'n' are 2,3
+ *
+ *
+ *
+ * @param token OAUth token
+ * @param categoryTreeId The category tree id for the marketplace
+ * @param categoryId - Level one category id
+ * @return The category response for the marketplace and category id
+ */
+ public CategoryResponse loadLeafCategories(String token, String categoryTreeId, String categoryId);
}
diff --git a/src/main/java/com/ebay/feed/api/TaxonomyImpl.java b/src/main/java/com/ebay/feed/api/TaxonomyImpl.java
index 47d2d1c..774574e 100644
--- a/src/main/java/com/ebay/feed/api/TaxonomyImpl.java
+++ b/src/main/java/com/ebay/feed/api/TaxonomyImpl.java
@@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package com.ebay.feed.api;
import java.util.HashMap;
@@ -36,246 +37,239 @@
* Taxonomy implementation which consists of the following capabilities
*
*
- * getCategoryTreeId - Get the category tree id for the marketplace. For
- * EBAY_US, it returns 0
+ * getCategoryTreeId - Get the category tree id for the marketplace. For EBAY_US, it returns
+ * 0
*
- * loadLeafCategories - Creates a map between level two categories to
- * leaf categories, and level three categories to leaf categories. Useful when
- * filtering on level two or level three categories
- *
+ * loadLeafCategories - Creates a map between level two categories to leaf categories, and
+ * level three categories to leaf categories. Useful when filtering on level two or level three
+ * categories
+ *
*
+ * Loads the relationship between level three and leaf categories in a map
+ *
+ *
+ * @param taxonomyResponse The response from calling taxonomy API
+ * @return Map of string -> set of string. The key represents the level three category, the set of
+ * string represents the leaf categories associated with the level three category
+ */
+ private Map> getLevelThreeLeafCategories(TaxonomyResponse taxonomyResponse) {
- /**
- *
- * Loads the relationship between level three and leaf categories in a map
- *
- *
- * @param taxonomyResponse The response from calling taxonomy API
- * @return Map of string -> set of string. The key represents the level
- * three category, the set of string represents the leaf categories
- * associated with the level three category
- */
- private Map> getLevelThreeLeafCategories(TaxonomyResponse taxonomyResponse) {
-
- Set leafCategories = null;
- Map> levelThreeCategoryMap = new HashMap<>();
- try {
-
- // L1
- CategorySubtreeNode node = taxonomyResponse.getCategorySubtreeNode();
-
- // L2
- CategorySubtreeNode[] l2Nodes = node.getChildCategoryTreeNodes();
- for (CategorySubtreeNode l2CategoryNode : l2Nodes) {
-
- if (l2CategoryNode.getLeafCategoryTreeNode() != null
- && l2CategoryNode.getLeafCategoryTreeNode().equals(Constants.TRUE)) {
- continue;
- }
-
- CategorySubtreeNode[] l3Nodes = l2CategoryNode.getChildCategoryTreeNodes();
-
- for (CategorySubtreeNode l3Node : l3Nodes) {
-
- if (l3Node == null) {
- continue;
- }
-
- LOGGER.debug("l3 category = {}", l3Node.getCategory().getCategoryId());
- leafCategories = new HashSet<>();
- getLeaf(l3Node, leafCategories);
- LOGGER.debug("leaf size = {}", leafCategories.size());
- LOGGER.debug("leaf categories = {}", leafCategories.toString());
- levelThreeCategoryMap.put(l3Node.getCategory().getCategoryId(), leafCategories);
- }
- }
-
- } catch (Exception e) {
- LOGGER.error("Exception in getLevelThreeLeafCategories() ", e);
+ Set leafCategories = null;
+ Map> levelThreeCategoryMap = new HashMap<>();
+ try {
+
+ // L1
+ CategorySubtreeNode node = taxonomyResponse.getCategorySubtreeNode();
+
+ // L2
+ CategorySubtreeNode[] l2Nodes = node.getChildCategoryTreeNodes();
+ for (CategorySubtreeNode l2CategoryNode : l2Nodes) {
+
+ if (l2CategoryNode.getLeafCategoryTreeNode() != null
+ && l2CategoryNode.getLeafCategoryTreeNode().equals(Constants.TRUE))
+ continue;
+
+ CategorySubtreeNode[] l3Nodes = l2CategoryNode.getChildCategoryTreeNodes();
+
+ for (CategorySubtreeNode l3Node : l3Nodes) {
+
+ if (l3Node == null)
+ continue;
+
+ LOGGER.debug("l3 category = {}", l3Node.getCategory().getCategoryId());
+ leafCategories = new HashSet<>();
+ getLeaf(l3Node, leafCategories);
+ LOGGER.debug("leaf size = {}", leafCategories.size());
+ LOGGER.debug("leaf categories = {}", leafCategories.toString());
+ levelThreeCategoryMap.put(l3Node.getCategory().getCategoryId(), leafCategories);
}
+ }
- return levelThreeCategoryMap;
+ } catch (Exception e) {
+ LOGGER.error("Exception in getLevelThreeLeafCategories() ", e);
}
- /**
- *
- * Loads the relationship between level two and leaf categories in a map
- *
- *
- * @param taxonomyResponse The response from calling taxonomy API
- * @return Map of string -> set of string. The key represents the level
- * three category, the set of string represents the leaf categories
- * associated with the level three category
- */
- private Map> getLevelTwoLeafCategories(TaxonomyResponse taxonomyResponse) {
-
- Set leafCategories = null;
- Map> levelTwoCategoryMap = new HashMap<>();
- try {
-
- // L1
- CategorySubtreeNode node = taxonomyResponse.getCategorySubtreeNode();
-
- // L2
- CategorySubtreeNode[] l2Nodes = node.getChildCategoryTreeNodes();
- for (CategorySubtreeNode l2Node : l2Nodes) {
-
- if (l2Node == null) {
- continue;
- }
-
- LOGGER.debug("l2 category = {}", l2Node.getCategory().getCategoryId());
- leafCategories = new HashSet<>();
- getLeaf(l2Node, leafCategories);
- LOGGER.debug("leaf size = {}", leafCategories.size());
- LOGGER.debug("leaf categories = {}", leafCategories.toString());
- levelTwoCategoryMap.put(l2Node.getCategory().getCategoryId(), leafCategories);
- }
-
- } catch (Exception e) {
- LOGGER.error("Exception in getLevelTwoLeafCategories() ", e);
- }
+ return levelThreeCategoryMap;
+ }
- return levelTwoCategoryMap;
+ /**
+ *
+ * Loads the relationship between level two and leaf categories in a map
+ *
+ *
+ * @param taxonomyResponse The response from calling taxonomy API
+ * @return Map of string -> set of string. The key represents the level three category, the set of
+ * string represents the leaf categories associated with the level three category
+ */
+ private Map> getLevelTwoLeafCategories(TaxonomyResponse taxonomyResponse) {
+
+ Set leafCategories = null;
+ Map> levelTwoCategoryMap = new HashMap<>();
+ try {
+
+ // L1
+ CategorySubtreeNode node = taxonomyResponse.getCategorySubtreeNode();
+
+ // L2
+ CategorySubtreeNode[] l2Nodes = node.getChildCategoryTreeNodes();
+ for (CategorySubtreeNode l2Node : l2Nodes) {
+
+
+ if (l2Node == null)
+ continue;
+
+ LOGGER.debug("l2 category = {}", l2Node.getCategory().getCategoryId());
+ leafCategories = new HashSet<>();
+ getLeaf(l2Node, leafCategories);
+ LOGGER.debug("leaf size = {}", leafCategories.size());
+ LOGGER.debug("leaf categories = {}", leafCategories.toString());
+ levelTwoCategoryMap.put(l2Node.getCategory().getCategoryId(), leafCategories);
+ }
+
+ } catch (Exception e) {
+ LOGGER.error("Exception in getLevelTwoLeafCategories() ", e);
}
- /**
- *
- * Recursively traverses through nodes to find out the leaf node and adds to
- * list
- *
* Responsible for loading consumer credentials and generating token.
*
- * In order to generate token, the {@link #loadCredentials() loadCredentials}
- * method needs to be invoked, which loads the credentials from the provided
- * config file.
+ * In order to generate token, the {@link #loadCredentials() loadCredentials} method needs to be
+ * invoked, which loads the credentials from the provided config file.
*
* Once the credentials are loaded, the token can be obtained by invoking the
* {@link #getOauthResponse() getOauthResponse}
@@ -61,9 +60,8 @@ public CredentialLoader(AuthRequest authRequest) {
*/
public void loadCredentials() throws Exception {
- if (authRequest == null) {
+ if (authRequest == null)
throw new Exception("null AuthRequest");
- }
LOGGER.debug("****** Begin loadCredentials with configPath = {}",
authRequest.getConfigFilePath());
@@ -102,7 +100,7 @@ public OAuthResponse getOauthResponse() throws IOException {
* Generates oauth token, based on the loaded credentials
*
*
- * @param environment
+ * @param environment
* @return Returns the OAuthResponse which contains the token
* @throws IOException Thrown if file is not found
*/
@@ -114,7 +112,7 @@ public OAuthResponse getOauthResponse(String environment) throws IOException {
OAuthResponse res = null;
//checking environment for token
if (environment.equalsIgnoreCase("SANDBOX")) {
- res = api.getApplicationToken(Environment.SANDBOX, authRequest.getScopes());
+ res = api.getApplicationToken(Environment.SANDBOX, authRequest.getScopes());
} else {
res = api.getApplicationToken(Environment.PRODUCTION, authRequest.getScopes());
}
diff --git a/src/main/java/com/ebay/feed/cli/FeedCli.java b/src/main/java/com/ebay/feed/cli/FeedCli.java
index 506ae52..2210ae3 100644
--- a/src/main/java/com/ebay/feed/cli/FeedCli.java
+++ b/src/main/java/com/ebay/feed/cli/FeedCli.java
@@ -57,8 +57,7 @@ public static void main(String[] args) throws Exception {
options.addOption("help", false, "display help");
- /**
- * *
+ /***
* options for downloading the file
*/
// date
@@ -173,34 +172,28 @@ public static void main(String[] args) throws Exception {
// populate feed request
FeedRequestBuilder builder = new FeedRequestBuilder();
- if (cmd.hasOption("dt")) {
+ if (cmd.hasOption("dt"))
builder.date(cmd.getOptionValue("dt"));
- }
- if (cmd.hasOption("sdt")) {
+ if (cmd.hasOption("sdt"))
builder.snapshotDate(cmd.getOptionValue("sdt"));
- }
- if (cmd.hasOption("c1")) {
+ if (cmd.hasOption("c1"))
builder.categoryId(cmd.getOptionValue("c1"));
- }
- if (cmd.hasOption("mkt")) {
+ if (cmd.hasOption("mkt"))
builder.siteId(cmd.getOptionValue("mkt"));
- }
- if (cmd.hasOption("scope")) {
+ if (cmd.hasOption("scope"))
builder.feedScope(cmd.getOptionValue("scope"));
- }
- if (cmd.hasOption("token")) {
+ if (cmd.hasOption("token"))
builder.token("Bearer " + cmd.getOptionValue("token"));
- }
- if (cmd.hasOption("env")) {
+ if (cmd.hasOption("env")){
builder.env(cmd.getOptionValue("env"));
- }
-
+ }
+
if (cmd.hasOption("type")) {
builder.type(cmd.getOptionValue("type"));
} else {
@@ -217,16 +210,14 @@ public static void main(String[] args) throws Exception {
String optionalDownloadPath = null;
List scopes = null;
- LOGGER.info(cmd.getOptionValue("lf"));
- if (cmd.hasOption("lf")) {
+ System.out.println(cmd.getOptionValue("lf"));
+ if (cmd.hasOption("lf"))
filterRequest
.setLeafCategoryIds(new HashSet(Arrays.asList(cmd.getOptionValues("lf"))));
- }
- if (cmd.hasOption("c3f")) {
+ if (cmd.hasOption("c3f"))
filterRequest.setLevelThreeCategories(new HashSet(Arrays.asList(cmd
.getOptionValues("c3f"))));
- }
if (cmd.hasOption("c2f")) {
filterRequest.setLevelTwoCategories(new HashSet(Arrays.asList(cmd
@@ -346,7 +337,7 @@ private static void start(FeedRequest feedRequest, FeedFilterRequest filterReque
// filter
filterRequest.setInputFilePath(unzipResponse.getFilePath());
Response filterResponse = feed.filter(filterRequest);
- LOGGER.info("Filter response = " + filterResponse.toString());
+ System.out.println("Filter response = " + filterResponse.toString());
}
}
diff --git a/src/main/java/com/ebay/feed/example/CombiningFilters.java b/src/main/java/com/ebay/feed/example/CombiningFilters.java
index b8a1229..0ffd291 100644
--- a/src/main/java/com/ebay/feed/example/CombiningFilters.java
+++ b/src/main/java/com/ebay/feed/example/CombiningFilters.java
@@ -17,15 +17,12 @@
import java.util.Set;
import com.ebay.feed.api.Feed;
import com.ebay.feed.api.FeedImpl;
-import com.ebay.feed.cli.FeedCli;
import com.ebay.feed.constants.Constants;
import com.ebay.feed.model.feed.download.GetFeedResponse;
import com.ebay.feed.model.feed.operation.feed.FeedRequest;
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
@@ -49,8 +46,6 @@
*/
public class CombiningFilters {
- private static final Logger LOGGER = LoggerFactory.getLogger(CombiningFilters.class);
-
// oauth token with Bearer prefix
static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#I^3....";
@@ -69,14 +64,14 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in downloading feed. Cannot proceed");
+ System.out.println("Exception in downloading feed. Cannot proceed");
return;
}
@@ -84,7 +79,7 @@ public static void main(String[] args) {
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ System.out.println("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -106,8 +101,8 @@ public static void main(String[] args) {
Response response = feed.filter(filterRequest);
- LOGGER.info("Filter status = " + response.getStatusCode());
- LOGGER.info("Filtered file = " + response.getFilePath());
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java b/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
index 9ae5098..2cc3915 100644
--- a/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
+++ b/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
@@ -19,13 +19,9 @@
import com.ebay.feed.auth.CredentialLoader;
import com.ebay.feed.model.feed.operation.filter.Response;
import com.ebay.feed.model.oauth.AuthRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class ConfigFileBasedExample {
- private static final Logger LOGGER = LoggerFactory.getLogger(ConfigFileBasedExample.class);
-
// credentials file absolute path
static String credentialFilePath = "credentials.yaml";
@@ -34,21 +30,21 @@ public class ConfigFileBasedExample {
public static void main(String[] args) throws Exception {
- // null scopes result in default values being used
- AuthRequest authRequest = new AuthRequest(credentialFilePath, null);
-
- // load credentials and generate token
- CredentialLoader credentialLoader = new CredentialLoader(authRequest);
- credentialLoader.loadCredentials();
- String token = credentialLoader.getOauthResponse().getAccessToken().get().getToken();
-
+ // null scopes result in default values being used
+ AuthRequest authRequest = new AuthRequest(credentialFilePath, null);
+
+ // load credentials and generate token
+ CredentialLoader credentialLoader = new CredentialLoader(authRequest);
+ credentialLoader.loadCredentials();
+ String token = credentialLoader.getOauthResponse().getAccessToken().get().getToken();
+
// expects path to the config file. The config file should be a json with the
// structure mirroring the pojo ConfigFileBasedRequest.java
String configFilePath = "sample-config/config-file-download-unzip-filter";
List responses = feed.processConfigFile(configFilePath, token);
for (Response response : responses) {
- LOGGER.info(response.toString());
+ System.out.println(response.toString());
}
}
diff --git a/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java b/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
index c9d16b2..6b8d8e2 100644
--- a/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
+++ b/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
@@ -24,8 +24,6 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
@@ -44,8 +42,6 @@
*/
public class FeedTypeItemSnapShot {
- private static final Logger LOGGER = LoggerFactory.getLogger(FeedTypeItemSnapShot.class);
-
// oauth token - Bearer xxx
static String token
= Constants.TOKEN_BEARER_PREFIX
@@ -72,14 +68,14 @@ public static void main(String[] args) {
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in downloading feed. Cannot proceed");
+ System.out.println("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ System.out.println("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -91,8 +87,8 @@ public static void main(String[] args) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- LOGGER.info("Filter status = " + response.getStatusCode());
- LOGGER.info("Filtered file = " + response.getFilePath());
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByEnv.java b/src/main/java/com/ebay/feed/example/FilterByEnv.java
index b5115ef..157da90 100644
--- a/src/main/java/com/ebay/feed/example/FilterByEnv.java
+++ b/src/main/java/com/ebay/feed/example/FilterByEnv.java
@@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package com.ebay.feed.example;
import com.ebay.feed.api.Feed;
@@ -22,77 +23,74 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on environment.
- * The download location is default - current working directory
+ * Example showing how to download and filter feed files based on environment. The download location
+ * is default - current working directory
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByEnv {
- private static final Logger LOGGER = LoggerFactory.getLogger(FilterByEnv.class);
-
- // oauth token
- static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#r^0#I...";
-
- // init feed
- static Feed feed = new FeedImpl();
- private static final String CATEGORY = "15032";
+ // oauth token
+ static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#r^0#I...";
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20181005";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
- private static final String FEEDTYPE = "item";
+ // init feed
+ static Feed feed = new FeedImpl();
- public static void main(String[] args) {
+ private static final String CATEGORY = "15032";
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FEEDTYPE).env(EnvTypeEnum.SANDBOX.name());
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20181005";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
+
+ public static void main(String[] args) {
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
+ .type(FEEDTYPE).env(EnvTypeEnum.SANDBOX.name());
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
- if (unzipOpResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in unzipping feed. Cannot proceed");
- return;
- }
-
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
-
- // set price lower and upper lomit
- filterRequest.setPriceLowerLimit(10.0);
- filterRequest.setPriceLowerLimit(20.0);
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- LOGGER.info("Filter status = " + response.getStatusCode());
- LOGGER.info("Filtered file = " + response.getFilePath());
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
}
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+
+ // set price lower and upper lomit
+ filterRequest.setPriceLowerLimit(10.0);
+ filterRequest.setPriceLowerLimit(20.0);
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
+
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByEpids.java b/src/main/java/com/ebay/feed/example/FilterByEpids.java
index d2ca812..21e4233 100644
--- a/src/main/java/com/ebay/feed/example/FilterByEpids.java
+++ b/src/main/java/com/ebay/feed/example/FilterByEpids.java
@@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package com.ebay.feed.example;
import java.util.HashSet;
@@ -23,87 +24,83 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on seller user
- * names. The download location is default - current working directory
- * This example downloads the bootstrap feed file for L1 category : 1
- * (Collectibles) and filters on seller user names.
+ * Example showing how to download and filter feed files based on seller user names. The download
+ * location is default - current working directory
+ * This example downloads the bootstrap feed file for L1 category : 1 (Collectibles) and filters on
+ * seller user names.
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByEpids {
- private static final Logger LOGGER = LoggerFactory.getLogger(FilterByEpids.class);
-
- // oauth token
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^...";
-
- // init feed
- static Feed feed = new FeedImpl();
+ // oauth token
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^...";
- private static final String CATEGORY = "1281";
+ // init feed
+ static Feed feed = new FeedImpl();
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180805";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
- private static final String FEEDTYPE = "item";
+ private static final String CATEGORY = "1281";
- public static void main(String[] args) {
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20180805";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT)
- .token(token).type(FEEDTYPE);
+ public static void main(String[] args) {
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT)
+ .token(token).type(FEEDTYPE);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
-
- if (unzipOpResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in unzipping feed. Cannot proceed");
- return;
- }
-
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setEpids(getEpids());
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- LOGGER.info("Filter status = " + response.getStatusCode());
- LOGGER.info("Filtered file = " + response.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
}
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
- /**
- * Get the set of seller user names to filter on
- *
- * @return
- */
- private static Set getEpids() {
- Set epidSet = new HashSet<>();
- epidSet.add("710154699");
- return epidSet;
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
}
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setEpids(getEpids());
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
+
+ }
+
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getEpids() {
+ Set epidSet = new HashSet<>();
+ epidSet.add("710154699");
+ return epidSet;
+ }
+
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByGtins.java b/src/main/java/com/ebay/feed/example/FilterByGtins.java
index b9e90fa..24df20d 100644
--- a/src/main/java/com/ebay/feed/example/FilterByGtins.java
+++ b/src/main/java/com/ebay/feed/example/FilterByGtins.java
@@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package com.ebay.feed.example;
import java.util.HashSet;
@@ -20,54 +21,50 @@
import com.ebay.feed.constants.Constants;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
- * Simple example of applying a filter on an already downlaoded file
+ * Simple example of applying a filter on an already downlaoded file
*
* The filtering is performed on the unzipped file.
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByGtins {
- private static final Logger LOGGER = LoggerFactory.getLogger(FilterByGtins.class);
-
- // oauth token
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#...";
-
- // init feed
- static Feed feed = new FeedImpl();
+ // oauth token
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#...";
- public static void main(String[] args) {
+ // init feed
+ static Feed feed = new FeedImpl();
+
+ public static void main(String[] args) {
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setGtins(getGtins());
- // set input file
- // absolute path to the unzipped file
- filterRequest
- .setInputFilePath("item_bootstrap-1281-20180708-EBAY_US");
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setGtins(getGtins());
+ // set input file
+ // absolute path to the unzipped file
+ filterRequest
+ .setInputFilePath("item_bootstrap-1281-20180708-EBAY_US");
- Response response = feed.filter(filterRequest);
- LOGGER.info("Filter status = " + response.getStatusCode());
- LOGGER.info("Filtered file = " + response.getFilePath());
+ Response response = feed.filter(filterRequest);
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
- }
+ }
- /**
- * Get the set of seller user names to filter on
- *
- * @return
- */
- private static Set getGtins() {
- Set gtinSet = new HashSet<>();
- gtinSet.add("647369501375");
- return gtinSet;
- }
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getGtins() {
+ Set gtinSet = new HashSet<>();
+ gtinSet.add("647369501375");
+ return gtinSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByItemIds.java b/src/main/java/com/ebay/feed/example/FilterByItemIds.java
index 69ddc45..eccece9 100644
--- a/src/main/java/com/ebay/feed/example/FilterByItemIds.java
+++ b/src/main/java/com/ebay/feed/example/FilterByItemIds.java
@@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package com.ebay.feed.example;
import java.util.HashSet;
@@ -23,90 +24,86 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on seller user
- * names. The download location is default - current working directory
- * This example downloads the bootstrap feed file for L1 category : 1
- * (Collectibles) and filters on seller user names.
+ * Example showing how to download and filter feed files based on seller user names. The download
+ * location is default - current working directory
+ * This example downloads the bootstrap feed file for L1 category : 1 (Collectibles) and filters on
+ * seller user names.
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByItemIds {
- private static final Logger LOGGER = LoggerFactory.getLogger(FilterByItemIds.class);
-
- // oauth token - Bearer xxx
- static String token
- = Constants.TOKEN_BEARER_PREFIX
- + "v^1.1#i^1#f...";
-
- // init feed
- static Feed feed = new FeedImpl();
+ // oauth token - Bearer xxx
+ static String token =
+ Constants.TOKEN_BEARER_PREFIX
+ + "v^1.1#i^1#f...";
- private static final String CATEGORY = "1281";
+ // init feed
+ static Feed feed = new FeedImpl();
- private static final String DATE = "20180805";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
- private static final String FEEDTYPE = "item";
+ private static final String CATEGORY = "1281";
- public static void main(String[] args) {
+ private static final String DATE = "20180805";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
+ public static void main(String[] args) {
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(FEEDTYPE);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
-
- if (unzipOpResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in unzipping feed. Cannot proceed");
- return;
- }
-
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setItemIds(getItemIds());
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- LOGGER.info("Filter status = " + response.getStatusCode());
- LOGGER.info("Filtered file = " + response.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
}
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
- /**
- * Get the set of seller user names to filter on
- *
- * @return
- */
- private static Set getItemIds() {
- Set itemIdSet = new HashSet<>();
- itemIdSet.add("132029430107");
- itemIdSet.add("132676918161");
- itemIdSet.add("14270967132");
- return itemIdSet;
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
}
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setItemIds(getItemIds());
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
+
+ }
+
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getItemIds() {
+ Set itemIdSet = new HashSet<>();
+ itemIdSet.add("132029430107");
+ itemIdSet.add("132676918161");
+ itemIdSet.add("14270967132");
+ return itemIdSet;
+ }
+
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByItemLocation.java b/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
index f46879b..57dd2c3 100644
--- a/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
+++ b/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
@@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package com.ebay.feed.example;
import java.util.HashSet;
@@ -23,88 +24,85 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on item location.
- * The download location is default - current working directory
+ * Example showing how to download and filter feed files based on item location. The download
+ * location is default - current working directory
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByItemLocation {
- private static final Logger LOGGER = LoggerFactory.getLogger(FilterByItemLocation.class);
+ // oauth token - Bearer xxx
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#..";
- // oauth token - Bearer xxx
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#..";
+ // init feed
+ static Feed feed = new FeedImpl();
- // init feed
- static Feed feed = new FeedImpl();
+ private static final String CATEGORY = "11116";
- private static final String CATEGORY = "11116";
-
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180708";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20180708";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
private static final String FEEDTYPE = "item";
+
+ public static void main(String[] args) {
- public static void main(String[] args) {
-
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
-
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(FEEDTYPE);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
-
- if (unzipOpResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in unzipping feed. Cannot proceed");
- return;
- }
-
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setToken(token);
- filterRequest.setItemLocationCountries(getItemLocationSet());
-
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
-
- LOGGER.info("Filter status = " + response.getStatusCode());
- LOGGER.info("Filtered file = " + response.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ System.out.println("Exception in downloading feed. Cannot proceed");
+ return;
}
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
- /**
- * Get the set of item locations to filter on
- *
- * @return
- */
- private static Set getItemLocationSet() {
- Set itemLocationSet = new HashSet<>();
- itemLocationSet.add("CN");
- return itemLocationSet;
+ if (unzipOpResponse.getStatusCode() != 0) {
+ System.out.println("Exception in unzipping feed. Cannot proceed");
+ return;
}
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setToken(token);
+ filterRequest.setItemLocationCountries(getItemLocationSet());
+
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
+
+
+ }
+
+ /**
+ * Get the set of item locations to filter on
+ *
+ * @return
+ */
+ private static Set getItemLocationSet() {
+ Set itemLocationSet = new HashSet<>();
+ itemLocationSet.add("CN");
+ return itemLocationSet;
+ }
+
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java b/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
index b1cd7c0..32ed26a 100644
--- a/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
+++ b/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
@@ -23,8 +23,6 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
@@ -42,8 +40,6 @@
*/
public class FilterByLeafCategories {
- private static final Logger LOGGER = LoggerFactory.getLogger(FilterByLeafCategories.class);
-
// oauth token
static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#I^3...";
@@ -62,21 +58,21 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in downloading feed. Cannot proceed");
+ System.out.println("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ System.out.println("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -87,8 +83,8 @@ public static void main(String[] args) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- LOGGER.info("Filter status = " + response.getStatusCode());
- LOGGER.info("Filtered file = " + response.getFilePath());
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java b/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
index b5817b5..f66d6e3 100644
--- a/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
+++ b/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
@@ -25,8 +25,6 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
@@ -50,8 +48,6 @@
*/
public class FilterByLevelThreeCategory {
- private static final Logger LOGGER = LoggerFactory.getLogger(FilterByLevelThreeCategory.class);
-
// oauth token : Bearer xxx
/**
* For filtering on level two or level three categories, the token scope
@@ -83,13 +79,13 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
if (getFeedResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in downloading feed. Cannot proceed");
+ System.out.println("Exception in downloading feed. Cannot proceed");
return;
}
@@ -97,7 +93,7 @@ public static void main(String[] args) {
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ System.out.println("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -119,8 +115,8 @@ public static void main(String[] args) {
Response response = feed.filter(filterRequest);
- LOGGER.info("Filter status = " + response.getStatusCode());
- LOGGER.info("Filtered file = " + response.getFilePath());
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByPrice.java b/src/main/java/com/ebay/feed/example/FilterByPrice.java
index 011e629..f3a6e05 100644
--- a/src/main/java/com/ebay/feed/example/FilterByPrice.java
+++ b/src/main/java/com/ebay/feed/example/FilterByPrice.java
@@ -21,8 +21,6 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
@@ -40,8 +38,6 @@
*/
public class FilterByPrice {
- private static final Logger LOGGER = LoggerFactory.getLogger(FilterByPrice.class);
-
// oauth token
static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#r^0#I^3...";
@@ -61,21 +57,21 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in downloading feed. Cannot proceed");
+ System.out.println("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ System.out.println("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -89,8 +85,8 @@ public static void main(String[] args) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- LOGGER.info("Filter status = " + response.getStatusCode());
- LOGGER.info("Filtered file = " + response.getFilePath());
+ System.out.println("Filter status = " + response.getStatusCode());
+ System.out.println("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java b/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
index 59ecfa1..01ae3fa 100644
--- a/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
+++ b/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
@@ -23,8 +23,6 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
*
null - Failure non null value - Path of the file that was created as a
- * result of this operation
+ *
null - Failure non null value - Path of the file that was created as a result of this operation
*
*
* appliedFilters - List of all the filters that were applied
- *
+ *
*
- *
+ *
* @author shanganesh
*
*/
public class Response {
- private FeedFilterRequest appliedFilters;
- private Integer statusCode;
- private String message;
- private String filePath;
+ private FeedFilterRequest appliedFilters;
+ private Integer statusCode;
+ private String message;
+ private String filePath;
- public Integer getStatusCode() {
- return statusCode;
- }
+ public Integer getStatusCode() {
+ return statusCode;
+ }
- public void setStatusCode(Integer statusCode) {
- this.statusCode = statusCode;
- }
+ public void setStatusCode(Integer statusCode) {
+ this.statusCode = statusCode;
+ }
- public String getFilePath() {
- return filePath;
- }
+ public String getFilePath() {
+ return filePath;
+ }
- public void setFilePath(String filePath) {
- this.filePath = filePath;
- }
+ public void setFilePath(String filePath) {
+ this.filePath = filePath;
+ }
- public String getMessage() {
- return message;
- }
+ public String getMessage() {
+ return message;
+ }
- public void setMessage(String message) {
- this.message = message;
- }
+ public void setMessage(String message) {
+ this.message = message;
+ }
- public FeedFilterRequest getAppliedFilters() {
- return appliedFilters;
- }
+ public FeedFilterRequest getAppliedFilters() {
+ return appliedFilters;
+ }
- public void setAppliedFilters(FeedFilterRequest appliedFilters) {
- this.appliedFilters = appliedFilters;
- }
+ public void setAppliedFilters(FeedFilterRequest appliedFilters) {
+ this.appliedFilters = appliedFilters;
+ }
- /**
- *
- * @param statusCode 0 success
- * @param message Detailed message regarding the error
- * @param filePath In case of success, the path to the resulting file
- * @param appliedFilters Applied filters
- */
- public Response(Integer statusCode, String message, String filePath,
- FeedFilterRequest appliedFilters) {
- super();
- this.appliedFilters = appliedFilters;
- this.statusCode = statusCode;
- this.message = message;
- this.filePath = filePath;
- }
+ /**
+ *
+ * @param statusCode 0 success
+ * @param message Detailed message regarding the error
+ * @param filePath In case of success, the path to the resulting file
+ * @param appliedFilters Applied filters
+ */
+ public Response(Integer statusCode, String message, String filePath,
+ FeedFilterRequest appliedFilters) {
+ super();
+ this.appliedFilters = appliedFilters;
+ this.statusCode = statusCode;
+ this.message = message;
+ this.filePath = filePath;
+ }
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("Response [appliedFilters=").append(appliedFilters).append(", statusCode=")
- .append(statusCode).append(", message=").append(message).append(", filePath=")
- .append(filePath).append("]");
- return builder.toString();
- }
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Response [appliedFilters=").append(appliedFilters).append(", statusCode=")
+ .append(statusCode).append(", message=").append(message).append(", filePath=")
+ .append(filePath).append("]");
+ return builder.toString();
+ }
}
diff --git a/src/main/java/com/ebay/feed/model/oauth/AuthRequest.java b/src/main/java/com/ebay/feed/model/oauth/AuthRequest.java
index 9a1c96e..9740aa0 100644
--- a/src/main/java/com/ebay/feed/model/oauth/AuthRequest.java
+++ b/src/main/java/com/ebay/feed/model/oauth/AuthRequest.java
@@ -44,8 +44,8 @@ public void setScopes(List scopes) {
public AuthRequest(String configFilePath, List scopes) {
super();
- this.configFilePath = configFilePath;
-
+ this.configFilePath = configFilePath;
+
if (scopes == null) {
List defaultScopes = new ArrayList<>();
defaultScopes.add("https://api.ebay.com/oauth/api_scope");
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index f509dd0..ac7aff9 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -1,48 +1,48 @@
+ ~ /**
+ ~ * Copyright (c) 2018 eBay Inc.
+ ~ *
+ ~ * 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.
+ ~ **/
+ -->
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
-
- ${LOG_HOME:-.}/feed-sdk-log.log
-
- feedsdk-log.%d{yyyy-MM-dd}.log
-
- 7
- 100MB
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
+
+ ${LOG_HOME:-.}/feed-sdk-log.log
+
+ feedsdk-log.%d{yyyy-MM-dd}.log
+
+ 7
+ 100MB
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
-
-
-
-
-
+
+
+
+
+
diff --git a/src/test/java/com/ebay/feed/util/FilterUtilTest.java b/src/test/java/com/ebay/feed/util/FilterUtilTest.java
index d99ffa2..3f57b7a 100644
--- a/src/test/java/com/ebay/feed/util/FilterUtilTest.java
+++ b/src/test/java/com/ebay/feed/util/FilterUtilTest.java
@@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package com.ebay.feed.util;
import java.util.HashSet;
@@ -21,40 +22,40 @@
public class FilterUtilTest {
- FilterUtil filterUtil = new FilterUtil();
+ FilterUtil filterUtil = new FilterUtil();
- @Test
- public void evaluateNegativeTest() {
+ @Test
+ public void evaluateNegativeTest() {
- FeedFilterRequest request = new FeedFilterRequest();
- request.setLeafCategoryIds(getFilterSet());;
- Assert.assertTrue(filterUtil.evaluate(getLine("123"), request));
+ FeedFilterRequest request = new FeedFilterRequest();
+ request.setLeafCategoryIds(getFilterSet());;
+ Assert.assertTrue(filterUtil.evaluate(getLine("123"), request));
- }
+ }
+
+ @Test
+ public void evaluatePositiveTest() {
- @Test
- public void evaluatePositiveTest() {
+ FeedFilterRequest request = new FeedFilterRequest();
+ request.setLeafCategoryIds(getFilterSet());;
+ Assert.assertFalse(filterUtil.evaluate(getLine("456"), request));
- FeedFilterRequest request = new FeedFilterRequest();
- request.setLeafCategoryIds(getFilterSet());;
- Assert.assertFalse(filterUtil.evaluate(getLine("456"), request));
+ }
- }
-
- private Set getFilterSet() {
- Set filterSet = new HashSet<>();
- filterSet.add("123");
- return filterSet;
- }
+ private Set getFilterSet() {
+ Set filterSet = new HashSet<>();
+ filterSet.add("123");
+ return filterSet;
+ }
- private String[] getLine(String filterValue) {
+ private String[] getLine(String filterValue) {
- String[] arr = new String[50];
+ String[] arr = new String[50];
- for (int i = 0; i < 50; i++) {
- arr[i] = filterValue;
- }
- return arr;
+ for (int i = 0; i < 50; i++) {
+ arr[i] = filterValue;
}
+ return arr;
+ }
}
From 2c9b120741422413f8db1fe126e3a3e98877670a Mon Sep 17 00:00:00 2001
From: Babar Shahzad
Date: Wed, 24 Mar 2021 18:08:05 +0500
Subject: [PATCH 06/17] Replaced sout with Logger
Replaced sout with Logger
and
Formatted all source code using NetBeans IDE Source formatter
---
.classpath | 58 +--
nbactions.xml | 88 ++--
pom.xml | 432 +++++++++---------
.../com/ebay/feed/auth/CredentialLoader.java | 12 +-
src/main/java/com/ebay/feed/cli/FeedCli.java | 37 +-
.../ebay/feed/example/CombiningFilters.java | 14 +-
.../feed/example/ConfigFileBasedExample.java | 22 +-
.../feed/example/FeedTypeItemSnapShot.java | 12 +-
.../com/ebay/feed/example/FilterByEnv.java | 96 ++--
.../com/ebay/feed/example/FilterByEpids.java | 113 ++---
.../com/ebay/feed/example/FilterByGtins.java | 63 +--
.../ebay/feed/example/FilterByItemIds.java | 13 +-
.../feed/example/FilterByItemLocation.java | 116 ++---
.../feed/example/FilterByLeafCategories.java | 14 +-
.../example/FilterByLevelThreeCategory.java | 14 +-
.../com/ebay/feed/example/FilterByPrice.java | 14 +-
.../feed/example/FilterBySellerUserNames.java | 18 +-
.../feed/example/UsingCredentialFile.java | 12 +-
.../UsingCredentialFileForSandBoxEnv.java | 14 +-
.../ebay/feed/example/UsingMutliThread.java | 16 +-
src/main/resources/logback.xml | 82 ++--
21 files changed, 663 insertions(+), 597 deletions(-)
diff --git a/.classpath b/.classpath
index a5d9509..d223a57 100644
--- a/.classpath
+++ b/.classpath
@@ -1,32 +1,32 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nbactions.xml b/nbactions.xml
index a8f8955..1671d43 100644
--- a/nbactions.xml
+++ b/nbactions.xml
@@ -1,46 +1,46 @@
-
- run
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
-
-
- -classpath %classpath com.ebay.feed.example.UsingCredentialFileForSandBoxEnv
- java
-
-
-
- debug
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
-
-
- -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.ebay.feed.example.UsingCredentialFileForSandBoxEnv
- java
- true
-
-
-
- profile
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
-
-
- -classpath %classpath com.ebay.feed.example.UsingCredentialFileForSandBoxEnv
- java
-
-
-
+
+ run
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
+
+
+ -classpath %classpath com.ebay.feed.example.UsingCredentialFileForSandBoxEnv
+ java
+
+
+
+ debug
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
+
+
+ -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.ebay.feed.example.UsingCredentialFileForSandBoxEnv
+ java
+ true
+
+
+
+ profile
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
+
+
+ -classpath %classpath com.ebay.feed.example.UsingCredentialFileForSandBoxEnv
+ java
+
+
+
diff --git a/pom.xml b/pom.xml
index 474f221..4736082 100755
--- a/pom.xml
+++ b/pom.xml
@@ -1,227 +1,227 @@
+~ /**
+~ * Copyright (c) 2018 eBay Inc.
+~ *
+~ * 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.
+~ **/
+-->
- 4.0.0
- com.ebay.api
- feed-sdk
- 1.1.0-SNAPSHOT
- jar
- ${project.groupId}:${project.artifactId}
- eBay Feed SDK helps in downloading and filtering feed files
- https://github.com/eBay/FeedSDK
-
- scm:git:git@github.com:eBay/FeedSDK.git
- https://github.com/eBay/FeedSDK
- HEAD
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ com.ebay.api
+ feed-sdk
+ 1.1.0-SNAPSHOT
+ jar
+ ${project.groupId}:${project.artifactId}
+ eBay Feed SDK helps in downloading and filtering feed files
+ https://github.com/eBay/FeedSDK
+
+ scm:git:git@github.com:eBay/FeedSDK.git
+ https://github.com/eBay/FeedSDK
+ HEAD
+
-
-
- shanganesh
- Shankar Ganesh
- shanganesh@ebay.com
- eBay
- https://www.ebay.com
-
-
- skumaravelayutham
- Seethalakshmi Kumaravelayutham
- skumaravelayutham@ebay.com
- eBay
- https://www.ebay.com
-
-
+
+
+ shanganesh
+ Shankar Ganesh
+ shanganesh@ebay.com
+ eBay
+ https://www.ebay.com
+
+
+ skumaravelayutham
+ Seethalakshmi Kumaravelayutham
+ skumaravelayutham@ebay.com
+ eBay
+ https://www.ebay.com
+
+
-
-
- The Apache Software License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
-
-
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
-
- UTF-8
- 1.6.4
- 1.0.1
-
+
+ UTF-8
+ 1.6.4
+ 1.0.1
+
-
-
- com.squareup.okhttp3
- okhttp
- 3.10.0
-
-
-
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
-
- ch.qos.logback
- logback-classic
- ${logback.version}
-
-
- ch.qos.logback
- logback-core
- ${logback.version}
-
-
-
- com.google.code.gson
- gson
- 2.8.5
-
-
- commons-cli
- commons-cli
- 1.4
-
-
- com.ebay.auth
- ebay-oauth-java-client
- 1.1.0
-
-
- junit
- junit
- 4.12
-
-
+
+
+ com.squareup.okhttp3
+ okhttp
+ 3.10.0
+
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+ ch.qos.logback
+ logback-core
+ ${logback.version}
+
+
+
+ com.google.code.gson
+ gson
+ 2.8.5
+
+
+ commons-cli
+ commons-cli
+ 1.4
+
+
+ com.ebay.auth
+ ebay-oauth-java-client
+ 1.1.0
+
+
+ junit
+ junit
+ 4.12
+
+
-
-
-
- maven-compiler-plugin
- 3.7.0
-
-
- 1.8
-
-
+
+
+
+ maven-compiler-plugin
+ 3.7.0
+
+
+ 1.8
+
+
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.1.1
-
-
-
- package
-
- shade
-
-
- ${project.artifactId}-${project.version}-uber
-
-
-
- com.ebay.feed.cli.FeedCli
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
- 3.0.1
-
-
- attach-sources
-
- jar-no-fork
-
-
-
-
-
-
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.1.1
+
+
+
+ package
+
+ shade
+
+
+ ${project.artifactId}-${project.version}-uber
+
+
+
+ com.ebay.feed.cli.FeedCli
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.0.1
+
+
+ attach-sources
+
+ jar-no-fork
+
+
+
+
+
+
-
-
- release
-
-
- ossrh
- https://oss.sonatype.org/content/repositories/snapshots
-
-
- ossrh
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.21.0
-
- true
-
-
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.7
- true
-
- ossrh
- https://oss.sonatype.org/
- true
-
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
- 1.6
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.10.4
-
-
- attach-javadocs
-
- jar
-
-
-
-
-
-
-
-
+
+
+ release
+
+
+ ossrh
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
+ ossrh
+ https://oss.sonatype.org/service/local/staging/deploy/maven2/
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.21.0
+
+ true
+
+
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.7
+ true
+
+ ossrh
+ https://oss.sonatype.org/
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.6
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.10.4
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/ebay/feed/auth/CredentialLoader.java b/src/main/java/com/ebay/feed/auth/CredentialLoader.java
index 5f8cac9..21e5072 100644
--- a/src/main/java/com/ebay/feed/auth/CredentialLoader.java
+++ b/src/main/java/com/ebay/feed/auth/CredentialLoader.java
@@ -29,8 +29,9 @@
*
* Responsible for loading consumer credentials and generating token.
*
- * In order to generate token, the {@link #loadCredentials() loadCredentials} method needs to be
- * invoked, which loads the credentials from the provided config file.
+ * In order to generate token, the {@link #loadCredentials() loadCredentials}
+ * method needs to be invoked, which loads the credentials from the provided
+ * config file.
*
* Once the credentials are loaded, the token can be obtained by invoking the
* {@link #getOauthResponse() getOauthResponse}
@@ -60,8 +61,9 @@ public CredentialLoader(AuthRequest authRequest) {
*/
public void loadCredentials() throws Exception {
- if (authRequest == null)
+ if (authRequest == null) {
throw new Exception("null AuthRequest");
+ }
LOGGER.debug("****** Begin loadCredentials with configPath = {}",
authRequest.getConfigFilePath());
@@ -100,7 +102,7 @@ public OAuthResponse getOauthResponse() throws IOException {
* Generates oauth token, based on the loaded credentials
*
*
- * @param environment
+ * @param environment
* @return Returns the OAuthResponse which contains the token
* @throws IOException Thrown if file is not found
*/
@@ -112,7 +114,7 @@ public OAuthResponse getOauthResponse(String environment) throws IOException {
OAuthResponse res = null;
//checking environment for token
if (environment.equalsIgnoreCase("SANDBOX")) {
- res = api.getApplicationToken(Environment.SANDBOX, authRequest.getScopes());
+ res = api.getApplicationToken(Environment.SANDBOX, authRequest.getScopes());
} else {
res = api.getApplicationToken(Environment.PRODUCTION, authRequest.getScopes());
}
diff --git a/src/main/java/com/ebay/feed/cli/FeedCli.java b/src/main/java/com/ebay/feed/cli/FeedCli.java
index 2210ae3..506ae52 100644
--- a/src/main/java/com/ebay/feed/cli/FeedCli.java
+++ b/src/main/java/com/ebay/feed/cli/FeedCli.java
@@ -57,7 +57,8 @@ public static void main(String[] args) throws Exception {
options.addOption("help", false, "display help");
- /***
+ /**
+ * *
* options for downloading the file
*/
// date
@@ -172,28 +173,34 @@ public static void main(String[] args) throws Exception {
// populate feed request
FeedRequestBuilder builder = new FeedRequestBuilder();
- if (cmd.hasOption("dt"))
+ if (cmd.hasOption("dt")) {
builder.date(cmd.getOptionValue("dt"));
+ }
- if (cmd.hasOption("sdt"))
+ if (cmd.hasOption("sdt")) {
builder.snapshotDate(cmd.getOptionValue("sdt"));
+ }
- if (cmd.hasOption("c1"))
+ if (cmd.hasOption("c1")) {
builder.categoryId(cmd.getOptionValue("c1"));
+ }
- if (cmd.hasOption("mkt"))
+ if (cmd.hasOption("mkt")) {
builder.siteId(cmd.getOptionValue("mkt"));
+ }
- if (cmd.hasOption("scope"))
+ if (cmd.hasOption("scope")) {
builder.feedScope(cmd.getOptionValue("scope"));
+ }
- if (cmd.hasOption("token"))
+ if (cmd.hasOption("token")) {
builder.token("Bearer " + cmd.getOptionValue("token"));
+ }
- if (cmd.hasOption("env")){
+ if (cmd.hasOption("env")) {
builder.env(cmd.getOptionValue("env"));
- }
-
+ }
+
if (cmd.hasOption("type")) {
builder.type(cmd.getOptionValue("type"));
} else {
@@ -210,14 +217,16 @@ public static void main(String[] args) throws Exception {
String optionalDownloadPath = null;
List scopes = null;
- System.out.println(cmd.getOptionValue("lf"));
- if (cmd.hasOption("lf"))
+ LOGGER.info(cmd.getOptionValue("lf"));
+ if (cmd.hasOption("lf")) {
filterRequest
.setLeafCategoryIds(new HashSet(Arrays.asList(cmd.getOptionValues("lf"))));
+ }
- if (cmd.hasOption("c3f"))
+ if (cmd.hasOption("c3f")) {
filterRequest.setLevelThreeCategories(new HashSet(Arrays.asList(cmd
.getOptionValues("c3f"))));
+ }
if (cmd.hasOption("c2f")) {
filterRequest.setLevelTwoCategories(new HashSet(Arrays.asList(cmd
@@ -337,7 +346,7 @@ private static void start(FeedRequest feedRequest, FeedFilterRequest filterReque
// filter
filterRequest.setInputFilePath(unzipResponse.getFilePath());
Response filterResponse = feed.filter(filterRequest);
- System.out.println("Filter response = " + filterResponse.toString());
+ LOGGER.info("Filter response = " + filterResponse.toString());
}
}
diff --git a/src/main/java/com/ebay/feed/example/CombiningFilters.java b/src/main/java/com/ebay/feed/example/CombiningFilters.java
index 0ffd291..cf2dc66 100644
--- a/src/main/java/com/ebay/feed/example/CombiningFilters.java
+++ b/src/main/java/com/ebay/feed/example/CombiningFilters.java
@@ -23,6 +23,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -46,6 +48,8 @@
*/
public class CombiningFilters {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CombiningFilters.class);
+
// oauth token with Bearer prefix
static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#I^3....";
@@ -64,14 +68,14 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
@@ -79,7 +83,7 @@ public static void main(String[] args) {
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -101,8 +105,8 @@ public static void main(String[] args) {
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java b/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
index 2cc3915..9ae5098 100644
--- a/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
+++ b/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java
@@ -19,9 +19,13 @@
import com.ebay.feed.auth.CredentialLoader;
import com.ebay.feed.model.feed.operation.filter.Response;
import com.ebay.feed.model.oauth.AuthRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ConfigFileBasedExample {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConfigFileBasedExample.class);
+
// credentials file absolute path
static String credentialFilePath = "credentials.yaml";
@@ -30,21 +34,21 @@ public class ConfigFileBasedExample {
public static void main(String[] args) throws Exception {
- // null scopes result in default values being used
- AuthRequest authRequest = new AuthRequest(credentialFilePath, null);
-
- // load credentials and generate token
- CredentialLoader credentialLoader = new CredentialLoader(authRequest);
- credentialLoader.loadCredentials();
- String token = credentialLoader.getOauthResponse().getAccessToken().get().getToken();
-
+ // null scopes result in default values being used
+ AuthRequest authRequest = new AuthRequest(credentialFilePath, null);
+
+ // load credentials and generate token
+ CredentialLoader credentialLoader = new CredentialLoader(authRequest);
+ credentialLoader.loadCredentials();
+ String token = credentialLoader.getOauthResponse().getAccessToken().get().getToken();
+
// expects path to the config file. The config file should be a json with the
// structure mirroring the pojo ConfigFileBasedRequest.java
String configFilePath = "sample-config/config-file-download-unzip-filter";
List responses = feed.processConfigFile(configFilePath, token);
for (Response response : responses) {
- System.out.println(response.toString());
+ LOGGER.info(response.toString());
}
}
diff --git a/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java b/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
index 6b8d8e2..c9d16b2 100644
--- a/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
+++ b/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
@@ -24,6 +24,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -42,6 +44,8 @@
*/
public class FeedTypeItemSnapShot {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FeedTypeItemSnapShot.class);
+
// oauth token - Bearer xxx
static String token
= Constants.TOKEN_BEARER_PREFIX
@@ -68,14 +72,14 @@ public static void main(String[] args) {
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -87,8 +91,8 @@ public static void main(String[] args) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByEnv.java b/src/main/java/com/ebay/feed/example/FilterByEnv.java
index 157da90..b5115ef 100644
--- a/src/main/java/com/ebay/feed/example/FilterByEnv.java
+++ b/src/main/java/com/ebay/feed/example/FilterByEnv.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import com.ebay.feed.api.Feed;
@@ -23,74 +22,77 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on environment. The download location
- * is default - current working directory
+ * Example showing how to download and filter feed files based on environment.
+ * The download location is default - current working directory
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByEnv {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByEnv.class);
- // oauth token
- static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#r^0#I...";
+ // oauth token
+ static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#r^0#I...";
- // init feed
- static Feed feed = new FeedImpl();
+ // init feed
+ static Feed feed = new FeedImpl();
- private static final String CATEGORY = "15032";
+ private static final String CATEGORY = "15032";
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20181005";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
- private static final String FEEDTYPE = "item";
-
- public static void main(String[] args) {
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20181005";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FEEDTYPE).env(EnvTypeEnum.SANDBOX.name());
+ public static void main(String[] args) {
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
+ .type(FEEDTYPE).env(EnvTypeEnum.SANDBOX.name());
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+
+ // set price lower and upper lomit
+ filterRequest.setPriceLowerLimit(10.0);
+ filterRequest.setPriceLowerLimit(20.0);
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
-
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
-
- // set price lower and upper lomit
- filterRequest.setPriceLowerLimit(10.0);
- filterRequest.setPriceLowerLimit(20.0);
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
- }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByEpids.java b/src/main/java/com/ebay/feed/example/FilterByEpids.java
index 21e4233..d2ca812 100644
--- a/src/main/java/com/ebay/feed/example/FilterByEpids.java
+++ b/src/main/java/com/ebay/feed/example/FilterByEpids.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -24,83 +23,87 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on seller user names. The download
- * location is default - current working directory
- * This example downloads the bootstrap feed file for L1 category : 1 (Collectibles) and filters on
- * seller user names.
+ * Example showing how to download and filter feed files based on seller user
+ * names. The download location is default - current working directory
+ * This example downloads the bootstrap feed file for L1 category : 1
+ * (Collectibles) and filters on seller user names.
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByEpids {
- // oauth token
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^...";
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByEpids.class);
- // init feed
- static Feed feed = new FeedImpl();
+ // oauth token
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^...";
- private static final String CATEGORY = "1281";
+ // init feed
+ static Feed feed = new FeedImpl();
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180805";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
- private static final String FEEDTYPE = "item";
+ private static final String CATEGORY = "1281";
- public static void main(String[] args) {
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20180805";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
+ private static final String FEEDTYPE = "item";
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT)
- .token(token).type(FEEDTYPE);
+ public static void main(String[] args) {
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT)
+ .token(token).type(FEEDTYPE);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setEpids(getEpids());
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setEpids(getEpids());
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
- }
-
- /**
- * Get the set of seller user names to filter on
- *
- * @return
- */
- private static Set getEpids() {
- Set epidSet = new HashSet<>();
- epidSet.add("710154699");
- return epidSet;
- }
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getEpids() {
+ Set epidSet = new HashSet<>();
+ epidSet.add("710154699");
+ return epidSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByGtins.java b/src/main/java/com/ebay/feed/example/FilterByGtins.java
index 24df20d..b9e90fa 100644
--- a/src/main/java/com/ebay/feed/example/FilterByGtins.java
+++ b/src/main/java/com/ebay/feed/example/FilterByGtins.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -21,50 +20,54 @@
import com.ebay.feed.constants.Constants;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
- * Simple example of applying a filter on an already downlaoded file
+ * Simple example of applying a filter on an already downlaoded file
*
* The filtering is performed on the unzipped file.
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByGtins {
- // oauth token
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#...";
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByGtins.class);
+
+ // oauth token
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#...";
+
+ // init feed
+ static Feed feed = new FeedImpl();
- // init feed
- static Feed feed = new FeedImpl();
-
- public static void main(String[] args) {
+ public static void main(String[] args) {
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setGtins(getGtins());
- // set input file
- // absolute path to the unzipped file
- filterRequest
- .setInputFilePath("item_bootstrap-1281-20180708-EBAY_US");
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setGtins(getGtins());
+ // set input file
+ // absolute path to the unzipped file
+ filterRequest
+ .setInputFilePath("item_bootstrap-1281-20180708-EBAY_US");
- Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ Response response = feed.filter(filterRequest);
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
- }
+ }
- /**
- * Get the set of seller user names to filter on
- *
- * @return
- */
- private static Set getGtins() {
- Set gtinSet = new HashSet<>();
- gtinSet.add("647369501375");
- return gtinSet;
- }
+ /**
+ * Get the set of seller user names to filter on
+ *
+ * @return
+ */
+ private static Set getGtins() {
+ Set gtinSet = new HashSet<>();
+ gtinSet.add("647369501375");
+ return gtinSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByItemIds.java b/src/main/java/com/ebay/feed/example/FilterByItemIds.java
index eccece9..76b5e8e 100644
--- a/src/main/java/com/ebay/feed/example/FilterByItemIds.java
+++ b/src/main/java/com/ebay/feed/example/FilterByItemIds.java
@@ -24,6 +24,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -42,6 +44,9 @@
*
*/
public class FilterByItemIds {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByItemIds.class);
+
// oauth token - Bearer xxx
static String token =
@@ -70,14 +75,14 @@ public static void main(String[] args) {
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -88,8 +93,8 @@ public static void main(String[] args) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByItemLocation.java b/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
index 57dd2c3..f46879b 100644
--- a/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
+++ b/src/main/java/com/ebay/feed/example/FilterByItemLocation.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.example;
import java.util.HashSet;
@@ -24,85 +23,88 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
- * Example showing how to download and filter feed files based on item location. The download
- * location is default - current working directory
+ * Example showing how to download and filter feed files based on item location.
+ * The download location is default - current working directory
* The filtering is performed on the unzipped file.
* So the sequence of events that are followed is :-
* - Download feed file
* - Unzip feed file
* - Filter feed file
*
- *
+ *
* @author shanganesh
*
*/
public class FilterByItemLocation {
- // oauth token - Bearer xxx
- static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#..";
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByItemLocation.class);
- // init feed
- static Feed feed = new FeedImpl();
+ // oauth token - Bearer xxx
+ static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#p^1#..";
- private static final String CATEGORY = "11116";
+ // init feed
+ static Feed feed = new FeedImpl();
- // TODO : Check if the date is within 14 days, before making the call
- private static final String DATE = "20180708";
- private static final String SCOPE = "ALL_ACTIVE";
- private static final String MKT = "EBAY_US";
+ private static final String CATEGORY = "11116";
+
+ // TODO : Check if the date is within 14 days, before making the call
+ private static final String DATE = "20180708";
+ private static final String SCOPE = "ALL_ACTIVE";
+ private static final String MKT = "EBAY_US";
private static final String FEEDTYPE = "item";
-
- public static void main(String[] args) {
- // create request
- FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
- builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
+ public static void main(String[] args) {
- // using null for download directory - defaults to current working directory
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+ // create request
+ FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
+ builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
+ .type(FEEDTYPE);
- // 0 denotes successful response
- if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
- return;
- }
- // unzip
- Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+ // using null for download directory - defaults to current working directory
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
+
+ // 0 denotes successful response
+ if (getFeedResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
+ return;
+ }
+ // unzip
+ Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
+
+ if (unzipOpResponse.getStatusCode() != 0) {
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
+ return;
+ }
+
+ // filter
+ FeedFilterRequest filterRequest = new FeedFilterRequest();
+ filterRequest.setToken(token);
+ filterRequest.setItemLocationCountries(getItemLocationSet());
+
+ // set input file
+ filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
+
+ Response response = feed.filter(filterRequest);
+
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
- if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
- return;
}
- // filter
- FeedFilterRequest filterRequest = new FeedFilterRequest();
- filterRequest.setToken(token);
- filterRequest.setItemLocationCountries(getItemLocationSet());
-
- // set input file
- filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
-
- Response response = feed.filter(filterRequest);
-
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
-
-
- }
-
- /**
- * Get the set of item locations to filter on
- *
- * @return
- */
- private static Set getItemLocationSet() {
- Set itemLocationSet = new HashSet<>();
- itemLocationSet.add("CN");
- return itemLocationSet;
- }
+ /**
+ * Get the set of item locations to filter on
+ *
+ * @return
+ */
+ private static Set getItemLocationSet() {
+ Set itemLocationSet = new HashSet<>();
+ itemLocationSet.add("CN");
+ return itemLocationSet;
+ }
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java b/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
index 32ed26a..b1cd7c0 100644
--- a/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
+++ b/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java
@@ -23,6 +23,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -40,6 +42,8 @@
*/
public class FilterByLeafCategories {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByLeafCategories.class);
+
// oauth token
static String token = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#f^0#I^3...";
@@ -58,21 +62,21 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(token)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -83,8 +87,8 @@ public static void main(String[] args) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java b/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
index f66d6e3..b5817b5 100644
--- a/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
+++ b/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java
@@ -25,6 +25,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -48,6 +50,8 @@
*/
public class FilterByLevelThreeCategory {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByLevelThreeCategory.class);
+
// oauth token : Bearer xxx
/**
* For filtering on level two or level three categories, the token scope
@@ -79,13 +83,13 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
@@ -93,7 +97,7 @@ public static void main(String[] args) {
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -115,8 +119,8 @@ public static void main(String[] args) {
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterByPrice.java b/src/main/java/com/ebay/feed/example/FilterByPrice.java
index f3a6e05..011e629 100644
--- a/src/main/java/com/ebay/feed/example/FilterByPrice.java
+++ b/src/main/java/com/ebay/feed/example/FilterByPrice.java
@@ -21,6 +21,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -38,6 +40,8 @@
*/
public class FilterByPrice {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterByPrice.class);
+
// oauth token
static String TOKEN = Constants.TOKEN_BEARER_PREFIX + "v^1.1#i^1#r^0#I^3...";
@@ -57,21 +61,21 @@ public static void main(String[] args) {
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
builder.categoryId(CATEGORY).date(DATE).feedScope(SCOPE).siteId(MKT).token(TOKEN)
- .type(FEEDTYPE);
+ .type(FEEDTYPE);
// using null for download directory - defaults to current working directory
GetFeedResponse getFeedResponse = feed.get(builder.build(), null);
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -85,8 +89,8 @@ public static void main(String[] args) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java b/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
index 01ae3fa..59ecfa1 100644
--- a/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
+++ b/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java
@@ -23,6 +23,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -41,6 +43,8 @@
*/
public class UsingCredentialFileForSandBoxEnv {
+ private static final Logger LOGGER = LoggerFactory.getLogger(UsingCredentialFileForSandBoxEnv.class);
+
// credentials file absolute path
static String credentialFilePath = "credentials.yaml";
@@ -72,18 +76,18 @@ public static void main(String[] args) throws Exception {
// using null for download directory - defaults to current working directory
// passing credentialFilePath as required for token refresh on the fly to support resume capability while downloading feed
- GetFeedResponse getFeedResponse = feed.get(builder.build(), null,credentialFilePath);
+ GetFeedResponse getFeedResponse = feed.get(builder.build(), null, credentialFilePath);
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -97,8 +101,8 @@ public static void main(String[] args) throws Exception {
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
}
diff --git a/src/main/java/com/ebay/feed/example/UsingMutliThread.java b/src/main/java/com/ebay/feed/example/UsingMutliThread.java
index 7346a95..ed04384 100644
--- a/src/main/java/com/ebay/feed/example/UsingMutliThread.java
+++ b/src/main/java/com/ebay/feed/example/UsingMutliThread.java
@@ -24,6 +24,8 @@
import com.ebay.feed.model.feed.operation.feed.FeedRequest.FeedRequestBuilder;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.filter.Response;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -42,6 +44,8 @@
*/
public class UsingMutliThread {
+ private static final Logger LOGGER = LoggerFactory.getLogger(UsingMutliThread.class);
+
// oauth token - Bearer xxx
static String token
= Constants.TOKEN_BEARER_PREFIX
@@ -70,7 +74,7 @@ public static void main(String[] args) {
}
private static void getUnzipAndFilterFeed(String feedType) {
- System.out.println("starting thread for feedType: " + feedType);
+ LOGGER.info("starting thread for feedType: " + feedType);
// create request
FeedRequest.FeedRequestBuilder builder = new FeedRequestBuilder();
if (feedType.equalsIgnoreCase("item_snapshot")) {
@@ -85,14 +89,14 @@ private static void getUnzipAndFilterFeed(String feedType) {
// 0 denotes successful response
if (getFeedResponse.getStatusCode() != 0) {
- System.out.println("Exception in downloading feed. Cannot proceed");
+ LOGGER.info("Exception in downloading feed. Cannot proceed");
return;
}
// unzip
Response unzipOpResponse = feed.unzip(getFeedResponse.getFilePath());
if (unzipOpResponse.getStatusCode() != 0) {
- System.out.println("Exception in unzipping feed. Cannot proceed");
+ LOGGER.info("Exception in unzipping feed. Cannot proceed");
return;
}
@@ -103,9 +107,9 @@ private static void getUnzipAndFilterFeed(String feedType) {
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
Response response = feed.filter(filterRequest);
- System.out.println("Filter status = " + response.getStatusCode());
- System.out.println("Filtered file = " + response.getFilePath());
- System.out.println("finished first thread");
+ LOGGER.info("Filter status = " + response.getStatusCode());
+ LOGGER.info("Filtered file = " + response.getFilePath());
+ LOGGER.info("finished first thread");
}
/**
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index ac7aff9..f509dd0 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -1,48 +1,48 @@
+~ /**
+~ * Copyright (c) 2018 eBay Inc.
+~ *
+~ * 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.
+~ **/
+-->
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
-
- ${LOG_HOME:-.}/feed-sdk-log.log
-
- feedsdk-log.%d{yyyy-MM-dd}.log
-
- 7
- 100MB
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
+
+ ${LOG_HOME:-.}/feed-sdk-log.log
+
+ feedsdk-log.%d{yyyy-MM-dd}.log
+
+ 7
+ 100MB
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
-
-
-
-
-
+
+
+
+
+
From 3c7911942ebb59bc9229dec6559216e762b35941 Mon Sep 17 00:00:00 2001
From: Babar Shahzad
Date: Wed, 7 Jul 2021 21:02:04 +0500
Subject: [PATCH 07/17] Update ReadMe.md
Added sample command to get ITEM_SNAPSHOT feed using CLI
---
README.md | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 8a0b256..85c38bc 100644
--- a/README.md
+++ b/README.md
@@ -299,9 +299,14 @@ usage: Feed SDK CLI
For example, to use the command line options to download, unzip and filter feed files
-Using token
+Using token For Item
```
-java -jar feed-sdk-1.1.0-SNAPSHOT-uber.jar -dt 20180701 -c1 1281 -scope ALL_ACTIVE -lf 46310 177789 -mkt EBAY_US -c3f 177792 116381 -pricelf 2 -priceuf 100 -locf US CN -token xxx
+java -jar feed-sdk-1.1.0-SNAPSHOT-uber.jar -dt 20180701 -type ITEM -c1 1281 -scope ALL_ACTIVE -lf 46310 177789 -mkt EBAY_US -c3f 177792 116381 -pricelf 2 -priceuf 100 -locf US CN -token xxx
+```
+
+Using token For ITEM_SNAPSHOT
+```
+java -jar feed-sdk-1.1.0-SNAPSHOT-uber.jar -sdt 2021-06-10T02:00:00.000Z -type ITEM_SNAPSHOT -env SANDBOX -c1 625 -mkt EBAY_US -pricelf 2 -priceuf 100 -locf US CN -token xxx
```
Using credentials file
From 054dd4daedb19a332fd553f4bd77e104c98d8d83 Mon Sep 17 00:00:00 2001
From: Babar Shahzad
Date: Fri, 20 Aug 2021 15:31:03 +0500
Subject: [PATCH 08/17] ITEM_SNAPSHOT filters incorporated
---
.../config-file-download-unzip-filter | 3 +-
src/main/java/com/ebay/feed/cli/FeedCli.java | 4 +
.../feed/example/FeedTypeItemSnapShot.java | 2 +
.../operation/filter/FeedFilterRequest.java | 17 +-
.../java/com/ebay/feed/util/FilterUtil.java | 505 ++++++++++--------
5 files changed, 298 insertions(+), 233 deletions(-)
diff --git a/sample-config/config-file-download-unzip-filter b/sample-config/config-file-download-unzip-filter
index 9794f73..4249d82 100644
--- a/sample-config/config-file-download-unzip-filter
+++ b/sample-config/config-file-download-unzip-filter
@@ -12,7 +12,8 @@
"sellerNames":["andy14nq", "gigaparts"],
"itemLocationCountries":["US", "CN"],
"priceLowerLimit":10.0,
- "priceUpperLimit":100.0
+ "priceUpperLimit":100.0,
+ "type":"ITEM_SNAPSHOT"
}
},
{
diff --git a/src/main/java/com/ebay/feed/cli/FeedCli.java b/src/main/java/com/ebay/feed/cli/FeedCli.java
index 506ae52..cc4996d 100644
--- a/src/main/java/com/ebay/feed/cli/FeedCli.java
+++ b/src/main/java/com/ebay/feed/cli/FeedCli.java
@@ -279,6 +279,10 @@ public static void main(String[] args) throws Exception {
if (cmd.hasOption("mkt")) {
filterRequest.setMarketplace(cmd.getOptionValue("mkt"));
}
+
+ if (cmd.hasOption("type")) {
+ filterRequest.setType(cmd.getOptionValue("type"));
+ }
if (cmd.hasOption("cl")) {
credentialFile = cmd.getOptionValue("cl");
diff --git a/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java b/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
index c9d16b2..65c13f2 100644
--- a/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
+++ b/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java
@@ -87,6 +87,8 @@ public static void main(String[] args) {
FeedFilterRequest filterRequest = new FeedFilterRequest();
// set price lower and upper limit
filterRequest.setPriceLowerLimit(10.0);
+ // filter for item type
+ filterRequest.setType(FEEDTYPE);
// set input file
filterRequest.setInputFilePath(unzipOpResponse.getFilePath());
diff --git a/src/main/java/com/ebay/feed/model/feed/operation/filter/FeedFilterRequest.java b/src/main/java/com/ebay/feed/model/feed/operation/filter/FeedFilterRequest.java
index 462c38a..a0232b0 100644
--- a/src/main/java/com/ebay/feed/model/feed/operation/filter/FeedFilterRequest.java
+++ b/src/main/java/com/ebay/feed/model/feed/operation/filter/FeedFilterRequest.java
@@ -42,6 +42,7 @@
*
inferredEpids - Set of inferred epids for filtering
*
gtins - Set of gtins for filtering
*
itemIds - Set of item ids for filtering
+ *
type - Currently supported - ITEM
*
*
*
@@ -50,13 +51,14 @@
*/
public class FeedFilterRequest {
- /**
+ /**
* This is needed to calculate the leaf categories for level two and level three This is not used
* to filter
*/
private String levelOneCategory;
private String marketplace;
private String token;
+ private String type;
private Set leafCategoryIds = new HashSet<>();
private Set sellerNames;
@@ -218,12 +220,23 @@ public void setToken(String token) {
this.token = token;
}
+
+ public String getType() {
+ if(type == null || type.isEmpty()){
+ return "item";
+ }
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("FeedFilterRequest [levelOneCategory=").append(levelOneCategory)
- .append(", marketplace=").append(marketplace).append(", leafCategoryIds=")
+ .append(", marketplace=").append(marketplace).append(", type=").append(type).append(", leafCategoryIds=")
.append(leafCategoryIds).append(", sellerNames=").append(sellerNames)
.append(", itemLocationCountries=").append(itemLocationCountries)
.append(", priceLowerLimit=").append(priceLowerLimit).append(", priceUpperLimit=")
diff --git a/src/main/java/com/ebay/feed/util/FilterUtil.java b/src/main/java/com/ebay/feed/util/FilterUtil.java
index 2670da5..4f96192 100644
--- a/src/main/java/com/ebay/feed/util/FilterUtil.java
+++ b/src/main/java/com/ebay/feed/util/FilterUtil.java
@@ -11,7 +11,6 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package com.ebay.feed.util;
import java.io.BufferedReader;
@@ -28,6 +27,7 @@
import com.ebay.feed.api.Taxonomy;
import com.ebay.feed.api.TaxonomyImpl;
import com.ebay.feed.constants.Constants;
+import com.ebay.feed.enums.FeedTypeEnum;
import com.ebay.feed.model.feed.operation.filter.FeedFilterRequest;
import com.ebay.feed.model.feed.operation.taxonomy.CategoryResponse;
@@ -35,60 +35,59 @@
*
* Utility class to perform filtering on feed files
*
- *
+ *
* @author shanganesh
*
*/
public class FilterUtil {
- private static final Logger LOGGER = LoggerFactory.getLogger(FilterUtil.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(FilterUtil.class);
- /**
- *
- * Apply the filters to the contents specified in the baseFilePath
- *
- *
- * @param baseFilePath Path to the unzipped feed file
- * @param filterRequest Container for capturing the filter parameters
- * @return string The path of the filtered file
- * @throws Exception exception
- */
- public String filter(Path baseFilePath, FeedFilterRequest filterRequest) throws Exception {
+ /**
+ *
+ * Apply the filters to the contents specified in the baseFilePath
+ *
+ *
+ * @param baseFilePath Path to the unzipped feed file
+ * @param filterRequest Container for capturing the filter parameters
+ * @return string The path of the filtered file
+ * @throws Exception exception
+ */
+ public String filter(Path baseFilePath, FeedFilterRequest filterRequest) throws Exception {
- LOGGER.debug("******* Begin filtering on file = {} with parameters = {}", baseFilePath,
- filterRequest);
+ LOGGER.debug("******* Begin filtering on file = {} with parameters = {}", baseFilePath,
+ filterRequest);
- String filteredFile = getFilteredFileName(baseFilePath, filterRequest);
+ String filteredFile = getFilteredFileName(baseFilePath, filterRequest);
- try (BufferedReader r = new BufferedReader(new FileReader(baseFilePath.toFile()));
- BufferedWriter w = new BufferedWriter(new FileWriter(filteredFile))) {
+ try (BufferedReader r = new BufferedReader(new FileReader(baseFilePath.toFile()));
+ BufferedWriter w = new BufferedWriter(new FileWriter(filteredFile))) {
- String line = null;
+ String line = null;
- while ((line = r.readLine()) != null) {
- String[] tsv = line.split(Constants.SEPARATOR);
+ while ((line = r.readLine()) != null) {
+ String[] tsv = line.split(Constants.SEPARATOR);
- // only for header
- if (evaluateHeader(tsv)) {
- w.write(line + System.lineSeparator());
- }
+ // only for header
+ if (evaluateHeader(tsv)) {
+ w.write(line + System.lineSeparator());
+ }
- // actual listings
- if (evaluate(tsv, filterRequest)) {
- w.write(line + System.lineSeparator());
- }
- }
+ // actual listings
+ if (evaluate(tsv, filterRequest)) {
+ w.write(line + System.lineSeparator());
+ }
+ }
- } catch (Exception e) {
- LOGGER.error("Error in FilterUtils.filter()", e);
- throw e;
+ } catch (Exception e) {
+ LOGGER.error("Error in FilterUtils.filter()", e);
+ throw e;
+ }
+ return filteredFile;
}
- return filteredFile;
- }
-
- /**
- *
+ /**
+ *
Evaluate the provided conditions The column number passed as a parameter to the 'evaluateField'
method, represents the column number in the actual file in the response.
@@ -102,217 +101,263 @@ public String filter(Path baseFilePath, FeedFilterRequest filterRequest) throws
0 - item id
- *
- * @param line One record from the feed file
- * @param filterRequest Container for capturing the filter parameters
- * @return boolean Indicates whether any filters apply to this record
- */
- protected boolean evaluate(String[] line, FeedFilterRequest filterRequest) {
- return evaluateField(line, filterRequest.getLeafCategoryIds(), 4)
- && evaluateField(line, filterRequest.getSellerNames(), 6)
- && evaluateField(line, filterRequest.getItemLocationCountries(), 21)
- && evaluateItemPrice(line, filterRequest)
- && evaluateField(line, filterRequest.getEpids(), 12)
- && evaluateField(line, filterRequest.getInferredEpids(), 40)
- && evaluateField(line, filterRequest.getGtins(), 9)
- && evaluateField(line, filterRequest.getItemIds(), 0);
- }
-
- /**
- *
- * Evaluate if the line is a headerline
- *
- *
- * @param line One record from the feed file
- * @return boolean Checks if the line is a header line
- */
- private boolean evaluateHeader(String[] line) {
- return line[0].contains(Constants.ITEM_ID);
- }
-
- /**
- *
+ *
+ * @param line One record from the feed file
+ * @return boolean Checks if the line is a header line
+ */
+ private boolean evaluateHeader(String[] line) {
+ return line[0].contains(Constants.ITEM_ID);
+ }
+
+ /**
+ *
* Evaluate if the item price based on the inputs - within a range - higher than a limit - lower
* than given limit
- *
- *
- * @param line One record from the feed file
- * @param filterRequest Container for capturing the filter parameters
- * @return boolean Checks if the price filter applies to this item
- */
- private boolean evaluateItemPrice(String[] line, FeedFilterRequest filterRequest) {
-
- boolean isValid = true;
-
- if (filterRequest == null
- || (filterRequest.getPriceLowerLimit() == null && filterRequest.getPriceUpperLimit() == null))
- return isValid;
-
- Double price = null;
- int colNo = 15;
-
- if (!isColumnValid(colNo, line.length))
- return isValid;
-
- try {
- price = Double.valueOf(line[colNo]);
- } catch (Exception e) {
- return false;
- }
+ *
+ *
+ * @param line One record from the feed file
+ * @param filterRequest Container for capturing the filter parameters
+ * @return boolean Checks if the price filter applies to this item
+ */
+ private boolean evaluateItemPrice(String[] line, FeedFilterRequest filterRequest) {
+
+ boolean isValid = true;
+
+ if (filterRequest == null
+ || (filterRequest.getPriceLowerLimit() == null && filterRequest.getPriceUpperLimit() == null))
+ return isValid;
+
+ Double price = null;
+ int colNo = 15;
+ if (filterRequest.getType().equalsIgnoreCase(FeedTypeEnum.ITEM_SNAPSHOT.name())) {
+ colNo = 16;
+ }
+
+ if (!isColumnValid(colNo, line.length))
+ return isValid;
- // between range
- if (filterRequest.getPriceLowerLimit() != null && filterRequest.getPriceUpperLimit() != null) {
+ try {
+ price = Double.valueOf(line[colNo]);
+ } catch (Exception e) {
+ return false;
+ }
+
+ // between range
+ if (filterRequest.getPriceLowerLimit() != null && filterRequest.getPriceUpperLimit() != null) {
- if (price < filterRequest.getPriceLowerLimit() || price > filterRequest.getPriceUpperLimit()) {
- isValid = false;
+ if (price < filterRequest.getPriceLowerLimit() || price > filterRequest.getPriceUpperLimit()) {
+ isValid = false;
- }
- } else if (filterRequest.getPriceLowerLimit() != null) {
+ }
+ } else if (filterRequest.getPriceLowerLimit() != null) {
- if (price < filterRequest.getPriceLowerLimit())
- isValid = false;
+ if (price < filterRequest.getPriceLowerLimit())
+ isValid = false;
- } else if (filterRequest.getPriceUpperLimit() != null) {
+ } else if (filterRequest.getPriceUpperLimit() != null) {
- if (price > filterRequest.getPriceUpperLimit())
- isValid = false;
+ if (price > filterRequest.getPriceUpperLimit())
+ isValid = false;
+ }
+ return isValid;
}
- return isValid;
- }
-
-
- /**
- *
- * Evaluates the presence of field at 'columnNo', is present in the given set.
- *
- * This method is generic for handling filtering on 'set of string' filters.
- *
- *
- * @param line One record from the feed file
- * @param filterSet Set of filters
- * @param column Column to filter on
- * @return
- */
- private boolean evaluateField(String[] line, Set filterSet, Integer columnNo) {
-
- boolean isValid = true;
-
- // nothing to evaluate
- if (filterSet == null || filterSet.isEmpty() || columnNo == null)
- return isValid;
-
- // guard against parsing issues
- if (!isColumnValid(columnNo, line.length))
- return isValid;
-
- String field = line[columnNo];
-
- if (filterSet != null && !filterSet.isEmpty() && !filterSet.contains(field)) {
- isValid = false;
+
+ /**
+ *
+ * Evaluates the presence of field at 'columnNo', is present in the given set.
+ *
+ * This method is generic for handling filtering on 'set of string' filters.
+ *
+ *
+ * @param line One record from the feed file
+ * @param filterSet Set of filters
+ * @param column Column to filter on
+ * @return
+ */
+ private boolean evaluateField(String[] line, Set filterSet, Integer columnNo) {
+
+ boolean isValid = true;
+
+ // nothing to evaluate
+ if (filterSet == null || filterSet.isEmpty() || columnNo == null)
+ return isValid;
+
+ // guard against parsing issues
+ if (!isColumnValid(columnNo, line.length))
+ return isValid;
+
+ String field = line[columnNo];
+
+ if (filterSet != null && !filterSet.isEmpty() && !filterSet.contains(field)) {
+ isValid = false;
+ }
+ return isValid;
+
+ }
+
+
+ /**
+ *
+ * Evaluates the presence of field at 'columnNo', is present in the given set.
+ *
+ * This method is for skipping UNAVAILABLE items
+ *
+ *
+ * @param line One record from the feed file
+ * @param column Column to filter on
+ * @return
+ */
+ private boolean checkItemAvailability(String[] line, Integer columnNo) {
+ boolean isValid = true;
+
+ // guard against parsing issues
+ if (!isColumnValid(columnNo, line.length))
+ return isValid;
+
+ String field = line[columnNo];
+
+ if(columnNo == 1 && field.equalsIgnoreCase("UNAVAILABLE"))
+ isValid = false;
+
+ return isValid;
+
+ }
+
+ /**
+ *
+ * Generate filtered file name based on base file path and timestamp
+ *
+ *
+ * @param baseFilePath Path of the unzipped file
+ * @param filterRequest Container for capturing the filter parameters
+ * @return
+ */
+ private String getFilteredFileName(Path baseFilePath, FeedFilterRequest filterRequest) {
+ Date d = new Date();
+ String filteredFile = baseFilePath.toString() + "-filtered-" + d.getTime();
+ return filteredFile;
}
- return isValid;
-
- }
-
- /**
- *
- * Generate filtered file name based on base file path and timestamp
- *
- *
- * @param baseFilePath Path of the unzipped file
- * @param filterRequest Container for capturing the filter parameters
- * @return
- */
- private String getFilteredFileName(Path baseFilePath, FeedFilterRequest filterRequest) {
- Date d = new Date();
- String filteredFile = baseFilePath.toString() + "-filtered-" + d.getTime();
- return filteredFile;
- }
-
- /**
- *
- * Calculate leaf categories if level two or level three category filters have been specified
- *
- *
- *
- * @param filterRequest Container for capturing the filter parameters
- * @return Set of leaf categories
- */
- public Set calculateLeaves(FeedFilterRequest filterRequest) {
-
- Set leafCategories = new HashSet<>();
- // return null of level two and level three categories are absent.
- // no need to invoke taxonomy
- if (isLevelNAbsent(filterRequest))
- return leafCategories;
-
- Taxonomy taxonomy = new TaxonomyImpl();
+
+ /**
+ *
+ * Calculate leaf categories if level two or level three category filters have been specified
+ *
+ *
+ *
+ * @param filterRequest Container for capturing the filter parameters
+ * @return Set of leaf categories
+ */
+ public Set calculateLeaves(FeedFilterRequest filterRequest) {
+
+ Set leafCategories = new HashSet<>();
+ // return null of level two and level three categories are absent.
+ // no need to invoke taxonomy
+ if (isLevelNAbsent(filterRequest))
+ return leafCategories;
+
+ Taxonomy taxonomy = new TaxonomyImpl();
String categoryTreeId =
taxonomy.getCategoryTreeId(filterRequest.getToken(), filterRequest.getMarketplace());
- if (categoryTreeId == null) {
- LOGGER.debug("Could not load category tree id. Cannot proceed...");
- return null;
- }
+ if (categoryTreeId == null) {
+ LOGGER.debug("Could not load category tree id. Cannot proceed...");
+ return null;
+ }
CategoryResponse categoryResponse =
taxonomy.loadLeafCategories(filterRequest.getToken(), categoryTreeId,
- filterRequest.getLevelOneCategory());
-
- Set levelTwoCats = filterRequest.getLevelTwoCategories();
- Set levelThreeCats = filterRequest.getLevelThreeCategories();
-
-
- if (levelTwoCats != null && !levelTwoCats.isEmpty())
- leafCategories.addAll(getLeafCategories(categoryResponse.getLevelTwoCategoryLeaves(),
- levelTwoCats));
-
- if (levelThreeCats != null && !levelThreeCats.isEmpty())
- leafCategories.addAll(getLeafCategories(categoryResponse.getLevelThreeCategoryLeaves(),
- levelThreeCats));
-
- return leafCategories;
- }
-
- /**
- *
- * Get map of leaf categories
- *
- *
- * @param map Map of level one to children categories
- * @param catSet Set of leaf categories
- * @return Set of leaf categories
- */
- private Set getLeafCategories(Map> map, Set catSet) {
- Set leafCategorySet = new HashSet<>();
- for (String cat : catSet) {
- leafCategorySet.addAll(map.get(cat));
+ filterRequest.getLevelOneCategory());
+
+ Set levelTwoCats = filterRequest.getLevelTwoCategories();
+ Set levelThreeCats = filterRequest.getLevelThreeCategories();
+
+ if (levelTwoCats != null && !levelTwoCats.isEmpty())
+ leafCategories.addAll(getLeafCategories(categoryResponse.getLevelTwoCategoryLeaves(),
+ levelTwoCats));
+
+ if (levelThreeCats != null && !levelThreeCats.isEmpty())
+ leafCategories.addAll(getLeafCategories(categoryResponse.getLevelThreeCategoryLeaves(),
+ levelThreeCats));
+
+ return leafCategories;
+ }
+
+ /**
+ *
+ * Get map of leaf categories
+ *
+ *
+ * @param map Map of level one to children categories
+ * @param catSet Set of leaf categories
+ * @return Set of leaf categories
+ */
+ private Set getLeafCategories(Map> map, Set catSet) {
+ Set leafCategorySet = new HashSet<>();
+ for (String cat : catSet) {
+ leafCategorySet.addAll(map.get(cat));
+ }
+ return leafCategorySet;
}
- return leafCategorySet;
- }
-
- /**
- *
- * @param colNo Column number from the feed file
- * @param len Total number of columns
- * @return boolean Indicates whether the column number is valid
- */
- private boolean isColumnValid(int colNo, int len) {
- return colNo < len;
- }
-
- /**
+
+ /**
+ *
+ * @param colNo Column number from the feed file
+ * @param len Total number of columns
+ * @return boolean Indicates whether the column number is valid
+ */
+ private boolean isColumnValid(int colNo, int len) {
+ return colNo < len;
+ }
+
+ /**
* Taxonomy invocation required only if l2 or l3 categories are present Read this method as Level
* 'n' absent, to signify level 2, or 3 (maybe more levels in the future)
- *
+ *
* @return boolean - Checks presence of l2 and l3 categories. If present, returns false. If both
* are empty/null, returns true
- */
- private boolean isLevelNAbsent(FeedFilterRequest filterRequest) {
- return filterRequest == null
- || ((filterRequest.getLevelThreeCategories() == null || filterRequest
- .getLevelThreeCategories().isEmpty()) && (filterRequest.getLevelTwoCategories() == null || filterRequest
- .getLevelTwoCategories().isEmpty()));
- }
+ */
+ private boolean isLevelNAbsent(FeedFilterRequest filterRequest) {
+ return filterRequest == null
+ || ((filterRequest.getLevelThreeCategories() == null || filterRequest
+ .getLevelThreeCategories().isEmpty()) && (filterRequest.getLevelTwoCategories() == null || filterRequest
+ .getLevelTwoCategories().isEmpty()));
+ }
}
From 1386bea463951342bcfd83038ee7a985a83a494b Mon Sep 17 00:00:00 2001
From: dvijayan-ebay <89428246+dvijayan-ebay@users.noreply.github.com>
Date: Thu, 26 Aug 2021 11:22:32 -0700
Subject: [PATCH 09/17] update links
---
README.md | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/README.md b/README.md
index 85c38bc..c2634de 100644
--- a/README.md
+++ b/README.md
@@ -344,11 +344,11 @@ The structure of the config file
```
An example of using the SDK through a config file is located at
-[Config file based approach example - ConfigFileBasedExample.java](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java)
+[Config file based approach example - ConfigFileBasedExample.java](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/ConfigFileBasedExample.java)
-[Example config file - 1](https://github.com/babar-shzd/FeedSDK/tree/incorporation-snapshot-feed-sdk/sample-config/config-file-download-unzip-filter)
+[Example config file - 1](https://github.com/eBay/FeedSDK/tree/1.1.0/sample-config/config-file-download-unzip-filter)
-[Example config file - 2](https://github.com/babar-shzd/FeedSDK/tree/incorporation-snapshot-feed-sdk/sample-config/config-file-filter)
+[Example config file - 2](https://github.com/eBay/FeedSDK/tree/1.1.0/sample-config/config-file-filter)
### Using java method calls
@@ -356,21 +356,21 @@ Samples showing the usage of available operations and filters.
#### Examples
-All the examples are located [__here__](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example)
-
-* [Filter by item location](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByItemLocation.java)
-* [Filter by leaf categories](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java)
-* [Filter by price](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByPrice.java)
-* [Filter by seller user names](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java)
-* [Combining multiple filters](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/CombiningFilters.java)
-* [Filter on level three category](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java)
-* [Filter on EPID](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByEpids.java)
-* [Filter on GTIN](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByGtins.java)
-* [Filter on item IDs](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByItemIds.java)
-* [Filter by env](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FilterByEnv.java)
-* [Feed type item_snapshot](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java)
-* [Multithreading usage MutliThreading](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/UsingMutliThread.java)
-* [Credential file usage 'Credential'](https://github.com/babar-shzd/FeedSDK/blob/incorporation-snapshot-feed-sdk/src/main/java/com/ebay/feed/example/UsingCredentialFileForSandBoxEnv.java)
+All the examples are located [__here__](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example)
+
+* [Filter by item location](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/FilterByItemLocation.java)
+* [Filter by leaf categories](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/FilterByLeafCategories.java)
+* [Filter by price](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/FilterByPrice.java)
+* [Filter by seller user names](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/FilterBySellerUserNames.java)
+* [Combining multiple filters](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/CombiningFilters.java)
+* [Filter on level three category](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/FilterByLevelThreeCategory.java)
+* [Filter on EPID](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/FilterByEpids.java)
+* [Filter on GTIN](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/FilterByGtins.java)
+* [Filter on item IDs](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/FilterByItemIds.java)
+* [Filter by env](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/FilterByEnv.java)
+* [Feed type item_snapshot](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/FeedTypeItemSnapShot.java)
+* [Multithreading usage MutliThreading](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/UsingMutliThread.java)
+* [Credential file usage 'Credential'](https://github.com/eBay/FeedSDK/blob/1.1.0/src/main/java/com/ebay/feed/example/UsingCredentialFileForSandBoxEnv.java)
---
From 2f01bb1b871eb082352876bb05dcc9208dfe87c9 Mon Sep 17 00:00:00 2001
From: dvijayan-ebay <89428246+dvijayan-ebay@users.noreply.github.com>
Date: Thu, 26 Aug 2021 11:29:10 -0700
Subject: [PATCH 10/17] update to release version
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 4736082..9816628 100755
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,7 @@
4.0.0com.ebay.apifeed-sdk
- 1.1.0-SNAPSHOT
+ 1.1.0-RELEASEjar${project.groupId}:${project.artifactId}eBay Feed SDK helps in downloading and filtering feed files
@@ -224,4 +224,4 @@
-
\ No newline at end of file
+
From b44b156c694a87eeb5ef57f24bd941431e290570 Mon Sep 17 00:00:00 2001
From: dvijayan-ebay <89428246+dvijayan-ebay@users.noreply.github.com>
Date: Thu, 26 Aug 2021 15:32:21 -0700
Subject: [PATCH 11/17] Library version changes
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9816628..9151291 100755
--- a/pom.xml
+++ b/pom.xml
@@ -59,7 +59,7 @@
UTF-81.6.4
- 1.0.1
+ 1.3.0-alpha7
@@ -103,7 +103,7 @@
junitjunit
- 4.12
+ 4.13.2
From c321410c14ec9665480cbe0f93e07aea5f56e520 Mon Sep 17 00:00:00 2001
From: dvijayan-ebay <89428246+dvijayan-ebay@users.noreply.github.com>
Date: Fri, 3 Sep 2021 15:07:42 -0700
Subject: [PATCH 12/17] slf4j library changes
---
pom.xml | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9151291..90efed6 100755
--- a/pom.xml
+++ b/pom.xml
@@ -73,16 +73,11 @@
org.slf4jslf4j-api${slf4j.version}
-
-
- ch.qos.logback
- logback-classic
- ${logback.version}
-
+
- ch.qos.logback
- logback-core
- ${logback.version}
+ org.slf4j
+ slf4j-simple
+ ${slf4j.version}
From 46a3a1d718effe0195d6cb1b8e8cf2530a0c8909 Mon Sep 17 00:00:00 2001
From: dvijayan-ebay <89428246+dvijayan-ebay@users.noreply.github.com>
Date: Fri, 10 Sep 2021 12:18:25 -0700
Subject: [PATCH 13/17] Updating to release version
---
README.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index c2634de..0d68d2f 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,7 @@ You are most welcome to collaborate and enhance the existing code base.
com.ebay.apifeed-sdk
- 1.1.0-SNAPSHOT
+ 1.1.
```
@@ -252,7 +252,7 @@ All the capabilities of the SDK can be invoked using the command line.
To see the available options and filters , use '-help'
```
-java -jar feed-sdk-1.1.0-SNAPSHOT-uber.jar -help
+java -jar feed-sdk-1.1.0-RELEASE-uber.jar -help
usage: Feed SDK CLI
-help display help
-dt the date when feed file was generated
@@ -306,12 +306,12 @@ java -jar feed-sdk-1.1.0-SNAPSHOT-uber.jar -dt 20180701 -type ITEM -c1 1281 -sco
Using token For ITEM_SNAPSHOT
```
-java -jar feed-sdk-1.1.0-SNAPSHOT-uber.jar -sdt 2021-06-10T02:00:00.000Z -type ITEM_SNAPSHOT -env SANDBOX -c1 625 -mkt EBAY_US -pricelf 2 -priceuf 100 -locf US CN -token xxx
+java -jar feed-sdk-1.1.0-RELEASE-uber.jar -sdt 2021-06-10T02:00:00.000Z -type ITEM_SNAPSHOT -env SANDBOX -c1 625 -mkt EBAY_US -pricelf 2 -priceuf 100 -locf US CN -token xxx
```
Using credentials file
```
-java -jar feed-sdk-1.1.0-SNAPSHOT-uber.jar -dt 20180801 -c1 11700 -scope ALL_ACTIVE -mkt EBAY_US -pricelf 2 -priceuf 100 -locf US CN -cl
+java -jar feed-sdk-1.1.0-RELEASE-uber.jar -dt 20180801 -c1 11700 -scope ALL_ACTIVE -mkt EBAY_US -pricelf 2 -priceuf 100 -locf US CN -cl
```
### Using config file driven approach
From 091c3805feca1f781675c4f2b24c677625938be5 Mon Sep 17 00:00:00 2001
From: dvijayan-ebay <89428246+dvijayan-ebay@users.noreply.github.com>
Date: Fri, 10 Sep 2021 12:18:52 -0700
Subject: [PATCH 14/17] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 0d68d2f..118da0e 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,7 @@ You are most welcome to collaborate and enhance the existing code base.
com.ebay.apifeed-sdk
- 1.1.
+ 1.1.RELEASE
```
From 3a3af49d93b29d9d81205b0de61236b9f82e33f9 Mon Sep 17 00:00:00 2001
From: dvijayan-ebay <89428246+dvijayan-ebay@users.noreply.github.com>
Date: Fri, 10 Sep 2021 12:19:41 -0700
Subject: [PATCH 15/17] 1.1.0-RELEASE readme update
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 118da0e..5c91868 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,7 @@ You are most welcome to collaborate and enhance the existing code base.
com.ebay.apifeed-sdk
- 1.1.RELEASE
+ 1.1.0-RELEASE
```
From 63199f2b43fe06a86d9a35296a05885bb53dd524 Mon Sep 17 00:00:00 2001
From: dvijayan-ebay <89428246+dvijayan-ebay@users.noreply.github.com>
Date: Fri, 12 Nov 2021 11:03:52 -0800
Subject: [PATCH 16/17] Update CHANGELOG.md
---
CHANGELOG.md | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 28e12bf..c13ada9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,9 +4,16 @@ Feed SDK CHANGE LOG
====================
Change log for Feed SDK which helps to download and filter the item feed files.
-* 1.0.0.beta-RELEASE
+* 1.0.0.beta-RELEASE (#1.0.0.beta-RELEASE)
* [1.0.1.beta-RELEASE](#1.0.1.beta-RELEASE)
* [1.0.2.beta-RELEASE](#1.0.2.beta-RELEASE)
+* [1.1.0-RELEASE](#1.1.0-RELEASE)
+
+# 1.1.0-RELEASE (2021/09/03)
+[Full Changelog](https://github.com/eBay/FeedSDK/compare/1.1.0-RELEASE...1.1.0-RELEASE)
+Enhancement Requests:
+* Updated sdk with item snapshot feature support
+
# 1.0.2.beta-RELEASE (2018/10/26)
[Full Changelog](https://github.com/eBay/FeedSDK/compare/1.0.1.beta-RELEASE...1.0.2.beta-RELEASE)
From 7d97b516a47a0bfd93b10512fa31d988ce88e3fb Mon Sep 17 00:00:00 2001
From: dvijayan-ebay <89428246+dvijayan-ebay@users.noreply.github.com>
Date: Fri, 12 Nov 2021 11:04:36 -0800
Subject: [PATCH 17/17] Update CHANGELOG.md
---
CHANGELOG.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c13ada9..6dcf0d5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,7 +10,6 @@ Change log for Feed SDK which helps to download and filter the item feed files.
* [1.1.0-RELEASE](#1.1.0-RELEASE)
# 1.1.0-RELEASE (2021/09/03)
-[Full Changelog](https://github.com/eBay/FeedSDK/compare/1.1.0-RELEASE...1.1.0-RELEASE)
Enhancement Requests:
* Updated sdk with item snapshot feature support