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

com.ksyun.ks3.service.request.RestoreObjectRequest Maven / Gradle / Ivy

package com.ksyun.ks3.service.request;

import static com.ksyun.ks3.exception.client.ClientIllegalArgumentExceptionGenerator.notNull;

import com.ksyun.ks3.http.HttpMethod;
import com.ksyun.ks3.http.Request;
import com.ksyun.ks3.utils.StringUtils;

public class RestoreObjectRequest extends Ks3WebServiceRequest {
	
	private String bucket;
	
	private String key;
	private String versionId;

	public RestoreObjectRequest(String bucketName, String objectKey) {
		this.bucket = bucketName;
		this.key = objectKey;
	}

	public RestoreObjectRequest(String bucketName, String objectKey, String versionId) {
		this.bucket = bucketName;
		this.key = objectKey;
		this.versionId = versionId;
	}
	
	@Override
	public void validateParams() throws IllegalArgumentException {
		if(StringUtils.isBlank(this.bucket))
			throw notNull("bucketname");
		if(StringUtils.isBlank(this.key))
			throw notNull("objectkey");
	}

	@Override
	public void buildRequest(Request request) {
		request.setMethod(HttpMethod.POST);
		request.setBucket(bucket);
		request.setKey(key);
		request.addQueryParam("restore", "");
		if (!StringUtils.isBlank(versionId)) {
			request.addQueryParam("versionId", versionId);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy