svn commit: r917407 [1/3] - in /ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore: EbayAccount.java EbayEvents.java EbayFeedback.java EbayStore.java EbayStoreHelper.java EbayStoreInventoryServices.java EbayStoreOptions.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r917407 [1/3] - in /ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore: EbayAccount.java EbayEvents.java EbayFeedback.java EbayStore.java EbayStoreHelper.java EbayStoreInventoryServices.java EbayStoreOptions.java

hansbak-2
Author: hansbak
Date: Mon Mar  1 07:24:40 2010
New Revision: 917407

URL: http://svn.apache.org/viewvc?rev=917407&view=rev
Log:
reformat and tabs to spaces ebaystore java files: no functional changes

Modified:
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayAccount.java
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayFeedback.java
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStore.java
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreHelper.java
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreInventoryServices.java
    ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayStoreOptions.java

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayAccount.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayAccount.java?rev=917407&r1=917406&r2=917407&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayAccount.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayAccount.java Mon Mar  1 07:24:40 2010
@@ -38,82 +38,82 @@
     private static final String resource = "EbayUiLabels";
     private static final String configFileName = "ebayExport.properties";
     private static final String module = EbayAccount.class.getName();
-    
- public static Map<String, Object> getEbayUser(DispatchContext dctx, Map<String, ? extends Object> context){
- Map<String, Object>result = FastMap.newInstance();
- String errorMsg = null;
- LocalDispatcher dispatcher = dctx.getDispatcher();
- GenericValue userLogin = (GenericValue) context.get("userLogin");
- Delegator delegator = dctx.getDelegator();
- Locale locale = (Locale) context.get("locale");
- String productStoreId = (String) context.get("productStoreId");
-
- // Output Variable
- String email = null,
- cityName = null,
- companyName = null,
- country = null,
- firstName = null,
- lastName = null,
- name = null,
- phone = null,
- postalCode = null,
- stateOrProvince = null,
- street = null,
- street1 = null,
- street2 = null,
- status = null;
- Map<String, Object>registrationAddress = FastMap.newInstance();
-
- try{
- Map<String, Object>infoMap = FastMap.newInstance();
- ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
- GetUserCall getUserCall  = new GetUserCall(apiContext);
- DetailLevelCodeType[] detailLevel = {DetailLevelCodeType.RETURN_ALL};
- getUserCall.setDetailLevel(detailLevel);
- UserType  user = getUserCall.getUser();
- if(user != null){
- email = user.getEmail();
- AddressType regAddress = user.getRegistrationAddress();
- if(regAddress != null){
- cityName = regAddress.getCityName();
- companyName = regAddress.getCompanyName();
- country = regAddress.getCountryName();
- firstName = regAddress.getFirstName();
- lastName = regAddress.getLastName();
- name = regAddress.getName();
- phone = regAddress.getPhone();
- postalCode = regAddress.getPostalCode();
- stateOrProvince = regAddress.getStateOrProvince();
- street = regAddress.getStreet();
- street1 = regAddress.getStreet1();
- street2 = regAddress.getStreet2();
- }
- if(firstName == null && lastName == null && name !=null){
- String nameArray[] = name.split(" ");
- firstName = nameArray[0];
- lastName = nameArray[1];
- }
- registrationAddress.put("cityName", cityName);
- registrationAddress.put("companyName", companyName);
- registrationAddress.put("country", country);
- registrationAddress.put("firstName", firstName);
- registrationAddress.put("lastName", lastName);
- registrationAddress.put("phone", phone);
- registrationAddress.put("postalCode", postalCode);
- registrationAddress.put("stateOrProvince", stateOrProvince);
- registrationAddress.put("street", street);
- registrationAddress.put("street1", street1);
- registrationAddress.put("street2", street2);
- status = user.getStatus().toString();
- }
- result.put("email", email);
- result.put("registrationAddress", registrationAddress);
- result.put("status", status);
- }catch(Exception e){
- // TODO Auto-generated catch block
- return  ServiceUtil.returnError(e.getMessage());
- }
- return result;
- }
-}
+
+    public static Map<String, Object> getEbayUser(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object>result = FastMap.newInstance();
+        String errorMsg = null;
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        Delegator delegator = dctx.getDelegator();
+        Locale locale = (Locale) context.get("locale");
+        String productStoreId = (String) context.get("productStoreId");
+
+        // Output Variable
+        String email = null,
+            cityName = null,
+            companyName = null,
+            country = null,
+            firstName = null,
+            lastName = null,
+            name = null,
+            phone = null,
+            postalCode = null,
+            stateOrProvince = null,
+            street = null,
+            street1 = null,
+            street2 = null,
+            status = null;
+        Map<String, Object>registrationAddress = FastMap.newInstance();
+
+        try {
+            Map<String, Object> infoMap = FastMap.newInstance();
+            ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+            GetUserCall getUserCall  = new GetUserCall(apiContext);
+            DetailLevelCodeType[] detailLevel = {DetailLevelCodeType.RETURN_ALL};
+            getUserCall.setDetailLevel(detailLevel);
+            UserType  user = getUserCall.getUser();
+            if (user != null) {
+                email = user.getEmail();
+                AddressType regAddress = user.getRegistrationAddress();
+                if (regAddress != null) {
+                    cityName = regAddress.getCityName();
+                    companyName = regAddress.getCompanyName();
+                    country = regAddress.getCountryName();
+                    firstName = regAddress.getFirstName();
+                    lastName = regAddress.getLastName();
+                    name = regAddress.getName();
+                    phone = regAddress.getPhone();
+                    postalCode = regAddress.getPostalCode();
+                    stateOrProvince = regAddress.getStateOrProvince();
+                    street = regAddress.getStreet();
+                    street1 = regAddress.getStreet1();
+                    street2 = regAddress.getStreet2();
+                }
+                if (firstName == null && lastName == null && name !=null) {
+                    String nameArray[] = name.split(" ");
+                    firstName = nameArray[0];
+                    lastName = nameArray[1];
+                }
+                registrationAddress.put("cityName", cityName);
+                registrationAddress.put("companyName", companyName);
+                registrationAddress.put("country", country);
+                registrationAddress.put("firstName", firstName);
+                registrationAddress.put("lastName", lastName);
+                registrationAddress.put("phone", phone);
+                registrationAddress.put("postalCode", postalCode);
+                registrationAddress.put("stateOrProvince", stateOrProvince);
+                registrationAddress.put("street", street);
+                registrationAddress.put("street1", street1);
+                registrationAddress.put("street2", street2);
+                status = user.getStatus().toString();
+            }
+            result.put("email", email);
+            result.put("registrationAddress", registrationAddress);
+            result.put("status", status);
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            return  ServiceUtil.returnError(e.getMessage());
+        }
+        return result;
+    }
+}
\ No newline at end of file

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java?rev=917407&r1=917406&r2=917407&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayEvents.java Mon Mar  1 07:24:40 2010
@@ -33,56 +33,55 @@
 import org.ofbiz.webapp.taglib.ServiceTag;
 
 public class EbayEvents {
-
- public static final String module = ServiceTag.class.getName();
-
- public static String sendLeaveFeedback(HttpServletRequest request, HttpServletResponse response) {
- HttpSession session = request.getSession(true);
- LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
- Map requestParams = UtilHttp.getParameterMap(request);
- GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
- int feedbackSize = Integer.parseInt((String)requestParams.get("feedbackSize"));
- String productStoreId = (String)requestParams.get("productStoreId");
- for(int i=1;i<=feedbackSize;i++){
- String commentType = (String)requestParams.get("commentType"+i);
- String commentText = (String)requestParams.get("commentText"+i);
- if(!commentType.equals("none") && commentText != null){
- String itemId = (String)requestParams.get("itemId"+i);
- String transactionId = (String)requestParams.get("transactionId"+i);
- String targetUser = (String)requestParams.get("targetUser"+i);
- String commentingUser = (String)requestParams.get("commentingUser"+i);
- String role = (String)requestParams.get("role"+i);
- String ratingItem = (String)requestParams.get("ratingItem"+i);
- String ratingComm = (String)requestParams.get("ratingComm"+i);
- String ratingShip = (String)requestParams.get("ratingShip"+i);
- String ratingShipHand = (String)requestParams.get("ratingShipHand"+i);
- String AqItemAsDescribedId = (String)requestParams.get("AqItemAsDescribedId"+i);
-
- Map leavefeedback =  FastMap.newInstance();
- leavefeedback.put("productStoreId", productStoreId);
- leavefeedback.put("userLogin", userLogin);
- leavefeedback.put("itemId", itemId);
- leavefeedback.put("transactionId", transactionId);
- leavefeedback.put("targetUser", targetUser);
- leavefeedback.put("commentingUser", commentingUser);
- leavefeedback.put("role", role);
- leavefeedback.put("commentText", commentText);
- leavefeedback.put("commentType", commentType);
- leavefeedback.put("ratingItem", ratingItem);
- leavefeedback.put("ratingComm", ratingComm);
- leavefeedback.put("ratingShip", ratingShip);
- leavefeedback.put("ratingShipHand", ratingShipHand);
- leavefeedback.put("AqItemAsDescribedId", AqItemAsDescribedId);
-            // Call service
- try{
- Map result = dispatcher.runSync("leaveFeedback", leavefeedback);
- } catch (GenericServiceException e) {
-            Debug.logError(e, module);
-            return "error";
-        }
- }
- }
- return "success";
- }
 
-}
+    public static final String module = ServiceTag.class.getName();
+
+    public static String sendLeaveFeedback(HttpServletRequest request, HttpServletResponse response) {
+        HttpSession session = request.getSession(true);
+        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
+        Map requestParams = UtilHttp.getParameterMap(request);
+        GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
+        int feedbackSize = Integer.parseInt((String)requestParams.get("feedbackSize"));
+        String productStoreId = (String)requestParams.get("productStoreId");
+        for (int i = 1; i <= feedbackSize; i++) {
+            String commentType = (String)requestParams.get("commentType"+i);
+            String commentText = (String)requestParams.get("commentText"+i);
+            if (!commentType.equals("none") && commentText != null) {
+                String itemId = (String)requestParams.get("itemId"+i);
+                String transactionId = (String)requestParams.get("transactionId"+i);
+                String targetUser = (String)requestParams.get("targetUser"+i);
+                String commentingUser = (String)requestParams.get("commentingUser"+i);
+                String role = (String)requestParams.get("role"+i);
+                String ratingItem = (String)requestParams.get("ratingItem"+i);
+                String ratingComm = (String)requestParams.get("ratingComm"+i);
+                String ratingShip = (String)requestParams.get("ratingShip"+i);
+                String ratingShipHand = (String)requestParams.get("ratingShipHand"+i);
+                String AqItemAsDescribedId = (String)requestParams.get("AqItemAsDescribedId"+i);
+
+                Map leavefeedback =  FastMap.newInstance();
+                leavefeedback.put("productStoreId", productStoreId);
+                leavefeedback.put("userLogin", userLogin);
+                leavefeedback.put("itemId", itemId);
+                leavefeedback.put("transactionId", transactionId);
+                leavefeedback.put("targetUser", targetUser);
+                leavefeedback.put("commentingUser", commentingUser);
+                leavefeedback.put("role", role);
+                leavefeedback.put("commentText", commentText);
+                leavefeedback.put("commentType", commentType);
+                leavefeedback.put("ratingItem", ratingItem);
+                leavefeedback.put("ratingComm", ratingComm);
+                leavefeedback.put("ratingShip", ratingShip);
+                leavefeedback.put("ratingShipHand", ratingShipHand);
+                leavefeedback.put("AqItemAsDescribedId", AqItemAsDescribedId);
+                // Call service
+                try {
+                    Map result = dispatcher.runSync("leaveFeedback", leavefeedback);
+                } catch (GenericServiceException e) {
+                    Debug.logError(e, module);
+                    return "error";
+                }
+            }
+        }
+        return "success";
+    }
+}
\ No newline at end of file

