Search in sources :

Example 1 with GetImageStyleResult

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

the class TestForImg method testPutGetDeleteImageStyle.

public void testPutGetDeleteImageStyle() {
    PutBucketImageRequest request = new PutBucketImageRequest(bucketName);
    clientImg.putBucketImage(request);
    sleepSecond(10);
    PutImageStyleRequest requestStyle = new PutImageStyleRequest();
    requestStyle.SetBucketName(bucketName);
    String styleName = "myStyle";
    String style = "200w";
    requestStyle.SetStyle(style);
    requestStyle.SetStyleName(styleName);
    clientImg.putImageStyle(requestStyle);
    sleepSecond(10);
    GetImageStyleResult result = clientImg.getImageStyle(bucketName, styleName);
    Assert.assertEquals(result.GetStyle(), style);
    Assert.assertEquals(result.GetStyleName(), styleName);
    clientImg.deleteImageStyle(bucketName, styleName);
    sleepSecond(20);
    try {
        clientImg.getImageStyle(bucketName, styleName);
        Assert.assertTrue(false);
    } catch (Exception e) {
    // Do Nothing
    }
}
Also used : GetImageStyleResult(com.aliyun.oss.model.GetImageStyleResult) PutBucketImageRequest(com.aliyun.oss.model.PutBucketImageRequest) PutImageStyleRequest(com.aliyun.oss.model.PutImageStyleRequest)

Example 2 with GetImageStyleResult

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

the class ResponseParsers method parseImageStyle.

/**
 * Unmarshall get image style response body to corresponding result.
 */
public static GetImageStyleResult parseImageStyle(InputStream responseBody) throws ResponseParseException {
    try {
        Element root = getXmlRootElement(responseBody);
        GetImageStyleResult result = new GetImageStyleResult();
        result.SetStyleName(root.getChildText("Name"));
        result.SetStyle(root.getChildText("Content"));
        result.SetLastModifyTime(DateUtil.parseRfc822Date(root.getChildText("LastModifyTime")));
        result.SetCreationDate(DateUtil.parseRfc822Date(root.getChildText("CreateTime")));
        return result;
    } 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) Element(org.jdom.Element) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException) GetImageStyleResult(com.aliyun.oss.model.GetImageStyleResult) ParseException(java.text.ParseException) JDOMParseException(org.jdom.input.JDOMParseException) ResponseParseException(com.aliyun.oss.common.parser.ResponseParseException)

Aggregations

GetImageStyleResult (com.aliyun.oss.model.GetImageStyleResult)2 ResponseParseException (com.aliyun.oss.common.parser.ResponseParseException)1 PutBucketImageRequest (com.aliyun.oss.model.PutBucketImageRequest)1 PutImageStyleRequest (com.aliyun.oss.model.PutImageStyleRequest)1 ParseException (java.text.ParseException)1 Element (org.jdom.Element)1 JDOMParseException (org.jdom.input.JDOMParseException)1