extracting ZIP files has issues with the API design

Description

Lessons allow you to upload a ZIP file and extract it. There's currently a bug if the ZIP file doesn't have an extension. The back is traceable to ZipContentUtil.java
private String extractZipCollectionName(ContentResource resource)
{ String tmp = extractName(resource.getId()); return tmp.substring(0, tmp.lastIndexOf(".")); }

This will fail if there's no . in the name. However simply fixing the lastIndexOf isn't good enough. What it's doing is creating a collection to put the files into. It does that by removing the extension. So if you allow the ZIP file to have no extension you'll need some other way to create the collect. Perhaps add '-files" to the end (with provisions for internationalization).

But once you do that it raises problems for Lessons. Lessons need to know where the files went. Currently it duplicates the code in the kernel for producing the collection Id. If the kernel changes the way it produces the collection ID, I'd rather not have to update Lessons to match. Rather, I'd like the extract function (currently void) to return the collection ID it used. Then I could get rid of the code that predicts what the kernel will do.

Activity

Show:

Charles Hedrick October 14, 2016 at 11:51 AM

If you make this change, please create a Jira for Lessons, since I may not notice that this problem has been resolved.

Details

Priority

Affects versions

Components

Assignee

Reporter

Created October 14, 2016 at 11:50 AM
Updated April 25, 2018 at 3:18 PM

Flag notifications