Closed wwerner closed 4 years ago
It it not the wrong command that is triggered first but the handler before.
PATCH /organizations/<orgId>/units/<unitId>/contexts/<contextId>/schemas/<schemaId>/versions/<schemaVersionId>/description
is getting handled by UnitResource.describeAs
mapped to /organizations/{organizationId}/units/{unitId}/description
instead of by SchemaVersionResource.describeAs
mapped to /organizations/{organizationId}/units/{unitId}/contexts/{contextId}/schemas/{schemaId}/versions/{schemaVersionId}/description
The {unitId}
param is set to everything in between unitId/
and /description
, so GridAddressFactory
tries to parse a UUID from a string like <UUID>/schemas/<UUID>/versions/<UUID>
.
I'd guess that sth. in the way resource URLs are matched is broken.
Here are the relevant mappings as logged when starting the server:
Action: id=0, method=PATCH, uri=/organizations/{organizationId}/units/{unitId}/contexts/{contextId}/schemas/{schemaId}/versions/{schemaVersionId}/description, to=dynamic1(String organizationId, String unitId, String contextId, String schemaId, String schemaVersionId)
-> should handle the requestAction: id=0, method=PATCH, uri=/organizations/{organizationId}/units/{unitId}/description, to=dynamic1(String organizationId, String unitId)
-> actually does handle it@wwerner Suggestion. Register the resources with the same pattern, but that are lengthier URIs, earlier:
Resources allResources = Resources.are(
organizationResource.routes(),
unitResource.routes(),
contextResource.routes(),
schemaResource.routes(),
schemaVersionResource.routes(),
codeResource.routes(),
uiResource.routes()
);
Becomes:
Resources allResources = Resources.are(
schemaVersionResource.routes(),
schemaResource.routes(),
contextResource.routes(),
unitResource.routes(),
organizationResource.routes(),
codeResource.routes(),
uiResource.routes()
);
Let me know if this fixes the problem. I think it will and should be documented as a requirement.
For updates to the schema version's description, an Exception is thrown:
It seems that instead of
describeAs
inSchemaVersionCommands
, the command of the same name inUnitCommands
is called. I currently can't see where this comes from.To reproduce, create an org/unit/context/schema/schemaVersion and request the following:
with a body of
updated description
.Note that the content type needs to be
application/json
instead oftext/plain
, see https://github.com/vlingo/vlingo-http/issues/49The analogue to update a schema version specification works as expected:
Interesting to note that it calls a command of the same name but in a different class. The handler does reference the correct command in SchemaVersion commands.