Package com.jada.util

Examples of com.jada.util.JSONEscapeObject


      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      CategoryMaintActionForm form = (CategoryMaintActionForm) actionForm;
    AdminBean adminBean = getAdminBean(request);
    Site site = adminBean.getSite();
   
      JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);

    Long catId = Format.getLong(form.getCatId());
    Category category = CategoryDAO.load(site.getSiteId(), catId);
    String customAttribIds[] = form.getCustomAttribIds();
    if (customAttribIds != null) {
      for (int i = 0; i < customAttribIds.length; i++) {
        CustomAttribute customAttribute = em.find(CustomAttribute.class, Format.getLong(customAttribIds[i]));
        category.getCustomAttributes().remove(customAttribute);
      }
    }
    streamWebService(response, jsonResult.toHtmlString());
    return null;
  }
View Full Code Here


        HttpServletRequest request,
        HttpServletResponse response) throws Throwable {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    CategoryMaintActionForm form = (CategoryMaintActionForm) actionForm;
 
    JSONEscapeObject jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
   
    Long customAttribId = Format.getLong(form.getCustomAttribId());
    CustomAttribute customAttribute = em.find(CustomAttribute.class, customAttribId);
    Long catId = Format.getLong(form.getCatId());
    Category category = em.find(Category.class, catId);
    Iterator<?> iterator = category.getCustomAttributes().iterator();
    boolean found = false;
    while (iterator.hasNext()) {
      CustomAttribute attribute = (CustomAttribute) iterator.next();
      if (attribute.getCustomAttribId().equals(customAttribute.getCustomAttribId())) {
        found = true;
      }
    }
   
    if (!found) {
      category.getCustomAttributes().add(customAttribute);
      em.persist(category);
    }

    streamWebService(response, jsonResult.toHtmlString());
    return null;
  }
View Full Code Here

    MessageResources resources = this.getResources(request);
   
    String siteDomainId = form.getSiteDomainId();
        SiteDomain siteDomain = SiteDomainDAO.load(Format.getLong(siteDomainId));

        JSONEscapeObject json = new JSONEscapeObject();
    FormFile file = form.getFile();
    byte fileData[] = file.getFileData();
    if (file.getFileName().length() == 0) {
      json.put("status", Constants.WEBSERVICE_STATUS_FAILED);
      json.put("filename", resources.getMessage("error.string.required"));
      streamWebService(response, json.toHtmlString());
      return null;
    }
    ImageScaler scaler = new ImageScaler(fileData, file.getContentType());
    scaler.resize(600);

    initSiteProfiles(form, site);
        if (form.isSiteProfileClassDefault()) {
        siteDomain.getSiteDomainLanguage().setSiteLogoValue(scaler.getBytes());
        siteDomain.getSiteDomainLanguage().setSiteLogoContentType("image/jpeg");
        siteDomain.setRecUpdateBy(adminBean.getUser().getUserId());
        siteDomain.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        siteDomain.setRecCreateBy(adminBean.getUser().getUserId());
        siteDomain.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        form.setSiteLogoContentType(siteDomain.getSiteDomainLanguage().getSiteLogoContentType());
        em.persist(siteDomain);
        }
        else {
          SiteDomainLanguage siteDomainLanguage = null;
          for (SiteDomainLanguage language : siteDomain.getSiteDomainLanguages()) {
            Long siteProfileClassId = form.getSiteProfileClassId();
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
              siteDomainLanguage = language;
              break;
            }
          }
          siteDomainLanguage.setSiteLogoValue(scaler.getBytes());
          siteDomainLanguage.setSiteLogoContentType("image/jpeg");
          siteDomainLanguage.setRecUpdateBy(adminBean.getUser().getUserId());
          siteDomainLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
          siteDomainLanguage.setRecCreateBy(adminBean.getUser().getUserId());
          siteDomainLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
          form.setSiteLogoContentType(siteDomainLanguage.getSiteLogoContentType());
        em.persist(siteDomainLanguage);
        form.setSiteLogoContentTypeLang(siteDomainLanguage.getSiteLogoContentType());
        }
    
    json.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    streamWebService(response, json.toHtmlString());
   
    return null;
  }
View Full Code Here

       em.persist(siteDomainLanguage);
       form.setSiteLogoContentTypeLang(siteDomainLanguage.getSiteLogoContentType());
    form.setSiteLogoContentType(siteDomainLanguage.getSiteLogoContentType());
    FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
   
    JSONEscapeObject json = new JSONEscapeObject();
    json.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    streamWebService(response, json.toHtmlString());
    return null;
  }
View Full Code Here

      }
      return false;
    }
   
    static public String getSkuAttributeKey(Item item) throws JSONException {
      JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
      Vector<JSONEscapeObject> vector = new Vector<JSONEscapeObject>();
      for (ItemAttributeDetail itemAttributeDetail : item.getItemAttributeDetails()) {
        CustomAttribute customAttribute = itemAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
        if (customAttribute.getCustomAttribTypeCode() != Constants.CUSTOM_ATTRIBUTE_TYPE_SKU_MAKEUP) {
          continue;
        }
        JSONEscapeObject attribute = new JSONEscapeObject();
        attribute.put("customAttribDetailId", itemAttributeDetail.getCustomAttributeDetail().getCustomAttribDetailId().toString());
        attribute.put("customAttribOptionId", itemAttributeDetail.getCustomAttributeOption().getCustomAttribOptionId().toString());
        vector.add(attribute);
      }
      JSONEscapeObject.put("itemAttributeDetails", vector);
      return JSONEscapeObject.toHtmlString();
    }
