Search in sources :

Example 1 with InstanceFlavor

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

the class ResponseParsers method parseGetUdfApplicationInfo.

/**
 * Unmarshall get udf info response body to udf application info.
 */
public static UdfApplicationInfo parseGetUdfApplicationInfo(InputStream responseBody) throws ResponseParseException {
    try {
        Element root = getXmlRootElement(responseBody);
        String id = root.getChildText("ID");
        String name = root.getChildText("Name");
        String status = root.getChildText("Status");
        String region = root.getChildText("Region");
        Integer imageVersion = Integer.valueOf(root.getChildText("ImageVersion"));
        Integer instanceNum = Integer.valueOf(root.getChildText("InstanceNum"));
        Date date = DateUtil.parseIso8601Date(root.getChildText("CreationDate"));
        String instanceType = root.getChild("Flavor").getChildText("InstanceType");
        InstanceFlavor flavor = new InstanceFlavor(instanceType);
        return new UdfApplicationInfo(name, id, region, status, imageVersion, instanceNum, date, flavor);
    } catch (JDOMParseException e) {
        throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
    } catch (Exception e) {
        throw new ResponseParseException(e.getMessage(), e);
    }
}
Also used : BigInteger(java.math.BigInteger) JDOMParseException(org.jdom.input.JDOMParseException) InstanceFlavor(com.aliyun.oss.model.InstanceFlavor) Element(org.jdom.Element) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException) UdfApplicationInfo(com.aliyun.oss.model.UdfApplicationInfo) Date(java.util.Date) ParseException(java.text.ParseException) JDOMParseException(org.jdom.input.JDOMParseException) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException)

Example 2 with InstanceFlavor

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

the class ResponseParsers method parseListUdfApplicationInfo.

/**
 * Unmarshall get udf info response body to udf image info list.
 */
@SuppressWarnings("unchecked")
public static List<UdfApplicationInfo> parseListUdfApplicationInfo(InputStream responseBody) throws ResponseParseException {
    try {
        Element root = getXmlRootElement(responseBody);
        List<UdfApplicationInfo> udfApps = new ArrayList<UdfApplicationInfo>();
        if (root.getChild("UDFApplicationInfo") != null) {
            List<Element> udfImageElems = root.getChildren("UDFApplicationInfo");
            for (Element elem : udfImageElems) {
                String id = elem.getChildText("ID");
                String name = elem.getChildText("Name");
                String status = elem.getChildText("Status");
                String region = elem.getChildText("Region");
                Integer imageVersion = Integer.valueOf(elem.getChildText("ImageVersion"));
                Integer instanceNum = Integer.valueOf(elem.getChildText("InstanceNum"));
                Date date = DateUtil.parseIso8601Date(elem.getChildText("CreationDate"));
                String instanceType = elem.getChild("Flavor").getChildText("InstanceType");
                InstanceFlavor flavor = new InstanceFlavor(instanceType);
                UdfApplicationInfo udfApp = new UdfApplicationInfo(name, id, region, status, imageVersion, instanceNum, date, flavor);
                udfApps.add(udfApp);
            }
        }
        return udfApps;
    } catch (JDOMParseException e) {
        throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
    } catch (Exception e) {
        throw new ResponseParseException(e.getMessage(), e);
    }
}
Also used : BigInteger(java.math.BigInteger) JDOMParseException(org.jdom.input.JDOMParseException) InstanceFlavor(com.aliyun.oss.model.InstanceFlavor) Element(org.jdom.Element) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException) UdfApplicationInfo(com.aliyun.oss.model.UdfApplicationInfo) ArrayList(java.util.ArrayList) Date(java.util.Date) 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 InstanceFlavor (com.aliyun.oss.model.InstanceFlavor)2 UdfApplicationInfo (com.aliyun.oss.model.UdfApplicationInfo)2 BigInteger (java.math.BigInteger)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