com.qcloud.cos.demo.ci.CICommonDemo Maven / Gradle / Ivy
package com.qcloud.cos.demo.ci;
import com.qcloud.cos.internal.Unmarshallers;
import com.qcloud.cos.model.ciModel.job.DocJobResponse;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
/**
* 数据万象公共接口逻辑demo展示
*/
public class CICommonDemo {
public static void main(String[] args) throws Exception {
String src = "TaskFinish Success
2021-02-19T15:24:44+0800 2021-02-19T15:24:45+0800 d89c4cf4a728311ebb1229f23e6c9963b 1 -1 0 0 100 0 0 100 0 1 test1/1.jpg 1 1 p3615c32d66fa493bae4c43a5e655ab7f Success DocProcess ";
processCINotifyResponse(src);
}
/**
* 本示例用于解析回调数据,可通过获取Unmarshallers来进行xml数据的解析
* 可以通过查看CosClient的接口获取到需要使用的xml解析器
*/
public static void processCINotifyResponse(String response) throws Exception {
//这里以文档预览的任务回调为例
Unmarshallers.DescribeDocJobUnmarshaller describeDocJobUnmarshaller = new Unmarshallers.DescribeDocJobUnmarshaller();
InputStream is = new ByteArrayInputStream(response.getBytes());
DocJobResponse docJobResponse = describeDocJobUnmarshaller.unmarshall(is);
System.out.println(docJobResponse);
}
}