Skip to content

Commit

Permalink
Merge pull request sakaiproject#1633 from ern/SAK-30267
Browse files Browse the repository at this point in the history
SAK-30267 Drag n Drop updates
  • Loading branch information
ottenhoff committed Feb 8, 2016
2 parents 21f7377 + 10a3d97 commit a9ba561
Show file tree
Hide file tree
Showing 21 changed files with 2,969 additions and 1,949 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@
# content.upload.max=20
# **Note - online documentation states ceiling is set in bytes - this is incorrect. Settings are in MB.
# content.upload.ceiling=20
# The UI should show hidden as the default when uploading files
# content.dnd.visibility.hidden=false

# Enable zip content handling (affects resources), on by default
# Allows users to upload zip files and have them be expanded into the content (resources tool) and
Expand Down Expand Up @@ -492,10 +494,6 @@
# DEFAULT: true
# content.make.site.page=true

# Enable upload via drag n drop, on by default.
# DEFAULT: true
# content.upload.dragndrop=true

# SAK-21955 - Enforce a limit for how many files are displayed in resources
# Not having a limit could potentially lead to slow performance or errors
# Having a limit could mean that some files are not possible to access via the UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ display.users.present=true
# Test SAK-23812
assignment.usePeerAssessment=true

#Test SAK-22306
content.upload.dragndrop=true

#SAK-24423
sitemanage.join.joinerGroup.enabled=true
sitebrowser.join.enabled=true
Expand Down
9 changes: 5 additions & 4 deletions content/content-bundles/resources/types.properties
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@ avail.hide10 = Hide this item
#avail.hide2 = Hide this folder from non-administrators
avail.hide20 = Hide this folder and its contents
avail.hide30 = Hide this folder but allow access to its contents
avail.hide40 = Hidden
avail.uploaded = Uploaded items should be
avail.show = Show
avail.show1 = Show this item
avail.show2 = Show this folder
avail.show40 = Visible
avail.start = Beginning
avail.start1 = From
avail.title = Availability
Expand Down Expand Up @@ -186,7 +189,7 @@ to upload the file(s) to this web site. Text, graphics and other media files may
even if your site is restricted to site members.
instr.dnd.uploads = Files can be uploaded individually or in ZIP archives. Expand ZIPs after uploading via the \
file''s Action menu. Click Continue when ready to complete the upload. Note that you cannot upload more than {0} MB of \
material at once.<br /><br /> \
material at once.<br /> \
Copyright: It is your personal responsibility to verify that you have permission from the copyright holder \
to upload the file(s) to this web site. Text, graphics and other media files may all be subject to copyright control \
even if your site is restricted to site members.
Expand Down Expand Up @@ -567,11 +570,9 @@ multiple.file.upload.group = Group:
# SAK-23367
notes.expandfolder=Expand folder(s) of interest and select item(s) to copy to your current site above.

label.dragDescription=Drag and drop files from your desktop into the box below.
label.dragDescription=Drag and drop files from your desktop into the box above.
label.dragZoneMessage=Drop files here to upload.
alert.over-site-upload-quota=Your file upload attempt could not be completed because doing so would put you over your site quota. Please check the sum total file size of all items you wish to upload before your next attempt.
link.switch.to.dnd = Switch to Drag and Drop Upload?
link.switch.to.upload=Switch to file browser upload?

