You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2024/12/12 13:21:40 UTC
(sling-org-apache-sling-scripting-jsp-taglib) 02/02: SLING-12552 apply spotless formatting
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch feature/SLING-12552-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp-taglib.git
commit 18cca34b3de6333064a8a411552a0b5b85c69cfe
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Thu Dec 12 14:21:31 2024 +0100
SLING-12552 apply spotless formatting
---
pom.xml | 36 ++-
.../sling/scripting/jsp/taglib/AbstractCATag.java | 36 ++-
.../jsp/taglib/AbstractDispatcherTagHandler.java | 30 +-
.../sling/scripting/jsp/taglib/AdaptToTag.java | 53 ++--
.../apache/sling/scripting/jsp/taglib/CallTag.java | 41 +--
.../scripting/jsp/taglib/DefineObjectsTEI.java | 81 +++--
.../scripting/jsp/taglib/DefineObjectsTag.java | 32 +-
.../sling/scripting/jsp/taglib/EncodeTag.java | 30 +-
.../sling/scripting/jsp/taglib/EvalTagHandler.java | 40 +--
.../scripting/jsp/taglib/FindResourcesTag.java | 42 +--
.../scripting/jsp/taglib/ForwardTagHandler.java | 34 +-
.../jsp/taglib/GetCAConfigResourceTag.java | 55 ++--
.../jsp/taglib/GetCAConfigResourcesTag.java | 58 ++--
.../sling/scripting/jsp/taglib/GetParentTag.java | 38 +--
.../sling/scripting/jsp/taglib/GetParentsTag.java | 42 +--
.../sling/scripting/jsp/taglib/GetPropertyTag.java | 58 ++--
.../sling/scripting/jsp/taglib/GetResourceTag.java | 43 +--
.../scripting/jsp/taglib/IncludeTagHandler.java | 54 ++--
.../scripting/jsp/taglib/ListChildrenTag.java | 40 +--
.../sling/scripting/jsp/taglib/SlingFunctions.java | 70 +++--
.../scripting/jsp/taglib/internal/XSSSupport.java | 109 +++----
.../sling/scripting/jsp/taglib/package-info.java | 1 -
.../scripting/jsp/taglib/tei/AbstractVarTEI.java | 30 +-
.../sling/scripting/jsp/taglib/tei/AdaptToTEI.java | 36 ++-
.../scripting/jsp/taglib/tei/GetPropertyTEI.java | 28 +-
.../taglib/tei/ResourceIteratorVariableTEI.java | 31 +-
.../jsp/taglib/tei/ResourceVariableTEI.java | 30 +-
.../jsp/taglib/tei/StringVariableTEI.java | 26 +-
.../scripting/jsp/taglib/tei/package-info.java | 1 -
.../scripting/jsp/taglib/MockPageContext.java | 42 +--
.../scripting/jsp/taglib/TestAdaptObjectTag.java | 38 +--
.../sling/scripting/jsp/taglib/TestEncodeTag.java | 40 +--
.../scripting/jsp/taglib/TestFindResourceTag.java | 50 +--
.../scripting/jsp/taglib/TestGetParentTag.java | 205 ++++++------
.../scripting/jsp/taglib/TestGetParentsTag.java | 199 ++++++------
.../scripting/jsp/taglib/TestGetPropertyTag.java | 150 ++++-----
.../scripting/jsp/taglib/TestGetResourceTag.java | 46 +--
.../scripting/jsp/taglib/TestListChildrenTag.java | 164 +++++-----
.../scripting/jsp/taglib/TestSlingFunctions.java | 343 ++++++++++-----------
.../sling/scripting/jsp/taglib/XSSSupportRule.java | 37 ++-
.../scripting/jsp/taglib/tei/AdaptToTEITest.java | 34 +-
41 files changed, 1299 insertions(+), 1254 deletions(-)
diff --git a/pom.xml b/pom.xml
index 26e3558..356d875 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!-- 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
@@ -20,26 +20,17 @@
<name>Apache Sling Scripting JSP Tag Library</name>
<description>Core Tag Library for Apache Sling JSP support</description>
- <properties>
- <sling.java.version>8</sling.java.version>
- <project.build.outputTimestamp>1</project.build.outputTimestamp>
- </properties>
-
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp-taglib.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp-taglib.git</developerConnection>
- <url>https://github.com/apache/sling-org-apache-sling-scripting-jsp-taglib.git</url>
<tag>HEAD</tag>
+ <url>https://github.com/apache/sling-org-apache-sling-scripting-jsp-taglib.git</url>
</scm>
- <build>
- <plugins>
- <plugin>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>bnd-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
+ <properties>
+ <sling.java.version>8</sling.java.version>
+ <project.build.outputTimestamp>1</project.build.outputTimestamp>
+ </properties>
<dependencies>
<dependency>
@@ -57,7 +48,8 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
- <version>2.11.0</version> <!-- TODO - possible to use a lower version? -->
+ <version>2.11.0</version>
+ <!-- TODO - possible to use a lower version? -->
<!-- using compile scope to help IDEs -->
<scope>compile</scope>
</dependency>
@@ -83,7 +75,8 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.xss</artifactId>
- <version>2.0.0</version> <!-- TODO - check if lower version is possible -->
+ <version>2.0.0</version>
+ <!-- TODO - check if lower version is possible -->
<scope>provided</scope>
</dependency>
@@ -183,4 +176,13 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/AbstractCATag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/AbstractCATag.java
index 6c85667..193bcf8 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/AbstractCATag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/AbstractCATag.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -68,19 +70,19 @@ public abstract class AbstractCATag extends TagSupport {
/**
* Method for retrieving the ConfigurationResourceResolver from the page
* context.
- *
+ *
* @return the resource resolver
*/
protected ConfigurationResourceResolver getConfigurationResourceResolver() {
- final SlingBindings bindings = (SlingBindings) pageContext.getRequest()
- .getAttribute(SlingBindings.class.getName());
+ final SlingBindings bindings =
+ (SlingBindings) pageContext.getRequest().getAttribute(SlingBindings.class.getName());
final SlingScriptHelper scriptHelper = bindings.getSling();
return scriptHelper.getService(ConfigurationResourceResolver.class);
}
/**
* Gets the variable name to which to save the list of children.
- *
+ *
* @return the variable name
*/
public String getVar() {
@@ -110,7 +112,7 @@ public abstract class AbstractCATag extends TagSupport {
/**
* Sets the variable name to which to save the list of children.
- *
+ *
* @param var the variable name
*/
public void setVar(String var) {
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/AbstractDispatcherTagHandler.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/AbstractDispatcherTagHandler.java
index 65077f0..77d50d7 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/AbstractDispatcherTagHandler.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/AbstractDispatcherTagHandler.java
@@ -1,23 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import java.io.IOException;
-
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
@@ -27,6 +27,8 @@ import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
+import java.io.IOException;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.request.RequestDispatcherOptions;
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/AdaptToTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/AdaptToTag.java
index b8e67fe..3f49b97 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/AdaptToTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/AdaptToTag.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -38,7 +40,7 @@ public class AdaptToTag extends TagSupport {
/*
* (non-Javadoc)
- *
+ *
* @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
*/
@Override
@@ -57,7 +59,7 @@ public class AdaptToTag extends TagSupport {
log.warn("Unable to retrieve class " + adaptTo, e);
}
- log.debug("Saving {} to variable {}",adapted, var);
+ log.debug("Saving {} to variable {}", adapted, var);
pageContext.setAttribute(var, adapted);
} else {
log.debug("Null adaptable specified");
@@ -68,7 +70,7 @@ public class AdaptToTag extends TagSupport {
/**
* Get the adaptable object to be adapted.
- *
+ *
* @return the adaptable
*/
public Adaptable getAdaptable() {
@@ -77,7 +79,7 @@ public class AdaptToTag extends TagSupport {
/**
* Gets the class name to adapt the adaptable to.
- *
+ *
* @return the class to adapt to
*/
public String getAdaptTo() {
@@ -86,21 +88,21 @@ public class AdaptToTag extends TagSupport {
/**
* Method for retrieving the classloader from the OSGi console.
- *
+ *
* @return the classloader
*/
protected ClassLoader getClassLoader() {
- final SlingBindings bindings = (SlingBindings) pageContext.getRequest()
- .getAttribute(SlingBindings.class.getName());
+ final SlingBindings bindings =
+ (SlingBindings) pageContext.getRequest().getAttribute(SlingBindings.class.getName());
final SlingScriptHelper scriptHelper = bindings.getSling();
- final DynamicClassLoaderManager dynamicClassLoaderManager = scriptHelper
- .getService(DynamicClassLoaderManager.class);
+ final DynamicClassLoaderManager dynamicClassLoaderManager =
+ scriptHelper.getService(DynamicClassLoaderManager.class);
return dynamicClassLoaderManager.getDynamicClassLoader();
}
/**
* Gets the variable name to save the resulting object to.
- *
+ *
* @return the variable name
*/
public String getVar() {
@@ -109,7 +111,7 @@ public class AdaptToTag extends TagSupport {
/**
* Sets the adaptable object to be adapted.
- *
+ *
* @param adaptable the object to adapt
*/
public void setAdaptable(Adaptable adaptable) {
@@ -118,7 +120,7 @@ public class AdaptToTag extends TagSupport {
/**
* Sets the class name to adapt the adaptable to.
- *
+ *
* @param adaptTo the class to adapt to
*/
public void setAdaptTo(String adaptTo) {
@@ -127,11 +129,10 @@ public class AdaptToTag extends TagSupport {
/**
* Gets the variable name to save the resulting object to.
- *
+ *
* @param var the variable name
*/
public void setVar(String var) {
this.var = var;
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/CallTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/CallTag.java
index 9f3fefc..193a218 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/CallTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/CallTag.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -59,8 +61,8 @@ public class CallTag extends TagSupport {
@Override
public int doEndTag() throws JspException {
- final SlingBindings bindings = (SlingBindings) pageContext.getRequest().getAttribute(
- SlingBindings.class.getName());
+ final SlingBindings bindings =
+ (SlingBindings) pageContext.getRequest().getAttribute(SlingBindings.class.getName());
final SlingScriptHelper scriptHelper = bindings.getSling();
final ServletResolver servletResolver = scriptHelper.getService(ServletResolver.class);
@@ -74,8 +76,9 @@ public class CallTag extends TagSupport {
if (servlet != null) {
servletName = RequestUtil.getServletName(servlet);
- tracker.log("Including script {0} for path={1}, type={2}: {3}", script, resource.getPath(),
- resource.getResourceType(), servletName);
+ tracker.log(
+ "Including script {0} for path={1}, type={2}: {3}",
+ script, resource.getPath(), resource.getResourceType(), servletName);
}
} else {
@@ -84,7 +87,8 @@ public class CallTag extends TagSupport {
if (!script.startsWith("/")) {
// resolve relative script
- String parentPath = ResourceUtil.getParent(scriptHelper.getScript().getScriptResource().getPath());
+ String parentPath = ResourceUtil.getParent(
+ scriptHelper.getScript().getScriptResource().getPath());
// check if parent resides on search path
for (String sp : resolver.getSearchPath()) {
if (parentPath.startsWith(sp)) {
@@ -132,7 +136,7 @@ public class CallTag extends TagSupport {
throw new JspException("Error while executing script " + script, e);
}
}
-
+
@Override
public void setPageContext(PageContext pageContext) {
super.setPageContext(pageContext);
@@ -164,5 +168,4 @@ public class CallTag extends TagSupport {
public void setIgnoreComponentHierarchy(boolean ignoreComponentHierarchy) {
this.ignoreComponentHierarchy = ignoreComponentHierarchy;
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java
index 749a351..cec3213 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java
@@ -1,37 +1,30 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_BINDINGS_NAME;
-import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_LOG_NAME;
-import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_NODE_NAME;
-import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_REQUEST_NAME;
-import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_RESOURCE_NAME;
-import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_RESOURCE_RESOLVER_NAME;
-import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_RESPONSE_NAME;
-import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_SLING_NAME;
-
-import java.util.ArrayList;
-import java.util.List;
-
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
@@ -40,6 +33,15 @@ import org.apache.sling.api.scripting.SlingBindings;
import org.apache.sling.api.scripting.SlingScriptHelper;
import org.slf4j.Logger;
+import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_BINDINGS_NAME;
+import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_LOG_NAME;
+import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_NODE_NAME;
+import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_REQUEST_NAME;
+import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_RESOURCE_NAME;
+import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_RESOURCE_RESOLVER_NAME;
+import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_RESPONSE_NAME;
+import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_SLING_NAME;
+
/**
* This class defines the scripting variables that are created by the
* <code>DefineObjectsTag</code>.
@@ -121,40 +123,31 @@ public class DefineObjectsTEI extends TagExtraInfo {
List<VariableInfo> varInfos = new ArrayList<>();
- addVar(varInfos, data, ATTR_REQUEST_NAME, DEFAULT_REQUEST_NAME,
- SLING_REQUEST_CLASS);
- addVar(varInfos, data, ATTR_RESPONSE_NAME, DEFAULT_RESPONSE_NAME,
- SLING_RESPONSE_CLASS);
+ addVar(varInfos, data, ATTR_REQUEST_NAME, DEFAULT_REQUEST_NAME, SLING_REQUEST_CLASS);
+ addVar(varInfos, data, ATTR_RESPONSE_NAME, DEFAULT_RESPONSE_NAME, SLING_RESPONSE_CLASS);
- addVar(varInfos, data, ATTR_RESOURCE_NAME, DEFAULT_RESOURCE_NAME,
- RESOURCE_CLASS);
- if ( DefineObjectsTag.JCR_NODE_CLASS != null ) {
+ addVar(varInfos, data, ATTR_RESOURCE_NAME, DEFAULT_RESOURCE_NAME, RESOURCE_CLASS);
+ if (DefineObjectsTag.JCR_NODE_CLASS != null) {
addVar(varInfos, data, ATTR_NODE_NAME, DEFAULT_NODE_NAME, NODE_CLASS);
}
- addVar(varInfos, data, ATTR_RESOURCE_RESOLVER_NAME,
- DEFAULT_RESOURCE_RESOLVER_NAME, RESOURCE_RESOLVER_CLASS);
+ addVar(varInfos, data, ATTR_RESOURCE_RESOLVER_NAME, DEFAULT_RESOURCE_RESOLVER_NAME, RESOURCE_RESOLVER_CLASS);
- addVar(varInfos, data, ATTR_SLING_NAME,
- DEFAULT_SLING_NAME, SLING_CLASS);
+ addVar(varInfos, data, ATTR_SLING_NAME, DEFAULT_SLING_NAME, SLING_CLASS);
- addVar(varInfos, data, ATTR_LOG_NAME,
- DEFAULT_LOG_NAME, LOG_CLASS);
+ addVar(varInfos, data, ATTR_LOG_NAME, DEFAULT_LOG_NAME, LOG_CLASS);
- addVar(varInfos, data, ATTR_BINDINGS_NAME,
- DEFAULT_BINDINGS_NAME, BINDINGS_CLASS);
+ addVar(varInfos, data, ATTR_BINDINGS_NAME, DEFAULT_BINDINGS_NAME, BINDINGS_CLASS);
return varInfos.toArray(new VariableInfo[varInfos.size()]);
-
}
- private void addVar(List<VariableInfo> varInfos, TagData data,
- String attrName, String defaultValue, String varClass) {
+ private void addVar(
+ List<VariableInfo> varInfos, TagData data, String attrName, String defaultValue, String varClass) {
String value = getValue(data, attrName, defaultValue);
if (value != null && varClass != null) {
- varInfos.add(new VariableInfo(value, varClass, true,
- VariableInfo.AT_END));
+ varInfos.add(new VariableInfo(value, varClass, true, VariableInfo.AT_END));
}
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java
index 392048c..9bd5e99 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -96,6 +98,7 @@ public class DefineObjectsTag extends TagSupport {
private String resourceResolverName = DEFAULT_RESOURCE_RESOLVER_NAME;
static Class<?> JCR_NODE_CLASS;
+
static {
try {
JCR_NODE_CLASS = DefineObjectsTag.class.getClassLoader().loadClass("javax.jcr.Node");
@@ -126,7 +129,8 @@ public class DefineObjectsTag extends TagSupport {
*/
@Override
public int doEndTag() {
- final SlingBindings bindings = (SlingBindings)pageContext.getRequest().getAttribute(SlingBindings.class.getName());
+ final SlingBindings bindings =
+ (SlingBindings) pageContext.getRequest().getAttribute(SlingBindings.class.getName());
final SlingScriptHelper scriptHelper = bindings.getSling();
pageContext.setAttribute(requestName, scriptHelper.getRequest());
@@ -137,7 +141,7 @@ public class DefineObjectsTag extends TagSupport {
pageContext.setAttribute(slingName, scriptHelper);
pageContext.setAttribute(logName, bindings.getLog());
pageContext.setAttribute(bindingsName, bindings);
- if ( JCR_NODE_CLASS != null ) {
+ if (JCR_NODE_CLASS != null) {
final Object node = resource.adaptTo(JCR_NODE_CLASS);
if (node != null) {
pageContext.setAttribute(nodeName, node);
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/EncodeTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/EncodeTag.java
index ce3a460..b0b0616 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/EncodeTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/EncodeTag.java
@@ -1,26 +1,28 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import java.io.IOException;
-
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
+import java.io.IOException;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.scripting.jsp.taglib.internal.XSSSupport;
import org.apache.sling.scripting.jsp.taglib.internal.XSSSupport.EncodingMode;
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/EvalTagHandler.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/EvalTagHandler.java
index 8999960..bb74d7a 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/EvalTagHandler.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/EvalTagHandler.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -69,8 +71,8 @@ public class EvalTagHandler extends TagSupport {
public int doEndTag() throws JspException {
log.debug("EvalTagHandler doEndTag");
- final SlingBindings bindings = (SlingBindings) pageContext.getRequest()
- .getAttribute(SlingBindings.class.getName());
+ final SlingBindings bindings =
+ (SlingBindings) pageContext.getRequest().getAttribute(SlingBindings.class.getName());
final SlingScriptHelper scriptHelper = bindings.getSling();
final ServletResolver servletResolver = scriptHelper.getService(ServletResolver.class);
@@ -81,8 +83,10 @@ public class EvalTagHandler extends TagSupport {
if (this.resource != null) {
evalResource = this.resource;
} else if (this.resourceType != null) {
- evalResource = new SyntheticResource(bindings.getRequest().getResourceResolver(),
- bindings.getResource().getPath(), this.resourceType);
+ evalResource = new SyntheticResource(
+ bindings.getRequest().getResourceResolver(),
+ bindings.getResource().getPath(),
+ this.resourceType);
} else {
evalResource = bindings.getResource();
}
@@ -93,7 +97,8 @@ public class EvalTagHandler extends TagSupport {
if (!script.startsWith("/")) {
// resolve relative script
- String parentPath = ResourceUtil.getParent(scriptHelper.getScript().getScriptResource().getPath());
+ String parentPath = ResourceUtil.getParent(
+ scriptHelper.getScript().getScriptResource().getPath());
// check if parent resides on search path
for (String sp : rr.getSearchPath()) {
if (parentPath.startsWith(sp)) {
@@ -131,7 +136,6 @@ public class EvalTagHandler extends TagSupport {
} catch (Exception e) {
log.error("Error while executing script " + script, e);
throw new JspException("Error while executing script " + script, e);
-
}
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/FindResourcesTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/FindResourcesTag.java
index e9edc03..7cb30ff 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/FindResourcesTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/FindResourcesTag.java
@@ -1,25 +1,27 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import java.util.Iterator;
-
import javax.servlet.jsp.tagext.TagSupport;
+import java.util.Iterator;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.slf4j.Logger;
@@ -48,7 +50,7 @@ public class FindResourcesTag extends TagSupport {
/*
* (non-Javadoc)
- *
+ *
* @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
*/
@Override
@@ -65,15 +67,15 @@ public class FindResourcesTag extends TagSupport {
return EVAL_PAGE;
}
-
+
/**
* Method for retrieving the ResourceResolver from the page context.
- *
+ *
* @return the resource resolver
*/
protected ResourceResolver getResourceResolver() {
return SlingFunctions.getResourceResolver(pageContext);
- }
+ }
/**
* Gets the language.
@@ -95,7 +97,7 @@ public class FindResourcesTag extends TagSupport {
/**
* Gets the variable name to which to save the list of children.
- *
+ *
* @return the variable name
*/
public String getVar() {
@@ -122,7 +124,7 @@ public class FindResourcesTag extends TagSupport {
/**
* Sets the variable name to which to save the list of children.
- *
+ *
* @param var the variable name
*/
public void setVar(String var) {
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/ForwardTagHandler.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/ForwardTagHandler.java
index f008f8e..199783b 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/ForwardTagHandler.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/ForwardTagHandler.java
@@ -1,29 +1,31 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import java.io.IOException;
-
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.jsp.JspTagException;
+import java.io.IOException;
+
/**
* The <code>ForwardTagHandler</code> implements the
* <code><sling:forward></code> custom tag.
@@ -32,8 +34,7 @@ public class ForwardTagHandler extends AbstractDispatcherTagHandler {
private static final long serialVersionUID = 4516800311593983971L;
- protected void dispatch(RequestDispatcher dispatcher,
- ServletRequest request, ServletResponse response)
+ protected void dispatch(RequestDispatcher dispatcher, ServletRequest request, ServletResponse response)
throws IOException, ServletException, JspTagException {
try {
dispatcher.forward(request, response);
@@ -41,5 +42,4 @@ public class ForwardTagHandler extends AbstractDispatcherTagHandler {
throw new JspTagException(ise);
}
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetCAConfigResourceTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetCAConfigResourceTag.java
index dfa4925..e978f4c 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetCAConfigResourceTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetCAConfigResourceTag.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -27,25 +29,24 @@ import org.slf4j.LoggerFactory;
*/
public class GetCAConfigResourceTag extends AbstractCATag {
- /** Serialization UID */
- private static final long serialVersionUID = -8191004532757820167L;
+ /** Serialization UID */
+ private static final long serialVersionUID = -8191004532757820167L;
- /** The Constant log. */
- private static final Logger log = LoggerFactory.getLogger(GetCAConfigResourceTag.class);
+ /** The Constant log. */
+ private static final Logger log = LoggerFactory.getLogger(GetCAConfigResourceTag.class);
- @Override
- public int doEndTag() {
- log.trace("doEndTag");
+ @Override
+ public int doEndTag() {
+ log.trace("doEndTag");
- ConfigurationResourceResolver caResourceResolver = this.getConfigurationResourceResolver();
+ ConfigurationResourceResolver caResourceResolver = this.getConfigurationResourceResolver();
- log.debug("Finding configuration with {}/{} for {}", getBucket(), getName(), getResource());
- Resource config = caResourceResolver.getResource(getResource(), getBucket(), getName());
+ log.debug("Finding configuration with {}/{} for {}", getBucket(), getName(), getResource());
+ Resource config = caResourceResolver.getResource(getResource(), getBucket(), getName());
- log.debug("Saving {} to variable {}", config, getVar());
- pageContext.setAttribute(getVar(), config);
-
- return EVAL_PAGE;
- }
+ log.debug("Saving {} to variable {}", config, getVar());
+ pageContext.setAttribute(getVar(), config);
+ return EVAL_PAGE;
+ }
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetCAConfigResourcesTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetCAConfigResourcesTag.java
index d40e357..c3f3714 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetCAConfigResourcesTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetCAConfigResourcesTag.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -29,26 +31,26 @@ import org.slf4j.LoggerFactory;
*/
public class GetCAConfigResourcesTag extends AbstractCATag {
- /** Serialization UID */
- private static final long serialVersionUID = -8191004532757820167L;
+ /** Serialization UID */
+ private static final long serialVersionUID = -8191004532757820167L;
- /** The Constant log. */
- private static final Logger log = LoggerFactory.getLogger(GetCAConfigResourceTag.class);
-
+ /** The Constant log. */
+ private static final Logger log = LoggerFactory.getLogger(GetCAConfigResourceTag.class);
- @Override
- public int doEndTag() {
- log.trace("doEndTag");
+ @Override
+ public int doEndTag() {
+ log.trace("doEndTag");
- ConfigurationResourceResolver caResourceResolver = this.getConfigurationResourceResolver();
+ ConfigurationResourceResolver caResourceResolver = this.getConfigurationResourceResolver();
- log.debug("Finding configuration with {}/{} for {}", getBucket(), getName(), getResource());
- Iterator<Resource> config = caResourceResolver.getResourceCollection(getResource(), getBucket(), getName()).iterator();
+ log.debug("Finding configuration with {}/{} for {}", getBucket(), getName(), getResource());
+ Iterator<Resource> config = caResourceResolver
+ .getResourceCollection(getResource(), getBucket(), getName())
+ .iterator();
- log.debug("Saving {} to variable {}", config, getVar());
- pageContext.setAttribute(getVar(), config);
-
- return EVAL_PAGE;
- }
+ log.debug("Saving {} to variable {}", config, getVar());
+ pageContext.setAttribute(getVar(), config);
+ return EVAL_PAGE;
+ }
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetParentTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetParentTag.java
index a8cf10b..bb0ea71 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetParentTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetParentTag.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -68,7 +70,7 @@ public class GetParentTag extends TagSupport {
/**
* Gets the resource.
- *
+ *
* @return the resource
*/
public Resource getResource() {
@@ -77,7 +79,7 @@ public class GetParentTag extends TagSupport {
/**
* Get the level of the parent resource to retrieve.
- *
+ *
* @return the level
*/
public String getLevel() {
@@ -86,7 +88,7 @@ public class GetParentTag extends TagSupport {
/**
* Gets the variable name to which to save the list of children.
- *
+ *
* @return the variable name
*/
public String getVar() {
@@ -95,7 +97,7 @@ public class GetParentTag extends TagSupport {
/**
* Sets the resource.
- *
+ *
* @param resource the new resource
*/
public void setResource(Resource resource) {
@@ -104,7 +106,7 @@ public class GetParentTag extends TagSupport {
/**
* Set the level of the parent resource to retrieve.
- *
+ *
* @param level the level
*/
public void setLevel(String level) {
@@ -113,7 +115,7 @@ public class GetParentTag extends TagSupport {
/**
* Sets the variable name to which to save the parent resource.
- *
+ *
* @param var the variable name
*/
public void setVar(String var) {
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetParentsTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetParentsTag.java
index 7e56c12..167c133 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetParentsTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetParentsTag.java
@@ -1,27 +1,29 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
+import javax.servlet.jsp.tagext.TagSupport;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import javax.servlet.jsp.tagext.TagSupport;
-
import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -79,7 +81,7 @@ public class GetParentsTag extends TagSupport {
/**
* Gets the resource.
- *
+ *
* @return the resource
*/
public Resource getResource() {
@@ -88,7 +90,7 @@ public class GetParentsTag extends TagSupport {
/**
* Retrieves the start depth
- *
+ *
* @return the start depth to retrieve
*/
public String getStartDepth() {
@@ -97,7 +99,7 @@ public class GetParentsTag extends TagSupport {
/**
* Gets the variable name to which to save the list of children.
- *
+ *
* @return the variable name
*/
public String getVar() {
@@ -106,7 +108,7 @@ public class GetParentsTag extends TagSupport {
/**
* Sets the resource.
- *
+ *
* @param resource the new resource
*/
public void setResource(Resource resource) {
@@ -117,7 +119,7 @@ public class GetParentsTag extends TagSupport {
* The depth at which to start, for example given a path of:
* /content/page1/page2/page3 and a start depth of 3, the parents page2/page3
* would be returned
- *
+ *
* @param startDepth the start depth from which to retrieve the parent resources
*/
public void setStartDepth(String startDepth) {
@@ -126,7 +128,7 @@ public class GetParentsTag extends TagSupport {
/**
* Sets the variable name to which to save the parent resource.
- *
+ *
* @param var the variable name
*/
public void setVar(String var) {
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetPropertyTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetPropertyTag.java
index 5d7d16b..e128b0d 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetPropertyTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetPropertyTag.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -40,7 +42,7 @@ public class GetPropertyTag extends TagSupport {
/*
* (non-Javadoc)
- *
+ *
* @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
*/
@Override
@@ -78,22 +80,22 @@ public class GetPropertyTag extends TagSupport {
/**
* Method for retrieving the classloader from the OSGi console.
- *
+ *
* @return the classloader
*/
protected ClassLoader getClassLoader() {
- final SlingBindings bindings = (SlingBindings) pageContext.getRequest()
- .getAttribute(SlingBindings.class.getName());
+ final SlingBindings bindings =
+ (SlingBindings) pageContext.getRequest().getAttribute(SlingBindings.class.getName());
final SlingScriptHelper scriptHelper = bindings.getSling();
- final DynamicClassLoaderManager dynamicClassLoaderManager = scriptHelper
- .getService(DynamicClassLoaderManager.class);
+ final DynamicClassLoaderManager dynamicClassLoaderManager =
+ scriptHelper.getService(DynamicClassLoaderManager.class);
return dynamicClassLoaderManager.getDynamicClassLoader();
}
/**
* Gets the default value to return if no value exists for the key. If
* specified, this takes precedence over returnClass.
- *
+ *
* @return the default value
*/
public Object getDefaultValue() {
@@ -102,7 +104,7 @@ public class GetPropertyTag extends TagSupport {
/**
* Gets key to retrieve the value from from the ValueMap.
- *
+ *
* @return the key
*/
public String getKey() {
@@ -111,7 +113,7 @@ public class GetPropertyTag extends TagSupport {
/**
* Gets the ValueMap from which to retrieve the value.
- *
+ *
* @return the ValueMap of properties
*/
public ValueMap getProperties() {
@@ -120,7 +122,7 @@ public class GetPropertyTag extends TagSupport {
/**
* Gets the name of class into which to coerce the returned value.
- *
+ *
* @return the class name
*/
public String getReturnClass() {
@@ -129,7 +131,7 @@ public class GetPropertyTag extends TagSupport {
/**
* Gets the variable name to which to save the value
- *
+ *
* @return the variable name
*/
public String getVar() {
@@ -139,7 +141,7 @@ public class GetPropertyTag extends TagSupport {
/**
* Sets the default value to return if no value exists for the key. If
* specified, this takes precedence over returnClass.
- *
+ *
* @param defaultValue the default value
*/
public void setDefaultValue(Object defaultValue) {
@@ -148,7 +150,7 @@ public class GetPropertyTag extends TagSupport {
/**
* Sets the key to retrieve the value from from the ValueMap.
- *
+ *
* @param key the key
*/
public void setKey(String key) {
@@ -157,7 +159,7 @@ public class GetPropertyTag extends TagSupport {
/**
* Sets the ValueMap from which to retrieve the value.
- *
+ *
* @param properties the ValueMap of properties
*/
public void setProperties(ValueMap properties) {
@@ -166,7 +168,7 @@ public class GetPropertyTag extends TagSupport {
/**
* Sets the name of class into which to coerce the returned value.
- *
+ *
* @param returnClass the class name
*/
public void setReturnClass(String returnClass) {
@@ -175,7 +177,7 @@ public class GetPropertyTag extends TagSupport {
/**
* Sets the variable name to which to save the value.
- *
+ *
* @param var the variable name
*/
public void setVar(String var) {
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetResourceTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetResourceTag.java
index baeac13..5c58437 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/GetResourceTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/GetResourceTag.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -70,17 +72,16 @@ public class GetResourceTag extends TagSupport {
/**
* Method for retrieving the ResourceResolver from the page context.
- *
+ *
* @return the resource resolver
*/
protected ResourceResolver getResourceResolver() {
return SlingFunctions.getResourceResolver(pageContext);
- }
-
+ }
/**
* Gets the base resource.
- *
+ *
* @return the base resource
*/
public Resource getBase() {
@@ -89,7 +90,7 @@ public class GetResourceTag extends TagSupport {
/**
* Get the path of the resource to retrieve.
- *
+ *
* @return the path
*/
public String getPath() {
@@ -98,7 +99,7 @@ public class GetResourceTag extends TagSupport {
/**
* Gets the variable name to which to save the list of children.
- *
+ *
* @return the variable name
*/
public String getVar() {
@@ -107,7 +108,7 @@ public class GetResourceTag extends TagSupport {
/**
* Sets the base resource.
- *
+ *
* @param base the new base resource
*/
public void setBase(Resource base) {
@@ -116,7 +117,7 @@ public class GetResourceTag extends TagSupport {
/**
* Set the path of the resource to retrieve.
- *
+ *
* @param path the path
*/
public void setPath(String path) {
@@ -125,7 +126,7 @@ public class GetResourceTag extends TagSupport {
/**
* Sets the variable name to which to save the list of children.
- *
+ *
* @param var the variable name
*/
public void setVar(String var) {
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java
index b56008a..59d0857 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java
@@ -1,23 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import java.io.IOException;
-
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
@@ -26,6 +26,8 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyContent;
+import java.io.IOException;
+
import org.apache.sling.scripting.core.servlet.CaptureResponseWrapper;
/**
@@ -38,11 +40,11 @@ public class IncludeTagHandler extends AbstractDispatcherTagHandler {
/** flush argument */
private boolean flush = false;
+
private String var = null;
private Integer scope = PageContext.PAGE_SCOPE;
- protected void dispatch(RequestDispatcher dispatcher,
- ServletRequest request, ServletResponse response)
+ protected void dispatch(RequestDispatcher dispatcher, ServletRequest request, ServletResponse response)
throws IOException, ServletException {
// optionally flush
@@ -74,37 +76,36 @@ public class IncludeTagHandler extends AbstractDispatcherTagHandler {
public void setFlush(boolean flush) {
this.flush = flush;
}
-
+
public void setVar(String var) {
if (var != null && var.trim().length() > 0) {
this.var = var;
}
}
-
+
// for tag attribute
public void setScope(String scope) {
this.scope = validScope(scope);
}
-
+
/**
* Gets the int code for a valid scope, must be one of 'page', 'request',
* 'session' or 'application'. If an invalid or no scope is specified page
* scope is returned.
- *
+ *
* @param scope
* @return
*/
private Integer validScope(String scope) {
- scope = (scope != null && scope.trim().length() > 0 ? scope.trim()
- .toUpperCase() : null);
+ scope = (scope != null && scope.trim().length() > 0 ? scope.trim().toUpperCase() : null);
if (scope == null) {
return PageContext.PAGE_SCOPE;
}
- String[] scopes = { "PAGE", "REQUEST", "SESSION", "APPLICATION" };
- Integer[] iaScopes = { PageContext.PAGE_SCOPE,
- PageContext.REQUEST_SCOPE, PageContext.SESSION_SCOPE,
- PageContext.APPLICATION_SCOPE };
+ String[] scopes = {"PAGE", "REQUEST", "SESSION", "APPLICATION"};
+ Integer[] iaScopes = {
+ PageContext.PAGE_SCOPE, PageContext.REQUEST_SCOPE, PageContext.SESSION_SCOPE, PageContext.APPLICATION_SCOPE
+ };
for (int ndx = 0, len = scopes.length; ndx < len; ndx++) {
if (scopes[ndx].equals(scope)) {
@@ -113,5 +114,4 @@ public class IncludeTagHandler extends AbstractDispatcherTagHandler {
}
return PageContext.PAGE_SCOPE;
}
-
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/ListChildrenTag.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/ListChildrenTag.java
index 850d5bd..13d12d7 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/ListChildrenTag.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/ListChildrenTag.java
@@ -1,25 +1,27 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import java.util.Iterator;
-
import javax.servlet.jsp.tagext.TagSupport;
+import java.util.Iterator;
+
import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,7 +39,7 @@ public class ListChildrenTag extends TagSupport {
/*
* (non-Javadoc)
- *
+ *
* @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
*/
@Override
@@ -59,7 +61,7 @@ public class ListChildrenTag extends TagSupport {
/**
* Gets the resource of which to list the children.
- *
+ *
* @return the Sling Resource
*/
public Resource getResource() {
@@ -68,7 +70,7 @@ public class ListChildrenTag extends TagSupport {
/**
* Gets the variable name to which to save the list of children.
- *
+ *
* @return the variable name
*/
public String getVar() {
@@ -77,7 +79,7 @@ public class ListChildrenTag extends TagSupport {
/**
* Sets the resource of which to list the children.
- *
+ *
* @param resource the Sling Resource
*/
public void setResource(Resource resource) {
@@ -86,7 +88,7 @@ public class ListChildrenTag extends TagSupport {
/**
* Sets the variable name to which to save the list of children.
- *
+ *
* @param var the variable name
*/
public void setVar(String var) {
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/SlingFunctions.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/SlingFunctions.java
index 602c12d..34e07f7 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/SlingFunctions.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/SlingFunctions.java
@@ -1,29 +1,31 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
+import javax.servlet.jsp.PageContext;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import javax.servlet.jsp.PageContext;
-
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.adapter.Adaptable;
import org.apache.sling.api.resource.Resource;
@@ -48,7 +50,7 @@ public class SlingFunctions {
/**
* Adapt the adaptable to the adapter class.
- *
+ *
* @param adaptable the adaptable instance
* @param adapter the class to which to adapt the adaptable
* @return the adapted class instance
@@ -75,7 +77,7 @@ public class SlingFunctions {
/**
* XSS encodes the specified text using the specified mode.
- *
+ *
* @param value The text to encode
* @param mode The XSS mode to use, see XSSSupport for the list of available
* modes
@@ -88,7 +90,7 @@ public class SlingFunctions {
/**
* Searches for resources using the given query formulated in the given
* language.
- *
+ *
* @param resourceResolver the resource resolver to use to find resources with
* the specified query
* @param query The query string to use to find the resources.
@@ -110,7 +112,7 @@ public class SlingFunctions {
/**
* Method for retrieving an absolute parent resource.
- *
+ *
* @param current the current resource
* @param level the absolute level for the parent resource to retrieve
* @return the parent resource at the level
@@ -133,7 +135,7 @@ public class SlingFunctions {
/**
* Method for retrieving the CA Config resource for a specified resource
- *
+ *
* @param resource the resource for which to retrieve the CA Config resource
* @param bucket the bucket name of the configuration to retrieve
* @param name the configuration name to retrieve
@@ -141,14 +143,14 @@ public class SlingFunctions {
*/
public static final Resource getCAConfigResource(Resource resource, String bucket, String name) {
log.trace("getCAConfigResource");
- ConfigurationResourceResolver caResourceResolver = resource.getResourceResolver()
- .adaptTo(ConfigurationResourceResolver.class);
+ ConfigurationResourceResolver caResourceResolver =
+ resource.getResourceResolver().adaptTo(ConfigurationResourceResolver.class);
return caResourceResolver.getResource(resource, bucket, name);
}
/**
* Method for retrieving the CA Config resources for a specified resource
- *
+ *
* @param resource the resource for which to retrieve the CA Config resources
* @param bucket the bucket name of the configuration to retrieve
* @param name the configuration name to retrieve
@@ -156,15 +158,15 @@ public class SlingFunctions {
*/
public static final Iterator<Resource> getCAConfigResources(Resource resource, String bucket, String name) {
log.trace("getCAConfigResource");
- ConfigurationResourceResolver caResourceResolver = resource.getResourceResolver()
- .adaptTo(ConfigurationResourceResolver.class);
+ ConfigurationResourceResolver caResourceResolver =
+ resource.getResourceResolver().adaptTo(ConfigurationResourceResolver.class);
return caResourceResolver.getResourceCollection(resource, bucket, name).iterator();
}
/**
* Function for retrieving all of the parent resources of a specified resource,
* returning them in hierarchy order.
- *
+ *
* @param current the current resource for which to retrieve the parents
* @param startDepth The depth at which to start, for example given a path of:
* /content/page1/page2/page3 and a start depth of 3, the
@@ -195,7 +197,7 @@ public class SlingFunctions {
/**
* Gets the resource at the relative path to the provided resource.
- *
+ *
* @param base the resource relative to which to find the path
* @param path the relative path at which to find the resource
* @return the resource
@@ -216,7 +218,7 @@ public class SlingFunctions {
/**
* Method allow for the retrieval of resources.
- *
+ *
* @param resolver the current resource resolver
* @param path the path of the resource to retrieve
* @return the resource at the path or null
@@ -233,12 +235,12 @@ public class SlingFunctions {
/**
* Method for retrieving the ResourceResolver from the page context.
- *
+ *
* @return the resource resolver
*/
protected static final ResourceResolver getResourceResolver(PageContext pageContext) {
- final SlingBindings bindings = (SlingBindings) pageContext.getRequest()
- .getAttribute(SlingBindings.class.getName());
+ final SlingBindings bindings =
+ (SlingBindings) pageContext.getRequest().getAttribute(SlingBindings.class.getName());
final SlingScriptHelper scriptHelper = bindings.getSling();
return scriptHelper.getRequest().getResourceResolver();
}
@@ -247,7 +249,7 @@ public class SlingFunctions {
* Gets the value of the specified key from the ValueMap and either coerses the
* value into the specified type or uses the specified type as a default
* depending on the parameter passed in.
- *
+ *
* @param properties the ValueMap from which to retrieve the value
* @param key the key for the value to retrieve
* @param defaultOrType either the default value or the class to which to coerce
@@ -265,7 +267,7 @@ public class SlingFunctions {
/**
* Method for checking whether or not a resource has child resources.
- *
+ *
* @param resource the resource to check for child resources
* @return true if the resource has child resources, false otherwise
* @since 2.2.2
@@ -276,7 +278,7 @@ public class SlingFunctions {
/**
* Method for allowing the invocation of the Sling Resource listChildren method.
- *
+ *
* @param resource the resource of which to list the children
* @return the children of the resource
* @see org.apache.sling.api.resource.Resource#listChildren()
@@ -296,7 +298,7 @@ public class SlingFunctions {
/**
* Loads the Class for the name from the current thread's classload.
- *
+ *
* @param className The name of the class to load
* @return the class
* @throws ClassNotFoundException a class with the specified name could not be
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/internal/XSSSupport.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/internal/XSSSupport.java
index 9704a77..cb5604f 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/internal/XSSSupport.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/internal/XSSSupport.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib.internal;
@@ -23,66 +25,69 @@ import org.osgi.service.component.annotations.Reference;
/**
* Support for basic XSS protection as provided by the OWASP ESAPI's escape
* methods.
- *
+ *
* <p>Note that this class is an OSGi component only to make sure it can get a reference to the
* {@link XSSAPI} correctly. Its usage is intended to be only within this bundle. For all other usages,
* directly accessing the {@link XSSAPI} service is strongly recommended.</p>
*/
@Component
public class XSSSupport {
-
+
@Reference
private XSSAPI xssApi;
-
+
private static volatile XSSAPI XSS_API;
-
+
protected void activate() {
XSS_API = xssApi;
}
-
+
protected void deactivate() {
XSS_API = null;
}
- /**
- * The encoding modes supported by this tag.
- */
- public enum EncodingMode {
- /**
- * Encodes the content as HTML
- */
- HTML, HTML_ATTR, XML, XML_ATTR, JS
- }
-
- /**
- * Encodes the unencoded string using the specified mode. This will be
- * deferred to the corresponding OWASP ESAPI encoding method.
- *
- * @param unencoded
- * the unencoded string
- * @param mode
- * the mode with which to encode the string
- * @return the encoded string
- */
- public static String encode(String unencoded, EncodingMode mode) {
+ /**
+ * The encoding modes supported by this tag.
+ */
+ public enum EncodingMode {
+ /**
+ * Encodes the content as HTML
+ */
+ HTML,
+ HTML_ATTR,
+ XML,
+ XML_ATTR,
+ JS
+ }
+
+ /**
+ * Encodes the unencoded string using the specified mode. This will be
+ * deferred to the corresponding OWASP ESAPI encoding method.
+ *
+ * @param unencoded
+ * the unencoded string
+ * @param mode
+ * the mode with which to encode the string
+ * @return the encoded string
+ */
+ public static String encode(String unencoded, EncodingMode mode) {
- if ( XSS_API == null )
- throw new IllegalStateException("No XSS_API field set. Is the XSSAPI service available?");
- switch ( mode ) {
- case HTML:
- return XSS_API.encodeForHTML(unencoded);
- case HTML_ATTR:
- return XSS_API.encodeForHTMLAttr(unencoded);
- case XML:
- return XSS_API.encodeForXML(unencoded);
- case XML_ATTR:
- return XSS_API.encodeForHTMLAttr(unencoded);
- case JS:
- return XSS_API.encodeForJSString(unencoded);
+ if (XSS_API == null) throw new IllegalStateException("No XSS_API field set. Is the XSSAPI service available?");
+ switch (mode) {
+ case HTML:
+ return XSS_API.encodeForHTML(unencoded);
+ case HTML_ATTR:
+ return XSS_API.encodeForHTMLAttr(unencoded);
+ case XML:
+ return XSS_API.encodeForXML(unencoded);
+ case XML_ATTR:
+ return XSS_API.encodeForHTMLAttr(unencoded);
+ case JS:
+ return XSS_API.encodeForJSString(unencoded);
default:
return unencoded;
}
- }
+ }
/**
* Retrieves the encoding mode associated with the specified string. Will throw
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/package-info.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/package-info.java
index 84dcca7..d4ade38 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/package-info.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/package-info.java
@@ -18,4 +18,3 @@
*/
@org.osgi.annotation.versioning.Version("2.4.0")
package org.apache.sling.scripting.jsp.taglib;
-
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/AbstractVarTEI.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/AbstractVarTEI.java
index b55040f..6f25d3b 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/AbstractVarTEI.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/AbstractVarTEI.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib.tei;
@@ -90,9 +92,7 @@ public abstract class AbstractVarTEI extends TagExtraInfo {
if (variableName == null) {
return new VariableInfo[0];
} else {
- return new VariableInfo[]{
- new VariableInfo(variableName, getClassName(data), true, VariableInfo.AT_END)
- };
+ return new VariableInfo[] {new VariableInfo(variableName, getClassName(data), true, VariableInfo.AT_END)};
}
}
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/AdaptToTEI.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/AdaptToTEI.java
index 653619c..8e9f51d 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/AdaptToTEI.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/AdaptToTEI.java
@@ -1,28 +1,30 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib.tei;
import javax.servlet.jsp.tagext.TagData;
public class AdaptToTEI extends AbstractVarTEI {
- public static final String ATTR_ADAPT_TO = "adaptTo";
+ public static final String ATTR_ADAPT_TO = "adaptTo";
- @Override
- protected String getClassName(TagData data) {
- return safeGetStringAttribute(data, ATTR_ADAPT_TO, OBJECT_CLASS_NAME);
- }
+ @Override
+ protected String getClassName(TagData data) {
+ return safeGetStringAttribute(data, ATTR_ADAPT_TO, OBJECT_CLASS_NAME);
+ }
}
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/GetPropertyTEI.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/GetPropertyTEI.java
index 40c6829..825776b 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/GetPropertyTEI.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/GetPropertyTEI.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib.tei;
@@ -29,7 +31,7 @@ public class GetPropertyTEI extends AbstractVarTEI {
final String className = safeGetStringAttribute(data, ATTR_RETURN_CLASS, OBJECT_CLASS_NAME);
if (defaultValue != null) {
return defaultValue.getClass().getName();
- } else if (className != null){
+ } else if (className != null) {
return className;
} else {
return OBJECT_CLASS_NAME;
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/ResourceIteratorVariableTEI.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/ResourceIteratorVariableTEI.java
index c509da8..2103ffd 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/ResourceIteratorVariableTEI.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/ResourceIteratorVariableTEI.java
@@ -1,26 +1,29 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib.tei;
-import org.apache.sling.api.resource.Resource;
-
import javax.servlet.jsp.tagext.TagData;
+
import java.util.Iterator;
+import org.apache.sling.api.resource.Resource;
+
public class ResourceIteratorVariableTEI extends AbstractVarTEI {
private static final String ITERATOR_CLASS_NAME = Iterator.class.getName();
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/ResourceVariableTEI.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/ResourceVariableTEI.java
index 53ada3c..d974fd3 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/ResourceVariableTEI.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/ResourceVariableTEI.java
@@ -1,25 +1,27 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib.tei;
-import org.apache.sling.api.resource.Resource;
-
import javax.servlet.jsp.tagext.TagData;
+import org.apache.sling.api.resource.Resource;
+
public class ResourceVariableTEI extends AbstractVarTEI {
private static final String RESOURCE_CLASS_NAME = Resource.class.getName();
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/StringVariableTEI.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/StringVariableTEI.java
index 260d03c..0a84550 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/StringVariableTEI.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/StringVariableTEI.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib.tei;
diff --git a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/package-info.java b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/package-info.java
index a25f90a..286d67c 100644
--- a/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/package-info.java
+++ b/src/main/java/org/apache/sling/scripting/jsp/taglib/tei/package-info.java
@@ -18,4 +18,3 @@
*/
@org.osgi.annotation.versioning.Version("2.2.0")
package org.apache.sling.scripting.jsp.taglib.tei;
-
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/MockPageContext.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/MockPageContext.java
index 97f806b..2a25168 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/MockPageContext.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/MockPageContext.java
@@ -1,26 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@@ -33,6 +30,11 @@ import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.el.ExpressionEvaluator;
import javax.servlet.jsp.el.VariableResolver;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
public class MockPageContext extends PageContext {
private Map<String, Object> attributes = new HashMap<String, Object>();
@@ -98,8 +100,9 @@ public class MockPageContext extends PageContext {
}
@Override
- public void initialize(Servlet arg0, ServletRequest arg1, ServletResponse arg2, String arg3, boolean arg4, int arg5,
- boolean arg6) throws IOException, IllegalStateException, IllegalArgumentException {
+ public void initialize(
+ Servlet arg0, ServletRequest arg1, ServletResponse arg2, String arg3, boolean arg4, int arg5, boolean arg6)
+ throws IOException, IllegalStateException, IllegalArgumentException {
throw new java.lang.UnsupportedOperationException();
}
@@ -168,5 +171,4 @@ public class MockPageContext extends PageContext {
public void setAttribute(String arg0, Object arg1, int arg2) {
attributes.put(arg0, arg1);
}
-
}
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestAdaptObjectTag.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestAdaptObjectTag.java
index b4826fc..b4825a5 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestAdaptObjectTag.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestAdaptObjectTag.java
@@ -1,27 +1,24 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.junit.Before;
@@ -30,9 +27,13 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Unit Tests for the Class AdaptObject.
- *
+ *
* @see org.apache.sling.scripting.jsp.taglib.AdaptObjectTag
*/
public class TestAdaptObjectTag {
@@ -41,6 +42,7 @@ public class TestAdaptObjectTag {
@Rule
public final SlingContext context = new SlingContext();
+
private AdaptToTag adaptToTag;
private Resource resource;
private MockPageContext pageContext;
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestEncodeTag.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestEncodeTag.java
index 6fc5d58..fc5d8e6 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestEncodeTag.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestEncodeTag.java
@@ -1,37 +1,39 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
+import java.io.IOException;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+
/**
* Unit Tests for the Class EscapeTag.
- *
+ *
* @see org.apache.sling.scripting.jsp.taglib.EscapeTag
*/
public class TestEncodeTag {
@@ -40,6 +42,7 @@ public class TestEncodeTag {
private EncodeTag encodeTag;
private MockPageContext pageContext;
private StringBuilder sb;
+
@Rule
public XSSSupportRule xssSupportRule = new XSSSupportRule();
/**
@@ -155,7 +158,6 @@ public class TestEncodeTag {
public void write(char[] cbuf, int off, int len) throws IOException {
sb.append(cbuf);
}
-
};
pageContext = new MockPageContext() {
public JspWriter getOut() {
@@ -168,7 +170,7 @@ public class TestEncodeTag {
/**
* Tests the adapt object Tag functionality.
- *
+ *
* @throws JspException
*/
@Test
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestFindResourceTag.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestFindResourceTag.java
index 3acf620..3ab2a95 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestFindResourceTag.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestFindResourceTag.java
@@ -1,31 +1,29 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import javax.jcr.Session;
+import javax.servlet.ServletRequest;
import java.util.Arrays;
import java.util.Iterator;
-import javax.jcr.Session;
-import javax.servlet.ServletRequest;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.testing.mock.jcr.MockJcr;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -36,9 +34,13 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Unit Tests for the Class FindResourceTag.
- *
+ *
* @see org.apache.sling.scripting.jsp.taglib.FindResourceTag
*/
public class TestFindResourceTag {
@@ -47,6 +49,7 @@ public class TestFindResourceTag {
@Rule
public final SlingContext ctx = new SlingContext(ResourceResolverType.JCR_MOCK);
+
private FindResourcesTag findResourcesTag;
private Resource resource;
private MockPageContext pageContext;
@@ -60,12 +63,11 @@ public class TestFindResourceTag {
public void init() {
log.info("init");
- ctx.build()
- .resource("/")
- .resource(TEST_PATH);
-
+ ctx.build().resource("/").resource(TEST_PATH);
+
resource = ctx.resourceResolver().getResource(TEST_PATH);
- MockJcr.setQueryResult(ctx.resourceResolver().adaptTo(Session.class), Arrays.asList(resource.adaptTo(javax.jcr.Node.class)));
+ MockJcr.setQueryResult(
+ ctx.resourceResolver().adaptTo(Session.class), Arrays.asList(resource.adaptTo(javax.jcr.Node.class)));
pageContext = new MockPageContext() {
public ServletRequest getRequest() {
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetParentTag.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetParentTag.java
index 5ccdca8..e283339 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetParentTag.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetParentTag.java
@@ -1,26 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.junit.Before;
@@ -29,99 +26,101 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Unit Tests for the Class GetResourceTag.
- *
+ *
* @see org.apache.sling.scripting.jsp.taglib.GetResourceTag
*/
public class TestGetParentTag {
- private static final Logger log = LoggerFactory
- .getLogger(TestGetParentTag.class);
+ private static final Logger log = LoggerFactory.getLogger(TestGetParentTag.class);
@Rule
public final SlingContext ctx = new SlingContext();
- private GetParentTag getParentTag;
- private MockPageContext pageContext;
- private Resource child;
- private static final String VAR_KEY = "resource";
- private static final String TEST_ABSOLUTE_PATH = "/content";
- private static final String TEST_RELATIVE_PATH = "test";
-
- /**
- * Initializes the fields for this test.
- */
- @Before
- public void init() {
- log.info("init");
-
- ctx.build()
- .resource("/")
- .resource(TEST_ABSOLUTE_PATH)
- .resource(TEST_ABSOLUTE_PATH + "/" + TEST_RELATIVE_PATH);
-
- child = ctx.resourceResolver().getResource(TEST_ABSOLUTE_PATH + "/" + TEST_RELATIVE_PATH);
-
- getParentTag = new GetParentTag();
-
- pageContext = new MockPageContext();
- getParentTag.setPageContext(pageContext);
-
- log.info("init Complete");
- }
-
- /**
- * Tests using an absolute path.
- */
- @Test
- public void testAbsoluteParent() {
- log.info("testAbsoluteParent");
-
- getParentTag.setVar(VAR_KEY);
- getParentTag.setResource(child);
- getParentTag.setLevel("1");
- getParentTag.doEndTag();
- Object result = pageContext.getAttribute(VAR_KEY);
- assertNotNull(result);
- assertTrue(result instanceof Resource);
- assertEquals(TEST_ABSOLUTE_PATH, ((Resource) result).getPath());
-
- log.info("Test successful!");
- }
-
- /**
- * Tests using an relative path.
- */
- @Test
- public void testParent() {
- log.info("testParent");
-
- getParentTag.setVar(VAR_KEY);
- getParentTag.setResource(child);
- getParentTag.doEndTag();
- Object result = pageContext.getAttribute(VAR_KEY);
- assertNotNull(result);
- assertTrue(result instanceof Resource);
- assertEquals(TEST_ABSOLUTE_PATH, ((Resource) result).getPath());
-
- log.info("Test successful!");
- }
-
- /**
- * Tests to see what happens if a bad path is specified, this should just
- * return a null value instead of a resource.
- */
- @Test
- public void testBadPath() {
- log.info("testBadPath");
-
- getParentTag.setVar(VAR_KEY);
- getParentTag.setResource(child);
- getParentTag.setLevel("4");
- getParentTag.doEndTag();
- Object result = pageContext.getAttribute(VAR_KEY);
- assertNull(result);
-
- log.info("Test successful!");
- }
+
+ private GetParentTag getParentTag;
+ private MockPageContext pageContext;
+ private Resource child;
+ private static final String VAR_KEY = "resource";
+ private static final String TEST_ABSOLUTE_PATH = "/content";
+ private static final String TEST_RELATIVE_PATH = "test";
+
+ /**
+ * Initializes the fields for this test.
+ */
+ @Before
+ public void init() {
+ log.info("init");
+
+ ctx.build().resource("/").resource(TEST_ABSOLUTE_PATH).resource(TEST_ABSOLUTE_PATH + "/" + TEST_RELATIVE_PATH);
+
+ child = ctx.resourceResolver().getResource(TEST_ABSOLUTE_PATH + "/" + TEST_RELATIVE_PATH);
+
+ getParentTag = new GetParentTag();
+
+ pageContext = new MockPageContext();
+ getParentTag.setPageContext(pageContext);
+
+ log.info("init Complete");
+ }
+
+ /**
+ * Tests using an absolute path.
+ */
+ @Test
+ public void testAbsoluteParent() {
+ log.info("testAbsoluteParent");
+
+ getParentTag.setVar(VAR_KEY);
+ getParentTag.setResource(child);
+ getParentTag.setLevel("1");
+ getParentTag.doEndTag();
+ Object result = pageContext.getAttribute(VAR_KEY);
+ assertNotNull(result);
+ assertTrue(result instanceof Resource);
+ assertEquals(TEST_ABSOLUTE_PATH, ((Resource) result).getPath());
+
+ log.info("Test successful!");
+ }
+
+ /**
+ * Tests using an relative path.
+ */
+ @Test
+ public void testParent() {
+ log.info("testParent");
+
+ getParentTag.setVar(VAR_KEY);
+ getParentTag.setResource(child);
+ getParentTag.doEndTag();
+ Object result = pageContext.getAttribute(VAR_KEY);
+ assertNotNull(result);
+ assertTrue(result instanceof Resource);
+ assertEquals(TEST_ABSOLUTE_PATH, ((Resource) result).getPath());
+
+ log.info("Test successful!");
+ }
+
+ /**
+ * Tests to see what happens if a bad path is specified, this should just
+ * return a null value instead of a resource.
+ */
+ @Test
+ public void testBadPath() {
+ log.info("testBadPath");
+
+ getParentTag.setVar(VAR_KEY);
+ getParentTag.setResource(child);
+ getParentTag.setLevel("4");
+ getParentTag.doEndTag();
+ Object result = pageContext.getAttribute(VAR_KEY);
+ assertNull(result);
+
+ log.info("Test successful!");
+ }
}
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetParentsTag.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetParentsTag.java
index 6741ac1..55abaf2 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetParentsTag.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetParentsTag.java
@@ -1,26 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.util.Iterator;
import org.apache.sling.api.resource.Resource;
@@ -31,96 +28,96 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Unit Tests for the Class GetResourceTag.
- *
+ *
* @see org.apache.sling.scripting.jsp.taglib.GetResourceTag
*/
public class TestGetParentsTag {
- private static final Logger log = LoggerFactory
- .getLogger(TestGetParentsTag.class);
+ private static final Logger log = LoggerFactory.getLogger(TestGetParentsTag.class);
@Rule
- public final SlingContext ctx = new SlingContext();
- private GetParentsTag getParentsTag;
- private MockPageContext pageContext;
- private Resource child;
- private static final String VAR_KEY = "resource";
- private static final String TEST_ABSOLUTE_PATH = "/content";
- private static final String TEST_RELATIVE_PATH = "test";
-
- /**
- * Initializes the fields for this test.
- */
- @Before
- public void init() {
- log.info("init");
-
- ctx.build()
- .resource("/")
- .resource(TEST_ABSOLUTE_PATH)
- .resource(TEST_ABSOLUTE_PATH + "/" + TEST_RELATIVE_PATH);
-
- child = ctx.resourceResolver().getResource(TEST_ABSOLUTE_PATH + "/" + TEST_RELATIVE_PATH);
-
- getParentsTag = new GetParentsTag();
-
- pageContext = new MockPageContext();
- getParentsTag.setPageContext(pageContext);
-
- log.info("init Complete");
- }
-
- /**
- * Tests basic functionality.
- */
- @Test
- public void testParents() {
- log.info("testParents");
-
- getParentsTag.setVar(VAR_KEY);
- getParentsTag.setResource(child);
- getParentsTag.setStartDepth("0");
- getParentsTag.doEndTag();
- Object result = pageContext.getAttribute(VAR_KEY);
- assertNotNull(result);
- assertTrue(result instanceof Iterator);
- @SuppressWarnings("unchecked")
- Iterator<Resource> parents = (Iterator<Resource>)result;
- assertTrue(parents.hasNext());
-
- assertEquals("/", parents.next().getPath());
- assertTrue(parents.hasNext());
- assertEquals(TEST_ABSOLUTE_PATH, parents.next().getPath());
- assertFalse(parents.hasNext());
-
- log.info("Test successful!");
- }
-
-
- /**
- * Tests basic functionality.
- */
- @Test
- public void testParentsWithStartDepth() {
- log.info("testParentsWithStartDepth");
-
- getParentsTag.setVar(VAR_KEY);
- getParentsTag.setResource(child);
- getParentsTag.setStartDepth("1");
- getParentsTag.doEndTag();
- Object result = pageContext.getAttribute(VAR_KEY);
- assertNotNull(result);
- assertTrue(result instanceof Iterator);
- @SuppressWarnings("unchecked")
- Iterator<Resource> parents = (Iterator<Resource>)result;
- assertTrue(parents.hasNext());
-
- assertEquals(TEST_ABSOLUTE_PATH, parents.next().getPath());
- assertFalse(parents.hasNext());
-
- log.info("Test successful!");
- }
-
+ public final SlingContext ctx = new SlingContext();
+
+ private GetParentsTag getParentsTag;
+ private MockPageContext pageContext;
+ private Resource child;
+ private static final String VAR_KEY = "resource";
+ private static final String TEST_ABSOLUTE_PATH = "/content";
+ private static final String TEST_RELATIVE_PATH = "test";
+
+ /**
+ * Initializes the fields for this test.
+ */
+ @Before
+ public void init() {
+ log.info("init");
+
+ ctx.build().resource("/").resource(TEST_ABSOLUTE_PATH).resource(TEST_ABSOLUTE_PATH + "/" + TEST_RELATIVE_PATH);
+
+ child = ctx.resourceResolver().getResource(TEST_ABSOLUTE_PATH + "/" + TEST_RELATIVE_PATH);
+
+ getParentsTag = new GetParentsTag();
+
+ pageContext = new MockPageContext();
+ getParentsTag.setPageContext(pageContext);
+
+ log.info("init Complete");
+ }
+
+ /**
+ * Tests basic functionality.
+ */
+ @Test
+ public void testParents() {
+ log.info("testParents");
+
+ getParentsTag.setVar(VAR_KEY);
+ getParentsTag.setResource(child);
+ getParentsTag.setStartDepth("0");
+ getParentsTag.doEndTag();
+ Object result = pageContext.getAttribute(VAR_KEY);
+ assertNotNull(result);
+ assertTrue(result instanceof Iterator);
+ @SuppressWarnings("unchecked")
+ Iterator<Resource> parents = (Iterator<Resource>) result;
+ assertTrue(parents.hasNext());
+
+ assertEquals("/", parents.next().getPath());
+ assertTrue(parents.hasNext());
+ assertEquals(TEST_ABSOLUTE_PATH, parents.next().getPath());
+ assertFalse(parents.hasNext());
+
+ log.info("Test successful!");
+ }
+
+ /**
+ * Tests basic functionality.
+ */
+ @Test
+ public void testParentsWithStartDepth() {
+ log.info("testParentsWithStartDepth");
+
+ getParentsTag.setVar(VAR_KEY);
+ getParentsTag.setResource(child);
+ getParentsTag.setStartDepth("1");
+ getParentsTag.doEndTag();
+ Object result = pageContext.getAttribute(VAR_KEY);
+ assertNotNull(result);
+ assertTrue(result instanceof Iterator);
+ @SuppressWarnings("unchecked")
+ Iterator<Resource> parents = (Iterator<Resource>) result;
+ assertTrue(parents.hasNext());
+
+ assertEquals(TEST_ABSOLUTE_PATH, parents.next().getPath());
+ assertFalse(parents.hasNext());
+
+ log.info("Test successful!");
+ }
}
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetPropertyTag.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetPropertyTag.java
index 38a9e04..fbbe9fe 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetPropertyTag.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetPropertyTag.java
@@ -1,24 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
import java.util.HashMap;
import org.apache.sling.api.resource.ValueMap;
@@ -28,77 +27,78 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
/**
* Unit Tests for the Class GetPropertyTag.
* @see org.apache.sling.scripting.jsp.taglib.GetPropertyTag
*/
public class TestGetPropertyTag {
- private static final Logger log = LoggerFactory
- .getLogger(TestGetPropertyTag.class);
- private GetPropertyTag getPropertyTag;
- private MockPageContext pageContext;
- private static final String VAR_KEY = "value";
- private static final String TEST_KEY = "key";
- private static final String TEST_EMPTY_KEY = "key2";
- private static final String TEST_VALUE = "Sling";
+ private static final Logger log = LoggerFactory.getLogger(TestGetPropertyTag.class);
+ private GetPropertyTag getPropertyTag;
+ private MockPageContext pageContext;
+ private static final String VAR_KEY = "value";
+ private static final String TEST_KEY = "key";
+ private static final String TEST_EMPTY_KEY = "key2";
+ private static final String TEST_VALUE = "Sling";
+
+ /**
+ * Initializes the fields for this test.
+ */
+ @SuppressWarnings("serial")
+ @Before
+ public void init() {
+ log.info("init");
+ getPropertyTag = new GetPropertyTag() {
+ protected ClassLoader getClassLoader() {
+ return TestGetPropertyTag.class.getClassLoader();
+ }
+ };
- /**
- * Initializes the fields for this test.
- */
- @SuppressWarnings("serial")
- @Before
- public void init() {
- log.info("init");
- getPropertyTag = new GetPropertyTag() {
- protected ClassLoader getClassLoader() {
- return TestGetPropertyTag.class.getClassLoader();
- }
- };
+ pageContext = new MockPageContext();
+ getPropertyTag.setPageContext(pageContext);
+ }
- pageContext = new MockPageContext();
- getPropertyTag.setPageContext(pageContext);
- }
+ /**
+ * Tests the adapt object Tag functionality.
+ */
+ @Test
+ public void testAdaptObject() {
+ log.info("testAdaptObject");
- /**
- * Tests the adapt object Tag functionality.
- */
- @Test
- public void testAdaptObject() {
- log.info("testAdaptObject");
+ log.info("Setting up tests");
+ ValueMap properties = new ValueMapDecorator(new HashMap<String, Object>());
+ properties.put(TEST_KEY, TEST_VALUE);
+ getPropertyTag.setProperties(properties);
+ getPropertyTag.setVar(VAR_KEY);
- log.info("Setting up tests");
- ValueMap properties = new ValueMapDecorator(
- new HashMap<String, Object>());
- properties.put(TEST_KEY, TEST_VALUE);
- getPropertyTag.setProperties(properties);
- getPropertyTag.setVar(VAR_KEY);
+ log.info("Testing retrieving value with default value");
+ getPropertyTag.setDefaultValue(TEST_VALUE);
+ getPropertyTag.setKey(TEST_KEY);
+ getPropertyTag.doEndTag();
+ Object value = pageContext.getAttribute(VAR_KEY);
+ assertNotNull(value);
+ assertEquals(TEST_VALUE, value);
- log.info("Testing retrieving value with default value");
- getPropertyTag.setDefaultValue(TEST_VALUE);
- getPropertyTag.setKey(TEST_KEY);
- getPropertyTag.doEndTag();
- Object value = pageContext.getAttribute(VAR_KEY);
- assertNotNull(value);
- assertEquals(TEST_VALUE, value);
-
- log.info("Testing retrieving default value");
- getPropertyTag.setDefaultValue(TEST_VALUE);
- getPropertyTag.setKey(TEST_EMPTY_KEY);
- getPropertyTag.doEndTag();
- value = pageContext.getAttribute(VAR_KEY);
- assertNotNull(value);
- assertEquals(TEST_VALUE, value);
+ log.info("Testing retrieving default value");
+ getPropertyTag.setDefaultValue(TEST_VALUE);
+ getPropertyTag.setKey(TEST_EMPTY_KEY);
+ getPropertyTag.doEndTag();
+ value = pageContext.getAttribute(VAR_KEY);
+ assertNotNull(value);
+ assertEquals(TEST_VALUE, value);
- log.info("Testing retrieving value");
- getPropertyTag.setDefaultValue(null);
- getPropertyTag.setReturnClass(String.class.getCanonicalName());
- getPropertyTag.setKey(TEST_KEY);
- getPropertyTag.doEndTag();
- value = pageContext.getAttribute(VAR_KEY);
- assertNotNull(value);
- assertEquals(TEST_VALUE, value);
+ log.info("Testing retrieving value");
+ getPropertyTag.setDefaultValue(null);
+ getPropertyTag.setReturnClass(String.class.getCanonicalName());
+ getPropertyTag.setKey(TEST_KEY);
+ getPropertyTag.doEndTag();
+ value = pageContext.getAttribute(VAR_KEY);
+ assertNotNull(value);
+ assertEquals(TEST_VALUE, value);
- log.info("Test successful!");
- }
+ log.info("Test successful!");
+ }
}
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetResourceTag.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetResourceTag.java
index 5d849fc..2f1bcd2 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetResourceTag.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestGetResourceTag.java
@@ -1,26 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import javax.servlet.ServletRequest;
import org.apache.sling.api.resource.Resource;
@@ -31,9 +28,14 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Unit Tests for the Class GetResourceTag.
- *
+ *
* @see org.apache.sling.scripting.jsp.taglib.GetResourceTag
*/
public class TestGetResourceTag {
@@ -42,6 +44,7 @@ public class TestGetResourceTag {
@Rule
public final SlingContext ctx = new SlingContext();
+
private GetResourceTag getResourceTag;
private MockPageContext pageContext;
private Resource resource;
@@ -57,11 +60,8 @@ public class TestGetResourceTag {
public void init() {
log.info("init");
- ctx.build()
- .resource("/")
- .resource(TEST_ABSOLUTE_PATH)
- .resource(TEST_ABSOLUTE_PATH + "/" + TEST_RELATIVE_PATH);
-
+ ctx.build().resource("/").resource(TEST_ABSOLUTE_PATH).resource(TEST_ABSOLUTE_PATH + "/" + TEST_RELATIVE_PATH);
+
resource = ctx.resourceResolver().getResource(TEST_ABSOLUTE_PATH);
pageContext = new MockPageContext() {
public ServletRequest getRequest() {
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestListChildrenTag.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestListChildrenTag.java
index 09a7938..ebbe978 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestListChildrenTag.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestListChildrenTag.java
@@ -1,25 +1,23 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import java.util.Iterator;
import org.apache.sling.api.resource.Resource;
@@ -30,78 +28,82 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Unit Tests for the Class ListChildrenTag.
* @see org.apache.sling.scripting.jsp.taglib.ListChildrenTag
*/
public class TestListChildrenTag {
- private static final Logger log = LoggerFactory
- .getLogger(TestListChildrenTag.class);
+ private static final Logger log = LoggerFactory.getLogger(TestListChildrenTag.class);
@Rule
public final SlingContext ctx = new SlingContext();
- private ListChildrenTag listChildrenTag = new ListChildrenTag();
- private Resource resource;
- private MockPageContext pageContext;
- private static final String TEST_PATH = "/content";
- private static final String VAR_KEY = "children";
-
- /**
- * Initializes the fields for this test.
- */
- @Before
- public void init() {
- log.info("init");
-
- log.info("Creating Resource Structure");
- ctx.build()
- .resource("/")
- .resource(TEST_PATH)
- .resource(TEST_PATH + "/child1")
- .resource(TEST_PATH + "/child2");
-
- resource = ctx.resourceResolver().getResource(TEST_PATH);
-
- log.info("Adding page context");
- pageContext = new MockPageContext();
- listChildrenTag.setPageContext(pageContext);
-
- log.info("init Complete");
- }
-
- /**
- * Tests to ensure the base ListChildren functionality works.
- */
- @SuppressWarnings("unchecked")
- @Test
- public void testListChildren() {
- log.info("testGoodPath");
-
- listChildrenTag.setResource(resource);
- listChildrenTag.setVar(VAR_KEY);
- listChildrenTag.doEndTag();
- Object result = pageContext.getAttribute(VAR_KEY);
- assertNotNull(result);
- assertTrue(result instanceof Iterator);
- assertTrue(((Iterator<Resource>) result).hasNext());
-
- log.info("Test successful!");
- }
-
- /**
- * Tests to see what happens if a null Resource is provided
- */
- @Test
- public void testNullResource() {
- log.info("testNullResource");
-
- listChildrenTag.setVar(VAR_KEY);
- listChildrenTag.setResource(null);
- listChildrenTag.doEndTag();
- Object result = pageContext.getAttribute(VAR_KEY);
- assertNull(result);
-
- log.info("Test successful!");
- }
+
+ private ListChildrenTag listChildrenTag = new ListChildrenTag();
+ private Resource resource;
+ private MockPageContext pageContext;
+ private static final String TEST_PATH = "/content";
+ private static final String VAR_KEY = "children";
+
+ /**
+ * Initializes the fields for this test.
+ */
+ @Before
+ public void init() {
+ log.info("init");
+
+ log.info("Creating Resource Structure");
+ ctx.build()
+ .resource("/")
+ .resource(TEST_PATH)
+ .resource(TEST_PATH + "/child1")
+ .resource(TEST_PATH + "/child2");
+
+ resource = ctx.resourceResolver().getResource(TEST_PATH);
+
+ log.info("Adding page context");
+ pageContext = new MockPageContext();
+ listChildrenTag.setPageContext(pageContext);
+
+ log.info("init Complete");
+ }
+
+ /**
+ * Tests to ensure the base ListChildren functionality works.
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testListChildren() {
+ log.info("testGoodPath");
+
+ listChildrenTag.setResource(resource);
+ listChildrenTag.setVar(VAR_KEY);
+ listChildrenTag.doEndTag();
+ Object result = pageContext.getAttribute(VAR_KEY);
+ assertNotNull(result);
+ assertTrue(result instanceof Iterator);
+ assertTrue(((Iterator<Resource>) result).hasNext());
+
+ log.info("Test successful!");
+ }
+
+ /**
+ * Tests to see what happens if a null Resource is provided
+ */
+ @Test
+ public void testNullResource() {
+ log.info("testNullResource");
+
+ listChildrenTag.setVar(VAR_KEY);
+ listChildrenTag.setResource(null);
+ listChildrenTag.doEndTag();
+ Object result = pageContext.getAttribute(VAR_KEY);
+ assertNull(result);
+
+ log.info("Test successful!");
+ }
}
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestSlingFunctions.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestSlingFunctions.java
index 48c6ed2..f4ce9f0 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/TestSlingFunctions.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/TestSlingFunctions.java
@@ -1,33 +1,29 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import javax.jcr.Session;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
-import javax.jcr.Session;
-
import org.apache.sling.api.adapter.Adaptable;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
@@ -41,168 +37,167 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
* Unit Tests for the Class SlingFunctions.
- *
+ *
* @see org.apache.sling.scripting.jsp.taglib.SlingFunctions
*/
public class TestSlingFunctions {
- private static final Logger log = LoggerFactory
- .getLogger(TestGetResourceTag.class);
-
- @Rule
+ private static final Logger log = LoggerFactory.getLogger(TestGetResourceTag.class);
+
+ @Rule
public XSSSupportRule xssSupportRule = new XSSSupportRule();
- @Rule
+
+ @Rule
public final SlingContext ctx = new SlingContext(ResourceResolverType.JCR_MOCK);
+
private ResourceResolver resolver;
- private Resource resource;
- private Date date;
- private static final String TEST_PATH = "/content";
-
- /**
- * Initializes the fields for this test.
- */
- @Before
- public void init() {
- log.info("init");
-
- this.date = new Date();
-
- ctx.build()
- .resource("/")
- .resource(TEST_PATH, "date", date, "long", new Long(0L))
- .resource(TEST_PATH +"/child1")
- .resource(TEST_PATH +"/child2");
-
- resource = ctx.resourceResolver().getResource(TEST_PATH);
- resolver = ctx.resourceResolver();
- MockJcr.setQueryResult(ctx.resourceResolver().adaptTo(Session.class), Arrays.asList(resource.adaptTo(javax.jcr.Node.class)));
-
- log.info("init Complete");
- }
-
- @Test
- public void testEncode() {
- log.info("testEncode");
-
- log.info("Testing HTML Encoding");
- assertEquals("&nbsp;Here is some text!",
- SlingFunctions.encode(" Here is some text!", "HTML"));
-
- log.info("Testing HTML Attr Encoding");
- assertEquals(
- "&nbsp;Here is some text!"",
- SlingFunctions
- .encode(" Here is some text!\"", "HTML_ATTR"));
-
- log.info("Testing invalid values");
- try {
- SlingFunctions.encode(null, null);
- fail("Expected null pointer exception");
- } catch (NullPointerException npe) {
- log.info("Encountered expected exception");
- }
- try {
- SlingFunctions.encode(null, "Invalid");
- fail("Expected invalid argument exception");
- } catch (IllegalArgumentException iae) {
- log.info("Encountered expected exception");
- }
-
- log.info("Testing null/empty values");
- assertNull(SlingFunctions.encode(null, "html"));
- assertEquals("", SlingFunctions.encode("", "html"));
-
- log.info("Tests successful!");
- }
-
- @Test
- public void testGetResource() {
- log.info("testGetResource");
- Resource resource = SlingFunctions.getResource(resolver, TEST_PATH);
- assertNotNull(resource);
- assertEquals(TEST_PATH, resource.getPath());
-
- log.info("Tests successful!");
- }
-
- @Test
- public void testFindResources() throws ClassNotFoundException {
- log.info("testFindResources");
-
- Iterator<Resource> resources = SlingFunctions.findResources(resolver,
- "query", "sql");
- assertNotNull(resources);
- assertTrue(resources.hasNext());
- assertEquals(resource.getPath(), resources.next().getPath());
-
- log.info("Tests successful!");
- }
-
- @Test
- public void testAdaptTo() throws ClassNotFoundException {
- log.info("testAdaptTo");
-
- Adaptable adaptable = SlingFunctions.getResource(resolver, TEST_PATH);
- Object adapted = SlingFunctions.adaptTo(adaptable,
- ValueMap.class.getCanonicalName());
- assertNotNull(adapted);
- assertTrue(adapted instanceof ValueMap);
-
- log.info("Tests successful!");
- }
-
- @Test
- public void testGetRelativeResource() {
- log.info("testGetRelativeResource");
- Resource parent = SlingFunctions.getResource(resolver, TEST_PATH);
- Resource child = SlingFunctions.getRelativeResource(parent, "child1");
- assertNotNull(child);
- assertEquals(TEST_PATH + "/child1", child.getPath());
-
- log.info("Tests successful!");
- }
-
- @Test
- public void testGetValue() {
- log.info("testGetValue");
- Resource resource = SlingFunctions.getResource(resolver, TEST_PATH);
- ValueMap properties = resource.adaptTo(ValueMap.class);
-
- log.info("Testing using class coersion");
- Date retrievedDate = SlingFunctions.getValue(properties, "date",
- Date.class);
- assertEquals(date, retrievedDate);
- assertTrue(retrievedDate instanceof Date);
-
- log.info("Testing with default value on existing key");
- Long retrievedLong = SlingFunctions.getValue(properties, "long",
- new Long(-123L));
- assertEquals(new Long(0L), retrievedLong);
- assertTrue(retrievedLong instanceof Long);
-
- log.info("Testing with no value and class coersion");
- Date fakeDate = SlingFunctions
- .getValue(properties, "date1", Date.class);
- assertTrue(fakeDate == null);
-
- log.info("Testing with no value and default specified");
- Long fakeLong = SlingFunctions.getValue(properties, "long1", new Long(
- -123L));
- assertEquals(new Long(-123L), fakeLong);
- assertTrue(fakeLong instanceof Long);
-
- log.info("Tests successful!");
- }
-
- @Test
- public void testListChildResources() {
- log.info("testListChildResources");
- Iterator<Resource> children = SlingFunctions.listChildren(resource);
- assertNotNull(children);
- assertTrue(children.hasNext());
-
- log.info("Tests successful!");
- }
+ private Resource resource;
+ private Date date;
+ private static final String TEST_PATH = "/content";
+
+ /**
+ * Initializes the fields for this test.
+ */
+ @Before
+ public void init() {
+ log.info("init");
+
+ this.date = new Date();
+
+ ctx.build()
+ .resource("/")
+ .resource(TEST_PATH, "date", date, "long", new Long(0L))
+ .resource(TEST_PATH + "/child1")
+ .resource(TEST_PATH + "/child2");
+
+ resource = ctx.resourceResolver().getResource(TEST_PATH);
+ resolver = ctx.resourceResolver();
+ MockJcr.setQueryResult(
+ ctx.resourceResolver().adaptTo(Session.class), Arrays.asList(resource.adaptTo(javax.jcr.Node.class)));
+
+ log.info("init Complete");
+ }
+
+ @Test
+ public void testEncode() {
+ log.info("testEncode");
+
+ log.info("Testing HTML Encoding");
+ assertEquals("&nbsp;Here is some text!", SlingFunctions.encode(" Here is some text!", "HTML"));
+
+ log.info("Testing HTML Attr Encoding");
+ assertEquals(
+ "&nbsp;Here is some text!"", SlingFunctions.encode(" Here is some text!\"", "HTML_ATTR"));
+
+ log.info("Testing invalid values");
+ try {
+ SlingFunctions.encode(null, null);
+ fail("Expected null pointer exception");
+ } catch (NullPointerException npe) {
+ log.info("Encountered expected exception");
+ }
+ try {
+ SlingFunctions.encode(null, "Invalid");
+ fail("Expected invalid argument exception");
+ } catch (IllegalArgumentException iae) {
+ log.info("Encountered expected exception");
+ }
+
+ log.info("Testing null/empty values");
+ assertNull(SlingFunctions.encode(null, "html"));
+ assertEquals("", SlingFunctions.encode("", "html"));
+
+ log.info("Tests successful!");
+ }
+
+ @Test
+ public void testGetResource() {
+ log.info("testGetResource");
+ Resource resource = SlingFunctions.getResource(resolver, TEST_PATH);
+ assertNotNull(resource);
+ assertEquals(TEST_PATH, resource.getPath());
+
+ log.info("Tests successful!");
+ }
+
+ @Test
+ public void testFindResources() throws ClassNotFoundException {
+ log.info("testFindResources");
+
+ Iterator<Resource> resources = SlingFunctions.findResources(resolver, "query", "sql");
+ assertNotNull(resources);
+ assertTrue(resources.hasNext());
+ assertEquals(resource.getPath(), resources.next().getPath());
+
+ log.info("Tests successful!");
+ }
+
+ @Test
+ public void testAdaptTo() throws ClassNotFoundException {
+ log.info("testAdaptTo");
+
+ Adaptable adaptable = SlingFunctions.getResource(resolver, TEST_PATH);
+ Object adapted = SlingFunctions.adaptTo(adaptable, ValueMap.class.getCanonicalName());
+ assertNotNull(adapted);
+ assertTrue(adapted instanceof ValueMap);
+
+ log.info("Tests successful!");
+ }
+
+ @Test
+ public void testGetRelativeResource() {
+ log.info("testGetRelativeResource");
+ Resource parent = SlingFunctions.getResource(resolver, TEST_PATH);
+ Resource child = SlingFunctions.getRelativeResource(parent, "child1");
+ assertNotNull(child);
+ assertEquals(TEST_PATH + "/child1", child.getPath());
+
+ log.info("Tests successful!");
+ }
+
+ @Test
+ public void testGetValue() {
+ log.info("testGetValue");
+ Resource resource = SlingFunctions.getResource(resolver, TEST_PATH);
+ ValueMap properties = resource.adaptTo(ValueMap.class);
+
+ log.info("Testing using class coersion");
+ Date retrievedDate = SlingFunctions.getValue(properties, "date", Date.class);
+ assertEquals(date, retrievedDate);
+ assertTrue(retrievedDate instanceof Date);
+
+ log.info("Testing with default value on existing key");
+ Long retrievedLong = SlingFunctions.getValue(properties, "long", new Long(-123L));
+ assertEquals(new Long(0L), retrievedLong);
+ assertTrue(retrievedLong instanceof Long);
+
+ log.info("Testing with no value and class coersion");
+ Date fakeDate = SlingFunctions.getValue(properties, "date1", Date.class);
+ assertTrue(fakeDate == null);
+
+ log.info("Testing with no value and default specified");
+ Long fakeLong = SlingFunctions.getValue(properties, "long1", new Long(-123L));
+ assertEquals(new Long(-123L), fakeLong);
+ assertTrue(fakeLong instanceof Long);
+
+ log.info("Tests successful!");
+ }
+
+ @Test
+ public void testListChildResources() {
+ log.info("testListChildResources");
+ Iterator<Resource> children = SlingFunctions.listChildren(resource);
+ assertNotNull(children);
+ assertTrue(children.hasNext());
+
+ log.info("Tests successful!");
+ }
}
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/XSSSupportRule.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/XSSSupportRule.java
index 9af5021..ae751c8 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/XSSSupportRule.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/XSSSupportRule.java
@@ -1,18 +1,20 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib;
@@ -42,13 +44,11 @@ public class XSSSupportRule extends ExternalResource {
private void setXssApiField(XSSAPIImpl val) throws ReflectiveOperationException {
Field xssApiField = XSSSupport.class.getDeclaredField("XSS_API");
boolean accessible = xssApiField.isAccessible();
- if (!accessible)
- xssApiField.setAccessible(true);
+ if (!accessible) xssApiField.setAccessible(true);
xssApiField.set(null, val);
- if (!accessible)
- xssApiField.setAccessible(false);
+ if (!accessible) xssApiField.setAccessible(false);
}
-
+
private XSSAPIImpl createXSSAPI() throws ReflectiveOperationException {
// not activating since it requires repository access and we don't need that part of the code anyway
XSSFilterImpl filter = new XSSFilterImpl();
@@ -56,8 +56,7 @@ public class XSSSupportRule extends ExternalResource {
Field filterField = XSSAPIImpl.class.getDeclaredField("xssFilter");
filterField.setAccessible(true);
filterField.set(api, filter);
-
+
return api;
}
-
}
diff --git a/src/test/java/org/apache/sling/scripting/jsp/taglib/tei/AdaptToTEITest.java b/src/test/java/org/apache/sling/scripting/jsp/taglib/tei/AdaptToTEITest.java
index 4da7bed..a28c7f1 100644
--- a/src/test/java/org/apache/sling/scripting/jsp/taglib/tei/AdaptToTEITest.java
+++ b/src/test/java/org/apache/sling/scripting/jsp/taglib/tei/AdaptToTEITest.java
@@ -1,30 +1,32 @@
/*
- * 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
+ * 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
+ * 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.
+ * 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.sling.scripting.jsp.taglib.tei;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.VariableInfo;
import java.util.Hashtable;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import static junit.framework.TestCase.assertEquals;
public class AdaptToTEITest {