KomodoVdbService extends KomodoService { @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.TRANSLATORS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.TRANSLATOR_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the named translator belonging to the vdb", response = RestVdbTranslator.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No translator could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) public Response getTranslator( final @Context HttpHeaders headers, final @Context UriInfo uriInfo, @ApiParam(value = "Name of the Vdb", required = true) final @PathParam( "vdbName" ) String vdbName, @ApiParam(value = "Name of the translator to be fetched", required = true) final @PathParam( "translatorName" ) String translatorName) throws KomodoRestException { SecurityPrincipal principal = checkSecurityContext(headers); if (principal.hasErrorResponse()) return principal.getErrorResponse(); List<MediaType> mediaTypes = headers.getAcceptableMediaTypes(); UnitOfWork uow = null; try { uow = createTransaction(principal, "getTranslator", true ); Vdb vdb = findVdb(uow, vdbName); if (vdb == null) return commitNoVdbFound(uow, mediaTypes, vdbName); Translator[] translators = vdb.getTranslators(uow); if (translators == null || translators.length == 0) { LOGGER.debug("getTranslators:No translators found for vdb '{0}'", vdbName); String resourceName = uri(vdbName, TRANSLATORS_SEGMENT, translatorName); return commit(uow, mediaTypes, new ResourceNotFound(resourceName, Messages.getString(GET_OPERATION_NAME))); } Translator translator = null; for (Translator tr : translators) { if (translatorName.equals(tr.getName(uow))) { translator = tr; break; } } if (translator == null) { return commit(uow, mediaTypes, new ResourceNotFound(uri(vdbName, V1Constants.TRANSLATORS_SEGMENT, translatorName), Messages.getString( GET_OPERATION_NAME))); } RestVdbTranslator restTranslator = entityFactory.create(translator, uriInfo.getBaseUri(), uow); LOGGER.debug("getTranslator:Translator '{0}' from VDB '{1}' entity was constructed", translatorName, vdbName); return commit( uow, mediaTypes, restTranslator); } catch ( final Exception e ) { if ( ( uow != null ) && ( uow.getState() != State.ROLLED_BACK ) ) { uow.rollback(); } if ( e instanceof KomodoRestException ) { throw ( KomodoRestException )e; } return createErrorResponseWithForbidden(mediaTypes, e, VDB_SERVICE_GET_TRANSLATOR_ERROR, translatorName, vdbName); } } KomodoVdbService( final KEngine engine ); @POST @Path( StringConstants.FORWARD_SLASH + V1Constants.VDB_PLACEHOLDER ) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Create a vdb in the workspace") @ApiResponses(value = { @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response createVdb( final @Context HttpHeaders headers,
                               final @Context UriInfo uriInfo,
                               @ApiParam(
                                         value = "Name of the Vdb to be created",
                                         required = true
                               )
                               final @PathParam( "vdbName" ) String vdbName,
                               @ApiParam(
                                         value = "" + 
                                                 "JSON of the properties of the Vdb to add:<br>" +
                                                 OPEN_PRE_TAG +
                                                 OPEN_BRACE + BR +
                                                 NBSP + "keng\\_\\_id: \"name of the Vdb\"" + COMMA + BR +
                                                 NBSP + "vdb\\_\\_name: \"name of the Vdb\"" + COMMA + BR +
                                                 NBSP + "keng\\_\\_dataPath: \"path of Vdb to create\"" + COMMA + BR +
                                                 NBSP + OPEN_PRE_CMT + "(eg keng\\_\\_dataPath: \"tko:komodo\\tko:workspace\\\\{username\\}\\\\{vdbName\\}\")" + CLOSE_PRE_CMT + BR +
                                                 NBSP + "vdb\\_\\_originalFile: \"original file location\"" + COMMA + BR +
                                                 NBSP + OPEN_PRE_CMT + "(same value as keng\\_\\_dataPath)" + CLOSE_PRE_CMT + BR +
                                                 NBSP + "keng\\_\\_kType: \"Vdb\"" + BR +
                                                 CLOSE_BRACE +
                                                 CLOSE_PRE_TAG,
                                         required = true
                               )
                               final String vdbJson); @PUT @Path( StringConstants.FORWARD_SLASH + V1Constants.VDB_PLACEHOLDER ) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Update a vdb in the workspace") @ApiResponses(value = { @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response updateVdb( final @Context HttpHeaders headers,
                               final @Context UriInfo uriInfo,
                               @ApiParam(
                                         value = "Name of the Vdb to be updated",
                                         required = true
                               )
                               final @PathParam( "vdbName" ) String vdbName,
                               @ApiParam(
                                         value = "" + 
                                                 "JSON of the properties of the Vdb to update:<br>" +
                                                 OPEN_PRE_TAG +
                                                 OPEN_BRACE + BR +
                                                 NBSP + "keng\\_\\_id: \"name of the Vdb\"" + COMMA + BR +
                                                 NBSP + "vdb\\_\\_name: \"name of the Vdb\"" + COMMA + BR +
                                                 NBSP + "keng\\_\\_dataPath: \"path of Vdb to update\"" + COMMA + BR +
                                                 NBSP + OPEN_PRE_CMT + "(eg keng\\_\\_dataPath: \"tko:komodo\\tko:workspace\\\\{username\\}\\\\{vdbName\\}\")" + CLOSE_PRE_CMT + BR +
                                                 NBSP + "vdb\\_\\_originalFile: \"original file location\"" + COMMA + BR +
                                                 NBSP + OPEN_PRE_CMT + "(same value as keng\\_\\_dataPath)" + CLOSE_PRE_CMT + BR +
                                                 NBSP + "keng\\_\\_kType: \"Vdb\"" + BR +
                                                 CLOSE_BRACE +
                                                 CLOSE_PRE_TAG,
                                         required = true
                               )
                               final String vdbJson); @POST @Path( StringConstants.FORWARD_SLASH + V1Constants.CLONE_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.VDB_PLACEHOLDER ) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Clone a VDB in the workspace") @ApiResponses(value = { @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response cloneVdb( final @Context HttpHeaders headers,
                              final @Context UriInfo uriInfo,
                              @ApiParam(
                                        value = "Name of the Vdb to be cloned",
                                        required = true
                              )
                              final @PathParam( "vdbName" ) String vdbName,
                              @ApiParam(
                                        value = "name of the new Vdb", 
                                        required = true
                              )
                              final String newVdbName); @DELETE @Path("{vdbName}") @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Delete a vdb from the workspace") @ApiResponses(value = { @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response deleteVdb( final @Context HttpHeaders headers,
                               final @Context UriInfo uriInfo,
                               @ApiParam(
                                         value = "Name of the Vdb to be removed",
                                         required = true
                               )
                               final @PathParam( "vdbName" ) String vdbName); @GET @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Display the collection of vdbs", response = RestVdb[].class) @ApiResponses(value = { @ApiResponse(code = 403, message = "An error has occurred.") }) Response getVdbs( final @Context HttpHeaders headers,
                             final @Context UriInfo uriInfo ); @GET @Path( V1Constants.VDB_PLACEHOLDER ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @ApiOperation(value = "Find vdb by name", response = RestVdb.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 406, message = "Only JSON or XML is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getVdb( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb to be fetched", required = true)
                            final @PathParam( "vdbName" ) String vdbName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT ) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find all models belonging to the vdb", response = RestVdb.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 200, message = "No models could be found but an empty list is returned"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getModels( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the named model belonging to the vdb", response = RestVdbModel.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No model could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getModel( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Model to be fetched", required = true)
                            final @PathParam( "modelName" ) String modelName); @POST @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Create a Model in a VDB") @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response createModel( final @Context HttpHeaders headers,
                                 final @Context UriInfo uriInfo,
                                 @ApiParam(
                                           value = "Name of the Vdb",
                                           required = true
                                 )
                                 final @PathParam( "vdbName" ) String vdbName,
                                 @ApiParam(
                                           value = "Name of the Model",
                                           required = true
                                 )
                                 final @PathParam( "modelName" ) String modelName,
                                 @ApiParam(
                                           value = "" + 
                                                   "JSON of the properties of the Model to add:<br>" +
                                                   OPEN_PRE_TAG +
                                                   OPEN_BRACE + BR +
                                                   NBSP + "keng\\_\\_id: \"name of the Model\"" + COMMA + BR +
                                                   NBSP + "keng\\_\\_dataPath: \"path of Model to create\"" + COMMA + BR +
                                                   NBSP + OPEN_PRE_CMT + "(eg keng\\_\\_dataPath: \"tko:komodo\\tko:workspace\\\\{username\\}\\\\{vdbName\\}\\\\{modelName\\}\")" + CLOSE_PRE_CMT + BR +
                                                   NBSP + "keng\\_\\_kType: \"Model\"" + BR +
                                                   CLOSE_BRACE +
                                                   CLOSE_PRE_TAG,
                                           required = true
                                 )
                                 final String modelJson); @PUT @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Update a Model in the VDB") @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No model could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response updateModel( final @Context HttpHeaders headers,
                                 final @Context UriInfo uriInfo,
                                 @ApiParam(
                                           value = "Name of the Vdb",
                                           required = true
                                 )
                                 final @PathParam( "vdbName" ) String vdbName,
                                 @ApiParam(
                                           value = "Name of the Model to be updated",
                                           required = true
                                 )
                                 final @PathParam( "modelName" ) String modelName,
                                 @ApiParam(
                                           value = "" + 
                                                   "JSON of the properties of the Model to update:<br>" +
                                                   OPEN_PRE_TAG +
                                                   OPEN_BRACE + BR +
                                                   NBSP + "keng\\_\\_id: \"name of the Model\"" + COMMA + BR +
                                                   NBSP + "keng\\_\\_dataPath: \"path of Model to update\"" + COMMA + BR +
                                                   NBSP + OPEN_PRE_CMT + "(eg keng\\_\\_dataPath: \"tko:komodo\\tko:workspace\\\\{username\\}\\\\{vdbName\\}\\\\{modelName\\}\")" + CLOSE_PRE_CMT + BR +
                                                   NBSP + "keng\\_\\_kType: \"Model\"" + BR +
                                                   CLOSE_BRACE +
                                                   CLOSE_PRE_TAG,
                                           required = true
                                 )
                                 final String modelJson); @DELETE @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Delete a Model from the VDB") @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No model could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response deleteModel( final @Context HttpHeaders headers,
                                 final @Context UriInfo uriInfo,
                                 @ApiParam(
                                           value = "Name of the Vdb",
                                           required = true
                                 )
                                 final @PathParam( "vdbName" ) String vdbName,
                                 @ApiParam(
                                           value = "Name of the Model to remove",
                                           required = true
                                 )
                                 final @PathParam( "modelName" ) String modelName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.TRANSLATORS_SEGMENT ) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find all translators belonging to the Vdb", response = RestVdbTranslator[].class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 200, message = "No translators could be found but an empty list is returned"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getTranslators( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the VDB", required = true)
                            final @PathParam( "vdbName" ) String vdbName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.TRANSLATORS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.TRANSLATOR_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the named translator belonging to the vdb", response = RestVdbTranslator.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No translator could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getTranslator( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the translator to be fetched", required = true)
                            final @PathParam( "translatorName" ) String translatorName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.IMPORTS_SEGMENT ) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find all imports belonging to the vdb", response = RestVdbImport[].class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 200, message = "No imports could be found but an empty list is returned"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getImports( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.IMPORTS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.IMPORT_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the named vdb import belonging to the vdb", response = RestVdbImport.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No import could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getImport( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Vdb import to be fetched", required = true)
                            final @PathParam( "importName" ) String importName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLES_SEGMENT ) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find all data roles belonging to the vdb", response = RestBasicEntity[].class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 200, message = "No data roles could be found but an empty list is returned"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getDataRoles( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName); @POST @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLE_PLACEHOLDER ) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Create a VDB data role") @ApiResponses(value = { @ApiResponse(code = 404, message = "No VDB could be found with specified name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response createDataRole( final @Context HttpHeaders headers,
                                    final @Context UriInfo uriInfo,
                                    @ApiParam( value = "Name of the VDB", required = true ) 
                                    final @PathParam( "vdbName" ) String vdbName,
                                    @ApiParam( value = "Name of the data role", required = true )
                                    final @PathParam( "dataRoleId" ) String dataRoleName,
                                    @ApiParam( value = ""
                                                       + "JSON of the properties of the data role to add:<br>"
                                                       + OPEN_PRE_TAG
                                                       + OPEN_BRACE
                                                       + BR
                                                       + NBSP
                                                       + "keng\\_\\_id: \"name of the data role\""
                                                       + COMMA
                                                       + BR
                                                       + NBSP
                                                       + "keng\\_\\_dataPath: \"path of the data role to create\""
                                                       + COMMA
                                                       + BR
                                                       + NBSP
                                                       + OPEN_PRE_CMT
                                                       + "(eg keng\\_\\_dataPath: \"tko:komodo\\tko:workspace\\\\{username\\}\\\\{vdbName\\}\\vdb:dataRoles\\\\{dataRoleName\\}\")"
                                                       + CLOSE_PRE_CMT
                                                       + BR
                                                       + NBSP
                                                       + "keng\\_\\_kType: \"DataRole\""
                                                       + BR
                                                       + CLOSE_BRACE
                                                       + CLOSE_PRE_TAG, required = true )
                                    final String dataRoleJson ); @DELETE @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLE_PLACEHOLDER ) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation( value = "Delete a data role from the VDB" ) @ApiResponses( value = { @ApiResponse( code = 404, message = "No VDB could be found with name" ), @ApiResponse( code = 404, message = "No data role could be found with name" ), @ApiResponse( code = 406, message = "Only JSON is returned by this operation" ), @ApiResponse( code = 403, message = "An error has occurred." ) } ) Response deleteDataRole( final @Context HttpHeaders headers,
                                    final @Context UriInfo uriInfo,
                                    @ApiParam( value = "Name of the VDB", required = true ) final @PathParam( "vdbName" ) String vdbName,
                                    @ApiParam( value = "Name of the data role to remove", required = true ) final @PathParam( "dataRoleId" ) String dataRoleName ); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLE_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the named data role belonging to the vdb", response = RestVdbDataRole.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No data role could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getDataRole( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Data Role to be fetched", required = true)
                            final @PathParam( "dataRoleId" ) String dataRoleId); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.SOURCES_SEGMENT) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find all ModelSources belonging to the Vdb Model", response = RestVdbModelSource[].class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 200, message = "No sources could be found but an empty list is returned"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getModelSources( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Model to get its Sources", required = true)
                            final @PathParam( "modelName" ) String modelName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.SOURCES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.SOURCE_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the ModelSource belonging to the Vdb Model", response = RestVdbModelSource.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No model could be found with name"), @ApiResponse(code = 404, message = "No source could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getModelSource( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Model", required = true)
                            final @PathParam( "modelName" ) String modelName,
                            @ApiParam(value = "Name of the Model Source to be fetched", required = true)
                            final @PathParam( "sourceName" ) String sourceName); @POST @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.SOURCES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.SOURCE_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Create a ModelSource within a Vdb Model", response = RestVdbModelSource.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No model could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response createModelSource( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Model", required = true)
                            final @PathParam( "modelName" ) String modelName,
                            @ApiParam(value = "Name of the Model Source to be created", required = true)
                            final @PathParam( "sourceName" ) String sourceName,
                            @ApiParam(
                                      value = "" + 
                                              "JSON of the properties of the Model Source to add:<br>" +
                                              OPEN_PRE_TAG +
                                              OPEN_BRACE + BR +
                                              NBSP + "keng\\_\\_id: \"name of the VdbModelSource\"" + COMMA + BR +
                                              NBSP + "keng\\_\\_dataPath: \"path of VdbModelSource to create\"" + COMMA + BR +
                                              NBSP + OPEN_PRE_CMT + "(eg keng\\_\\_dataPath: \"tko:komodo\\tko:workspace\\\\{username\\}\\\\{vdbName\\}\\\\{modelName\\}\\vdb:sources\\\\{sourceName\\}\")" + CLOSE_PRE_CMT + BR +
                                              NBSP + "keng\\_\\_kType: \"VdbModelSource\"" + COMMA + BR +
                                              NBSP + "vdb\\_\\_sourceJndiName: \"the jndi name\"" + COMMA + BR +
                                              NBSP + "vdb\\_\\_sourceTranslator: \"the translator name\"" + BR +
                                              CLOSE_BRACE +
                                              CLOSE_PRE_TAG,
                                      required = true
                            )
                            final String sourceJson); @PUT @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.SOURCES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.SOURCE_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Update the ModelSource belonging to the Vdb Model", response = RestVdbModelSource.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No model could be found with name"), @ApiResponse(code = 404, message = "No source could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response updateModelSource( final @Context HttpHeaders headers,
                                       final @Context UriInfo uriInfo,
                                       @ApiParam(value = "Name of the Vdb", required = true)
                                       final @PathParam( "vdbName" ) String vdbName,
                                       @ApiParam(value = "Name of the Model", required = true)
                                       final @PathParam( "modelName" ) String modelName,
                                       @ApiParam(value = "Name of the Model Source to be updated", required = true)
                                       final @PathParam( "sourceName" ) String sourceName,
                                       @ApiParam(
                                                 value = "" + 
                                                         "JSON of the properties of the Model Source to update:<br>" +
                                                         OPEN_PRE_TAG +
                                                         OPEN_BRACE + BR +
                                                         NBSP + "keng\\_\\_id: \"name of the VdbModelSource\"" + COMMA + BR +
                                                         NBSP + "keng\\_\\_dataPath: \"path of VdbModelSource to update\"" + COMMA + BR +
                                                         NBSP + OPEN_PRE_CMT + "(eg keng\\_\\_dataPath: \"tko:komodo\\tko:workspace\\\\{username\\}\\\\{vdbName\\}\\\\{modelName\\}\\vdb:sources\\\\{sourceName\\}\")" + CLOSE_PRE_CMT + BR +
                                                         NBSP + "keng\\_\\_kType: \"VdbModelSource\"" + COMMA + BR +
                                                         NBSP + "vdb\\_\\_sourceJndiName: \"the jndi name\"" + COMMA + BR +
                                                         NBSP + "vdb\\_\\_sourceTranslator: \"the translator name\"" + BR +
                                                         CLOSE_BRACE +
                                                         CLOSE_PRE_TAG,
                                                 required = true
                                       )
                                       final String sourceJson); @DELETE @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.SOURCES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.SOURCE_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Delete the ModelSource in the specified Vdb Model", response = RestVdbModelSource.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 404, message = "No model could be found with name"), @ApiResponse(code = 404, message = "No source could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response deleteModelSource( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Model", required = true)
                            final @PathParam( "modelName" ) String modelName,
                            @ApiParam(value = "Name of the Model Source to be deleted", required = true)
                            final @PathParam( "sourceName" ) String sourceName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.TABLES_SEGMENT) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find all tables of the model belonging to the vdb", response = RestVdbModelTable[].class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 200, message = "No tables could be found but an empty list is returned"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getModelTables( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Model to get its tables", required = true)
                            final @PathParam( "modelName" ) String modelName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MODELS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MODEL_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.TABLES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.TABLE_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.COLUMNS_SEGMENT) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find all columns of the specified vdb model table", response = RestVdbModelTableColumn[].class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb could be found with name"), @ApiResponse(code = 200, message = "No tables could be found but an empty list is returned"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getModelTableColumns( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Model", required = true)
                            final @PathParam( "modelName" ) String modelName,
        	                @ApiParam(value = "Name of the Table to get its columns", required = true)
                            final @PathParam( "tableName" ) String tableName); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLE_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.PERMISSIONS_SEGMENT) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find all permissions belonging to the vdb data role", response = RestVdbPermission[].class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb or data role could be found with given names"), @ApiResponse(code = 200, message = "No permissions could be found but an empty list is returned"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getPermissions( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Data Role to get its permissions", required = true)
                            final @PathParam( "dataRoleId" ) String dataRoleId); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLE_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.PERMISSIONS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.PERMISSION_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the named permission belonging to the data role of the vdb", response = RestVdbPermission.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb, data role or permission could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getPermission( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Data Role", required = true)
                            final @PathParam( "dataRoleId" ) String dataRoleId,
                            @ApiParam(value = "Name of the Permission to be fetched", required = true)
                            final @PathParam( "permissionId" ) String permissionId); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLE_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.PERMISSIONS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.PERMISSION_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.CONDITIONS_SEGMENT) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the conditions belonging to the permission of the data role of the vdb", response = RestVdbPermission.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb, data role or permission could be found with given names"), @ApiResponse(code = 200, message = "No conditions could be found but an empty list is returned"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getConditions( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Data Role", required = true)
                            final @PathParam( "dataRoleId" ) String dataRoleId,
                            @ApiParam(value = "Name of the Permission to get its Conditions", required = true)
                            final @PathParam( "permissionId" ) String permissionId); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLE_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.PERMISSIONS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.PERMISSION_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.CONDITIONS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.CONDITION_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the condition belonging to the permission of the data role of the vdb", response = RestVdbPermission.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb, data role, permission or condition could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getCondition( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Data Role", required = true)
                            final @PathParam( "dataRoleId" ) String dataRoleId,
                            @ApiParam(value = "Name of the Permission", required = true)
                            final @PathParam( "permissionId" ) String permissionId,
                            @ApiParam(value = "Name of the Condition to be fetched", required = true)
                            final @PathParam( "conditionId" ) String conditionId); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLE_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.PERMISSIONS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.PERMISSION_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MASKS_SEGMENT) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the masks belonging to the permission of the data role of the vdb", response = RestVdbPermission.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb, data role or permission could be found with given names"), @ApiResponse(code = 200, message = "No masks could be found but an empty list is returned"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getMasks( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Data Role", required = true)
                            final @PathParam( "dataRoleId" ) String dataRoleId,
                            @ApiParam(value = "Name of the Permission to get its Masks", required = true)
                            final @PathParam( "permissionId" ) String permissionId); @GET @Path( V1Constants.VDB_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLES_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.DATA_ROLE_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.PERMISSIONS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.PERMISSION_PLACEHOLDER + StringConstants.FORWARD_SLASH + V1Constants.MASKS_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.MASK_PLACEHOLDER) @Produces( MediaType.APPLICATION_JSON ) @ApiOperation(value = "Find the mask belonging to the permission of the data role of the vdb", response = RestVdbPermission.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "No vdb, data role, permission or mask could be found with name"), @ApiResponse(code = 406, message = "Only JSON is returned by this operation"), @ApiResponse(code = 403, message = "An error has occurred.") }) Response getMask( final @Context HttpHeaders headers,
                            final @Context UriInfo uriInfo,
                            @ApiParam(value = "Name of the Vdb", required = true)
                            final @PathParam( "vdbName" ) String vdbName,
                            @ApiParam(value = "Name of the Data Role", required = true)
                            final @PathParam( "dataRoleId" ) String dataRoleId,
                            @ApiParam(value = "Name of the Permission", required = true)
                            final @PathParam( "permissionId" ) String permissionId,
                            @ApiParam(value = "Name of the Mask to be fetched", required = true)
                            final @PathParam( "maskId" ) String maskId); @GET @Path( V1Constants.NAME_VALIDATION_SEGMENT + StringConstants.FORWARD_SLASH + V1Constants.VDB_PLACEHOLDER ) @Produces( { MediaType.TEXT_PLAIN } ) @ApiOperation( value = "Returns an error message if the VDB name is invalid" ) @ApiResponses( value = { @ApiResponse( code = 400, message = "The URI cannot contain encoded slashes or backslashes." ), @ApiResponse( code = 403, message = "An unexpected error has occurred." ), @ApiResponse( code = 500, message = "The VDB name cannot be empty." ) } ) Response validateVdbName( final @Context HttpHeaders headers,
                                     final @Context UriInfo uriInfo,
                                     @ApiParam( value = "The VDB name being checked", required = true )
                                     final @PathParam( "vdbName" ) String vdbName );  }
