77 lines
2.4 KiB
Java
77 lines
2.4 KiB
Java
/*
|
|
* Copyright 2015 Trento Rise.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
package org.gcube.datacatalogue.utillibrary.shared.jackan.model.exceptions;
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import org.gcube.datacatalogue.utillibrary.jackan.CkanClient;
|
|
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanResponse;
|
|
|
|
/**
|
|
* Runtime exception for ckan-related problems. For possible cases description, see {@link eu.trentorise.opendata.jackan.model.CkanError CkanError}
|
|
*
|
|
* @author David Leoni
|
|
*/
|
|
public class CkanException extends JackanException {
|
|
|
|
|
|
@Nullable
|
|
private CkanResponse ckanResponse = null;
|
|
@Nullable
|
|
private CkanClient ckanClient = null;
|
|
|
|
private static String makeMessage(String msg, @Nullable CkanResponse ckanResponse, @Nullable CkanClient client) {
|
|
return msg + " "
|
|
+ (ckanResponse != null ? ckanResponse + " " : "")
|
|
+ (client != null ? client : "");
|
|
}
|
|
|
|
|
|
public CkanException(String msg, CkanClient client) {
|
|
super(makeMessage(msg, null, client));
|
|
this.ckanClient = client;
|
|
}
|
|
|
|
public CkanException(String msg, CkanResponse ckanResponse, CkanClient client) {
|
|
super(makeMessage(msg, ckanResponse, client));
|
|
this.ckanResponse = ckanResponse;
|
|
this.ckanClient = client;
|
|
}
|
|
|
|
public CkanException(String msg, CkanClient client, Throwable ex) {
|
|
this(msg, null, client, ex);
|
|
}
|
|
|
|
public CkanException(String msg, CkanResponse ckanResponse, CkanClient client, Throwable ex) {
|
|
super(makeMessage(msg, ckanResponse, client),
|
|
ex);
|
|
this.ckanResponse = ckanResponse;
|
|
this.ckanClient = client;
|
|
}
|
|
|
|
@Nullable
|
|
public CkanResponse getCkanResponse() {
|
|
return ckanResponse;
|
|
}
|
|
|
|
@Nullable
|
|
public CkanClient getCkanClient() {
|
|
return ckanClient;
|
|
}
|
|
|
|
}
|