#SAK-25747
dragndrop.dictFallbackMessage=Your browser does not support drag'n'drop file uploads.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3928,7 +3928,7 @@ else if(pipe.isErrorEncountered())
String msg = pipe.getErrorMessage();
if(msg == null || msg.trim().equals(""))
{
msg = rb.getString("alert.unknown");
msg = trb.getString("alert.unknown");
}
addAlert(state, msg);
state.setAttribute(STATE_MODE, MODE_LIST);
Expand Down Expand Up @@ -4820,7 +4820,7 @@ else if(pipe.isErrorEncountered())
String msg = pipe.getErrorMessage();
if(msg == null || msg.trim().equals(""))
{
msg = rb.getString("alert.unknown");
msg = trb.getString("alert.unknown");
}
addAlert(state, msg);
state.setAttribute(STATE_MODE, MODE_LIST);
Expand Down Expand Up @@ -8168,7 +8168,7 @@ protected void finishAction(SessionState state, ToolSession toolSession, Resourc
String msg = pipe.getErrorMessage();
if(msg == null || msg.trim().equals(""))
{
msg = rb.getString("alert.unknown");
msg = trb.getString("alert.unknown");
}
addAlert(state, msg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,9 @@ public class ResourcesHelperAction extends VelocityPortletPaneledAction
/** The title of the new page to be created in the site */
protected static final String STATE_PAGE_TITLE = PREFIX + "page_title";

/** Tool property to enable Drag and Drop uploads in a per-tool basis */
private static final String TOOL_PROP_DRAGNDROP_ENABLED = "content.upload.dragndrop";

/** We need to send a single email with every D&D upload reported in it */

private static final String DRAGNDROP_FILENAME_REFERENCE_LIST = "dragndrop_filename_reference_list";

private NotificationService notificationService = (NotificationService) ComponentManager.get(NotificationService.class);
private EventTrackingService eventTrackingService = (EventTrackingService) ComponentManager.get(EventTrackingService.class);

Expand Down Expand Up @@ -660,16 +657,6 @@ protected String buildUploadFilesContext(VelocityPortlet portlet, Context contex
String instr_dnd_uploads = rb.getFormattedMessage("instr.dnd.uploads", new String[]{ uploadMax });
context.put("instr_dnd_uploads", instr_dnd_uploads);

Boolean dragAndDrop = ServerConfigurationService.getBoolean("content.upload.dragndrop", true);
String strDragAndDropEnabled = ToolManager.getCurrentPlacement().getConfig().getProperty(TOOL_PROP_DRAGNDROP_ENABLED);

if (StringUtils.isNotBlank(strDragAndDropEnabled))
{
dragAndDrop = dragAndDrop || (new Boolean(strDragAndDropEnabled));
}

context.put("dragAndDrop", dragAndDrop);

// int max_bytes = 1024 * 1024;
// try
// {
Expand Down Expand Up @@ -718,6 +705,7 @@ protected String buildUploadFilesContext(VelocityPortlet portlet, Context contex
if(ContentHostingService.isAvailabilityEnabled())
{
context.put("availability_is_enabled", Boolean.TRUE);
context.put("upload_visibility_hidden", ServerConfigurationService.getBoolean("content.dnd.visibility.hidden", false));
}

if(model.isDropbox)
Expand Down Expand Up @@ -1910,7 +1898,8 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
{
String fullPath = request.getParameter("fullPath");
String action = request.getParameter("sakai_action");
logger.debug("Received action: "+action+" for file: "+fullPath);
boolean hidden = Boolean.valueOf(request.getParameter("hidden"));
logger.debug("Received action: "+action+" for file: "+fullPath+" with visibilty "+Boolean.toString(!hidden));

// set up rundata, in case we're called from RSF
checkRunData(request);
Expand Down Expand Up @@ -1987,7 +1976,7 @@ else if( !siteQuotaUnlimited && fileSizeMB > siteQuota )
{
JetspeedRunData rundata = (JetspeedRunData) request.getAttribute(ATTR_RUNDATA);
if (checkCSRFToken(request,rundata,action)) {
doDragDropUpload(request, response, fullPath);
doDragDropUpload(request, response, fullPath, hidden);
}
}
}
Expand Down Expand Up @@ -2020,7 +2009,7 @@ else if( !siteQuotaUnlimited && fileSizeMB > siteQuota )
}


private synchronized void doDragDropUpload(HttpServletRequest request, HttpServletResponse response, String fullPath)
private synchronized void doDragDropUpload(HttpServletRequest request, HttpServletResponse response, String fullPath, boolean hidden)
{
//Feel free to sent comments/warnings/advices to me at daniel.merino AT unavarra.es

Expand Down Expand Up @@ -2108,9 +2097,11 @@ private synchronized void doDragDropUpload(HttpServletRequest request, HttpServl
resourceProps.addProperty(ResourcePropertiesEdit.PROP_DISPLAY_NAME, uploadFileName);
resource.setContent(uploadFile.getInputStream());
resource.setContentType(contentType);
resource.setAvailability(hidden, null, null);
ContentHostingService.commitResource(resource, NotificationService.NOTI_NONE);

if (collection != null){
collection.setAvailability(hidden, null, null);
ContentHostingService.commitCollection(collection);
logger.debug("Collection commited: "+collection.getId());
}
Expand Down
Loading

0 comments on commit a9ba561

Please sign in to comment.