Ignore:
Timestamp:
Apr 30, 2011, 1:40:23 PM (14 years ago)
Author:
mlg
Message:

Bug correction : nullpointerexception on image search

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/jiwigo-ws-api/src/main/java/fr/mael/jiwigo/dao/impl/ImageDaoImpl.java

    r10505 r10699  
    222222    private List<Image> getImagesFromElement(Element element) {
    223223        //      List<Element> listElement = (List<Element>) element.getChildren("image");
     224        System.out.println(Tools.documentToString(element));
    224225        NodeList listImages = element.getElementsByTagName("image");
    225226        ArrayList<Image> images = new ArrayList<Image>();
     
    238239                myImage.setName(Tools.getStringValueDom(im, "name"));
    239240                Element elementCategories = (Element) im.getElementsByTagName("categories").item(0);
    240                 Element elementCategory = (Element) elementCategories.getElementsByTagName("category").item(0);
    241                 myImage.setIdCategory(Integer.valueOf(elementCategory.getAttribute("id")));
    242                 if (myImage.getName() == null) {
    243                     myImage.setName(myImage.getFile());
     241                if (elementCategories != null) {
     242                    Element elementCategory = (Element) elementCategories.getElementsByTagName("category").item(0);
     243                    myImage.setIdCategory(Integer.valueOf(elementCategory.getAttribute("id")));
     244                    if (myImage.getName() == null) {
     245                        myImage.setName(myImage.getFile());
     246                    }
    244247                }
    245248                images.add(myImage);
Note: See TracChangeset for help on using the changeset viewer.