public static Map<String,Object> getEbayStoreOutput(DispatchContext dctx, Map<String,Object> context) {
Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
Delegator delegator = dctx.getDelegator();
Map<String,Object> result = FastMap.newInstance();
StoreType returnedStoreType = null;
GetStoreRequestType req = new GetStoreRequestType();
GetStoreResponseType resp = null;
String userLoginId = null;
String password = null;
if (context.get("productStoreId") != null) {
String partyId = null;
try {
List<GenericValue> productStoreRoles = delegator.findByAnd("ProductStoreRole", UtilMisc.toMap("productStoreId", context.get("productStoreId").toString(),"roleTypeId","EBAY_ACCOUNT"));
if (productStoreRoles.size() != 0) {
partyId= (String)productStoreRoles.get(0).get("partyId");
List<GenericValue> userLogins = delegator.findByAnd("UserLogin", UtilMisc.toMap("partyId", partyId));
if (userLogins.size() != 0) {
userLoginId = (String)userLogins.get(0).get("userLoginId");
password = (String)userLogins.get(0).get("currentPassword");
}
}
} catch (GenericEntityException e1) {
e1.printStackTrace();
}
Debug.logInfo("userLoginId is "+userLoginId+" and productStoreId is "+ context.get("productStoreId"), module);
GetStoreCall call = new GetStoreCall(EbayStoreHelper.getApiContext((String)context.get("productStoreId"), locale, delegator));
//call.setSite(EbayHelper.getSiteCodeType((String)context.get("productStoreId"), locale, delegator));
call.setCategoryStructureOnly(false);
call.setUserID(userLoginId);
try {
resp = (GetStoreResponseType)call.execute(req);
if (resp != null && "SUCCESS".equals(resp.getAck().toString())) {
returnedStoreType = resp.getStore();
result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
//result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "EbayStoreLoadSuccess", locale));
// update product store in ofbiz
updateProductStore(dctx, context, returnedStoreType,(String) context.get("productStoreId"));
Map<String,Object> ebayResp = FastMap.newInstance();
ebayResp.put("storeName", returnedStoreType.getName());
ebayResp.put("storeUrl", returnedStoreType.getURL());
ebayResp.put("storeUrlPath", returnedStoreType.getURLPath());
String desc = returnedStoreType.getDescription();
if (desc != null) desc = desc.trim();
ebayResp.put("storeDesc", desc);
StoreLogoType logoType = returnedStoreType.getLogo();
ebayResp.put("storeLogoId", logoType.getLogoID());
ebayResp.put("storeLogoName", logoType.getName());
ebayResp.put("storeLogoURL", logoType.getURL());
StoreThemeType themeType = returnedStoreType.getTheme();
ebayResp.put("storeThemeId", themeType.getThemeID());
ebayResp.put("storeThemeName", themeType.getName());
StoreColorSchemeType colorSchemeType = themeType.getColorScheme();
ebayResp.put("storeColorSchemeId", colorSchemeType.getColorSchemeID());
StoreColorType colorType = colorSchemeType.getColor();
ebayResp.put("storeColorPrimary", colorType.getPrimary());
ebayResp.put("storeColorAccent", colorType.getAccent());
ebayResp.put("storeColorSecondary", colorType.getSecondary());
StoreFontType fontType = colorSchemeType.getFont();
ebayResp.put("storeDescColor", fontType.getDescColor());
ebayResp.put("storeNameColor", fontType.getNameColor());
ebayResp.put("storeTitleColor", fontType.getTitleColor());
if (fontType != null) {// basic & advance theme
String themeId = themeType.getThemeID().toString().concat("-").concat(colorSchemeType.getColorSchemeID().toString());
context.put("themeId", themeId);
Map<String,Object> results = retrieveThemeColorSchemeByThemeId(dctx, context);
if (results != null) {
Map<String,Object> storeFontScheme = (Map<String,Object>) results.get("storeFontScheme");
if (storeFontScheme != null) {
ebayResp.put("storeDescFontFace", storeFontScheme.get("storeFontTypeFontDescValue"));
ebayResp.put("storeDescSizeCode", storeFontScheme.get("storeDescSizeValue"));
ebayResp.put("storeNameFontFace", storeFontScheme.get("storeFontTypeFontFaceValue"));
ebayResp.put("storeNameFontFaceSize", storeFontScheme.get("storeFontTypeSizeFaceValue"));
ebayResp.put("storeTitleFontFace", storeFontScheme.get("storeFontTypeFontTitleValue"));
ebayResp.put("storeTitleFontFaceSize", storeFontScheme.get("storeFontSizeTitleValue"));
}
}
}
StoreHeaderStyleCodeType storeHeaderStyleCodeType = returnedStoreType.getHeaderStyle();
ebayResp.put("storeHeaderStyle", storeHeaderStyleCodeType.value());
StoreHeaderStyleCodeType[] storeHeaderStyleCodeList = storeHeaderStyleCodeType.values();
if (storeHeaderStyleCodeList != null) {
List<Map<String,Object>> storeHeaderStyleList = FastList.newInstance();
int i=0;
while (i<storeHeaderStyleCodeList.length) {
Map<String,Object> storeHeaderStyleMap = FastMap.newInstance();
StoreHeaderStyleCodeType storeHeaderStyleCode = storeHeaderStyleCodeList[i];
storeHeaderStyleMap.put("storeHeaderStyleName", storeHeaderStyleCode.name());
storeHeaderStyleMap.put("storeHeaderStyleValue", storeHeaderStyleCode.value());
storeHeaderStyleList.add(storeHeaderStyleMap);
i++;
}
ebayResp.put("storeHeaderStyleList", storeHeaderStyleList);
}
ebayResp.put("storeHomePage", returnedStoreType.getHomePage().toString());
StoreItemListLayoutCodeType storeItemListLayoutCodeType = returnedStoreType.getItemListLayout();
ebayResp.put("storeItemLayoutSelected", storeItemListLayoutCodeType.value());
StoreItemListLayoutCodeType[] storeItemListLayoutCodeTypeList = storeItemListLayoutCodeType.values();
if (storeItemListLayoutCodeTypeList != null) {
List<Map<String,Object>> storeItemListLayoutCodeList = FastList.newInstance();
int i = 0;
while (i < storeItemListLayoutCodeTypeList.length) {
Map<String,Object> storeItemListLayoutCodeMap = FastMap.newInstance();
StoreItemListLayoutCodeType storeItemListLayoutCode = storeItemListLayoutCodeTypeList[i];
storeItemListLayoutCodeMap.put("storeItemLayoutName", storeItemListLayoutCode.name());
storeItemListLayoutCodeMap.put("storeItemLayoutValue", storeItemListLayoutCode.value());
storeItemListLayoutCodeList.add(storeItemListLayoutCodeMap);
i++;
}
ebayResp.put("storeItemLayoutList", storeItemListLayoutCodeList);
}
StoreItemListSortOrderCodeType storeItemListSortOrderCodeType = returnedStoreType.getItemListSortOrder();
ebayResp.put("storeItemSortOrderSelected", storeItemListSortOrderCodeType.value());
StoreItemListSortOrderCodeType[] storeItemListSortOrderCodeTypeList = storeItemListSortOrderCodeType.values();
if (storeItemListSortOrderCodeTypeList != null) {
List<Map<String,Object>> storeItemSortOrderCodeList = FastList.newInstance();
int i = 0;
while (i < storeItemListSortOrderCodeTypeList.length) {
Map<String,Object> storeItemSortOrderCodeMap = FastMap.newInstance();
StoreItemListSortOrderCodeType storeItemListLayoutCode = storeItemListSortOrderCodeTypeList[i];
storeItemSortOrderCodeMap.put("storeItemSortLayoutName", storeItemListLayoutCode.name());
storeItemSortOrderCodeMap.put("storeItemSortLayoutValue", storeItemListLayoutCode.value());
storeItemSortOrderCodeList.add(storeItemSortOrderCodeMap);
i++;
}
ebayResp.put("storeItemSortOrderList", storeItemSortOrderCodeList);
}
ebayResp.put("storeCustomHeader", returnedStoreType.getCustomHeader());
StoreCustomHeaderLayoutCodeType storeCustomHeaderLayoutCodeType = returnedStoreType.getCustomHeaderLayout();
ebayResp.put("storeCustomHeaderLayout", storeCustomHeaderLayoutCodeType.value());
StoreCustomHeaderLayoutCodeType[] storeCustomHeaderLayoutCodeTypeList = storeCustomHeaderLayoutCodeType.values();
if (storeCustomHeaderLayoutCodeTypeList != null) {
List<Map<String,Object>> storeCustomHeaderLayoutList = FastList.newInstance();
int i = 0;
while (i < storeCustomHeaderLayoutCodeTypeList.length) {
Map<String,Object> storeCustomHeaderLayoutMap = FastMap.newInstance();
StoreCustomHeaderLayoutCodeType StoreCustomHeaderLayoutCode = storeCustomHeaderLayoutCodeTypeList[i];
storeCustomHeaderLayoutMap.put("storeCustomHeaderLayoutName", StoreCustomHeaderLayoutCode.name());
storeCustomHeaderLayoutMap.put("storeCustomHeaderLayoutValue", StoreCustomHeaderLayoutCode.value());
storeCustomHeaderLayoutList.add(storeCustomHeaderLayoutMap);
i++;
}
ebayResp.put("storeCustomHeaderLayoutList", storeCustomHeaderLayoutList);
}
StoreCustomListingHeaderType storeCustomListingHeaderType = returnedStoreType.getCustomListingHeader();
if (storeCustomListingHeaderType != null) {
StoreCustomListingHeaderDisplayCodeType storeCustomListingHeaderDisplayCodeType = storeCustomListingHeaderType.getDisplayType();
ebayResp.put("isLogo", storeCustomListingHeaderType.isLogo());
ebayResp.put("isSearchBox", storeCustomListingHeaderType.isSearchBox());
ebayResp.put("isAddToFavoriteStores", storeCustomListingHeaderType.isAddToFavoriteStores());
ebayResp.put("isSignUpForStoreNewsletter", storeCustomListingHeaderType.isSignUpForStoreNewsletter());
ebayResp.put("storeCustomListingHeaderDisplayName", storeCustomListingHeaderDisplayCodeType.name());
ebayResp.put("storeCustomListingHeaderDisplayValue", storeCustomListingHeaderDisplayCodeType.value());
StoreCustomListingHeaderDisplayCodeType[] storeCustomListingHeaderDisplayCodeTypeList = storeCustomListingHeaderDisplayCodeType.values();
if (storeCustomListingHeaderDisplayCodeTypeList != null) {
List<Map<String,Object>> storeCustomListingHeaderDisplayCodeList = FastList.newInstance();
int i = 0;
while (i < storeCustomListingHeaderDisplayCodeTypeList.length) {
Map<String,Object> storeCustomListingHeaderDisplayCodeMap = FastMap.newInstance();
StoreCustomListingHeaderDisplayCodeType storeCustomListingHeaderDisplayCode = storeCustomListingHeaderDisplayCodeTypeList[i];
storeCustomListingHeaderDisplayCodeMap.put("storeCustomHeaderLayoutName", storeCustomListingHeaderDisplayCode.name());
storeCustomListingHeaderDisplayCodeMap.put("storeCustomHeaderLayoutValue", storeCustomListingHeaderDisplayCode.value());
storeCustomListingHeaderDisplayCodeList.add(storeCustomListingHeaderDisplayCodeMap);
i++;
}
ebayResp.put("storeCustomListingHeaderDisplayList", storeCustomListingHeaderDisplayCodeList);
}
}
//CustomListingHeader
MerchDisplayCodeType merchDisplayCodeType = returnedStoreType.getMerchDisplay();
ebayResp.put("storeMerchDisplay",merchDisplayCodeType.value());
MerchDisplayCodeType[] merchDisplayCodeTypeList = merchDisplayCodeType.values();
if (merchDisplayCodeTypeList != null) {
List<Map<String,Object>> merchDisplayCodeList = FastList.newInstance();
int i = 0;
while (i < merchDisplayCodeTypeList.length) {
Map<String,Object> merchDisplayCodeMap = FastMap.newInstance();
MerchDisplayCodeType merchDisplayCode = merchDisplayCodeTypeList[i];
merchDisplayCodeMap.put("merchDisplayCodeName", merchDisplayCode.name());
merchDisplayCodeMap.put("merchDisplayCodeValue", merchDisplayCode.value());
merchDisplayCodeList.add(merchDisplayCodeMap);
i++;
}
ebayResp.put("storeMerchDisplayList",merchDisplayCodeList);
}
Calendar calendar = returnedStoreType.getLastOpenedTime();
ebayResp.put("storeLastOpenedTime", calendar.getTime().toString());
ebayResp.put("storeSubscriptionLevel", returnedStoreType.getSubscriptionLevel().value());
StoreSubscriptionLevelCodeType[] storeSubscriptionlevelList = returnedStoreType.getSubscriptionLevel().values();
if (storeSubscriptionlevelList != null) {
List<Map<String,Object>> storeSubscriptionLevelCodeList = FastList.newInstance();
int i = 0;
while (i < storeSubscriptionlevelList.length) {
Map<String,Object> storeSubscriptionLevelCodeMap = FastMap.newInstance();