/** Returns the store specific/account specific path for the image. @see storeFileImagePath */ public static String getSIP( HttpServletRequest pRequest, String pPortal, String pFileName, boolean absolutePath) { if (pFileName == null) { return ""; } HttpSession session = pRequest.getSession(); HashMap filePathHM = (HashMap) session.getAttribute("store.files"); if (filePathHM == null) { filePathHM = new HashMap(); session.setAttribute("store.files", filePathHM); } CleanwiseUser user = (CleanwiseUser) session.getAttribute(Constants.APP_USER); StoreData storeD = null; AccountData accountD = null; if (user != null) { storeD = user.getUserStore(); accountD = user.getUserAccount(); } String rootDir = (String) session.getAttribute("store.dir"); // String storeDir = rootDir + ".clw"; Locale locale = ClwI18nUtil.getUserLocale(pRequest); String storePrefix = (String) session.getAttribute("pages.store.prefix"); String webDir = (String) session.getAttribute("webdeploy"); return getSIP( pPortal, pFileName, storePrefix, locale, filePathHM, storeD, accountD, webDir, rootDir, absolutePath); }
private void initColumnsAdnWidths(CleanwiseUser appUser) { mShowPrice = appUser.getShowPrice(); String showSize = mRequest.getParameter("showSize"); if (Utility.isSet(showSize) && !Utility.isTrue(showSize)) { mShowSize = false; } if (!catalogOnly) { mColumnCount++; } if (mShowSize) { mColumnCount++; } if (mShowPrice) { mColumnCount++; } itmColumnWidth = new int[mColumnCount]; int i = 0; if (!catalogOnly) { itmColumnWidth[i++] = 8; // empty itmColumnWidth[i++] = 8; // qty itmColumnWidth[i++] = 10; // sku itmColumnWidth[i++] = 40; // name if (mShowSize) { itmColumnWidth[i++] = 10; // size } // itmColumnWidth[i++] = 6; // itmColumnWidth[i++] = 6; if (mShowPrice) { itmColumnWidth[i++] = 16; // price } itmColumnWidth[i] = 8; // empty } else { itmColumnWidth[i++] = 10; // empty itmColumnWidth[i++] = 12; // sku itmColumnWidth[i++] = 36; // name if (mShowSize) { itmColumnWidth[i++] = 20; // size } // itmColumnWidth[i++] = 4; // itmColumnWidth[i++] = 3; if (mShowPrice) { itmColumnWidth[i++] = 16; // price } itmColumnWidth[i] = 3; // spl } }
public static Object getJavaObject(HttpServletRequest pRequest, String pFullClassName) throws Exception { HttpSession session = pRequest.getSession(); CleanwiseUser appUser = (CleanwiseUser) session.getAttribute(Constants.APP_USER); StoreData storeD = appUser.getUserStore(); AccountData accountD = appUser.getUserAccount(); int storeId = 0; int accountId = 0; if (storeD != null) storeId = storeD.getBusEntity().getBusEntityId(); if (accountD != null) accountId = accountD.getBusEntity().getBusEntityId(); String key = storeId + "@" + accountId + "@" + pFullClassName; Object javaObj = session.getAttribute(key); if (javaObj == null) { ArrayList prefAL = new ArrayList(); String path = ""; PropertyData storePrefixPD = storeD.getPrefix(); if (storePrefixPD != null) { path = Utility.strNN(storePrefixPD.getValue()); } String accountDir = accountD.getPropertyValue(RefCodeNames.PROPERTY_TYPE_CD.ACCOUNT_FOLDER); if (Utility.isSet(accountDir)) { path += "/" + accountDir; } path = path.replace('\\', '/').toLowerCase(); String[] pathDirA = Utility.parseStringToArray(path, "/"); String pathInc = null; for (int ii = 0; ii < pathDirA.length; ii++) { String ss = pathDirA[ii]; if (Utility.isSet(ss)) { if (pathInc == null) { pathInc = "." + ss; } else { pathInc += "." + ss; } pathDirA[ii] = pathInc; } else { pathDirA[ii] = null; } } int ll = pFullClassName.lastIndexOf("."); String defaultPath = pFullClassName.substring(0, ll); String className = pFullClassName.substring(ll); Class clazz = null; for (int ii = pathDirA.length - 1; ii >= 0; ii--) { if (pathDirA[ii] != null) { String fullClassNameTest = defaultPath + pathDirA[ii] + className; try { clazz = Class.forName(fullClassNameTest); if (clazz != null) { break; } } catch (Exception exc) { } } } if (clazz == null) { clazz = Class.forName(pFullClassName); } if (clazz != null) { javaObj = clazz.newInstance(); session.setAttribute(key, javaObj); } } return javaObj; }
public static String getStoreFilePath( HttpServletRequest pRequest, String pPortal, String pFileName) { if (pFileName == null) { return ""; } pFileName = pFileName.trim(); HttpSession session = pRequest.getSession(); HashMap filePathHM = (HashMap) session.getAttribute("store.files"); if (filePathHM == null) { filePathHM = new HashMap(); session.setAttribute("store.files", filePathHM); } if (pPortal == null) pPortal = "store"; // Make key int storeId = 0; int accountId = 0; CleanwiseUser user = (CleanwiseUser) session.getAttribute(Constants.APP_USER); String accountDir = ""; if (user != null) { StoreData storeD = user.getUserStore(); if (storeD != null) { storeId = storeD.getBusEntity().getBusEntityId(); } AccountData accountD = user.getUserAccount(); if (accountD != null) { accountId = accountD.getBusEntity().getBusEntityId(); accountDir = accountD.getPropertyValue(RefCodeNames.PROPERTY_TYPE_CD.ACCOUNT_FOLDER); } } Locale locale = ClwI18nUtil.getUserLocale(pRequest); String key = pPortal + "@" + locale + "@" + pFileName + "@" + storeId + "@" + accountId; String resultFilePath = (String) filePathHM.get(key); if (resultFilePath != null) { return resultFilePath; } String storeDir = (String) session.getAttribute("store.dir") + ".clw"; String storePrefix = (String) session.getAttribute("pages.store.prefix"); if (storePrefix == null) storePrefix = ""; // String webDir = System.getProperty("webdeploy"); String webDir = (String) session.getAttribute("webdeploy"); if (webDir == null) webDir = ""; int ind = webDir.indexOf("deploy"); if (ind < 0) { (new Exception("Invalid current directory: " + webDir)).printStackTrace(); return ""; } // trying to find file String storeAcctPrefix = (Utility.isSet(accountDir)) ? storePrefix + "/" + accountDir : storePrefix; StringTokenizer tok = new StringTokenizer(storeAcctPrefix, "/"); String[] storeAcctPrefixA = new String[tok.countTokens() + 1]; storeAcctPrefixA[0] = ""; ind = 1; while (tok.hasMoreTokens()) { String nextToken = tok.nextToken(); if (ind == 1) { storeAcctPrefixA[ind] = nextToken; } else { storeAcctPrefixA[ind] = storeAcctPrefixA[ind - 1] + "/" + nextToken; } ind++; } String absPath = ""; String filePath = ""; boolean foundFl = false; for (int ii = storeAcctPrefixA.length - 1; ii >= 0; ii--) { filePath = "/" + pPortal + "/" + storeAcctPrefixA[ii] + "/" + locale + "/" + pFileName; absPath = webDir + filePath; File tf = new File(absPath); if (tf.exists()) { foundFl = true; break; } if (Utility.isSet(locale.getLanguage())) { filePath = "/" + pPortal + "/" + storeAcctPrefixA[ii] + "/" + locale.getLanguage() + "/" + pFileName; absPath = webDir + filePath; tf = new File(absPath); if (tf.exists()) { foundFl = true; break; } } filePath = "/" + pPortal + "/" + storeAcctPrefixA[ii] + "/" + pFileName; absPath = webDir + filePath; tf = new File(absPath); if (tf.exists()) { foundFl = true; break; } /* filePath = "/" + pPortal + "/" + storeAcctPrefixA[ii] + "/" + pFileName; absPath = webDir + filePath; tf = new File(absPath); if(tf.exists()) { foundFl = true; break; } */ } if (foundFl) { filePathHM.put(key, filePath); } return filePath; }