Juan Hernandez has posted comments on this change.
Change subject: restapi: Return Additional Info For 400 Messages (#867794)
......................................................................
Patch Set 1:
(5 comments)
....................................................
File
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/UsageFinder.java
Line 31: if (isMatch(link, uriInfo, httpMethod)) {
Line 32: return link;
Line 33: }
Line 34: }
Line 35: return null; // should never happen
Makes sense.
Line 36: }
Line 37:
Line 38: private RSDL getRSDL(Application application) {
Line 39: for (Object obj : application.getSingletons()) {
Line 34: }
Line 35: return null; // should never happen
Line 36: }
Line 37:
Line 38: private RSDL getRSDL(Application application) {
Unfortunately we don't have a generic injection mechanism yet. If we had then
we should use it to inject the reference to the RSDL manager where needed.
As we don't have this injection capabilities I think that we can use the "poor
man injection", just an old style singleton.
So the users will access the RSDL as follows:
RSDL rsdl = RSDLManager.getInstance().getRSDL();
I think that the only problem for doing this is that the hrefs inside the RSDL
depend on the path where the application is deployed, so the RSDLManager needs
to know this. We can solve that with a method that receives that prefix:
String prefix = getThePrefixFromTheInjectedUriInfo(...),
RSDL rsdl = RSDLManager.getInstance().getRSDL(prefix);
The RSDLManager can then have a map of RSDL objects indexed by prefix, or can
build them on the fly using the given prefix.
One of the reasons why I think this is needed is because we need to be able to
generate the RSDL document without starting the engine, during the build
process. If we have a class like this RSDL manager, and if it doesn't depend on
the runtime environment, then we can do it. Say that we put that code in a
"main" method. We could then run that main method as part of the maven build to
generate the RSDL document, and then we can use that generated RSDL document to
regenerate the SDKs.
Line 39: for (Object obj : application.getSingletons()) {
Line 40: if (obj instanceof BackendApiResource) {
Line 41: BackendApiResource resource = (BackendApiResource) obj;
Line 42: return resource.getRSDL();
....................................................
File
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/rsdl/RsdlBuilder.java
Line 90:
Line 91: private static final String RESOURCES_PACKAGE =
"org.ovirt.engine.api.resource";
Line 92: private static final String PARAMS_METADATA = "rsdl_metadata.yaml";
Line 93:
Line 94: public RsdlBuilder(UriInfo uriInfo, ApplicationMode
applicationMode) {
Ok.
Line 95: this.uriInfo = uriInfo;
Line 96: this.applicationMode = applicationMode;
Line 97: this.parametersMetaData = loadParametersMetaData();
Line 98: }
Line 249: applicationMode == ApplicationMode.GlusterOnly ?
ApiUtils.getGlusterRels(uriInfo)
Line 250: : ApiUtils.getAllRels(uriInfo);
Line 251: for (String path : paths) {
Line 252: Class<?> resource = findResource(path, classes);
Line 253: String entryPointPath = uriInfo.getBaseUri().getPath();
Not in this case. The compiler can't know that the call to
uriInfo.getBaseUri().getPath() will always return the same value.
Line 254: String prefix = entryPointPath.endsWith("/") ?
entryPointPath + path : entryPointPath + "/" + path;
Line 255: results.addAll(describe(resource, prefix, new
HashMap<String, Type>()));
Line 256: }
Line 257: return results;
....................................................
File
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/ApiUtils.java
Line 13: import org.ovirt.engine.api.model.Link;
Line 14: import org.ovirt.engine.api.model.Parameter;
Line 15: import org.ovirt.engine.api.model.ParametersSet;
Line 16:
Line 17: public class ApiUtils {
You are right, maybe something related to "links".
Line 18:
Line 19: public static Collection<DetailedLink> getLinks(UriInfo uriInfo) {
Line 20: Collection<DetailedLink> links = new
LinkedList<DetailedLink>();
Line 21: links.add(createLink("capabilities", uriInfo));
--
To view, visit http://gerrit.ovirt.org/23017
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ic7a6da4fbb00ea5f1e6919ddfe21dd7b3dd126fd
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Ori Liel <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Michael Pasternak <[email protected]>
Gerrit-Reviewer: Ori Liel <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches