* ============LICENSE_END=========================================================\r
*/\r
\r
-/*\r
- * ============LICENSE_START==========================================\r
- * ===================================================================\r
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * ===================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END============================================\r
- *\r
- * ECOMP and OpenECOMP are trademarks\r
- * and service marks of AT&T Intellectual Property.\r
- *\r
- */\r
\r
package com.woorea.openstack.base.client;\r
\r
* Implement only the basic constructors\r
*/\r
public OpenStackBaseException () {}\r
- \r
+\r
public OpenStackBaseException(String message) {\r
super(message);\r
}\r
public OpenStackBaseException(String message, Throwable cause) {\r
super(message, cause);\r
}\r
-}\r
+}
\ No newline at end of file
import java.util.ServiceLoader;
public class OpenStackClient {
-
+
protected String endpoint;
-
+
protected OpenStackTokenProvider tokenProvider;
protected static int AUTHENTICATION_RETRIES = 1;
protected OpenStackClientConnector connector;
-
+
protected Properties properties = new Properties();
-
+
protected static OpenStackClientConnector DEFAULT_CONNECTOR;
static {
public <T> OpenStackResponse request(OpenStackRequest<T> request) {
OpenStackResponseException authException = null;
- //System.out.println("Openstack query:"+request.toString());
+
for (int i = 0; i <= AUTHENTICATION_RETRIES; i++) {
request.endpoint(endpoint);
tokenProvider.expireToken();
}
}
- if(null == authException){
- authException = new OpenStackResponseException("Unknown issue",500);
+ if(null == authException){
+ authException = new OpenStackResponseException("Unknown issue",500);
}
- throw authException;
+ throw authException;
}
public <T> T execute(OpenStackRequest<T> request) {
public void property(String property, String value) {
properties.put(property, value);
}
-
+
public void setTokenProvider(OpenStackTokenProvider tokenProvider) {
this.tokenProvider = tokenProvider;
}
-
+
public void token(String token) {
setTokenProvider(new OpenStackSimpleTokenProvider(token));
}
-
+
public <R> OpenStackRequest<R> get(String path, Class<R> returnType) {
return new OpenStackRequest<>(this, HttpMethod.GET, path, null, returnType);
}
-
-}
+
+}
\ No newline at end of file