Package com.google.code.magja.service

Examples of com.google.code.magja.service.ServiceException


  @Override
  public void remove(Product product, ProductLink link)
      throws ServiceException {

    if (!ProductServiceUtil.validateProduct(product))
      throw new ServiceException("the product id or sku must be setted");
    if (!validadeProductLink(link))
      throw new ServiceException(
          "you must specify the products to be assigned");

    List<Object> params = new LinkedList<Object>();
    params.add(link.getLinkType().toString().toLowerCase());
    params.add(product.getId() != null ? product.getId() : product.getSku());
    params.add(link.getId() != null ? link.getId() : link.getSku());

    try {
      soapClient.call(ResourcePath.ProductLinkRemove, params);
    } catch (AxisFault e) {
      if(debug) e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }

  }
View Full Code Here


  @Override
  public void update(Product product, ProductLink link)
      throws ServiceException {

    if (!ProductServiceUtil.validateProduct(product))
      throw new ServiceException("the product id or sku must be setted");
    if (!validadeProductLink(link))
      throw new ServiceException(
          "you must specify the products to be assigned");

    try {
      soapClient.call(ResourcePath.ProductLinkUpdate, buildLinkToPersist(
          product, link));
    } catch (AxisFault e) {
      if(debug) e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }
  }
View Full Code Here

      cat = (Map<String, Object>) soapClient.call(
          ResourcePath.CategoryInfo, id);
    } catch (AxisFault e) {
      if (debug)
        e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }

    if (cat == null)
      return null;
View Full Code Here

      cat = (Map<String, Object>) soapClient.call(
          ResourcePath.CategoryTree, id);
    } catch (AxisFault e) {
      if (debug)
        e.printStackTrace();
      throw new ServiceException(e.getMessage());
    }

    if (cat == null)
      return null;
View Full Code Here

          break;
        }
      }

      if (!found) {
        throw new ServiceException("Category \"" + name
            + "\" not found.");
      }
    }

    return categories;
View Full Code Here

          return child;
        }
      }
    }

    throw new ServiceException("Child not found");
  }
View Full Code Here

            ResourcePath.CategoryCreate, newCategory));
        if (id > -1) {
          category.setId(id);
          return id;
        } else {
          throw new ServiceException("Error inserting new Category");
        }
      } catch (NumberFormatException e) {
        if (debug)
          e.printStackTrace();
        throw new ServiceException(e.getMessage());
      } catch (AxisFault e) {
        if (debug)
          e.printStackTrace();

        if(e.getMessage().indexOf("available_sort_by") > 0) {
          System.out.println("Broken Magento API? Run this SQL code first\n" +
              "update eav_attribute set is_required = 0 where attribute_code = 'available_sort_by';");
        }

        throw new ServiceException(e.getMessage());
      }
    } else {
      // update existing category
      List<Object> newCategory = new LinkedList<Object>();
      newCategory.add(category.getId());
      newCategory.add(category.getAllProperties());
      if(!storeView.isEmpty()) {
        newCategory.add(storeView);
      }
      try {
        Boolean sucessed = (Boolean) soapClient.call(
            ResourcePath.CategoryUpdate, newCategory);
        if (!sucessed) {
          throw new ServiceException("Error on update Category");
        }
      } catch (AxisFault e) {
        if (debug)
          e.printStackTrace();
        throw new ServiceException(e.getMessage());
      }
      return category.getId();
    }
  }
View Full Code Here

    try {
      success = (Boolean) soapClient
          .call(ResourcePath.CategoryDelete, id);
    } catch (AxisFault e) {
      System.out.println(e.getMessage());
      throw new ServiceException(e.getMessage());
    }
    if (!success) {
      throw new ServiceException("Not success deleting category.");
    }
  }
View Full Code Here

      }

      return categories.get(0);
    }

    throw new ServiceException("Category list is empty");
  }
View Full Code Here

          return categories;
        }
      }
    }

    throw new ServiceException("Fail to create a new category");
  }
View Full Code Here

TOP

Related Classes of com.google.code.magja.service.ServiceException

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.