Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
TEIIDTOOLS-549 Updates rest method naming for syndesis (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin authored and rareddy committed Dec 10, 2018
1 parent 0220b23 commit 8e3c777
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 68 deletions.
Expand Up @@ -595,9 +595,14 @@ public static String version() {
String PING_TYPE_PARAMETER = "pingType"; //$NON-NLS-1$

/**
* Available sources from OpenShift Service catalog
* syndesis source segment
*/
String SERVICE_CATALOG_SOURCES = "serviceCatalogSources"; //$NON-NLS-1$
String SYNDESIS_SOURCE = "syndesisSource"; //$NON-NLS-1$

/**
* syndesis sources segment
*/
String SYNDESIS_SOURCES = "syndesisSources"; //$NON-NLS-1$

/**
* Bind to available source in OpenShift Service catalog
Expand Down
Expand Up @@ -224,9 +224,9 @@ public enum Info {
CONNECTION_TO_REPO_SUCCESS,

/**
* Bind operation with Service Catalog Data Source
* Bind operation with Syndesis Source
*/
METADATA_SERVICE_CATALOG_DATA_SERVIVE_BIND_TITLE;
METADATA_SYNDESIS_SOURCE_BIND_TITLE;

/**
* {@inheritDoc}
Expand Down Expand Up @@ -1451,24 +1451,24 @@ public enum Error {
IMPORT_EXPORT_SERVICE_NO_NAMED_GIT_REPO_ERROR,

/**
* An error indicating the failed status of to get a data services from service catalog
* An error indicating the failed status of to get syndesis sources
*/
METADATA_GET_DATA_SOURCES_ERROR,
METADATA_GET_SYNDESIS_SOURCES_ERROR,

/**
* An error indicating a name of data service missing from bind operation on service catalog service
* An error indicating a name of syndesis source missing from bind operation
*/
METADATA_DATA_SERVICE_BIND_MISSING_NAME,
METADATA_SYNDESIS_SOURCE_BIND_MISSING_NAME,

/**
* An error indicating payload parse error from bind operation on service catalog service
* An error indicating payload parse error from bind operation
*/
METADATA_DATA_SERVICE_BIND_PARSE_ERROR,
METADATA_SYNDESIS_SOURCE_BIND_PARSE_ERROR,

/**
* An error indicating from bind operation on service catalog service
*/
METADATA_DATA_SERVIVE_BIND_ERROR,
METADATA_SYNDESIS_SOURCE_BIND_ERROR,

/**
* An error indicating the about service failed
Expand Down
Expand Up @@ -237,7 +237,6 @@ public RestMetadataConnection createMetadataDataSource(UnitOfWork transaction, R
TeiidDataSource teiidDataSource, URI baseUri)
throws Exception {
checkTransaction(transaction);
ArgCheck.isTrue(transaction.isRollbackOnly(), "transaction should be rollback-only");

KomodoObject parent = createTemporaryParent(transaction, repository, null);
Connection connection = RelationalModelFactory.createConnection(transaction, repository,parent.getAbsolutePath(), teiidDataSource.getName());
Expand Down
Expand Up @@ -1033,20 +1033,6 @@ public Response copyConnectionsIntoRepo( final @Context HttpHeaders headers,
String title = RelationalMessages.getString(RelationalMessages.Info.CONNECTION_TO_REPO_STATUS_TITLE);
KomodoStatusObject status = new KomodoStatusObject(title);

// Remove any connections that dont belong to user. Compile list of remaining workspace connections
for(Connection workspaceConn : workspaceConns) {
// Connections not belonging to user are removed
if(workspaceConn.hasProperty(uow, DSB_PROP_SERVICE_SOURCE)) {
String owner = workspaceConn.getProperty(uow, DSB_PROP_SERVICE_SOURCE).getStringValue(uow);
if(! uow.getUserName().equals(owner)) {
mgr.delete(uow, workspaceConn);
continue;
}
}

workspaceConnNames.add(workspaceConn.getName(uow));
}

// Copy the teiid connection into the workspace, if no workspace connection with the same name
for(TeiidDataSource teiidConn : teiidConns) {
String name = teiidConn.getName();
Expand Down Expand Up @@ -2492,12 +2478,22 @@ public Response getConnectionTemplateEntries(final @Context HttpHeaders headers,
}
}

/**
* Get the syndesis sources
* @param headers
* the request headers (never <code>null</code>)
* @param uriInfo
* the request URI information (never <code>null</code>)
* @return a JSON document representing all syndesis connections (never <code>null</code>)
* @throws KomodoRestException
* if there is a problem constructing the JSON document
*/
@GET
@Path(V1Constants.SERVICE_CATALOG_SOURCES)
@Path(V1Constants.SYNDESIS_SOURCES)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Display the collection of a", response = RestSyndesisDataSource[].class)
@ApiOperation(value = "Display the collection of syndesis sources", response = RestSyndesisDataSource[].class)
@ApiResponses(value = { @ApiResponse(code = 403, message = "An error has occurred.") })
public Response getServiceCatalogSources(final @Context HttpHeaders headers, final @Context UriInfo uriInfo)
public Response getSyndesisSources(final @Context HttpHeaders headers, final @Context UriInfo uriInfo)
throws KomodoRestException {

SecurityPrincipal principal = checkSecurityContext(headers);
Expand All @@ -2509,19 +2505,19 @@ public Response getServiceCatalogSources(final @Context HttpHeaders headers, fin

try {
Repository repo = this.kengine.getDefaultRepository();
uow = createTransaction(principal, "availableSources", true); //$NON-NLS-1$
uow = createTransaction(principal, "getSyndesisSources", true); //$NON-NLS-1$

// Get OpenShift based available data services
// Get OpenShift based syndesis sources
Collection<SyndesisDataSource> dataSources = this.openshiftClient.getSyndesisSources(getAuthenticationToken());
LOGGER.info("serviceCatalogSources '{0}' DataSources", dataSources.size()); //$NON-NLS-1$
LOGGER.info("syndesisSources - '{0}' Sources", dataSources.size()); //$NON-NLS-1$

final List<RestSyndesisDataSource> entities = new ArrayList<>();

for (SyndesisDataSource dataSource : dataSources) {
RestSyndesisDataSource entity = entityFactory.createServiceCatalogDataSource(uow, repo,
dataSource, uriInfo.getBaseUri());
entities.add(entity);
LOGGER.info("serviceCatalogSources:Data Source '{0}' entity was constructed", dataSource.getName()); //$NON-NLS-1$
LOGGER.info("syndesisSources:Source '{0}' entity was constructed", dataSource.getName()); //$NON-NLS-1$
}
// create response
return commit(uow, mediaTypes, entities);
Expand All @@ -2535,12 +2531,12 @@ public Response getServiceCatalogSources(final @Context HttpHeaders headers, fin
throw (KomodoRestException) e;
}
return createErrorResponseWithForbidden(mediaTypes, e,
RelationalMessages.Error.METADATA_GET_DATA_SOURCES_ERROR);
RelationalMessages.Error.METADATA_GET_SYNDESIS_SOURCES_ERROR);
}
}

/**
* Binds a Syndesis Data Service
* Bind a Syndesis source - creates a corresponding connection in the teiid engine.
*
* @param headers
* the request headers (never <code>null</code>)
Expand All @@ -2553,17 +2549,16 @@ public Response getServiceCatalogSources(final @Context HttpHeaders headers, fin
* @throws KomodoRestException
* if there is an error adding the Connection
*/
@SuppressWarnings("nls")
@POST
@Path(V1Constants.SERVICE_CATALOG_SOURCES)
@Path(V1Constants.SYNDESIS_SOURCE)
@Produces(MediaType.APPLICATION_JSON)
@Consumes({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Create connection Teiid Engine based on Syndesis connection configuration")
@ApiOperation(value = "Create a connection in the teiid engine for a Syndesis source")
@ApiResponses(value = { @ApiResponse(code = 406, message = "Only JSON is returned by this operation"),
@ApiResponse(code = 403, message = "An error has occurred.") })
public Response bindSyndesisSource(final @Context HttpHeaders headers, final @Context UriInfo uriInfo,
@ApiParam(value = "JSON of the properties of the connection:<br>" + OPEN_PRE_TAG + OPEN_BRACE + BR + NBSP
+ "name: \"Name of the Syndesis Data Service\"" + BR + CLOSE_BRACE
@ApiParam(value = "JSON of the syndesis source name:<br>" + OPEN_PRE_TAG + OPEN_BRACE + BR + NBSP
+ "name: \"Name of the Syndesis source\"" + BR + CLOSE_BRACE
+ CLOSE_PRE_TAG, required = true) final String payload)
throws KomodoRestException {

Expand All @@ -2583,20 +2578,20 @@ public Response bindSyndesisSource(final @Context HttpHeaders headers, final @Co
attributes = KomodoJsonMarshaller.unmarshall(payload, KomodoSyndesisDataSourceAttributes.class);
if (attributes.getName() == null) {
return createErrorResponseWithForbidden(mediaTypes,
RelationalMessages.Error.METADATA_DATA_SERVICE_BIND_MISSING_NAME);
RelationalMessages.Error.METADATA_SYNDESIS_SOURCE_BIND_MISSING_NAME);
}
} catch (Exception ex) {
return createErrorResponseWithForbidden(mediaTypes, ex,
RelationalMessages.Error.METADATA_DATA_SERVICE_BIND_PARSE_ERROR);
RelationalMessages.Error.METADATA_SYNDESIS_SOURCE_BIND_PARSE_ERROR);
}

UnitOfWork uow = null;

try {
uow = createTransaction(principal, "bindServiceCatalogService", false); //$NON-NLS-1$
uow = createTransaction(principal, "bindSyndesisSource", false); //$NON-NLS-1$
this.openshiftClient.bindToSyndesisSource(getAuthenticationToken(), attributes.getName());
String title = RelationalMessages.getString(
RelationalMessages.Info.METADATA_SERVICE_CATALOG_DATA_SERVIVE_BIND_TITLE, attributes.getName());
RelationalMessages.Info.METADATA_SYNDESIS_SOURCE_BIND_TITLE, attributes.getName());
KomodoStatusObject status = new KomodoStatusObject(title);
return commit(uow, mediaTypes, status);
} catch (final Exception e) {
Expand All @@ -2607,7 +2602,7 @@ public Response bindSyndesisSource(final @Context HttpHeaders headers, final @Co
throw (KomodoRestException) e;
}
return createErrorResponse(Status.FORBIDDEN, mediaTypes, e,
RelationalMessages.Error.METADATA_DATA_SERVIVE_BIND_ERROR, e, attributes.getName());
RelationalMessages.Error.METADATA_SYNDESIS_SOURCE_BIND_ERROR, e, attributes.getName());
}
}

Expand Down
Expand Up @@ -54,7 +54,7 @@ Info.CONNECTION_TO_REPO_STATUS_TITLE = Connection transfer to workspace Status
Info.CONNECTION_TO_REPO_SUCCESS = Connection transfer to workspace was successful
Info.CONNECTION_UNDEPLOYMENT_REQUEST_SENT = A request has been sent to delete the connection '%s'
Info.CONNECTION_SUCCESSFULLY_UNDEPLOYED = The connection '%s' has been undeployed
Info.METADATA_SERVICE_CATALOG_DATA_SERVIVE_BIND_TITLE=Bind Operation for Service Catalog Data Source %s
Info.METADATA_SYNDESIS_SOURCE_BIND_TITLE=Bind Operation for Syndesis Source %s

Error.ENCRYPT_FAILURE=An error occurred while attempting to encrypt sensitive data for the user %s
Error.DECRYPT_FAILURE=An error occurred while attempting to decrypt sensitive data for the user %s
Expand Down Expand Up @@ -307,10 +307,10 @@ Error.IMPORT_EXPORT_SERVICE_MISSING_PARAMETER_ERROR = The parameter %s is requir
Error.IMPORT_EXPORT_SERVICE_IMPORT_ARTIFACT_ERROR = An error occurred while attempting to perform the import: %s
Error.IMPORT_EXPORT_SERVICE_NO_NAMED_GIT_REPO_ERROR = No git repository configuration named %s is defined in the user's profile

Error.METADATA_GET_DATA_SOURCES_ERROR= An error occurred while attempting to read configured data sources: %s
Error.METADATA_DATA_SERVICE_BIND_MISSING_NAME=The payload is missing name of the data source to bind to
Error.METADATA_DATA_SERVICE_BIND_PARSE_ERROR=An error occurred while trying to parse payload for bind operation
Error.METADATA_DATA_SERVIVE_BIND_ERROR=An error occurred during bind operation of source %s
Error.METADATA_GET_SYNDESIS_SOURCES_ERROR= An error occurred while attempting to read syndesis sources: %s
Error.METADATA_SYNDESIS_SOURCE_BIND_MISSING_NAME=The payload is missing name of the syndesis source to bind to
Error.METADATA_SYNDESIS_SOURCE_BIND_PARSE_ERROR=An error occurred while trying to parse payload for bind operation
Error.METADATA_SYNDESIS_SOURCE_BIND_ERROR=An error occurred during bind operation of syndesis source %s
Error.ABOUT_SERVICE_ERROR=An error occurred while fetching information about the application: %s
Error.USER_PROFILE_SERVICE_ERROR=An error occurred while fetching user profile information for the user: %s
Error.NO_USER_PROFILE=The user profile for %s cannot be located
Expand Down
Expand Up @@ -447,7 +447,7 @@ export class AddConnectionWizardComponent implements OnInit {

const self = this;
this.connectionService
.getAllServiceCatalogSources()
.getAllSyndesisSources()
.subscribe(
(sources) => {
// Only keep the service catalog sources whose type matches the connectionType. empty source is always included.
Expand Down
24 changes: 12 additions & 12 deletions ui/beetle-lib/src/connections/shared/connection.service.ts
Expand Up @@ -147,14 +147,14 @@ export class ConnectionService extends ApiService {
}

/**
* Bind a service catalog source via the komodo rest interface
* @param {string} serviceCatalogSourceName
* Bind a syndesis source via the komodo rest interface
* @param {string} syndesisSourceName
* @returns {Observable<boolean>}
*/
public bindServiceCatalogSource(serviceCatalogSourceName: string): Observable<any> {
public bindSyndesisSource(syndesisSourceName: string): Observable<any> {
return this.http
.post(environment.komodoTeiidUrl + ConnectionsConstants.serviceCatalogSourcesRootPath,
{ name: serviceCatalogSourceName}, this.getAuthRequestOptions())
.post(environment.komodoTeiidUrl + ConnectionsConstants.syndesisSourcesRootPath,
{ name: syndesisSourceName}, this.getAuthRequestOptions())
.map((response) => {
return response.ok;
})
Expand Down Expand Up @@ -208,12 +208,12 @@ export class ConnectionService extends ApiService {
}

/**
* Get the available ServiceCatalogSources from the komodo rest interface
* Get the available SyndesisSources from the komodo rest interface
* @returns {Observable<ServiceCatalogSource[]>}
*/
public getAllServiceCatalogSources(): Observable<ServiceCatalogSource[]> {
public getAllSyndesisSources(): Observable<ServiceCatalogSource[]> {
return this.http
.get(environment.komodoTeiidUrl + ConnectionsConstants.serviceCatalogSourcesRootPath, this.getAuthRequestOptions())
.get(environment.komodoTeiidUrl + ConnectionsConstants.syndesisSourcesRootPath, this.getAuthRequestOptions())
.map((response) => {
const catalogSources = response.json();
return catalogSources.map((catSource) => ServiceCatalogSource.create( catSource ));
Expand Down Expand Up @@ -265,7 +265,7 @@ export class ConnectionService extends ApiService {
}

/**
* Create a connection in the Komodo repo - also binds the specified serviceCatalogSource
* Create a connection in the Komodo repo - also binds the specified syndesisSource
* @param {NewConnection} connection the connection object
* @returns {Observable<boolean>}
*/
Expand All @@ -280,7 +280,7 @@ export class ConnectionService extends ApiService {
}

/**
* Update a connection in the Komodo repo - also binds the specified serviceCatalogSource.
* Update a connection in the Komodo repo - also binds the specified syndesisSource.
* @param {NewConnection} connection the connection object
* @returns {Observable<boolean>}
*/
Expand All @@ -295,7 +295,7 @@ export class ConnectionService extends ApiService {
}

/**
* Creates a workspace Connection, binds it to the specified serviceCatalogSource, and initiates
* Creates a workspace Connection, binds it to the specified syndesisSource, and initiates
* a refresh of the connection schema.
* @param {NewConnection} connection the connection object
* @returns {Observable<boolean>}
Expand All @@ -307,7 +307,7 @@ export class ConnectionService extends ApiService {
}

/**
* Updates a workspace Connection, binds it to the specified serviceCatalogSource, and initiates
* Updates a workspace Connection, binds it to the specified syndesisSource, and initiates
* a refresh of the connection schema.
* @param {NewConnection} connection the connection object
* @returns {Observable<boolean>}
Expand Down
4 changes: 2 additions & 2 deletions ui/beetle-lib/src/connections/shared/connections-constants.ts
Expand Up @@ -23,8 +23,8 @@ export class ConnectionsConstants {
public static readonly addConnectionRoute = ConnectionsConstants.connectionsRootRoute + "/add-connection";
public static readonly addConnectionPath = ConnectionsConstants.connectionsRootPath + "/add-connection";

public static readonly serviceCatalogSourcesRootRoute = "serviceCatalogSources";
public static readonly serviceCatalogSourcesRootPath = "/" + ConnectionsConstants.serviceCatalogSourcesRootRoute;
public static readonly syndesisSourcesRootRoute = "syndesisSources";
public static readonly syndesisSourcesRootPath = "/" + ConnectionsConstants.syndesisSourcesRootRoute;

public static readonly connectionType_postgresql = "postgresql";
public static readonly connectionType_mysql = "mysql";
Expand Down
Expand Up @@ -118,7 +118,7 @@ export class MockConnectionService extends ConnectionService {
* Get the available ServiceCatalogSources from the komodo rest interface
* @returns {Observable<ServiceCatalogSource[]>}
*/
public getAllServiceCatalogSources(): Observable<ServiceCatalogSource[]> {
public getAllSyndesisSources(): Observable<ServiceCatalogSource[]> {
return Observable.of(this.serviceCatalogSources);
}

Expand All @@ -143,7 +143,7 @@ export class MockConnectionService extends ConnectionService {
}

/**
* Create a connection in the Komodo repo - also binds the specified serviceCatalogSource
* Create a connection in the Komodo repo - also binds the specified syndesisSource
* @param {NewConnection} connection the connection object
* @returns {Observable<boolean>}
*/
Expand All @@ -152,7 +152,7 @@ export class MockConnectionService extends ConnectionService {
}

/**
* Update a connection in the Komodo repo - also binds the specified serviceCatalogSource.
* Update a connection in the Komodo repo - also binds the specified syndesisSource.
* @param {NewConnection} connection the connection object
* @returns {Observable<boolean>}
*/
Expand Down

0 comments on commit 8e3c777

Please sign in to comment.