From commits-return-18367-archive-asf-public=cust-asf.ponee.io@struts.apache.org Tue Apr 23 06:23:06 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id DD2C6180621 for ; Tue, 23 Apr 2019 08:23:05 +0200 (CEST) Received: (qmail 33927 invoked by uid 500); 23 Apr 2019 06:23:05 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 33916 invoked by uid 99); 23 Apr 2019 06:23:05 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Apr 2019 06:23:05 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id DD10787A46; Tue, 23 Apr 2019 06:23:04 +0000 (UTC) Date: Tue, 23 Apr 2019 06:23:04 +0000 To: "commits@struts.apache.org" Subject: [struts] branch master updated: use Tiles already provided URLApplicationResource MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155600058464.30648.13834220068054126630@gitbox.apache.org> From: lukaszlenart@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: struts X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 47a8a21da276ca1f2521685f7445330be84c66ee X-Git-Newrev: 517c2d690b5ec4d10bd86a490341239beccc530f X-Git-Rev: 517c2d690b5ec4d10bd86a490341239beccc530f X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/master by this push: new 517c2d6 use Tiles already provided URLApplicationResource new 33137a4 Merge pull request #352 from yasserzamani/WW-5011 517c2d6 is described below commit 517c2d690b5ec4d10bd86a490341239beccc530f Author: Yasser Zamani AuthorDate: Sat Apr 20 12:28:07 2019 +0430 use Tiles already provided URLApplicationResource fixes WW-5011 see also: https://github.com/joshlong/spring-framework/blob/910dd4146721a803cd9d246b91854e77ffe9272a/spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/SpringWildcardServletTilesApplicationContext.java#L88 --- .../struts2/tiles/StrutsApplicationResource.java | 55 ---------------------- .../StrutsWildcardServletApplicationContext.java | 6 ++- 2 files changed, 4 insertions(+), 57 deletions(-) diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsApplicationResource.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsApplicationResource.java deleted file mode 100644 index 1f636f9..0000000 --- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsApplicationResource.java +++ /dev/null @@ -1,55 +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.tiles; - -import org.apache.tiles.request.locale.PostfixedApplicationResource; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -public class StrutsApplicationResource extends PostfixedApplicationResource { - - private final URL url; - - public StrutsApplicationResource(URL url) { - super(url.getPath()); - this.url = url; - } - - @Override - public InputStream getInputStream() throws IOException { - return url.openStream(); - } - - @Override - public long getLastModified() throws IOException { - File file = new File(url.getPath()); - if (file.exists()) { - return file.lastModified(); - } - return 0; - } - - @Override - public String toString() { - return "Resource " + getLocalePath() + " at " + url.toString(); - } -} diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java index 7af6069..5b1181f 100644 --- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java +++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java @@ -24,6 +24,7 @@ import com.opensymphony.xwork2.util.finder.ResourceFinder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.tiles.request.ApplicationResource; +import org.apache.tiles.request.locale.URLApplicationResource; import org.apache.tiles.request.servlet.ServletApplicationContext; import javax.servlet.ServletContext; @@ -101,7 +102,7 @@ public class StrutsWildcardServletApplicationContext extends ServletApplicationC File localFile = new File(localePath); if (localFile.exists()) { try { - return new StrutsApplicationResource(localFile.toURI().toURL()); + return new URLApplicationResource(localePath, localFile.toURI().toURL()); } catch (MalformedURLException e) { LOG.warn("Cannot access [{}]", localePath, e); return null; @@ -120,7 +121,8 @@ public class StrutsWildcardServletApplicationContext extends ServletApplicationC for (Map.Entry entry : matches.entrySet()) { if (pattern.matcher(entry.getKey()).matches()) { - resources.add(new StrutsApplicationResource(entry.getValue())); + URL url = entry.getValue(); + resources.add(new URLApplicationResource(url.toExternalForm(), url)); } }