@Test public void shouldCreateModelSource() throws Exception { final String vdbName = "blah"; { final Properties settings = _uriBuilder.createSettings(SettingNames.VDB_NAME, vdbName); _uriBuilder.addSetting(settings, SettingNames.VDB_PARENT_PATH, _uriBuilder.workspaceVdbsUri()); final URI uri = _uriBuilder.vdbUri(LinkType.SELF, settings); final RestVdb vdb = new RestVdb(); vdb.setName(vdbName); vdb.setDescription("blah VDB description"); vdb.setOriginalFilePath("/Users/elvis/vdbs/blah.vdb"); vdb.setPreview(false); vdb.setConnectionType("connType"); vdb.setVersion(1); vdb.setId(vdbName); vdb.setkType(KomodoType.VDB); vdb.setDataPath("/tko:komodo/tko:workspace/user/blah"); final String json = KomodoJsonMarshaller.marshall(vdb); final ClientRequest request = request(uri, MediaType.APPLICATION_JSON_TYPE); addBody(request, json); final ClientResponse<String> response = request.post(String.class); assertThat(response, is(notNullValue())); assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode())); } final String modelName = "elvis"; { final RestVdbModel model = new RestVdbModel(); model.setDataPath("/tko:komodo/tko:workspace/user/blah/elvis"); model.setDdl("CREATE VIEW Tweet AS select * FROM twitterview.getTweets;"); model.setDescription("model description goes here"); model.setId(modelName); model.setkType(KomodoType.MODEL); model.setMetadataType("DDL"); model.setModelType(Type.VIRTUAL); model.setVisible(true); final Properties settings = _uriBuilder.createSettings(SettingNames.VDB_NAME, vdbName); _uriBuilder.addSetting(settings, SettingNames.VDB_PARENT_PATH, _uriBuilder.workspaceVdbsUri()); _uriBuilder.addSetting(settings, SettingNames.MODEL_NAME, modelName); final URI uri = _uriBuilder.vdbModelUri(LinkType.SELF, settings); final String json = KomodoJsonMarshaller.marshall(model); final ClientRequest request = request(uri, MediaType.APPLICATION_JSON_TYPE); addBody(request, json); final ClientResponse<String> response = request.post(String.class); assertThat(response, is(notNullValue())); assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode())); } final String modelSourceName = "sledge"; final String id = modelSourceName; final String dataPath = "/tko:komodo/tko:workspace/user/blah/elvis/vdb:sources/sledge"; final KomodoType kType = KomodoType.VDB_MODEL_SOURCE; final String jndiName = "myJndiName"; final String translator = "myTranslator"; final Properties settings = _uriBuilder.createSettings(SettingNames.VDB_NAME, vdbName); _uriBuilder.addSetting(settings, SettingNames.VDB_PARENT_PATH, _uriBuilder.workspaceVdbsUri()); _uriBuilder.addSetting(settings, SettingNames.MODEL_NAME, modelName); _uriBuilder.addSetting(settings, SettingNames.SOURCE_NAME, modelSourceName); final URI uri = _uriBuilder.vdbModelSourceUri(LinkType.SELF, settings); { final RestVdbModelSource inModelSource = new RestVdbModelSource(); inModelSource.setDataPath(dataPath); inModelSource.setId(id); inModelSource.setkType(kType); inModelSource.setJndiName(jndiName); inModelSource.setTranslator(translator); final String json = KomodoJsonMarshaller.marshall(inModelSource); final ClientRequest request = request(uri, MediaType.APPLICATION_JSON_TYPE); addBody(request, json); final ClientResponse<String> response = request.post(String.class); assertThat(response, is(notNullValue())); assertThat(response.getStatus(), is(Response.Status.OK.getStatusCode())); final String entity = response.getEntity(); assertThat(entity, is(notNullValue())); final RestVdbModelSource outModelSource = KomodoJsonMarshaller.unmarshall(entity, RestVdbModelSource.class); assertNotNull(outModelSource); assertThat(outModelSource.getDataPath(), is(dataPath)); assertThat(outModelSource.getId(), is(id)); assertThat(outModelSource.getkType(), is(kType)); assertThat(outModelSource.getJndiName(), is(jndiName)); assertThat(outModelSource.getTranslator(), is(translator)); } { final ClientRequest request = request(uri, MediaType.APPLICATION_JSON_TYPE); final ClientResponse<String> response = request.get(String.class); assertThat(response.getStatus(), is(Status.OK.getStatusCode())); final String entity = response.getEntity(); assertThat(entity, is(notNullValue())); final RestVdbModelSource newModelSource = KomodoJsonMarshaller.unmarshall(entity, RestVdbModelSource.class); assertNotNull(newModelSource); assertThat(newModelSource.getDataPath(), is(dataPath)); assertThat(newModelSource.getId(), is(id)); assertThat(newModelSource.getkType(), is(kType)); assertThat(newModelSource.getJndiName(), is(jndiName)); assertThat(newModelSource.getTranslator(), is(translator)); } }
@Test public void shouldGetVdbModelSources() throws Exception { loadVdbs(); Properties settings = _uriBuilder.createSettings(SettingNames.VDB_NAME, TestUtilities.PORTFOLIO_VDB_NAME); _uriBuilder.addSetting(settings, SettingNames.VDB_PARENT_PATH, _uriBuilder.workspaceVdbsUri()); _uriBuilder.addSetting(settings, SettingNames.MODEL_NAME, "PersonalValuations"); URI uri = _uriBuilder.vdbModelUri(LinkType.SOURCES, settings); ClientRequest request = request(uri, MediaType.APPLICATION_JSON_TYPE); ClientResponse<String> response = request.get(String.class); final String entities = response.getEntity(); assertThat(entities, is(notNullValue())); RestVdbModelSource[] sources = KomodoJsonMarshaller.unmarshallArray(entities, RestVdbModelSource[].class); assertEquals(1, sources.length); RestVdbModelSource source = sources[0]; assertEquals("excelconnector", source.getId()); assertEquals(KomodoType.VDB_MODEL_SOURCE, source.getkType()); assertEquals("java:/excel-file", source.getJndiName()); assertEquals("excel", source.getTranslator()); Collection<RestLink> links = source.getLinks(); assertEquals(3, links.size()); }
@Test public void shouldGetVdbModelSourcesIncludeReferenceForTranslator() throws Exception { loadVdbs(); Properties settings = _uriBuilder.createSettings(SettingNames.VDB_NAME, TestUtilities.TWEET_EXAMPLE_VDB_NAME); _uriBuilder.addSetting(settings, SettingNames.VDB_PARENT_PATH, _uriBuilder.workspaceVdbsUri()); _uriBuilder.addSetting(settings, SettingNames.MODEL_NAME, "twitter"); URI uri = _uriBuilder.vdbModelUri(LinkType.SOURCES, settings); ClientRequest request = request(uri, MediaType.APPLICATION_JSON_TYPE); ClientResponse<String> response = request.get(String.class); final String entities = response.getEntity(); assertThat(entities, is(notNullValue())); RestVdbModelSource[] sources = KomodoJsonMarshaller.unmarshallArray(entities, RestVdbModelSource[].class); assertEquals(1, sources.length); RestVdbModelSource source = sources[0]; assertEquals("twitter", source.getId()); assertEquals(KomodoType.VDB_MODEL_SOURCE, source.getkType()); assertEquals("java:/twitterDS", source.getJndiName()); assertEquals("rest", source.getTranslator()); Collection<RestLink> links = source.getLinks(); assertEquals(4, links.size()); RestLink refLink = null; for (RestLink link : links) { if (LinkType.REFERENCE.equals(link.getRel())) refLink = link; } assertNotNull(refLink); URI href = refLink.getHref(); assertTrue(href.toString().endsWith("workspace/vdbs/twitter/VdbTranslators/rest")); }
@Test public void shouldGetVdbModelSource() throws Exception { loadVdbs(); Properties settings = _uriBuilder.createSettings(SettingNames.VDB_NAME, TestUtilities.PORTFOLIO_VDB_NAME); _uriBuilder.addSetting(settings, SettingNames.VDB_PARENT_PATH, _uriBuilder.workspaceVdbsUri()); _uriBuilder.addSetting(settings, SettingNames.MODEL_NAME, "PersonalValuations"); _uriBuilder.addSetting(settings, SettingNames.SOURCE_NAME, "excelconnector"); URI uri = _uriBuilder.vdbModelSourceUri(LinkType.SELF, settings); ClientRequest request = request(uri, MediaType.APPLICATION_JSON_TYPE); ClientResponse<String> response = request.get(String.class); final String entity = response.getEntity(); assertThat(entity, is(notNullValue())); RestVdbModelSource source = KomodoJsonMarshaller.unmarshall(entity, RestVdbModelSource.class); assertNotNull(source); assertEquals("excelconnector", source.getId()); assertEquals(KomodoType.VDB_MODEL_SOURCE, source.getkType()); assertEquals("java:/excel-file", source.getJndiName()); assertEquals("excel", source.getTranslator()); Collection<RestLink> links = source.getLinks(); assertEquals(3, links.size()); }