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

org.gs4tr.gcc.restclient.operation.Context Maven / Gradle / Ivy

Go to download

GlobalLink Connect Cloud java is a library to connect your system to GlobalLink Connect Cloud REST API.

There is a newer version: 3.1.3
Show newest version
package org.gs4tr.gcc.restclient.operation;

import org.gs4tr.gcc.restclient.GCConfig;
import org.gs4tr.gcc.restclient.dto.GCResponse;
import org.gs4tr.gcc.restclient.request.GCRequest;
import org.gs4tr.gcc.restclient.request.UploadFileContextRequest;
import org.gs4tr.gcc.restclient.request.UploadFileContextRequest.ContextType;

import com.fasterxml.jackson.annotation.JsonProperty;

public class Context extends GCOperation {

	private final UploadFileContextRequest request;

	public Context(GCConfig config, UploadFileContextRequest request) {
		super(config);
		this.request = request;
	}

	private static final String REQUEST_URL_HTML = "context/upload/html";
	private static final String REQUEST_URL_XSLT = "context/upload/xslt";
	private static final String REQUEST_URL_ZIP = "context/upload/zip";
	private static final String REQUEST_METHOD = "POST";

	@Override
	public String getRequestMethod() {
		return REQUEST_METHOD;
	}

	@Override
	protected String getApiUrl() {
		if (ContextType.HTML.equals(this.getRequest().getContextType())) {
			return REQUEST_URL_HTML;
		} else if (ContextType.ZIP.equals(this.getRequest().getContextType())) {
			return REQUEST_URL_ZIP;
		} else if (ContextType.XSLT.equals(this.getRequest().getContextType())) {
			return REQUEST_URL_XSLT;
		} else {
			throw new IllegalArgumentException("Value of contextType is unknown");
		}
	}

	@Override
	public GCRequest getRequestObject() {
		return getRequest();
	}

	@Override
	public Class getResponseClass() {
		return ContextResponse.class;
	}

	public UploadFileContextRequest getRequest() {
		return request;
	}

	public static class ContextResponse extends GCResponse {
		@JsonProperty("response_data")
		private ContextResponseData responseData;

		public ContextResponseData getResponseData() {
			return responseData;
		}

		public void setResponseData(ContextResponseData responseData) {
			this.responseData = responseData;
		}

	}

	public static class ContextResponseData {

		@JsonProperty("context_url")
		private String staticUrl;

		public String getStaticUrl() {
			return staticUrl;
		}

		public void setStaticUrl(String staticUrl) {
			this.staticUrl = staticUrl;
		}

	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy