struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [09/14] struts git commit: Reduces code duplication
Date Fri, 25 Nov 2016 18:18:04 GMT
Reduces code duplication


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/6280feb4
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/6280feb4
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/6280feb4

Branch: refs/heads/master
Commit: 6280feb4266f5f8906b72d48a292a81939c8d151
Parents: e152c15
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Tue Nov 22 17:56:56 2016 +0100
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Tue Nov 22 17:56:56 2016 +0100

----------------------------------------------------------------------
 .../multipart/JakartaMultiPartRequest.java      |  2 +-
 .../JakartaStreamMultiPartRequest.java          | 11 +---
 .../multipart/JakartaUploadedFile.java          | 61 --------------------
 .../multipart/StrutsUploadedFile.java           | 61 ++++++++++++++++++++
 .../interceptor/FileUploadInterceptorTest.java  |  4 +-
 .../multipart/PellMultiPartRequest.java         |  2 +-
 .../dispatcher/multipart/PellUploadedFile.java  | 61 --------------------
 7 files changed, 66 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/6280feb4/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
index 900733c..30ec33d 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaMultiPartRequest.java
@@ -240,7 +240,7 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
                     LOG.error("Cannot write uploaded empty file to disk: {}", storeLocation.getAbsolutePath(),
e);
                 }
             }
-            fileList.add(new JakartaUploadedFile(storeLocation));
+            fileList.add(new StrutsUploadedFile(storeLocation));
         }
 
         return fileList.toArray(new UploadedFile[fileList.size()]);

http://git-wip-us.apache.org/repos/asf/struts/blob/6280feb4/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
index a6e15b8..49ca2be 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaStreamMultiPartRequest.java
@@ -135,15 +135,6 @@ public class JakartaStreamMultiPartRequest implements MultiPartRequest
{
         return errors;
     }
 
-    /**
-     * Allows interceptor to fetch non-critical messages that can be passed to the action.
-     *
-     * @return list of string messages
-     */
-    public List<String> getMesssages() {
-        return messages;
-    }
-
     /* (non-Javadoc)
      * @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getFile(java.lang.String)
      */