Modified: ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayFeedback.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayFeedback.java?rev=917407&r1=917406&r2=917407&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayFeedback.java (original)
+++ ofbiz/trunk/specialpurpose/ebaystore/src/org/ofbiz/ebaystore/EbayFeedback.java Mon Mar  1 07:24:40 2010
@@ -52,334 +52,334 @@
 import javolution.util.FastMap;
 
 public class EbayFeedback {
-
+
     public static final String resource = "EbayUiLabels";
     private static final String module = EbayFeedback.class.getName();
 
- public static Map<String, Object> loadFeedback(DispatchContext dctx, Map<String, ? extends Object> context){
- Map<String, Object> result = FastMap.newInstance();
- LocalDispatcher dispatcher = dctx.getDispatcher();
- GenericValue userLogin = (GenericValue) context.get("userLogin");
- Delegator delegator = dctx.getDelegator();
- Locale locale = (Locale) context.get("locale");
- String productStoreId = (String) context.get("productStoreId");
-
- ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
- try {
- Map<String, Object> inMap = FastMap.newInstance();
- inMap.put("productStoreId", productStoreId);
- inMap.put("userLogin", userLogin);
- Map<String, Object> resultUser = dispatcher.runSync("getEbayStoreUser", inMap);
- String userID = (String)resultUser.get("userLoginId");
- GetFeedbackCall feedbackCall = new GetFeedbackCall();
- feedbackCall.setApiContext(apiContext);
- SiteCodeType SiteCodeType = EbayStoreHelper.getSiteCodeType(productStoreId,locale, delegator);
- feedbackCall.setSite(SiteCodeType.US);
- feedbackCall.setUserID(userID);
- DetailLevelCodeType[] detailLevelCodeType = {DetailLevelCodeType.RETURN_ALL};
- feedbackCall.setDetailLevel(detailLevelCodeType);
- FeedbackDetailType[] feedback = feedbackCall.getFeedback();
- if(feedback != null){
- String partyId = null;
- GenericValue userLoginEx = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", userID));
- if(userLoginEx == null){
- //Party
- GenericValue party =  delegator.makeValue("Party");
- partyId = delegator.getNextSeqId("Party");
- party.put("partyId", partyId);
- party.put("partyTypeId", "PERSON");
- party.create();
- //UserLogin
- userLoginEx =  delegator.makeValue("UserLogin");
- userLoginEx.put("userLoginId", userID);
- userLoginEx.put("partyId", partyId);
- userLoginEx.create();
- }else{
- partyId = userLoginEx.getString("partyId");
- }
- //PartyRole For eBay User
- List partyRoles = delegator.findByAnd("PartyRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", "OWNER"));
- if(partyRoles.size() == 0){
- GenericValue partyRole =  delegator.makeValue("PartyRole");
- partyRole.put("partyId", partyId);
- partyRole.put("roleTypeId", "OWNER");
- partyRole.create();
- }
- int feedbackLength = feedback.length;
- for(int i=0;i<feedbackLength;i++){
- //convert to ofbiz
- String contentId = feedback[i].getFeedbackID();
- Date eBayDateTime = feedback[i].getCommentTime().getTime();
- GenericValue contentCheck = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId));
- if(contentCheck != null){
- continue;
- }
- String textData = feedback[i].getCommentText();
- String commentingUserId= feedback[i].getCommentingUser();
- String commentingPartyId = null;
- List CommentingUserLogins = delegator.findByAnd("UserLogin", UtilMisc.toMap("userLoginId", commentingUserId));
- if(CommentingUserLogins.size() == 0){
- //Party
- GenericValue party =  delegator.makeValue("Party");
- commentingPartyId = delegator.getNextSeqId("Party");
- party.put("partyId", commentingPartyId);
- party.put("partyTypeId", "PERSON");
- party.create();
- //UserLogin
- userLoginEx =  delegator.makeValue("UserLogin");
- userLoginEx.put("userLoginId", commentingUserId);
- userLoginEx.put("partyId", commentingPartyId);
- userLoginEx.create();
- }else{
- userLoginEx = (GenericValue)CommentingUserLogins.get(0);
- commentingPartyId = userLoginEx.getString("partyId");
- }
- //DataResource
- GenericValue dataResource =  delegator.makeValue("DataResource");
- String dataResourceId = delegator.getNextSeqId("DataResource");
- dataResource.put("dataResourceId", dataResourceId);
- dataResource.put("dataResourceTypeId", "ELECTRONIC_TEXT");
- dataResource.put("mimeTypeId", "text/html");
- dataResource.create();
- //ElectronicText
- GenericValue electronicText =  delegator.makeValue("ElectronicText");
- electronicText.put("dataResourceId", dataResourceId);
- electronicText.put("textData", textData);
- electronicText.create();
- //Content
- GenericValue content =  delegator.makeValue("Content");
- content.put("contentId", contentId);
- content.put("contentTypeId", "DOCUMENT");
- content.put("dataResourceId", dataResourceId);
- content.put("createdDate", UtilDateTime.toTimestamp(eBayDateTime));
- content.create();
- //ContentPurpose
- GenericValue contentPurpose =  delegator.makeValue("ContentPurpose");
- contentPurpose.put("contentId", contentId);
- contentPurpose.put("contentPurposeTypeId", "FEEDBACK");
- contentPurpose.create();
- //PartyRole For eBay Commentator
- List commentingPartyRoles = delegator.findByAnd("PartyRole", UtilMisc.toMap("partyId", commentingPartyId, "roleTypeId", "COMMENTATOR"));
- if(commentingPartyRoles.size() == 0){
- GenericValue partyRole =  delegator.makeValue("PartyRole");
- partyRole.put("partyId", commentingPartyId);
- partyRole.put("roleTypeId", "COMMENTATOR");
- partyRole.create();
- }
- //ContentRole for eBay User
- List contentRoles = delegator.findByAnd("ContentRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", "OWNER", "contentId", contentId));
- if(contentRoles.size() == 0){
- GenericValue contentRole =  delegator.makeValue("ContentRole");
- contentRole.put("contentId", contentId);
- contentRole.put("partyId", partyId);
- contentRole.put("roleTypeId", "OWNER");
- contentRole.put("fromDate", UtilDateTime.nowTimestamp());
- contentRole.create();
- }
- //ContentRole for Commentator
- List commentingContentRoles = delegator.findByAnd("ContentRole", UtilMisc.toMap("partyId", commentingPartyId, "roleTypeId", "COMMENTATOR", "contentId", contentId));
- if(commentingContentRoles.size() == 0){
- GenericValue contentRole =  delegator.makeValue("ContentRole");
- contentRole.put("contentId", contentId);
- contentRole.put("partyId", commentingPartyId);
- contentRole.put("roleTypeId", "COMMENTATOR");
- contentRole.put("fromDate", UtilDateTime.nowTimestamp());
- contentRole.create();
- }
- }
- }
- } catch (ApiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SdkException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- String successMsg = "Load eBay Feedback Successfull.";
- result = ServiceUtil.returnSuccess(successMsg);
-    return result;
- }
- public static Map<String, Object> getItemsAwaitingFeedback(DispatchContext dctx, Map<String, ? extends Object> context){
- Map<String, Object> result = FastMap.newInstance();
- LocalDispatcher dispatcher = dctx.getDispatcher();
- GenericValue userLogin = (GenericValue) context.get("userLogin");
- Delegator delegator = dctx.getDelegator();
- Locale locale = (Locale) context.get("locale");
- String productStoreId = (String) context.get("productStoreId");
- ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
- List itemsResult = FastList.newInstance();
- try{
- GetItemsAwaitingFeedbackCall awaitingFeedbackCall = new GetItemsAwaitingFeedbackCall();
- awaitingFeedbackCall.setApiContext(apiContext);
- awaitingFeedbackCall.getItemsAwaitingFeedback();
- PaginatedTransactionArrayType itemsAwaitingFeedback = awaitingFeedbackCall.getReturnedItemsAwaitingFeedback();
- TransactionArrayType items = itemsAwaitingFeedback.getTransactionArray();
- GetUserCall getUserCall = new GetUserCall(apiContext);
- String commentingUser = getUserCall.getUser().getUserID();
- for(int i = 0;i<items.getTransactionLength();i++){
- Map<String, Object> entry = FastMap.newInstance();
- TransactionType transection = items.getTransaction(i);
- entry.put("itemID", transection.getItem().getItemID());
- entry.put("commentingUser", commentingUser);
- entry.put("title", transection.getItem().getTitle());
- entry.put("transactionID", transection.getTransactionID());
- if(transection.getBuyer() != null){
- entry.put("userID", transection.getBuyer().getUserID());
- entry.put("role", "buyer");
- }
-
- if(transection.getItem().getSeller() != null){
- entry.put("userID", transection.getItem().getSeller().getUserID());
- entry.put("role", "seller");
- }
- if(transection.getShippingDetails()!=null){
- entry.put("shippingCost", transection.getShippingDetails().getDefaultShippingCost().getValue());
- entry.put("shippingCurrency", transection.getShippingDetails().getDefaultShippingCost().getCurrencyID().name());
- }
-
- if(transection.getFeedbackLeft() != null){
- entry.put("commentType", transection.getFeedbackLeft().getCommentType().name());
- }
- itemsResult.add(entry);
- }
- result.put("itemsAwaitingFeedback", itemsResult);
- } catch (ApiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SdkException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return result;
- }
- public static Map<String, Object> leaveFeedback(DispatchContext dctx, Map<String, ? extends Object> context){
- Map<String, Object>result = FastMap.newInstance();
- Delegator delegator = dctx.getDelegator();
- Locale locale = (Locale) context.get("locale");
- String productStoreId = (String) context.get("productStoreId");
- ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
-
- String itemId = (String) context.get("itemId");
- String targetUser = (String) context.get("targetUser");
- String transactionId = (String) context.get("transactionId");
- String commentingUser = (String) context.get("commentingUser");
- String role = (String) context.get("role");
- String commentType = (String) context.get("commentType");
- String commentText = (String) context.get("commentText");
- String AqItemAsDescribed = null;
- String ratingItem = (String) context.get("ratingItem");
- String ratingComm = (String) context.get("ratingComm");
- String ratingShip = (String) context.get("ratingShip");
- String ratingShipHand = (String) context.get("ratingShipHand");
- try{
- if(commentType != null){
- LeaveFeedbackCall leaveFeedbackCall = new LeaveFeedbackCall();
- leaveFeedbackCall.setApiContext(apiContext);
- leaveFeedbackCall.setTargetUser(targetUser);
- leaveFeedbackCall.setTransactionID(transactionId);
-
- if(role.equals("seller")){
- ItemRatingDetailArrayType sellerItemRatingDetailArray = new ItemRatingDetailArrayType();
-
- //The item description
- ItemRatingDetailsType itemRatingDetailsType1 = new ItemRatingDetailsType();
- int ratingItemValue = 0;
- if(UtilValidate.isInteger(ratingItem)){
- ratingItemValue = Integer.parseInt(ratingItem);
- }
- if(ratingItemValue<3){
- int AqItemAsDescribedId = Integer.parseInt((String) context.get("AqItemAsDescribedId"));
- switch (AqItemAsDescribedId) {
- case 5:
- AqItemAsDescribed = "ItemNotReceived";
- break;
- case 6:
- AqItemAsDescribed = "ItemBadQuality";
- break;
- case 2:
- AqItemAsDescribed = "ItemDamaged";
- break;
- case 1:
- AqItemAsDescribed = "ItemIneligible";
- break;
- case 3:
- AqItemAsDescribed = "ItemLost";
- break;
- default:
- AqItemAsDescribed = "Other";
- break;
- }
- }
- itemRatingDetailsType1.setRating(ratingItemValue);
- itemRatingDetailsType1.setRatingDetail(FeedbackRatingDetailCodeType.ITEM_AS_DESCRIBED);
-
- //The seller's communication
- ItemRatingDetailsType itemRatingDetailsType2 = new ItemRatingDetailsType();
- int ratingCommValue = 0;
- if(UtilValidate.isInteger(ratingComm)){
- ratingCommValue = Integer.parseInt(ratingComm);
- }
- itemRatingDetailsType2.setRating(ratingCommValue);
- itemRatingDetailsType2.setRatingDetail(FeedbackRatingDetailCodeType.COMMUNICATION);
-
- //the seller ship the item
- ItemRatingDetailsType itemRatingDetailsType3 = new ItemRatingDetailsType();
- int ratingShipValue = 0;
- if(UtilValidate.isInteger(ratingShip)){
- ratingShipValue = Integer.parseInt(ratingShip);
- }
- itemRatingDetailsType3.setRating(ratingShipValue);
- itemRatingDetailsType3.setRatingDetail(FeedbackRatingDetailCodeType.SHIPPING_TIME);
-
- //the shipping and handling charges
- ItemRatingDetailsType itemRatingDetailsType4 = new ItemRatingDetailsType();
- int ratingShipHandValue = 0;
- if(UtilValidate.isInteger(ratingShipHand)){
- ratingShipHandValue = Integer.parseInt(ratingShipHand);
- }
- itemRatingDetailsType4.setRating(ratingShipHandValue);
- itemRatingDetailsType4.setRatingDetail(FeedbackRatingDetailCodeType.SHIPPING_AND_HANDLING_CHARGES);
-
- //Rating Summary
- ItemRatingDetailsType[] itemRatingDetailsType = {itemRatingDetailsType1, itemRatingDetailsType2, itemRatingDetailsType3, itemRatingDetailsType4};
- sellerItemRatingDetailArray.setItemRatingDetails(itemRatingDetailsType);
-
- leaveFeedbackCall.setSellerItemRatingDetailArray(sellerItemRatingDetailArray);
- }
- FeedbackDetailType feedbackDetail = new FeedbackDetailType();
- feedbackDetail.setItemID(itemId);
- feedbackDetail.setCommentingUser(commentingUser);
- feedbackDetail.setCommentText(commentText);
- feedbackDetail.setCommentTime(Calendar.getInstance());
- if(commentType.equals("positive")){
- feedbackDetail.setCommentType(CommentTypeCodeType.POSITIVE);
- }else if(commentType.equals("neutral")){
- feedbackDetail.setCommentType(CommentTypeCodeType.NEUTRAL);
- }else if(commentType.equals("negative")){
- feedbackDetail.setCommentType(CommentTypeCodeType.NEGATIVE);
- }
- leaveFeedbackCall.setFeedbackDetail(feedbackDetail);
- leaveFeedbackCall.leaveFeedback();
- }
- } catch (ApiException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SdkException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- result = ServiceUtil.returnSuccess();
- return result;
- }
+    public static Map<String, Object> loadFeedback(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        Delegator delegator = dctx.getDelegator();
+        Locale locale = (Locale) context.get("locale");
+        String productStoreId = (String) context.get("productStoreId");
+
+        ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+        try {
+            Map<String, Object> inMap = FastMap.newInstance();
+            inMap.put("productStoreId", productStoreId);
+            inMap.put("userLogin", userLogin);
+            Map<String, Object> resultUser = dispatcher.runSync("getEbayStoreUser", inMap);
+            String userID = (String)resultUser.get("userLoginId");
+            GetFeedbackCall feedbackCall = new GetFeedbackCall();
+            feedbackCall.setApiContext(apiContext);
+            SiteCodeType SiteCodeType = EbayStoreHelper.getSiteCodeType(productStoreId,locale, delegator);
+            feedbackCall.setSite(SiteCodeType.US);
+            feedbackCall.setUserID(userID);
+            DetailLevelCodeType[] detailLevelCodeType = {DetailLevelCodeType.RETURN_ALL};
+            feedbackCall.setDetailLevel(detailLevelCodeType);
+            FeedbackDetailType[] feedback = feedbackCall.getFeedback();
+            if (feedback != null) {
+                String partyId = null;
+                GenericValue userLoginEx = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", userID));
+                if (userLoginEx == null) {
+                    //Party
+                    GenericValue party =  delegator.makeValue("Party");
+                    partyId = delegator.getNextSeqId("Party");
+                    party.put("partyId", partyId);
+                    party.put("partyTypeId", "PERSON");
+                    party.create();
+                    //UserLogin
+                    userLoginEx =  delegator.makeValue("UserLogin");
+                    userLoginEx.put("userLoginId", userID);
+                    userLoginEx.put("partyId", partyId);
+                    userLoginEx.create();
+                } else {
+                    partyId = userLoginEx.getString("partyId");
+                }
+                //PartyRole For eBay User
+                List partyRoles = delegator.findByAnd("PartyRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", "OWNER"));
+                if (partyRoles.size() == 0) {
+                    GenericValue partyRole =  delegator.makeValue("PartyRole");
+                    partyRole.put("partyId", partyId);
+                    partyRole.put("roleTypeId", "OWNER");
+                    partyRole.create();
+                }
+                int feedbackLength = feedback.length;
+                for (int i = 0; i < feedbackLength; i++) {
+                    //convert to ofbiz
+                    String contentId = feedback[i].getFeedbackID();
+                    Date eBayDateTime = feedback[i].getCommentTime().getTime();
+                    GenericValue contentCheck = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId));
+                    if (contentCheck != null) {
+                        continue;
+                    }
+                    String textData = feedback[i].getCommentText();
+                    String commentingUserId= feedback[i].getCommentingUser();
+                    String commentingPartyId = null;
+                    List CommentingUserLogins = delegator.findByAnd("UserLogin", UtilMisc.toMap("userLoginId", commentingUserId));
+                    if (CommentingUserLogins.size() == 0) {
+                        //Party
+                        GenericValue party =  delegator.makeValue("Party");
+                        commentingPartyId = delegator.getNextSeqId("Party");
+                        party.put("partyId", commentingPartyId);
+                        party.put("partyTypeId", "PERSON");
+                        party.create();
+                        //UserLogin
+                        userLoginEx =  delegator.makeValue("UserLogin");
+                        userLoginEx.put("userLoginId", commentingUserId);
+                        userLoginEx.put("partyId", commentingPartyId);
+                        userLoginEx.create();
+                    } else {
+                        userLoginEx = (GenericValue)CommentingUserLogins.get(0);
+                        commentingPartyId = userLoginEx.getString("partyId");
+                    }
+                    //DataResource
+                    GenericValue dataResource =  delegator.makeValue("DataResource");
+                    String dataResourceId = delegator.getNextSeqId("DataResource");
+                    dataResource.put("dataResourceId", dataResourceId);
+                    dataResource.put("dataResourceTypeId", "ELECTRONIC_TEXT");
+                    dataResource.put("mimeTypeId", "text/html");
+                    dataResource.create();
+                    //ElectronicText
+                    GenericValue electronicText =  delegator.makeValue("ElectronicText");
+                    electronicText.put("dataResourceId", dataResourceId);
+                    electronicText.put("textData", textData);
+                    electronicText.create();
+                    //Content
+                    GenericValue content =  delegator.makeValue("Content");
+                    content.put("contentId", contentId);
+                    content.put("contentTypeId", "DOCUMENT");
+                    content.put("dataResourceId", dataResourceId);
+                    content.put("createdDate", UtilDateTime.toTimestamp(eBayDateTime));
+                    content.create();
+                    //ContentPurpose
+                    GenericValue contentPurpose =  delegator.makeValue("ContentPurpose");
+                    contentPurpose.put("contentId", contentId);
+                    contentPurpose.put("contentPurposeTypeId", "FEEDBACK");
+                    contentPurpose.create();
+                    //PartyRole For eBay Commentator
+                    List commentingPartyRoles = delegator.findByAnd("PartyRole", UtilMisc.toMap("partyId", commentingPartyId, "roleTypeId", "COMMENTATOR"));
+                    if (commentingPartyRoles.size() == 0) {
+                        GenericValue partyRole =  delegator.makeValue("PartyRole");
+                        partyRole.put("partyId", commentingPartyId);
+                        partyRole.put("roleTypeId", "COMMENTATOR");
+                        partyRole.create();
+                    }
+                    //ContentRole for eBay User
+                    List contentRoles = delegator.findByAnd("ContentRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", "OWNER", "contentId", contentId));
+                    if (contentRoles.size() == 0) {
+                        GenericValue contentRole =  delegator.makeValue("ContentRole");
+                        contentRole.put("contentId", contentId);
+                        contentRole.put("partyId", partyId);
+                        contentRole.put("roleTypeId", "OWNER");
+                        contentRole.put("fromDate", UtilDateTime.nowTimestamp());
+                        contentRole.create();
+                    }
+                    //ContentRole for Commentator
+                    List commentingContentRoles = delegator.findByAnd("ContentRole", UtilMisc.toMap("partyId", commentingPartyId, "roleTypeId", "COMMENTATOR", "contentId", contentId));
+                    if (commentingContentRoles.size() == 0) {
+                        GenericValue contentRole =  delegator.makeValue("ContentRole");
+                        contentRole.put("contentId", contentId);
+                        contentRole.put("partyId", commentingPartyId);
+                        contentRole.put("roleTypeId", "COMMENTATOR");
+                        contentRole.put("fromDate", UtilDateTime.nowTimestamp());
+                        contentRole.create();
+                    }
+                }
+            }
+        } catch (ApiException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (SdkException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        String successMsg = "Load eBay Feedback Successfull.";
+        result = ServiceUtil.returnSuccess(successMsg);
+        return result;
+    }
+
+    public static Map<String, Object> getItemsAwaitingFeedback(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object> result = FastMap.newInstance();
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        GenericValue userLogin = (GenericValue) context.get("userLogin");
+        Delegator delegator = dctx.getDelegator();
+        Locale locale = (Locale) context.get("locale");
+        String productStoreId = (String) context.get("productStoreId");
+        ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+        List itemsResult = FastList.newInstance();
+        try {
+            GetItemsAwaitingFeedbackCall awaitingFeedbackCall = new GetItemsAwaitingFeedbackCall();
+            awaitingFeedbackCall.setApiContext(apiContext);
+            awaitingFeedbackCall.getItemsAwaitingFeedback();
+            PaginatedTransactionArrayType itemsAwaitingFeedback = awaitingFeedbackCall.getReturnedItemsAwaitingFeedback();
+            TransactionArrayType items = itemsAwaitingFeedback.getTransactionArray();
+            GetUserCall getUserCall = new GetUserCall(apiContext);
+            String commentingUser = getUserCall.getUser().getUserID();
+            for (int i = 0;i < items.getTransactionLength(); i++) {
+                Map<String, Object> entry = FastMap.newInstance();
+                TransactionType transection = items.getTransaction(i);
+                entry.put("itemID", transection.getItem().getItemID());
+                entry.put("commentingUser", commentingUser);
+                entry.put("title", transection.getItem().getTitle());
+                entry.put("transactionID", transection.getTransactionID());
+                if (transection.getBuyer() != null) {
+                    entry.put("userID", transection.getBuyer().getUserID());
+                    entry.put("role", "buyer");
+                }
+
+                if (transection.getItem().getSeller() != null) {
+                    entry.put("userID", transection.getItem().getSeller().getUserID());
+                    entry.put("role", "seller");
+                }
+                if (transection.getShippingDetails()!=null) {
+                    entry.put("shippingCost", transection.getShippingDetails().getDefaultShippingCost().getValue());
+                    entry.put("shippingCurrency", transection.getShippingDetails().getDefaultShippingCost().getCurrencyID().name());
+                }
+
+                if (transection.getFeedbackLeft() != null) {
+                    entry.put("commentType", transection.getFeedbackLeft().getCommentType().name());
+                }
+                itemsResult.add(entry);
+            }
+            result.put("itemsAwaitingFeedback", itemsResult);
+        } catch (ApiException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (SdkException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    public static Map<String, Object> leaveFeedback(DispatchContext dctx, Map<String, ? extends Object> context) {
+        Map<String, Object>result = FastMap.newInstance();
+        Delegator delegator = dctx.getDelegator();
+        Locale locale = (Locale) context.get("locale");
+        String productStoreId = (String) context.get("productStoreId");
+        ApiContext apiContext = EbayStoreHelper.getApiContext(productStoreId, locale, delegator);
+
+        String itemId = (String) context.get("itemId");
+        String targetUser = (String) context.get("targetUser");
+        String transactionId = (String) context.get("transactionId");
+        String commentingUser = (String) context.get("commentingUser");
+        String role = (String) context.get("role");
+        String commentType = (String) context.get("commentType");
+        String commentText = (String) context.get("commentText");
+        String AqItemAsDescribed = null;
+        String ratingItem = (String) context.get("ratingItem");
+        String ratingComm = (String) context.get("ratingComm");
+        String ratingShip = (String) context.get("ratingShip");
+        String ratingShipHand = (String) context.get("ratingShipHand");
+        try {
+            if (commentType != null) {
+                LeaveFeedbackCall leaveFeedbackCall = new LeaveFeedbackCall();
+                leaveFeedbackCall.setApiContext(apiContext);
+                leaveFeedbackCall.setTargetUser(targetUser);
+                leaveFeedbackCall.setTransactionID(transactionId);
+
+                if (role.equals("seller")) {
+                    ItemRatingDetailArrayType sellerItemRatingDetailArray = new ItemRatingDetailArrayType();
+
+                    //The item description
+                    ItemRatingDetailsType itemRatingDetailsType1 = new ItemRatingDetailsType();
+                    int ratingItemValue = 0;
+                    if (UtilValidate.isInteger(ratingItem)) {
+                        ratingItemValue = Integer.parseInt(ratingItem);
+                    }
+                    if (ratingItemValue < 3) {
+                        int AqItemAsDescribedId = Integer.parseInt((String) context.get("AqItemAsDescribedId"));
+                        switch (AqItemAsDescribedId) {
+                        case 5:
+                            AqItemAsDescribed = "ItemNotReceived";
+                            break;
+                        case 6:
+                            AqItemAsDescribed = "ItemBadQuality";
+                            break;
+                        case 2:
+                            AqItemAsDescribed = "ItemDamaged";
+                            break;
+                        case 1:
+                            AqItemAsDescribed = "ItemIneligible";
+                            break;
+                        case 3:
+                            AqItemAsDescribed = "ItemLost";
+                            break;
+                        default:
+                            AqItemAsDescribed = "Other";
+                            break;
+                        }
+                    }
+                    itemRatingDetailsType1.setRating(ratingItemValue);
+                    itemRatingDetailsType1.setRatingDetail(FeedbackRatingDetailCodeType.ITEM_AS_DESCRIBED);
+
+                    //The seller's communication
+                    ItemRatingDetailsType itemRatingDetailsType2 = new ItemRatingDetailsType();
+                    int ratingCommValue = 0;
+                    if (UtilValidate.isInteger(ratingComm)) {
+                        ratingCommValue = Integer.parseInt(ratingComm);
+                    }
+                    itemRatingDetailsType2.setRating(ratingCommValue);
+                    itemRatingDetailsType2.setRatingDetail(FeedbackRatingDetailCodeType.COMMUNICATION);
+
+                    //the seller ship the item
+                    ItemRatingDetailsType itemRatingDetailsType3 = new ItemRatingDetailsType();
+                    int ratingShipValue = 0;
+                    if (UtilValidate.isInteger(ratingShip)) {
+                        ratingShipValue = Integer.parseInt(ratingShip);
+                    }
+                    itemRatingDetailsType3.setRating(ratingShipValue);
+                    itemRatingDetailsType3.setRatingDetail(FeedbackRatingDetailCodeType.SHIPPING_TIME);
+
+                    //the shipping and handling charges
+                    ItemRatingDetailsType itemRatingDetailsType4 = new ItemRatingDetailsType();
+                    int ratingShipHandValue = 0;
+                    if (UtilValidate.isInteger(ratingShipHand)) {
+                        ratingShipHandValue = Integer.parseInt(ratingShipHand);
+                    }
+                    itemRatingDetailsType4.setRating(ratingShipHandValue);
+                    itemRatingDetailsType4.setRatingDetail(FeedbackRatingDetailCodeType.SHIPPING_AND_HANDLING_CHARGES);
+
+                    //Rating Summary
+                    ItemRatingDetailsType[] itemRatingDetailsType = {itemRatingDetailsType1, itemRatingDetailsType2, itemRatingDetailsType3, itemRatingDetailsType4};
+                    sellerItemRatingDetailArray.setItemRatingDetails(itemRatingDetailsType);
 
+                    leaveFeedbackCall.setSellerItemRatingDetailArray(sellerItemRatingDetailArray);
+                }
+                FeedbackDetailType feedbackDetail = new FeedbackDetailType();
+                feedbackDetail.setItemID(itemId);
+                feedbackDetail.setCommentingUser(commentingUser);
+                feedbackDetail.setCommentText(commentText);
+                feedbackDetail.setCommentTime(Calendar.getInstance());
+                if (commentType.equals("positive")) {
+                    feedbackDetail.setCommentType(CommentTypeCodeType.POSITIVE);
+                } else if (commentType.equals("neutral")) {
+                    feedbackDetail.setCommentType(CommentTypeCodeType.NEUTRAL);
+                } else if (commentType.equals("negative")) {
+                    feedbackDetail.setCommentType(CommentTypeCodeType.NEGATIVE);
+                }
+                leaveFeedbackCall.setFeedbackDetail(feedbackDetail);
+                leaveFeedbackCall.leaveFeedback();
+            }
+        } catch (ApiException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (SdkException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        result = ServiceUtil.returnSuccess();
+        return result;
+    }
 }
\ No newline at end of file