Search in sources :

Example 1 with EventContent

use of com.tencentcloudapi.vod.v20180717.models.EventContent in project cloud-sdk by mizhousoft.

the class QCloudVODServiceImpl method pullEvents.

/**
 * {@inheritDoc}
 */
@Override
public List<VodEvent> pullEvents() throws CloudSDKException {
    try {
        PullEventsRequest req = new PullEventsRequest();
        PullEventsResponse resp = vodClient.PullEvents(req);
        EventContent[] list = resp.getEventSet();
        if (null != list) {
            List<VodEvent> events = new ArrayList<>(list.length);
            for (EventContent item : list) {
                VodEvent event = convertToEvent(item);
                events.add(event);
            }
            return events;
        }
        return new ArrayList<>(0);
    } catch (TencentCloudSDKException e) {
        throw new CloudSDKException(e.getErrorCode(), e.getMessage(), e);
    }
}
Also used : CloudSDKException(com.mizhousoft.cloudsdk.CloudSDKException) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) TencentCloudSDKException(com.tencentcloudapi.common.exception.TencentCloudSDKException) ArrayList(java.util.ArrayList) EventContent(com.tencentcloudapi.vod.v20180717.models.EventContent) PullEventsResponse(com.tencentcloudapi.vod.v20180717.models.PullEventsResponse) PullEventsRequest(com.tencentcloudapi.vod.v20180717.models.PullEventsRequest) VodEvent(com.mizhousoft.cloudsdk.vod.event.VodEvent)

Example 2 with EventContent

use of com.tencentcloudapi.vod.v20180717.models.EventContent in project cloud-sdk by mizhousoft.

the class QCloudVODServiceImpl method convertToEvent.

private VodEvent convertToEvent(EventContent content) {
    String eventId = content.getEventHandle();
    String eventType = content.getEventType();
    if ("NewFileUpload".equals(eventType)) {
        FileUploadTask uploadTask = content.getFileUploadEvent();
        MediaMeta mediaMeta = buildMediaMeta(uploadTask.getFileId(), uploadTask.getMediaBasicInfo(), uploadTask.getMetaData(), null);
        return new VodNewFileUploadEvent(eventId, mediaMeta);
    } else if ("ProcedureStateChanged".equals(eventType)) {
        ProcedureTask precTask = content.getProcedureStateChangeEvent();
        boolean completed = "FINISH".equals(precTask.getStatus());
        return new VodStateChangedEvent(eventId, precTask.getFileId(), completed);
    } else if ("FileDeleted".equals(eventType)) {
        FileDeleteTask deleteTask = content.getFileDeleteEvent();
        return new VodFileDeletedEvent(eventId, deleteTask.getFileIdSet());
    } else {
        return new VodEvent(eventId);
    }
}
Also used : VodFileDeletedEvent(com.mizhousoft.cloudsdk.vod.event.VodFileDeletedEvent) FileUploadTask(com.tencentcloudapi.vod.v20180717.models.FileUploadTask) FileDeleteTask(com.tencentcloudapi.vod.v20180717.models.FileDeleteTask) ProcedureTask(com.tencentcloudapi.vod.v20180717.models.ProcedureTask) VodNewFileUploadEvent(com.mizhousoft.cloudsdk.vod.event.VodNewFileUploadEvent) MediaMeta(com.mizhousoft.cloudsdk.vod.MediaMeta) VodStateChangedEvent(com.mizhousoft.cloudsdk.vod.event.VodStateChangedEvent) VodEvent(com.mizhousoft.cloudsdk.vod.event.VodEvent)

Aggregations

VodEvent (com.mizhousoft.cloudsdk.vod.event.VodEvent)2 CloudSDKException (com.mizhousoft.cloudsdk.CloudSDKException)1 MediaMeta (com.mizhousoft.cloudsdk.vod.MediaMeta)1 VodFileDeletedEvent (com.mizhousoft.cloudsdk.vod.event.VodFileDeletedEvent)1 VodNewFileUploadEvent (com.mizhousoft.cloudsdk.vod.event.VodNewFileUploadEvent)1 VodStateChangedEvent (com.mizhousoft.cloudsdk.vod.event.VodStateChangedEvent)1 TencentCloudSDKException (com.tencentcloudapi.common.exception.TencentCloudSDKException)1 EventContent (com.tencentcloudapi.vod.v20180717.models.EventContent)1 FileDeleteTask (com.tencentcloudapi.vod.v20180717.models.FileDeleteTask)1 FileUploadTask (com.tencentcloudapi.vod.v20180717.models.FileUploadTask)1 ProcedureTask (com.tencentcloudapi.vod.v20180717.models.ProcedureTask)1 PullEventsRequest (com.tencentcloudapi.vod.v20180717.models.PullEventsRequest)1 PullEventsResponse (com.tencentcloudapi.vod.v20180717.models.PullEventsResponse)1 ArrayList (java.util.ArrayList)1