View Full Code Here

    }
  }
 
  public String performCreate(HttpServletRequest request, String currentFolder) throws Exception {
    String result = null;
    JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
    String folder = request.getParameter("folder");
    String filename = getBaseDir(request);
    if (!currentFolder.equals("/")) {
      filename += currentFolder;
    }
    filename += "/" + folder;
    File file = new File(filename);
    if (file.exists()) {
      JSONEscapeObject.put("status", "failed");
      JSONEscapeObject.put("message", "Folder already exist");
      return JSONEscapeObject.toHtmlString();
    }
    if (!file.mkdir()) {
      JSONEscapeObject.put("status", "failed");
      JSONEscapeObject.put("message", "Unable to create directory");
      return JSONEscapeObject.toHtmlString();
    }
    JSONEscapeObject.put("status", "success");
    result = JSONEscapeObject.toHtmlString();
    return result;
  }
View Full Code Here

    return result;
  }
 
  public String performRemove(HttpServletRequest request, String currentFolder) throws Exception {
    String result = null;
    JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
    String filenames[] = request.getParameterValues("filenames");
    if (filenames != null) {
      for (int i = 0; i < filenames.length; i++) {
        String filename = getBaseDir(request);
        if (currentFolder.equals("/")) {
          filename += currentFolder;
        }
        filename += filenames[i];
        File file = new File(filename);
        if (!file.exists()) {
          JSONEscapeObject.put("status", "failed");
          JSONEscapeObject.put("message", "File " + filename + " does not exist");
          return JSONEscapeObject.toHtmlString();
        }
        removeFile(filename);
      }
    }
    JSONEscapeObject.put("status", "success");
    result = JSONEscapeObject.toHtmlString();
    return result;
  }
View Full Code Here

    return result;
  }
 
  public String performUpload(HttpServletRequest request, String currentFolder) throws Exception {
    String result = null;
    JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
    try {
      FileItemFactory factory = new DiskFileItemFactory();
      ServletFileUpload upload = new ServletFileUpload(factory);
      if (maxsize > 0) {
        upload.setSizeMax(maxsize);
      }
      List<?> items = upload.parseRequest(request);
      Iterator<?> iterator = items.iterator();
      while (iterator.hasNext()) {
        FileItem item = (FileItem) iterator.next();
        if (!item.isFormField()) {
          String fileName = getBaseDir(request);
          fileName += currentFolder;
          fileName += "/" + trimFileName(item.getName());
          File file = new File(fileName);
          item.write(file);
        }
      }
      JSONEscapeObject.put("status", "success");
    }
    catch (Exception e) {
      e.printStackTrace();
      JSONEscapeObject.put("status", "failed");
      JSONEscapeObject.put("message", e.getMessage());
    }
    result = JSONEscapeObject.toHtmlString();
    return result;
  }
View Full Code Here

      target = currentFolder + targetFolder;
    }
    String relativeTarget = target;
    target = getBaseDir(request) + target;
   
      JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
      JSONEscapeObject.put("folder", relativeTarget);
      Vector<JSONEscapeObject> folderList = new Vector<JSONEscapeObject>();
      String tokens[] = relativeTarget.split("/");
      String folder = "/";
      for (int i = 0; i < tokens.length; i++) {
        if (tokens[i].length() == 0) {
          continue;
        }
        JSONEscapeObject jsonLevel = new JSONEscapeObject();
        jsonLevel.put("name", tokens[i]);
        if (folder.length() > 1) {
          folder += "/";
        }
        folder += tokens[i];
        jsonLevel.put("folder", folder);
        folderList.add(jsonLevel);
      }
      JSONEscapeObject.put("breadcrumb", folderList);
     
      File file = new File(target);
      File entries[] = file.listFiles();
      Vector<JSONEscapeObject> files = new Vector<JSONEscapeObject>();
      for (int i = 0; i < entries.length; i++) {
        File entry = entries[i];
        if (!entry.isDirectory()) {
          continue;
        }
        JSONEscapeObject jsonFile = new JSONEscapeObject();
        jsonFile.put("name", entry.getName());
        jsonFile.put("isDirectory", entry.isDirectory());
        jsonFile.put("size", entry.length());
        jsonFile.put("isImage", false);
        Date lastUpdateOn = new Date(entry.lastModified());
        jsonFile.put("lastUpdateOn", Format.getFullDatetime(lastUpdateOn));
        files.add(jsonFile);
      }
      for (int i = 0; i < entries.length; i++) {
        File entry = entries[i];
        if (entry.isDirectory()) {
          continue;
        }
        JSONEscapeObject jsonFile = new JSONEscapeObject();
        jsonFile.put("name", entry.getName());
        jsonFile.put("isDirectory", entry.isDirectory());
        jsonFile.put("size", entry.length());
        if (isImage(entry.getName())) {
          jsonFile.put("isImage", true);
        }
        else {
          jsonFile.put("isImage", false);
        }
        Date lastUpdateOn = new Date(entry.lastModified());
        jsonFile.put("lastUpdateOn", Format.getFullDatetime(lastUpdateOn));
        files.add(jsonFile);
      }
      JSONEscapeObject.put("files", files);
     
      result = JSONEscapeObject.toHtmlString();
View Full Code Here

        ActionForm actionForm,
        HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
        TaxRegionMaintActionForm form = (TaxRegionMaintActionForm) actionForm;
       JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
     
        Long taxRegionId = Format.getLong(form.getTaxRegionId());
        TaxRegion taxRegion = (TaxRegion) em.find(TaxRegion.class, taxRegionId);

      String countryIds[] = form.getCountryIds();
View Full Code Here

TOP

Related Classes of com.jada.util.JSONEscapeObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.