org.jboss.pnc.client.GenericSettingClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-api Show documentation
Show all versions of rest-api Show documentation
Module with REST API bidings.
The newest version!
package org.jboss.pnc.client;
import java.lang.Boolean;
import java.lang.String;
import java.util.Optional;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.WebApplicationException;
import org.jboss.pnc.dto.response.Banner;
import org.jboss.pnc.rest.api.endpoints.GenericSettingEndpoint;
public class GenericSettingClient extends ClientBase {
public GenericSettingClient(Configuration configuration) {
super(configuration, GenericSettingEndpoint.class);
}
public Banner getAnnouncementBanner() throws RemoteResourceException {
try {
return getEndpoint().getAnnouncementBanner();
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setTokenSupplier(configuration.getBearerTokenSupplier());
return getEndpoint().getAnnouncementBanner();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public void setAnnouncementBanner(String banner) throws RemoteResourceException,
RemoteResourceNotFoundException {
try {
getEndpoint().setAnnouncementBanner(banner);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setTokenSupplier(configuration.getBearerTokenSupplier());
getEndpoint().setAnnouncementBanner(banner);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public Optional getPNCVersion() throws RemoteResourceException {
try {
return Optional.ofNullable(getEndpoint().getPNCVersion());
} catch (NotFoundException e) {
return Optional.empty();
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setTokenSupplier(configuration.getBearerTokenSupplier());
return Optional.ofNullable(getEndpoint().getPNCVersion());
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public void setPNCVersion(String version) throws RemoteResourceException,
RemoteResourceNotFoundException {
try {
getEndpoint().setPNCVersion(version);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setTokenSupplier(configuration.getBearerTokenSupplier());
getEndpoint().setPNCVersion(version);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public Boolean isInMaintenanceMode() throws RemoteResourceException {
try {
return getEndpoint().isInMaintenanceMode();
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setTokenSupplier(configuration.getBearerTokenSupplier());
return getEndpoint().isInMaintenanceMode();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public Boolean isCurrentUserAllowedToTriggerBuilds() throws RemoteResourceException {
try {
return getEndpoint().isCurrentUserAllowedToTriggerBuilds();
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setTokenSupplier(configuration.getBearerTokenSupplier());
return getEndpoint().isCurrentUserAllowedToTriggerBuilds();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public void activateMaintenanceMode(String reason) throws RemoteResourceException,
RemoteResourceNotFoundException {
try {
getEndpoint().activateMaintenanceMode(reason);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setTokenSupplier(configuration.getBearerTokenSupplier());
getEndpoint().activateMaintenanceMode(reason);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public void deactivateMaintenanceMode() throws RemoteResourceException,
RemoteResourceNotFoundException {
try {
getEndpoint().deactivateMaintenanceMode();
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setTokenSupplier(configuration.getBearerTokenSupplier());
getEndpoint().deactivateMaintenanceMode();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy