Skip to content

Share ImageTask access URL#7

Open
velmer wants to merge 14 commits intoremote-sharingfrom
share-task-access-url
Open

Share ImageTask access URL#7
velmer wants to merge 14 commits intoremote-sharingfrom
share-task-access-url

Conversation

@velmer
Copy link
Owner

@velmer velmer commented Jun 15, 2019

Purpose of this PR:
Create an API route to return the URLs of every file generated by execution of a ImageTask. The client must specify a list of IDs of ImageTasks through query parameter.

What problem will be solved:
Now a SAPS instance can request to one of its neighbors the URLs of files of a ImageTask, when sending an email of processed ImageTasks and at least one of these was processed in other SAPS instance.

Modifications:

  1. Creates a method and SQL query to return a list of ImageTask given an array of IDs;
  2. Creates the entity ImageTaskFile, it holds the informations about a file generated by the processing of ImageTask;
  3. Creates the entity ImageTaskFileList, it holds a list of ImageTaskFiles and the ImageTask that generated those files;
  4. Extracts a service - ObjectStoreService - of ProcessedImagesEmailBuilder to handle operations with Object Store;
  5. Extracts a service - ProcessedImagesService - of ProcessedImagesEmailBuilder to handle operations with processed ImageTasks;
  6. Updates ProcessedImagesEmailBuilder to utilize the extracted services.

@velmer velmer added the enhancement New feature or request label Jun 15, 2019
@velmer velmer requested a review from thiagomanel June 15, 2019 01:29
@velmer velmer changed the title Share task access url Share ImageTask access url Jun 15, 2019
@velmer velmer changed the title Share ImageTask access url Share ImageTask access URL Jun 15, 2019
Copy link
Collaborator

@thiagomanel thiagomanel left a comment

Choose a reason for hiding this comment

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

Nice, thank @velmer some suggestions for improvement

jsonObject.put(FILES, filesJSONArray);
} catch (JSONException e) {
jsonObject.put(STATUS, UNAVAILABLE);
throw e;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need to call this put if we throw the exception the line below?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I was deciding between two approaches, but ended up doing none oh them. I wanted to built the json object even if there was an error, but I didn't want to put logging in an instance method of a pojo, then I added the throw so the caller method can log the error... But both strategies cannot coexist. I'll fix it

private static final String STATUS = "status";
private static final String UNAVAILABLE = "UNAVAILABLE";

private ImageTask imageTask;
Copy link
Collaborator

Choose a reason for hiding this comment

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

add this declarations finals

private String name;
private String URL;

public ImageTaskFile(String path, String name) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need (sorry, I did not checkout the code) both these constructor (can we keep only one?)

Copy link
Owner Author

Choose a reason for hiding this comment

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

The other constructor isn't used externally, I added just for precaution, so yes, it can be removed

* Service that provides operations for communication with Object Store.
*/
public class ObjectStoreService {

Copy link
Collaborator

Choose a reason for hiding this comment

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

this class seems very coupled with SWIFT logic. I think it would be better to call it SwiftStorageService (or something like that). overall, I think it is a very nice idea to hide the complexity.
Also, why no passing the properties file to a constructor as a regular object instead of the more staless design

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, it is, I'll change it.

About the properties file, it's because that conversation we had about services of restlet's architecture, but because of the deadline I couldn't use them. So, my strategy was to simplify the utilization of services, making all of its methods as static, in order to avoid instantiate the services.

The expected strategy was to create an interface to define the contract of the services and the instantiations of its implementations be done by injection (or some like that, I don't know how restlet handle this)

I'm open for suggestions, should I change the methods to be instance's and instantiate the services in constructors of its users?

/**
* Service the provides operations with processed {@link ImageTask}.
*/
public class ProcessedImagesService {
Copy link
Collaborator

Choose a reason for hiding this comment

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

also very couple with Swift. I'd be better to add Swift in the class name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants