Skip to content

Conversation

pkharge
Copy link
Contributor

@pkharge pkharge commented Jul 29, 2022

Guidelines for Pull Requests

If you haven't yet read our code review guidelines, please do so, You can find them here.

Please confirm the following by adding an x for each item (turn [ ] into [x]).

  • I have removed all code style changes that are not necessary (e.g. changing blanks across the whole file that don’t need to be changed, adding empty lines in parts other than your own code)
  • I am not making any changes to files that don’t have any effect (e.g. imports added that don’t need to be added)
  • I do not have any sysout statements in my code or commented out code that isn’t needed anymore
  • I am not reformatting any files in the wrong format or without cause.
  • I am not changing file encoding or line endings to something else than UTF-8, LF
  • My pull request does not show an insane amount of files being changed although my ticket only requires a few files being changed
  • I have added Javadoc/documentation where appropriate
  • I have added test cases where appropriate
  • I have explained any part of my code/implementation decisions that is not be self-explanatory

Please provide a brief description of your ticket

The user would get a zip file that contains one html page for each page + any css, javascript, etc.

Anything else the reviewer needs to know?

... describe here ...

@diging-jenkins
Copy link

Can one of the admins verify this patch?

@pkharge pkharge marked this pull request as draft July 29, 2022 23:40
@pkharge pkharge marked this pull request as ready for review August 1, 2022 23:16
Copy link
Member

@jdamerow jdamerow left a comment

Choose a reason for hiding this comment

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

I didn't not go through everything but given I'm asking for some major changes, I'll leave it with this for now.

});
IOUtils.close(responseZipStream);
IOUtils.close(bufferedOutputStream);
IOUtils.close(byteArrayOutputStream);
Copy link
Member

Choose a reason for hiding this comment

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

this can probably be tightened up by using try-with statements

responseZipStream.closeEntry();

} catch (IOException e) {
System.err.println(e);
Copy link
Member

Choose a reason for hiding this comment

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

?

return byteArrayOutputStream.toByteArray();

} catch (IOException e) {
throw new IOException(e);
Copy link
Member

Choose a reason for hiding this comment

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

there is no point in wrapping an IOException in another IOException

Copy link
Member

Choose a reason for hiding this comment

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

this still



@Service
public class DownloadsManager {
Copy link
Member

Choose a reason for hiding this comment

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

needs an interface

Copy link
Member

Choose a reason for hiding this comment

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

From what I can tell so far, this class needs to be a little refactored. There should be several methods:

  • create a snapshot (or whatever you want to call the generated html pages)
  • get one
  • list all
  • get generated files

When the user generates a new snapshot the create method is called. This should be an @Async method as it might take a while. The user sees a progress page (polling for updates from the front end, not just one call as the server might time out).
When the generation process is done, the user will be sent to the page for that snapshot. The create method should return the created ExhibitionDownload object. The get method is probably called here, to get the object by its id. If the user wants to download the files, they can do so from that page (get generated files method will be called).
The list all snapshots page will call the list method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jdamerow , want to check my understanding on this once.
The first time user clicks on download button, the async rest api will return an newly created exhibitionDownload object with a unique folder name (used timestamps). this api will trigger create snapshot method.
then Ui will poll another rest api (this will be an simple GET api) by sending exhibitionDownload object as input, untill the requested folder is ready. once its ready, the folder should be download as zip folder.

so there will be 2 different rest apis in backend, one async which just returns exhibitionDownload object and trigger createSnapshot method. another one will be used simply to poll.

is this understanding correct?

Copy link
Member

Choose a reason for hiding this comment

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

Not 100% sure. What do you mean by "async rest api"?

The flow would be:

  • POST request to start zip generation (the request itself does not have to be async, but it will start an async method on the server)
  • the controller will return an id that the client can then use to poll (id could be the id of an exhibitionDownload object if that is being created and returned by the async method)
  • "then Ui will poll another rest api (this will be an simple GET api)" - yes, "by sending exhibitionDownload object as input" -> not sure what that means. It would use the id returned in the previous step
  • "untill the requested folder is ready." - yes
  • "once its ready, the folder should be download as zip folder." - once it's ready the user should be able to down load, it should probably show a message that the generation is done or something. It does not have to automatically start downloading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jdamerow , to show the progress of download to the user, do we want to create a separate page where user will be redirected to, or can we show it within a section in the same downloadlist page?
I tried putting it in an alert box, but if the page gets refreshed, the user won't be able to see the notification.

Copy link
Member

Choose a reason for hiding this comment

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

either is fine.

Copy link
Member

Choose a reason for hiding this comment

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

if it's on the same page and the user won't see the progress anymore after reloading the page, there is needs to be another indication that makes clear that export is in progress.

});
IOUtils.close(responseZipStream);
IOUtils.close(bufferedOutputStream);
IOUtils.close(byteArrayOutputStream);
Copy link
Member

Choose a reason for hiding this comment

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

are these needed since you're using the try-with statement?

