All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.qiniu.process.qdora.QiniuPfop Maven / Gradle / Ivy

There is a newer version: 8.4.8
Show newest version
package com.qiniu.process.qdora;

import com.qiniu.common.QiniuException;
import com.qiniu.process.Base;
import com.qiniu.sdk.OperationManager;
import com.qiniu.storage.Configuration;
import com.qiniu.util.*;

import java.io.IOException;
import java.util.Map;

public class QiniuPfop extends Base {

    private OperationManager operationManager;
    private StringMap pfopParams;
    private String fopsIndex;

    public QiniuPfop(String accessKey, String secretKey, Configuration configuration, String bucket, String pipeline,
                     String fopsIndex, String rmPrefix, String savePath, int saveIndex) throws IOException {
        super("pfop", accessKey, secretKey, configuration, bucket, rmPrefix, savePath, saveIndex);
        this.operationManager = new OperationManager(Auth.create(accessKey, secretKey), configuration.clone());
        set(pipeline, fopsIndex);
    }

    public void updateFop(String bucket, String pipeline, String fopsIndex, String rmPrefix) throws IOException {
        this.bucket = bucket;
        set(pipeline, fopsIndex);
        this.rmPrefix = rmPrefix;
    }

    private void set(String pipeline, String fopsIndex) throws IOException {
        this.pfopParams = new StringMap().putNotEmpty("pipeline", pipeline);
        if (fopsIndex == null || "".equals(fopsIndex)) throw new IOException("please set the fopsIndex.");
        else this.fopsIndex = fopsIndex;
    }

    public QiniuPfop(String accessKey, String secretKey, Configuration configuration, String bucket, String pipeline,
                     String fopsIndex, String rmPrefix, String savePath) throws IOException {
        this(accessKey, secretKey, configuration, bucket, pipeline, fopsIndex, rmPrefix, savePath, 0);
    }

    public QiniuPfop clone() throws CloneNotSupportedException {
        QiniuPfop qiniuPfop = (QiniuPfop)super.clone();
        qiniuPfop.operationManager = new OperationManager(Auth.create(accessKey, secretKey), configuration.clone());
        return qiniuPfop;
    }

    @Override
    protected String resultInfo(Map line) {
        return line.get("key") + "\t" + line.get(fopsIndex);
    }

    @Override
    protected String singleResult(Map line) throws QiniuException {
        return operationManager.pfop(bucket, line.get("key"), line.get(fopsIndex), pfopParams);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy