-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,465 additions
and
1,403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
connection.project.dir=../../ext | ||
connection.project.dir=../.. | ||
eclipse.preferences.version=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
Bundle-Name: API JSONWS JSPs Ext | ||
Bundle-Description: Overrides core/kernel API JSONWS JSPs | ||
Bundle-SymbolicName: it.baxtheman.liferay.apijsonwsext | ||
Bundle-Version: 7.1.0.5 | ||
Created-By: Daniele Baggio @baxtheman | ||
-sources: true | ||
Web-ContextPath: /api-jsonws-ext | ||
Bundle-Name: API JSONWS JSPs Ext | ||
Bundle-Description: Overrides core/kernel API JSONWS JSPs | ||
Bundle-SymbolicName: it.baxtheman.liferay.apijsonwsext | ||
Bundle-Version: 7.2.1.5 | ||
Created-By: Daniele Baggio @baxtheman | ||
-sources: true | ||
Web-ContextPath: /api-jsonws-ext | ||
Liferay-JS-Config:/META-INF/resources/js/config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
dependencies { | ||
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.impl" | ||
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel" | ||
compileOnly group: "org.osgi", name: "org.osgi.core" | ||
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations" | ||
dependencies { | ||
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.impl" | ||
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel" | ||
compileOnly group: "org.osgi", name: "org.osgi.core" | ||
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations" | ||
compileOnly group: "javax.servlet", name: "javax.servlet-api" | ||
} |
288 changes: 144 additions & 144 deletions
288
src/main/java/it/baxtheman/liferay/corejsphook/ApiJsonCustomJspBag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,145 +1,145 @@ | ||
/** | ||
* Copyright 2000-present Liferay, Inc. | ||
* | ||
* Licensed 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 it.baxtheman.liferay.corejsphook; | ||
|
||
import com.liferay.portal.deploy.hot.CustomJspBag; | ||
import com.liferay.portal.kernel.url.URLContainer; | ||
|
||
import java.net.URL; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Enumeration; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.osgi.framework.Bundle; | ||
import org.osgi.framework.BundleContext; | ||
import org.osgi.service.component.annotations.Activate; | ||
import org.osgi.service.component.annotations.Component; | ||
|
||
/** | ||
* Represents a custom JSP bag used to override Liferay's core JSPs. This class | ||
* sets the following properties: | ||
* | ||
* <ul> | ||
* <li> | ||
* <code>context.id</code>: the custom JSP bag class name | ||
* </li> | ||
* <li> | ||
* <code>context.name</code>: the human readable name for you service | ||
* </li> | ||
* <li> | ||
* <code>service.ranking</code>: the priority of your implementation. The | ||
* importance of your change dictates its service ranking. For example, if | ||
* another custom JSP bag implementation overriding the same JSP is deployed | ||
* with a service rank of <code>101</code>, it takes precedence over this one | ||
* because its service ranking is higher. | ||
* </li> | ||
* </ul> | ||
* | ||
* @author Liferay | ||
*/ | ||
@Component( | ||
immediate = true, | ||
property = { | ||
"context.id=ApiJsonCustomJspBag", "context.name=API JSONWS Extender", | ||
"service.ranking:Integer=100" | ||
} | ||
) | ||
public class ApiJsonCustomJspBag implements CustomJspBag { | ||
|
||
/** | ||
* Returns the directory path in the module JAR where the custom JSPs | ||
* reside. | ||
* | ||
* @return the directory path in the module JAR where the custom JSPs reside | ||
*/ | ||
@Override | ||
public String getCustomJspDir() { | ||
return "META-INF/jsps/"; | ||
} | ||
|
||
/** | ||
* Returns the custom JSP URL paths. | ||
* | ||
* @return the custom JSP URL paths | ||
*/ | ||
@Override | ||
public List<String> getCustomJsps() { | ||
return _customJsps; | ||
} | ||
|
||
@Override | ||
public URLContainer getURLContainer() { | ||
return _urlContainer; | ||
} | ||
|
||
@Override | ||
public boolean isCustomJspGlobal() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Adds the URL paths for all custom core JSPs to a list when the module is | ||
* activated. | ||
* | ||
* @param bundleContext the bundle context from which to get the custom | ||
* JSP's bundle | ||
*/ | ||
@Activate | ||
protected void activate(BundleContext bundleContext) { | ||
_bundle = bundleContext.getBundle(); | ||
|
||
_customJsps = new ArrayList<>(); | ||
|
||
Enumeration<URL> entries = _bundle.findEntries( | ||
getCustomJspDir(), "*.jsp*", true); | ||
|
||
while (entries.hasMoreElements()) { | ||
URL url = entries.nextElement(); | ||
|
||
_customJsps.add(url.getPath()); | ||
} | ||
} | ||
|
||
private Bundle _bundle; | ||
private List<String> _customJsps; | ||
|
||
private final URLContainer _urlContainer = new URLContainer() { | ||
|
||
@Override | ||
public URL getResource(String name) { | ||
return _bundle.getEntry(name); | ||
} | ||
|
||
@Override | ||
public Set<String> getResources(String path) { | ||
Set<String> paths = new HashSet<>(); | ||
|
||
for (String entry : _customJsps) { | ||
if (entry.startsWith(path)) { | ||
paths.add(entry); | ||
} | ||
} | ||
|
||
return paths; | ||
} | ||
|
||
}; | ||
|
||
/** | ||
* Copyright 2000-present Liferay, Inc. | ||
* | ||
* Licensed 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 it.baxtheman.liferay.corejsphook; | ||
|
||
import com.liferay.portal.deploy.hot.CustomJspBag; | ||
import com.liferay.portal.kernel.url.URLContainer; | ||
|
||
import java.net.URL; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Enumeration; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.osgi.framework.Bundle; | ||
import org.osgi.framework.BundleContext; | ||
import org.osgi.service.component.annotations.Activate; | ||
import org.osgi.service.component.annotations.Component; | ||
|
||
/** | ||
* Represents a custom JSP bag used to override Liferay's core JSPs. This class | ||
* sets the following properties: | ||
* | ||
* <ul> | ||
* <li> | ||
* <code>context.id</code>: the custom JSP bag class name | ||
* </li> | ||
* <li> | ||
* <code>context.name</code>: the human readable name for you service | ||
* </li> | ||
* <li> | ||
* <code>service.ranking</code>: the priority of your implementation. The | ||
* importance of your change dictates its service ranking. For example, if | ||
* another custom JSP bag implementation overriding the same JSP is deployed | ||
* with a service rank of <code>101</code>, it takes precedence over this one | ||
* because its service ranking is higher. | ||
* </li> | ||
* </ul> | ||
* | ||
* @author Liferay | ||
*/ | ||
@Component( | ||
immediate = true, | ||
property = { | ||
"context.id=ApiJsonCustomJspBag", "context.name=API JSONWS Extender", | ||
"service.ranking:Integer=100" | ||
} | ||
) | ||
public class ApiJsonCustomJspBag implements CustomJspBag { | ||
|
||
/** | ||
* Returns the directory path in the module JAR where the custom JSPs | ||
* reside. | ||
* | ||
* @return the directory path in the module JAR where the custom JSPs reside | ||
*/ | ||
@Override | ||
public String getCustomJspDir() { | ||
return "META-INF/jsps/"; | ||
} | ||
|
||
/** | ||
* Returns the custom JSP URL paths. | ||
* | ||
* @return the custom JSP URL paths | ||
*/ | ||
@Override | ||
public List<String> getCustomJsps() { | ||
return _customJsps; | ||
} | ||
|
||
@Override | ||
public URLContainer getURLContainer() { | ||
return _urlContainer; | ||
} | ||
|
||
@Override | ||
public boolean isCustomJspGlobal() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Adds the URL paths for all custom core JSPs to a list when the module is | ||
* activated. | ||
* | ||
* @param bundleContext the bundle context from which to get the custom | ||
* JSP's bundle | ||
*/ | ||
@Activate | ||
protected void activate(BundleContext bundleContext) { | ||
_bundle = bundleContext.getBundle(); | ||
|
||
_customJsps = new ArrayList<>(); | ||
|
||
Enumeration<URL> entries = _bundle.findEntries( | ||
getCustomJspDir(), "*.jsp*", true); | ||
|
||
while (entries.hasMoreElements()) { | ||
URL url = entries.nextElement(); | ||
|
||
_customJsps.add(url.getPath()); | ||
} | ||
} | ||
|
||
private Bundle _bundle; | ||
private List<String> _customJsps; | ||
|
||
private final URLContainer _urlContainer = new URLContainer() { | ||
|
||
@Override | ||
public URL getResource(String name) { | ||
return _bundle.getEntry(name); | ||
} | ||
|
||
@Override | ||
public Set<String> getResources(String path) { | ||
Set<String> paths = new HashSet<>(); | ||
|
||
for (String entry : _customJsps) { | ||
if (entry.startsWith(path)) { | ||
paths.add(entry); | ||
} | ||
} | ||
|
||
return paths; | ||
} | ||
|
||
}; | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/it/baxtheman/liferay/filter/ApiJsonwsFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package it.baxtheman.liferay.filter; | ||
|
||
import javax.servlet.Filter; | ||
import javax.servlet.FilterChain; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.osgi.service.component.annotations.Activate; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.Deactivate; | ||
|
||
import com.liferay.portal.kernel.log.Log; | ||
import com.liferay.portal.kernel.log.LogFactoryUtil; | ||
import com.liferay.portal.kernel.servlet.BaseFilter; | ||
|
||
@Component(immediate = true, property = { | ||
"servlet-context-name=", | ||
"servlet-filter-name=ApiJsonwsFilter", | ||
"url-pattern=/api/jsonws/invoke/*" }, | ||
service = Filter.class) | ||
public class ApiJsonwsFilter extends BaseFilter { | ||
|
||
@Activate | ||
void activate() { | ||
|
||
_log.info("init"); | ||
} | ||
|
||
@Deactivate | ||
void deactivate() { | ||
} | ||
|
||
@Override | ||
protected void processFilter(HttpServletRequest request, | ||
HttpServletResponse response, FilterChain filterChain) | ||
throws Exception { | ||
|
||
String cmd = request.getParameter("cmd"); | ||
|
||
if (_log.isDebugEnabled()) { | ||
|
||
_log.debug("ApiJsonwsFilter " + cmd); | ||
} | ||
|
||
super.processFilter(request, response, filterChain); | ||
} | ||
|
||
@Override | ||
protected Log getLog() { | ||
return _log; | ||
} | ||
|
||
private static final Log _log = LogFactoryUtil.getLog(ApiJsonwsFilter.class); | ||
} |
Oops, something went wrong.