View Javadoc
1   /*
2    * Copyright 2012-2017 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.mylasta.direction.sponsor;
17  
18  import org.codelibs.core.lang.StringUtil;
19  import org.codelibs.fess.util.ComponentUtil;
20  import org.dbflute.util.DfTypeUtil;
21  import org.lastaflute.web.path.ActionAdjustmentProvider;
22  import org.lastaflute.web.path.FormMappingOption;
23  
24  /**
25   * @author jflute
26   */
27  public class FessActionAdjustmentProvider implements ActionAdjustmentProvider {
28  
29      // _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
30      // you can adjust your actions by overriding
31      // default methods defined at the interface
32      // _/_/_/_/_/_/_/_/_/_/
33  
34      @Override
35      public FormMappingOption adjustFormMapping() {
36          return new FormMappingOption().filterSimpleTextParameter((parameter, meta) -> {
37              return parameter.trim();
38          });
39      }
40  
41      @Override
42      public String customizeActionMappingRequestPath(final String requestPath) {
43          if (StringUtil.isBlank(requestPath)) {
44              return null;
45          }
46          final String virtualHostKey = ComponentUtil.getFessConfig().getVirtualHostKey();
47          if (StringUtil.isBlank(virtualHostKey)) {
48              return null;
49          }
50          final String prefix = "/" + virtualHostKey;
51          if (requestPath.startsWith(prefix)) {
52              return requestPath.substring(prefix.length());
53          }
54          return null;
55      }
56  
57      @Override
58      public String toString() {
59          return DfTypeUtil.toClassTitle(this) + ":{}";
60      }
61  }