All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ksyun.ks3.service.response.GetBucketWormResponse Maven / Gradle / Ivy

package com.ksyun.ks3.service.response;

import com.ksyun.ks3.dto.GetBucketWormResult;
import com.ksyun.ks3.utils.DateUtils;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import java.util.ArrayList;
import java.util.List;

public class GetBucketWormResponse extends Ks3WebServiceXmlResponse{

    private List worms;
    private GetBucketWormResult.Worm worm;

    @Override
    public int[] expectedStatus() {
        return new int[]{200};
    }

    @Override
    public void preHandle() {

    }

    @Override
    public void startDocument() throws SAXException {
        result = new GetBucketWormResult();
        worms = new ArrayList<>();
    }

    @Override
    public void startEle(String uri, String localName, String qName, Attributes attributes) throws SAXException {
        String tag = getTag();
        if("Worm".equals(tag)){
            worm = new GetBucketWormResult.Worm();
        }
    }

    @Override
    public void endEle(String uri, String localName, String qName) throws SAXException {
        String tag = getTag();
        if("Worm".equals(tag)){
            worms.add(worm);
        }
        else if("WormConfiguration".equals(tag)){
            result.setWorms(worms);
        }
    }

    @Override
    public void string(String s) {
        String tag = getTag();
        if("WormId".equals(tag)){
            worm.setWormId(s);
        }
        else if("State".equals(tag)){
            worm.setState(GetBucketWormResult.Worm.Status.str2Status(s));
        }
        else if("RetentionPeriodInDays".equals(tag)){
            worm.setRetentionPeriodInDays(Integer.parseInt(s));
        }
        else if("CreationDate".equals(tag)){
            worm.setCreationDate(DateUtils.convertStr2Date(s));
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy