Skip to content

Commit

Permalink
Merge pull request #195 from gmkll/master
Browse files Browse the repository at this point in the history
JSP Connector Update
  • Loading branch information
psolom committed Jul 12, 2017
2 parents 9fbd702 + bf79228 commit 012078d
Show file tree
Hide file tree
Showing 22 changed files with 1,472 additions and 909 deletions.
4 changes: 4 additions & 0 deletions connectors/jsp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.gradle
build
libraries/java/bin/*
libraries/java/src/com/*
5 changes: 0 additions & 5 deletions connectors/jsp/ReadMe.txt

This file was deleted.

49 changes: 49 additions & 0 deletions connectors/jsp/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
group 'edu.fuberlin.cedis'
version '1.0-SNAPSHOT'

apply plugin: 'java'

targetCompatibility = '1.7'
sourceCompatibility = '1.7'

repositories {
mavenCentral()
}

dependencies {
compile('javax.servlet:servlet-api:2.5')
compile('org.slf4j:slf4j-api:1.7.25')
compile('commons-fileupload:commons-fileupload:1.2.2')
compile('org.jabsorb:jabsorb:1.3.2')
testCompile('junit:junit:4.11')
}


sourceSets {
main {
java {
// if copied the com/fabriceci/fmc/error into local folder uncomment line:
// srcDirs 'libraries/java/src'
// if using java connector by default
srcDirs 'libraries/java/src', '../java/src/main/java'
include "**/edu/fuberlin/*"
include "**/com/fabriceci/fmc/error/*"
include "**/com/fabriceci/fmc/util/FileUtils.*"
include "**/com/fabriceci/fmc/util/CopyDirectoryVisitor.*"
include "**/com/fabriceci/fmc/util/DeleteDirectoryVisitor.*"
include "**/com/fabriceci/fmc/util/StringUtils.*"
include "**/com/fabriceci/fmc/util/ImageUtils.*"
output.classesDir = 'libraries/java/bin'
//println output.classesDir
}
}
}

// Iterate over the source sets
sourceSets.all {
println name
}

clean {
delete sourceSets.main.java.outputDir
}
76 changes: 63 additions & 13 deletions connectors/jsp/config.properties
Original file line number Diff line number Diff line change
@@ -1,40 +1,90 @@
#Language settings
culture = en

# ------------------------
# Resources section
# ------------------------

# Default value "empty".
# By default the application will search `fileRoot` folder under server root folder.
# $context variable will be replaced by servlet context path
serverRoot= $context/userfiles/

# The directory containing the files
# Provide the document root, which is either absolute path or relative to servlet context if it does not start with '/' (slash)
fileRoot = userfiles

#Date format
date = dd MM yyyy kk:mm
#date=yyyy-MM-dd HH:mm:ss

# Means all capabilities handled by the application are available.
#capabilities=select,upload,download,rename,copy,move,replace,delete,edit
capabilities=select,upload,download,rename,copy,move,replace,delete

#Icons settings
icons-path = images/fileicons/
icons-directory = _Open.png
icons-default = default.png


# ------------------------
# Filter section
# ------------------------

# File types that are filtered out from the output list based on the type of filter ('getfolder' request)
outputFilter_images=jpg,jpe,jpeg,gif,png,svg,bmp

# ------------------------
# Upload section
# ------------------------

#Upload settings
upload-overwrite false
# in megabytes (0: no limit)
upload-size = 0
upload-size = 50
upload-imagesonly = false
# The maximum allowed file size (in Bytes). If set to "false", no size limitations applied.
# See https://github.com/blueimp/jQuery-File-Upload/wiki/Options#maxfilesize.
upload_fileSizeLimit=16000000

# Files extensions permitted for uploading/creating
upload_restrictions=jpg,jpe,jpeg,gif,png,svg,txt,pdf,odp,ods,odt,rtf,ppt,pptx,csv,ogv,avi,mkv,mp4,webm,m4v,ogg,mp3,wav,zip,rar,md


