use of com.aliyun.oss.model.Style in project aliyun-oss-java-sdk by aliyun.
the class TestForImg method testListImageStyle.
public void testListImageStyle() {
// Clear all image style
clientImg.deleteBucketImage(bucketName);
sleepSecond(10);
PutBucketImageRequest request = new PutBucketImageRequest(bucketName);
clientImg.putBucketImage(request);
sleepSecond(10);
PutImageStyleRequest requestStyle = new PutImageStyleRequest();
requestStyle.SetBucketName(bucketName);
// Same length with style
String[] styleName = { "myStyle", "myStyle1", "myStyle2", "myStyle3", "myStyle4" };
String[] style = { "200w", "300w", "400w", "500w", "600w" };
for (int i = 0; i < styleName.length; ++i) {
requestStyle.SetStyle(style[i]);
requestStyle.SetStyleName(styleName[i]);
clientImg.putImageStyle(requestStyle);
}
sleepSecond(10);
List<Style> styleList = clientImg.listImageStyle(bucketName);
Assert.assertEquals(styleList.size(), styleName.length);
int i;
for (Style s : styleList) {
for (i = 0; i < style.length; i++) {
if (s.GetStyle().equals(style[i]))
break;
}
Assert.assertTrue(i != style.length);
for (i = 0; i < styleName.length; i++) {
if (s.GetStyleName().equals(styleName[i]))
break;
}
Assert.assertTrue(i != styleName.length);
}
}
use of com.aliyun.oss.model.Style in project aliyun-oss-java-sdk by aliyun.
the class ResponseParsers method parseListImageStyle.
/**
* Unmarshall list image style response body to style list.
*/
@SuppressWarnings("unchecked")
public static List<Style> parseListImageStyle(InputStream responseBody) throws ResponseParseException {
try {
Element root = getXmlRootElement(responseBody);
List<Style> styleList = new ArrayList<Style>();
List<Element> styleElems = root.getChildren("Style");
for (Element e : styleElems) {
Style style = new Style();
style.SetStyleName(e.getChildText("Name"));
style.SetStyle(e.getChildText("Content"));
style.SetLastModifyTime(DateUtil.parseRfc822Date(e.getChildText("LastModifyTime")));
style.SetCreationDate(DateUtil.parseRfc822Date(e.getChildText("CreateTime")));
styleList.add(style);
}
return styleList;
} catch (JDOMParseException e) {
throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
} catch (Exception e) {
throw new ResponseParseException(e.getMessage(), e);
}
}
Aggregations