protected int readTimeout = 5000;
protected int connectionTimeout = 3000;
protected URI uri;
- private String queryParams, fragment;
+ private String oneCallQueryParams;
public static Pool<byte[]> buffPool = new Pool<byte[]>(new Pool.Creator<byte[]>() {
@Override
public byte[] create() throws APIException {
protected abstract EClient<CT> client() throws CadiException;
- public<T> Future<T> create(String pathinfo, String contentType, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ public<T> Future<T> create(final String pathinfo, final String contentType, final RosettaDF<T> df, final T t) throws APIException, CadiException {
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
client.addHeader(CONTENT_TYPE,contentType);
- client.setPathInfo(pathinfo);
- client.setQueryParams(qp);
- client.setFragment(fragment);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.futureCreate(df.getTypeClass());
}
public<T> Future<T> create(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
client.addHeader(CONTENT_TYPE,typeString(df.getTypeClass()));
- client.setPathInfo(pathinfo);
- client.setQueryParams(qp);
- client.setFragment(fragment);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.futureCreate(df.getTypeClass());
}
public<T> Future<T> create(String pathinfo, Class<?> cls, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
client.addHeader(CONTENT_TYPE,typeString(cls));
- client.setPathInfo(pathinfo);
- client.setQueryParams(qp);
- client.setFragment(fragment);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.futureCreate(df.getTypeClass());
}
public<T> Future<T> create(String pathinfo, Class<T> cls) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
client.addHeader(CONTENT_TYPE,typeString(cls));
- client.setPathInfo(pathinfo);
- client.setQueryParams(qp);
- client.setFragment(fragment);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(null);
client.send();
- queryParams = fragment = null;
return client.futureCreate(cls);
}
public Future<Void> create(String pathinfo, String contentType) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
client.addHeader(CONTENT_TYPE,contentType);
- client.setPathInfo(pathinfo);
- client.setQueryParams(qp);
- client.setFragment(fragment);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(null);
client.send();
- queryParams = fragment = null;
return client.futureCreate(Void.class);
}
* @throws CadiException
*/
public <T> Future<T> postForm(String pathinfo, final RosettaDF<T> df, final String ... formParam) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
default:
break;
}
- client.setPathInfo(pathinfo);
- client.setQueryParams(qp);
- client.setFragment(fragment);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(new Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
}});
client.send();
- queryParams = fragment = null;
return client.futureRead(df,TYPE.JSON);
}
* @throws CadiException
*/
public<T> Future<String> readPost(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
client.addHeader(CONTENT_TYPE,typeString(df.getTypeClass()));
- client.setPathInfo(pathinfo);
- client.setQueryParams(qp);
- client.setFragment(fragment);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.futureReadString();
}
* @throws CadiException
*/
public<T,R> Future<R> readPost(String pathinfo, final RosettaDF<T> df, final T t, final RosettaDF<R> resp) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
-
+ final ParsePath pp = new ParsePath(pathinfo);
+
EClient<CT> client = client();
client.setMethod(POST);
client.addHeader(CONTENT_TYPE,typeString(df.getTypeClass()));
- client.setPathInfo(pathinfo);
- client.setQueryParams(qp);
- client.setFragment(fragment);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.futureRead(resp,resp.getOutType());
}
public Future<String> readPost(String pathinfo, String contentType, String ... headers) throws CadiException, APIException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(POST);
client.addHeader(CONTENT_TYPE,contentType);
- client.setPathInfo(pathinfo);
- client.setQueryParams(qp);
- client.setFragment(fragment);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}});
client.send();
- queryParams = fragment = null;
return client.futureReadString();
}
public Future<String> read(String pathinfo, String accept, String ... headers) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(GET);
for(int i=1;i<headers.length;i=i+2) {
client.addHeader(headers[i-1],headers[i]);
}
- client.setQueryParams(qp);
- client.setFragment(fragment);
-
- client.setPathInfo(pathinfo);
-
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(null);
client.send();
- queryParams = fragment = null;
return client.futureReadString();
}
public<T> Future<T> read(String pathinfo, String accept, RosettaDF<T> df, String ... headers) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(GET);
for(int i=1;i<headers.length;i=i+2) {
client.addHeader(headers[i-1],headers[i]);
}
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
-
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(null);
client.send();
- queryParams = fragment = null;
return client.futureRead(df,type);
}
public<T> Future<T> read(String pathinfo, RosettaDF<T> df,String ... headers) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(GET);
for(int i=1;i<headers.length;i=i+2) {
client.addHeader(headers[i-1],headers[i]);
}
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(null);
client.send();
- queryParams = fragment = null;
return client.futureRead(df,type);
}
public<T> Future<T> read(String pathinfo, Class<?> cls, RosettaDF<T> df) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(GET);
client.addHeader(ACCEPT, typeString(cls));
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
-
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
+
client.setPayload(null);
client.send();
- queryParams = fragment = null;
return client.futureRead(df,type);
}
public<T> Future<T> update(String pathinfo, String contentType, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(PUT);
client.addHeader(CONTENT_TYPE,contentType);
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.future(t);
}
public<T> Future<String> updateRespondString(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
-
+ final ParsePath pp = new ParsePath(pathinfo);
+
EClient<CT> client = client();
client.setMethod(PUT);
client.addHeader(CONTENT_TYPE, typeString(df.getTypeClass()));
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
+
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.futureReadString();
}
public<T> Future<T> update(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(PUT);
client.addHeader(CONTENT_TYPE, typeString(df.getTypeClass()));
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
+
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.future(t);
}
public<T> Future<T> update(String pathinfo, Class<?> cls, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
-
+ final ParsePath pp = new ParsePath(pathinfo);
+
EClient<CT> client = client();
client.setMethod(PUT);
client.addHeader(CONTENT_TYPE, typeString(cls));
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
+
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.future(t);
}
* @throws CadiException
*/
public<T> Future<Void> update(String pathinfo) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(PUT);
client.addHeader(CONTENT_TYPE, typeString(Void.class));
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
+
// client.setPayload(new EClient.Transfer() {
// @Override
// public void transfer(OutputStream os) throws IOException, APIException {
// }
// });
client.send();
- queryParams = fragment = null;
return client.future(null);
}
public<T> Future<T> delete(String pathinfo, String contentType, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(DELETE);
client.addHeader(CONTENT_TYPE, contentType);
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
+
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.future(t);
}
public<T> Future<T> delete(String pathinfo, Class<?> cls, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(DELETE);
client.addHeader(CONTENT_TYPE, typeString(cls));
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
}
});
client.send();
- queryParams = fragment = null;
return client.future(t);
}
public<T> Future<T> delete(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(DELETE);
client.addHeader(CONTENT_TYPE, typeString(df.getTypeClass()));
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
client.setPayload(new EClient.Transfer() {
@Override
public void transfer(OutputStream os) throws IOException, APIException {
});
client.send();
- queryParams = fragment = null;
return client.future(t);
}
public<T> Future<T> delete(String pathinfo, Class<T> cls) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(DELETE);
client.addHeader(CONTENT_TYPE, typeString(cls));
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
+
client.setPayload(null);
client.send();
- queryParams = fragment = null;
return client.future((T)null);
}
public Future<Void> delete(String pathinfo, String contentType) throws APIException, CadiException {
- final String qp = setupParams(pathinfo);
+ final ParsePath pp = new ParsePath(pathinfo);
EClient<CT> client = client();
client.setMethod(DELETE);
client.addHeader(CONTENT_TYPE, contentType);
- client.setQueryParams(qp);
- client.setFragment(fragment);
- client.setPathInfo(pathinfo);
+ client.setPathInfo(pp.path());
+ client.setQueryParams(pp.query());
+ client.setFragment(pp.frag());
+
client.setPayload(null);
client.send();
- queryParams = fragment = null;
return client.future(null);
}
return client.future(resp, expected);
}
- private String setupParams(String pathinfo) {
- final String qp;
- if(pathinfo==null) {
- qp=queryParams;
- } else {
- final int idx = pathinfo.indexOf('?');
- if(idx>=0) {
- qp=pathinfo.substring(idx+1);
- pathinfo=pathinfo.substring(0,idx);
+ private class ParsePath {
+ private final String path;
+ private final int query;
+ private final int queryEnd;
+ private final int pound;
+ private final String queryParams;
+
+ public ParsePath(final String origPath) {
+ path = origPath;
+ if(origPath==null) {
+ query=queryEnd=pound=-1;
+ queryParams=null;
} else {
- qp=queryParams;
+ query = origPath.indexOf('?');
+ pound = origPath.indexOf('#');
+ queryEnd = pound>=0?pound:path.length();
+ if(oneCallQueryParams==null) {
+ if(query>=0) {
+ queryParams = path.substring(query+1,queryEnd);
+ } else {
+ queryParams=null;
+ }
+ } else {
+ if(query>=0) {
+ queryParams = oneCallQueryParams + '&' + path.substring(query+1,queryEnd);
+ } else {
+ queryParams = oneCallQueryParams;
+ }
+ oneCallQueryParams = null;
+ }
+ }
+ }
+
+ public String path() {
+ if(query>=0) {
+ if(pound>=0) {
+ return path.substring(pound+1);
+ }
+ return path.substring(0,query);
+ } else if(pound>=0) {
+ return path.substring(0,pound);
+ } else {
+ return path;
+ }
+ }
+
+ public String query() {
+ return queryParams;
+ }
+
+ public String frag() {
+ if(pound>=0) {
+ return path.substring(pound+1);
+ } else {
+ return null;
}
}
- return qp;
}
public String toString() {
return uri.toString();
}
- /**
- * @param queryParams the queryParams to set
- * @return
- */
- public Rcli<CT> setQueryParams(String queryParams) {
- this.queryParams = queryParams;
- return this;
- }
-
-
- /**
- * @param fragment the fragment to set
- * @return
- */
- public Rcli<CT> setFragment(String fragment) {
- this.fragment = fragment;
- return this;
- }
-
public URI getURI() {
return uri;
}
+ public void setQueryParams(final String queryParams) {
+ oneCallQueryParams=queryParams;
+ }
+
}
\ No newline at end of file
--- /dev/null
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * 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.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.cadi.enduser;
+
+import java.io.IOException;
+import java.net.ConnectException;
+import java.security.Principal;
+
+import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.LocatorException;
+import org.onap.aaf.cadi.client.Future;
+import org.onap.aaf.cadi.client.Rcli;
+import org.onap.aaf.cadi.client.Result;
+import org.onap.aaf.cadi.client.Retryable;
+import org.onap.aaf.cadi.config.Config;
+import org.onap.aaf.cadi.oauth.TimedToken;
+import org.onap.aaf.cadi.oauth.TokenClient;
+import org.onap.aaf.cadi.oauth.TokenClientFactory;
+import org.onap.aaf.cadi.oauth.TzClient;
+import org.onap.aaf.cadi.principal.TaggedPrincipal;
+import org.onap.aaf.misc.env.APIException;
+
+public class SimpleRESTClient {
+ private static final String[] EMPTY = new String[0];
+ private final TokenClient tokenClient;
+ private final TzClient restClient;
+ private int callTimeout;
+ private String client_id;
+ private String app;
+ private String chain;
+ private Headers headers = new Headers() {
+ @Override
+ public String[] headers() {
+ return EMPTY;
+ }};
+
+ public SimpleRESTClient(final TokenClientFactory tcf, final String tokenURL, final String endpoint, final String[] scope) throws CadiException, LocatorException, APIException {
+ callTimeout = Integer.parseInt(tcf.access.getProperty(Config.AAF_CALL_TIMEOUT,Config.AAF_CALL_TIMEOUT_DEF));
+ tokenClient = tcf.newClient(tokenURL);
+ Result<TimedToken> rtt = tokenClient.getToken(scope);
+ if(rtt.isOK()) {
+ restClient = tcf.newTzClient(endpoint);
+
+ if((client_id = tcf.access.getProperty(Config.AAF_APPID, null))==null) {
+ if((client_id = tcf.access.getProperty(Config.CADI_ALIAS, null))==null) {
+ throw new CadiException(Config.AAF_APPID + " or " + Config.CADI_ALIAS + " needs to be defined");
+ }
+ }
+ try {
+ restClient.setToken(client_id,rtt.value);
+ } catch (IOException e) {
+ throw new CadiException(e);
+ }
+ } else {
+ throw new CadiException(rtt.error);
+ }
+ }
+
+ public SimpleRESTClient timeout(int newTimeout) {
+ callTimeout = newTimeout;
+ return this;
+ }
+
+ //Format:<ID>:<APP>:<protocol>[:AS][,<ID>:<APP>:<protocol>]*
+ public SimpleRESTClient as(Principal principal) {
+ if(principal==null) {
+ chain = null;
+ } else {
+ if(principal instanceof TaggedPrincipal) {
+ TaggedPrincipal tp = (TaggedPrincipal)principal;
+ chain = tp.getName() + ':' + (app==null?"":app) + ':' + tp.tag() + ":AS";
+ } else {
+ chain = principal.getName() + (app==null?"":':'+app);
+ }
+ }
+ return this;
+ }
+
+ public String get(final String path) throws CadiException, LocatorException, APIException {
+ return get(path,"application/json");
+ }
+
+ public String get(final String path, final String accepts) throws CadiException, LocatorException, APIException {
+ return restClient.best(new Retryable<String>() {
+ @Override
+ public String code(Rcli<?> client) throws CadiException, ConnectException, APIException {
+ Future<String> future = client.read(path,accepts, headers());
+ if(future.get(callTimeout)) {
+ return future.value;
+ } else {
+ throw new APIException(future.code() + future.body());
+ }
+ }
+ });
+ }
+
+ public interface Headers {
+ String[] headers();
+ }
+
+ public String[] headers() {
+ if(chain==null) {
+ return headers.headers();
+ } else {
+ String[] strs = headers.headers();
+ String[] rv = new String[strs.length+2];
+ rv[0]=Config.CADI_USER_CHAIN;
+ rv[1]=chain;
+ for(int i = 0;i<strs.length;++i) {
+ rv[i+2]=strs[i];
+ }
+ return rv;
+ }
+ }
+}