Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

feat(bdpImport): Use of proper error message when importing projects #680

Merged
merged 2 commits into from Dec 11, 2017

Conversation

bodetc
Copy link

@bodetc bodetc commented Nov 15, 2017

Instead of a list of IDs, now a error message is shown for each failed ID with a reason for the failure.

Backend PR: sw360/sw360bdpImportService#5
Depends on PR: #661

(note that before the message was like 'there was some problem', now it shall display which projects etc)


// Project Import: user actions
public static final String PROJECT_IMPORT_USER_ACTION__IMPORT = "projectImport_import_action";
public static final String PROJECT_IMPORT_USER_ACTION__IMPORT_BDP = "projectImport_import_bdp_data";
Copy link
Contributor

@mcjaeger mcjaeger Nov 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about calling this PROJECT_IMPORT_USER_ACTION__IMPORT_DATA?

public static final String PROJECT_IMPORT_RESPONSE__SUCCESS = "projectImport_response_bdp_import_success";
public static final String PROJECT_IMPORT_RESPONSE__FAILURE = "projectImport_response_bdp_import_failure";
public static final String PROJECT_IMPORT_RESPONSE__GENERAL_FAILURE = "projectImport_response_bdp_import_general_failure";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe removing bdp could be also OK

@@ -128,12 +131,12 @@ private boolean isImportSuccessful(ImportStatus importStatus) {
return (importStatus.isSetRequestStatus() && importStatus.getRequestStatus().equals(RequestStatus.SUCCESS) && importStatus.getFailedIds().isEmpty());
}

private ImportStatus importDatasources(List<String> toImport, User user, RemoteCredentials remoteCredentials) {
private ImportStatus importDatasources(List<String> toImport, User user, RemoteCredentials remoteCredentials) {
ImportStatus importStatus = new ImportStatus();
try {
importStatus = bdpImportClient.importDatasources(toImport, user, remoteCredentials);
if (!isImportSuccessful(importStatus)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the thrift file could be renamed this could be also renamed at the same occasion.

@mcjaeger
Copy link
Contributor

Since you are adjusting labels / names, such as

SESSION_IMPORT_USER to PROJECT_IMPORT_USERNAME

How about eliminating also the references to BDP from the sw360portal code base? for example. it does not make sense to have the file "bdpImport.thrift" (https://github.com/sw360/sw360portal/blob/master/libraries/lib-datahandler/src/main/thrift/bdpimport.thrift), but it could be renamed to "projectImport.thrift"

At the same time, a variables named with bdp could be changed too ... do not get me wrong on this, I know that this PR is not targeting cleaning up the code. I am just proposing this because you are changing these lines anyway and then the changed lines could also remove the bdp references, because it would be cleaner if the project import functionality is actually called project import regardless of the source.

@mcjaeger
Copy link
Contributor

mcjaeger commented Nov 29, 2017

hi, I am not sure about the error message improvement. Got the following from screenshot (see below), what I did it is:

  • deployed bdpimporter branch dev/654-bdp-error-messages
  • deployed sw360portal branch bsinno:dev/654-bdp-error-messages

I keep on testing because the log says that the importing of the license crashes and I guess this does not work with the plain user:

 2017-11-29 15:06:48 ERROR ThriftExchange:249 - Could not add License for user with email=[user1@sw360.org]:org.apache.thrift.TApplicationException: addLicenses failed: unknown result

screen shot 2017-11-29 at 16 19 35

@mcjaeger
Copy link
Contributor

mcjaeger commented Nov 29, 2017

Update: with an admin user it seems to work. I guess the message is also improved. So, what do we do about the "License cannot be created" problem ... I think the import of projects is maybe not for every sw360 user but only for those who can create licenses anyways? As such the import menu item could be made visible only to those during deployment (requires updated lar though)
screen shot 2017-11-29 at 16 28 42

Attached a screenshot of the out that you maybe anticipated. It works both with admins and clearing admins

@mcjaeger mcjaeger removed their assignment Nov 29, 2017
@mcjaeger mcjaeger self-requested a review November 29, 2017 15:37
Copy link
Contributor

@mcjaeger mcjaeger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, having this as question from review: what do we do about the "License cannot be created" problem read from the logs ... I think the import of projects is maybe not for every sw360 user but only for those who can create licenses anyways (admin and clearing admin)? As such the import menu item could be made visible only to those during deployment (requires updated lar though). OK for that?

@bodetc
Copy link
Author

bodetc commented Nov 29, 2017

The "License cannot be created" is unfortunately hard to catch, as it comes as a exception in the addProject method of projects.thrift. It would require us to also refactor that method, and do one more breaking change in the thrift API.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants