Ignore:
Timestamp:
May 3, 2011, 8:25:38 PM (13 years ago)
Author:
mlg
Message:

Adds support for changing level on addSimple.

File:
1 edited

Legend:

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

    r10719 r10749  
    141141    public boolean create(Image image, Double chunkSize) throws FileAlreadyExistsException, IOException,
    142142            ProxyAuthenticationException, NoSuchAlgorithmException, WrongChunkSizeException, JiwigoException {
     143        if (exists(image)) {
     144            throw new FileAlreadyExistsException("Photo already exists");
     145        }
    143146        //thumbnail converted to base64
    144147        BASE64Encoder base64 = new BASE64Encoder();
     
    196199        return reussite;
    197200
     201    }
     202
     203    /**
     204     * Function to test if a photo already exists
     205     * @param image the image to test
     206     * @return true if the photo exists
     207     * @throws JiwigoException
     208     */
     209    private boolean exists(Image image) throws JiwigoException {
     210        try {
     211            String imageMD5 = Tools.getMD5Checksum(image.getOriginale().getAbsolutePath());
     212            Document docResult = sessionManager.executeReturnDocument(MethodsEnum.IMAGE_EXIST.getLabel(),
     213                    "md5sum_list", imageMD5);
     214            String result = Tools.getStringValueDom(docResult.getDocumentElement(), imageMD5);
     215
     216            if (result != null && !"".equals(result)) {
     217                return true;
     218            } else {
     219                return false;
     220            }
     221        } catch (NoSuchAlgorithmException e) {
     222            throw new JiwigoException(e);
     223        } catch (IOException e) {
     224            throw new JiwigoException(e);
     225        }
    198226    }
    199227
     
    279307    }
    280308
    281     public void addSimple(File file, Integer category, String title) throws JiwigoException {
     309    public void addSimple(File file, Integer category, String title, Integer level) throws JiwigoException {
    282310        HttpPost httpMethod = new HttpPost(((SessionManagerImpl) sessionManager).getUrl());
    283311
     
    299327                multipartEntity.addPart("category", new StringBody(category.toString()));
    300328                multipartEntity.addPart("name", new StringBody(title));
     329                if (level != null) {
     330                    multipartEntity.addPart("level", new StringBody(level.toString()));
     331                }
    301332            } catch (UnsupportedEncodingException e) {
    302333                throw new JiwigoException(e);
Note: See TracChangeset for help on using the changeset viewer.