Search in sources :

Example 1 with CannedUdfAcl

use of com.aliyun.oss.model.CannedUdfAcl in project aliyun-oss-java-sdk by aliyun.

the class ResponseParsers method parseGetUdfInfo.

/**
 * Unmarshall get udf info response body to udf info.
 */
public static UdfInfo parseGetUdfInfo(InputStream responseBody) throws ResponseParseException {
    try {
        Element root = getXmlRootElement(responseBody);
        String name = root.getChildText("Name");
        String id = root.getChildText("ID");
        String owner = root.getChildText("Owner");
        String desc = root.getChildText("Description");
        Date date = DateUtil.parseIso8601Date(root.getChildText("CreationDate"));
        CannedUdfAcl acl = CannedUdfAcl.parse(root.getChildText("ACL"));
        return new UdfInfo(name, owner, id, desc, acl, date);
    } catch (JDOMParseException e) {
        throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
    } catch (Exception e) {
        throw new ResponseParseException(e.getMessage(), e);
    }
}
Also used : JDOMParseException(org.jdom.input.JDOMParseException) UdfInfo(com.aliyun.oss.model.UdfInfo) Element(org.jdom.Element) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException) Date(java.util.Date) CannedUdfAcl(com.aliyun.oss.model.CannedUdfAcl) ParseException(java.text.ParseException) JDOMParseException(org.jdom.input.JDOMParseException) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException)

Example 2 with CannedUdfAcl

use of com.aliyun.oss.model.CannedUdfAcl in project aliyun-oss-java-sdk by aliyun.

the class ResponseParsers method parseListUdf.

/**
 * Unmarshall list udf response body to udf info list.
 */
@SuppressWarnings("unchecked")
public static List<UdfInfo> parseListUdf(InputStream responseBody) throws ResponseParseException {
    try {
        Element root = getXmlRootElement(responseBody);
        List<UdfInfo> udfs = new ArrayList<UdfInfo>();
        if (root.getChild("UDFInfo") != null) {
            List<Element> udfElems = root.getChildren("UDFInfo");
            for (Element elem : udfElems) {
                String name = elem.getChildText("Name");
                String id = elem.getChildText("ID");
                String owner = elem.getChildText("Owner");
                String desc = elem.getChildText("Description");
                Date date = DateUtil.parseIso8601Date(elem.getChildText("CreationDate"));
                CannedUdfAcl acl = CannedUdfAcl.parse(elem.getChildText("ACL"));
                udfs.add(new UdfInfo(name, owner, id, desc, acl, date));
            }
        }
        return udfs;
    } catch (JDOMParseException e) {
        throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
    } catch (Exception e) {
        throw new ResponseParseException(e.getMessage(), e);
    }
}
Also used : JDOMParseException(org.jdom.input.JDOMParseException) UdfInfo(com.aliyun.oss.model.UdfInfo) Element(org.jdom.Element) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException) ArrayList(java.util.ArrayList) Date(java.util.Date) CannedUdfAcl(com.aliyun.oss.model.CannedUdfAcl) ParseException(java.text.ParseException) JDOMParseException(org.jdom.input.JDOMParseException) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException)

Aggregations

ResponseParseException (com.aliyun.oss.common.parser.ResponseParseException)2 CannedUdfAcl (com.aliyun.oss.model.CannedUdfAcl)2 UdfInfo (com.aliyun.oss.model.UdfInfo)2 ParseException (java.text.ParseException)2 Date (java.util.Date)2 Element (org.jdom.Element)2 JDOMParseException (org.jdom.input.JDOMParseException)2 ArrayList (java.util.ArrayList)1