@@ -155,7 +146,7 @@ public class JakartaStreamMultiPartRequest implements MultiPartRequest
{
 
         List<UploadedFile> files = new ArrayList<>(infos.size());
         for (FileInfo fileInfo : infos) {
-            files.add(new JakartaUploadedFile(fileInfo.getFile()));
+            files.add(new StrutsUploadedFile(fileInfo.getFile()));
         }
 
         return files.toArray(new UploadedFile[files.size()]);

http://git-wip-us.apache.org/repos/asf/struts/blob/6280feb4/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaUploadedFile.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaUploadedFile.java
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaUploadedFile.java
deleted file mode 100644
index 3dfdea6..0000000
--- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/JakartaUploadedFile.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.struts2.dispatcher.multipart;
-
-import java.io.File;
-
-public class JakartaUploadedFile implements UploadedFile {
-
-    private File file;
-
-    public JakartaUploadedFile(File file) {
-        this.file = file;
-    }
-
-    @Override
-    public Long length() {
-        return file.length();
-    }
-
-    @Override
-    public String getName() {
-        return file.getName();
-    }
-
-    @Override
-    public boolean isFile() {
-        return file.isFile();
-    }
-
-    @Override
-    public boolean delete() {
-        return file.delete();
-    }
-
-    @Override
-    public String getAbsolutePath() {
-        return file.getAbsolutePath();
-    }
-
-    @Override
-    public File getContent() {
-        return file;
-    }
-}

http://git-wip-us.apache.org/repos/asf/struts/blob/6280feb4/core/src/main/java/org/apache/struts2/dispatcher/multipart/StrutsUploadedFile.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/StrutsUploadedFile.java
b/core/src/main/java/org/apache/struts2/dispatcher/multipart/StrutsUploadedFile.java
new file mode 100644
index 0000000..a185780
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/StrutsUploadedFile.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.struts2.dispatcher.multipart;
+
+import java.io.File;
+
+public class StrutsUploadedFile implements UploadedFile {
+
+    private File file;
+
+    public StrutsUploadedFile(File file) {
+        this.file = file;
+    }
+
+    @Override
+    public Long length() {
+        return file.length();
+    }
+
+    @Override
+    public String getName() {
+        return file.getName();
+    }
+
+    @Override
+    public boolean isFile() {
+        return file.isFile();
+    }
+
+    @Override
+    public boolean delete() {
+        return file.delete();
+    }
+
+    @Override
+    public String getAbsolutePath() {
+        return file.getAbsolutePath();
+    }
+
+    @Override
+    public File getContent() {
+        return file;
+    }
+}

http://git-wip-us.apache.org/repos/asf/struts/blob/6280feb4/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
b/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
index 87251cd..1cea2d7 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java
@@ -33,7 +33,7 @@ import org.apache.struts2.StrutsInternalTestCase;
 import org.apache.struts2.TestAction;
 import org.apache.struts2.dispatcher.HttpParameters;
 import org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest;
-import org.apache.struts2.dispatcher.multipart.JakartaUploadedFile;
+import org.apache.struts2.dispatcher.multipart.StrutsUploadedFile;
 import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
 import org.apache.struts2.dispatcher.multipart.UploadedFile;
 import org.springframework.mock.web.MockHttpServletRequest;
@@ -198,7 +198,7 @@ public class FileUploadInterceptorTest extends StrutsInternalTestCase
{
         URL url = ClassLoaderUtil.getResource("log4j2.xml", FileUploadInterceptorTest.class);
         File file = new File(new URI(url.toString()));
         assertTrue("log4j2.xml should be in src/test folder", file.exists());
-        boolean notOk = interceptor.acceptFile(action, new JakartaUploadedFile(file), "filename",
"text/html", "inputName", validation);
+        boolean notOk = interceptor.acceptFile(action, new StrutsUploadedFile(file), "filename",
"text/html", "inputName", validation);
 
         assertFalse(notOk);
         assertFalse(validation.getFieldErrors().isEmpty());

http://git-wip-us.apache.org/repos/asf/struts/blob/6280feb4/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
----------------------------------------------------------------------
diff --git a/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
b/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
index 1acfe46..40526e0 100644
--- a/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
+++ b/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java
@@ -93,7 +93,7 @@ public class PellMultiPartRequest implements MultiPartRequest {
     }
 
     public UploadedFile[] getFile(String fieldName) {
-        return new UploadedFile[]{ new PellUploadedFile(multi.getFile(fieldName)) };
+        return new UploadedFile[]{ new StrutsUploadedFile(multi.getFile(fieldName)) };
     }
 
     public String[] getFileNames(String fieldName) {

http://git-wip-us.apache.org/repos/asf/struts/blob/6280feb4/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellUploadedFile.java
----------------------------------------------------------------------
diff --git a/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellUploadedFile.java
b/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellUploadedFile.java
deleted file mode 100644
index b51c987..0000000
--- a/plugins/pell-multipart/src/main/java/org/apache/struts2/dispatcher/multipart/PellUploadedFile.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.struts2.dispatcher.multipart;
-
-import java.io.File;
-
-public class PellUploadedFile implements UploadedFile {
-
-    private File file;
-
-    public PellUploadedFile(File file) {
-        this.file = file;
-    }
-
-    @Override
-    public Long length() {
-        return file.length();
-    }
-
-    @Override
-    public String getName() {
-        return file.getName();
-    }
-
-    @Override
-    public boolean isFile() {
-        return file.isFile();
-    }
-
-    @Override
-    public boolean delete() {
-        return file.delete();
-    }
-
-    @Override
-    public String getAbsolutePath() {
-        return file.getAbsolutePath();
-    }
-
-    @Override
-    public File getContent() {
-        return file;
-    }
-}


Mime
View raw message