#Allowed image extensions
images = jpg,jpeg,gif,png
images = jpg,jpeg,gif,png,svg

#Files and folders
#excluded from filtree
unallowed_files = Thumbs.db
unallowed_dirs =

# provide the document root, which is relative to servlet context if it start not with '/'
doc_root =
# If set to "true", allow users to upload file with no extension.
allowNoExtension=false

# Array of file names excluded from listing.
excluded_files=.htaccess,web.config,.DS_Store

# Array of folder names excluded from listing.
excluded_dirs=_thumbs,.CDN_ACCESS_LOGS

# Files excluded from listing, using REGEX.
excluded_files_REGEXP=/^\\./

# Folders excluded from listing, using REGEX.
excluded_dirs_REGEXP=/^\\./

# Array of files extensions permitted for editing.
editRestrictions=txt,csv,md

# provide a preview path, may be relative, by default not supported
#preview =
extensions_ignoreCase = false
# one of ALLOW_LIST DISALLOW_LIST
extensions_policy = ALLOW_LIST

# allowed extensions, if renaming
extensions_restrictions = jpg,jpeg,gif,png,svg

#FEATURED OPTIONS
#for Vhost or outside files folder
# // No end slash:
#doc_root = C:\\dev\\workspace\\.metadata\\.plugins\\org.eclipse.wst.server.core\\tmp0\\wtpwebapps\\fcktest2\\userfiles
# redirect address ?
errorObject_arguments_redirect =

#not working yet
# string; if overwrite is false, the suffix will be added after the filename (before .ext)
#upload-suffix = _
134 changes: 73 additions & 61 deletions connectors/jsp/filemanager.jsp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<%@page import="org.slf4j.LoggerFactory"%>
<%@page import="org.slf4j.Logger"%>
<%@page import="edu.fuberlin.*"%>
<%@ page pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ page language="java" import="java.util.*"%>
<%@ page import="com.nartex.*"%>
<%@ page import="org.json.JSONObject"%>
<%@ page import="java.io.*"%>
<%@include file="auth.jsp"%>
Expand All @@ -16,15 +18,14 @@
* - check strictServletCompliance 8/16
* - dynamic content type setting 8/16
*/
//use new rich manager - or not
boolean rich = true;
FileManagerI fm = (rich)? new RichFileManager(getServletContext(), request) : new FileManager(getServletContext(), request);
FileManagerI fm = new RichFileManager(getServletContext(), request);
final Logger log = LoggerFactory.getLogger("filemanager");
boolean strictServletCompliance = false; // default value is ISO-8859-1.
JSONObject responseData = null;
String mode = "";
boolean putTextarea = false;
if(!auth(request)) {
fm.error(fm.lang("AUTHORIZATION_REQUIRED"));
responseData = fm.getErrorResponse(fm.lang("AUTHORIZATION_REQUIRED"));
}
else {
if(request.getMethod().equals("GET")) {
Expand All @@ -44,59 +45,73 @@
}
}
}
// renamed getinfo to getfile
if (mode.equals("getinfo") || mode.equals("getfile")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"): request.getParameter("path"))) {
responseData = fm.getInfo();
}
}
else if (mode.equals("getfolder")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path"))) {
responseData = fm.getFolder(request);
}
}
else if (mode.equals("rename")){
if(fm.setGetVar("old", (strictServletCompliance)? qpm.get("old"):request.getParameter("old")) &&
fm.setGetVar("new", (strictServletCompliance)? qpm.get("new"):request.getParameter("new"))) {
responseData = fm.rename();
}
}
else if (mode.equals("delete")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path"))) {
responseData = fm.delete();
}
}
else if (mode.equals("addfolder")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path")) &&
fm.setGetVar("name", (strictServletCompliance)? qpm.get("name"):request.getParameter("name"))) {
responseData = fm.addFolder();
}
}
else if (mode.equals("download")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path"))) {
responseData = fm.download(request, response);
}
}
else if (mode.equals("getimage")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path"))) {
String paramThumbs =request.getParameter("thumbnail");
fm.preview(request, response);
}
}
else if (mode.equals("readfile")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path"))) {
fm.preview(request, response);
}
}
else if (mode.equals("move")){
if(fm.setGetVar("old", (strictServletCompliance)? qpm.get("old"):request.getParameter("old")) &&
fm.setGetVar("new", (strictServletCompliance)? qpm.get("new"):request.getParameter("new"))
) {
responseData = fm.moveItem();
}
}
else {
fm.error(fm.lang("MODE_ERROR"));
try {
// renamed getinfo to getfile
if (mode.equals("getinfo") || mode.equals("getfile")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"): request.getParameter("path"))) {
responseData = fm.getInfo();
}
}
else if (mode.equals("initiate")){
responseData = fm.initiate(request);
}
else if (mode.equals("getfolder")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path"))) {
responseData = fm.getFolder(request);
}
}
else if (mode.equals("rename")){
if(fm.setGetVar("old", (strictServletCompliance)? qpm.get("old"):request.getParameter("old")) &&
fm.setGetVar("new", (strictServletCompliance)? qpm.get("new"):request.getParameter("new"))) {
responseData = fm.rename();
}
}
else if (mode.equals("delete")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path"))) {
responseData = fm.delete();
}
}
else if (mode.equals("addfolder")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path")) &&
fm.setGetVar("name", (strictServletCompliance)? qpm.get("name"):request.getParameter("name"))) {
responseData = fm.addFolder();
}
}
else if (mode.equals("download")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path"))) {
responseData = fm.download(request, response);
}
}
else if (mode.equals("getimage")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path"))) {
String paramThumbs =request.getParameter("thumbnail");
responseData = fm.preview(request, response);
}
}
else if (mode.equals("readfile")){
if(fm.setGetVar("path", (strictServletCompliance)? qpm.get("path"):request.getParameter("path"))) {
responseData = fm.preview(request, response);
}
}
else if (mode.equals("move")){
if(fm.setGetVar("old", (strictServletCompliance)? qpm.get("old"):request.getParameter("old")) &&
fm.setGetVar("new", (strictServletCompliance)? qpm.get("new"):request.getParameter("new"))
) {
responseData = fm.moveItem();
}
}
else if (mode.equals("copy")){
responseData = fm.copyItem(request);
}
else if (mode.equals("summarize")) {
responseData = fm.summarize();
} else {
responseData = fm.getErrorResponse(fm.lang("MODE_ERROR"));
}
} catch (Exception e) {
// already formatted if from setGetVar
log.error("error in filemanager.jsp:",e);
responseData = fm.getErrorResponse(e.getMessage());
}
}
} else if(request.getMethod().equals("POST")){
Expand All @@ -105,9 +120,6 @@
//putTextarea = true;
}
}
if (responseData == null){
responseData = fm.getError();
}
if (responseData != null){
//request.setCharacterEncoding("UTF-8");
// only if set
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified connectors/jsp/libraries/java/bin/org/json/JSONArray.class
Binary file not shown.
Binary file modified connectors/jsp/libraries/java/bin/org/json/JSONException.class
Binary file not shown.
Binary file modified connectors/jsp/libraries/java/bin/org/json/JSONObject$Null.class
Binary file not shown.
Binary file modified connectors/jsp/libraries/java/bin/org/json/JSONObject.class
Binary file not shown.
Binary file modified connectors/jsp/libraries/java/bin/org/json/JSONString.class
Binary file not shown.
Binary file modified connectors/jsp/libraries/java/bin/org/json/JSONTokener.class
Binary file not shown.
54 changes: 0 additions & 54 deletions connectors/jsp/libraries/java/src/com/nartex/FileManagerI.java

This file was deleted.

Loading

0 comments on commit 012078d

Please sign in to comment.