Resource resource = null;
try {
String pathToResources = request.getServletContext().getRealPath("") + "/resources";
String exhibitionFolderName= "Exhibition"+ LocalDateTime.now();
Copy link
Member

Choose a reason for hiding this comment

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

business logic that should not be in the controller

@jdamerow jdamerow closed this Oct 24, 2022
@pooja-thalur pooja-thalur reopened this Nov 12, 2024
@jdamerow
Copy link
Member

jdamerow commented Jan 6, 2025

Resolve conflicts please

@jdamerow jdamerow closed this Jan 6, 2025
# Conflicts:
#	vspace/src/main/java/edu/asu/diging/vspace/core/services/impl/SpaceManager.java
@pooja-thalur pooja-thalur reopened this Jan 7, 2025
try {
snapshotTask = createSnapshot(resourcesPath, exhibitionFolderName, sequenceHistory, exhibitionSnapshot);
storageEngineDownloads.generateZip(exhibitionFolderName);
snapshotTask.setTaskComplete(true);
Copy link
Member

Choose a reason for hiding this comment

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

wait, I'm confused. createSnapshot spins up a new thread, right? so you can't generate a zip file right after you call it, can you? and it also wont' be complete right after, doesn't it? Or am I missing something?

Copy link
Member

Choose a reason for hiding this comment

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

wait, actually, if this method calls createSnapshot, it won't spin up a new thread. It should though, since it could take quite a while.

Copy link
Member

Choose a reason for hiding this comment

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

This still. createSnapshot is annotated with@Async but if called from within the class, no new thread is created.

@jdamerow jdamerow closed this Feb 7, 2025
@pooja-thalur pooja-thalur reopened this Apr 2, 2025
import edu.asu.diging.vspace.core.services.ISnapshotManager;

@Service
@EnableAsync
Copy link
Member

Choose a reason for hiding this comment

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

This should not be necessary. This is an annotation for a configuration class.

exhibitionSnapshot = exhibitionSnapshotRepository.save(exhibitionSnapshot);

try {
snapshotTask = createSnapshot(resourcesPath, exhibitionFolderName, sequenceHistory, exhibitionSnapshot);
Copy link
Member

Choose a reason for hiding this comment

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

sequenceHistory never seems to be initialized?

Copy link
Member

Choose a reason for hiding this comment

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

also, createSnapshot will not create a new thread as you are calling the method from within this class!

}
try {
return storageEngineDownloads.getMediaContent("",exhibitionSnapshot.get().getFolderName()+ZIP_FILE_EXTENSION);
}catch(Exception e) {
Copy link
Member

Choose a reason for hiding this comment

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

is anything actually throwing Exception? If so, there should be a comment here. If not, then the specific exception thrown should be caught here.

}
Pageable requestedPageForFiles = PageRequest.of(filesPagenum - 1, pageSize);

Page<ExhibitionSnapshot> page = exhibitionSnapshotRepository.findAllByOrderByCreationDateDesc(requestedPageForFiles);
Copy link
Member

Choose a reason for hiding this comment

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

two blanks

public ResponseEntity<SnapshotTask> getSnapshotTaskStatus(HttpServletRequest request,
@PathVariable(required = false, name = "id") String snapshotId, HttpServletResponse response, Model model)
throws ExhibitionSnapshotNotFoundException {
SnapshotTask snapshotTask = (snapshotId == null && snapshotId == "")
Copy link
Member

Choose a reason for hiding this comment

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

you don't compare strings with ==

Copy link
Member

Choose a reason for hiding this comment

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

also how can a variable be null and also be ""?

@jdamerow
Copy link
Member

jdamerow commented Apr 2, 2025

also, there is a conflict

@jdamerow jdamerow closed this Apr 2, 2025
@pooja-thalur pooja-thalur reopened this Apr 15, 2025
# Conflicts:
#	vspace/src/test/java/edu/asu/diging/vspace/core/services/impl/ImageServiceTest.java
@jdamerow
Copy link
Member

Make it so, Jenkins.

@jdamerow
Copy link
Member

A couple of issues:

  • After clicking "Create Snapshot" nothing happens. There should be some indication that the snapshot generation has started. And if a snapshot generation is currently running, there needs to be some indication on the page as well.
  • The exported exhibition:
    • there is not index.html file in the generated root directory, so it's not clear what file is the first page of the exhibition
    • there are no links on any of the pages apparently! So one cannot move from one page to the next.

@jdamerow jdamerow closed this Jun 17, 2025
vspace/pom.xml Outdated
<uploaded.files.path></uploaded.files.path>

<downloaded.files.path></downloaded.files.path>
<resources.path></resources.path>
Copy link
Member

Choose a reason for hiding this comment

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

these two need a comment what should go here.

*/
@Async
@Transactional
public Future<SnapshotTask> createSnapshot(String resourcesPath, String exhibitionFolderName,SequenceHistory sequenceHistory, ExhibitionSnapshot exhibitionSnapshot)
Copy link
Member

Choose a reason for hiding this comment

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

ideally, resource path would not be required but calculate.

import edu.asu.diging.vspace.core.services.IRenderingManager;

@Service
public class AsyncSnapshotCreator {
Copy link
Member

Choose a reason for hiding this comment

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

needs an interface

@Girik1105 Girik1105 reopened this Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants