mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 19:45:51 +01:00
Delete EscapeUtil and dependencies
This commit is contained in:
@@ -1,207 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2010, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.15
|
||||
*/
|
||||
public final class EscapeUtil
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
private EscapeUtil() {}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param result
|
||||
*/
|
||||
public static void escape(BrowserResult result)
|
||||
{
|
||||
result.setBranch(escape(result.getBranch()));
|
||||
result.setTag(escape(result.getTag()));
|
||||
|
||||
for (FileObject fo : result)
|
||||
{
|
||||
escape(fo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param result
|
||||
* @since 1.17
|
||||
*/
|
||||
public static void escape(BlameResult result)
|
||||
{
|
||||
for (BlameLine line : result.getBlameLines())
|
||||
{
|
||||
escape(line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param line
|
||||
* @since 1.17
|
||||
*/
|
||||
public static void escape(BlameLine line)
|
||||
{
|
||||
line.setDescription(escape(line.getDescription()));
|
||||
escape(line.getAuthor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param fo
|
||||
*/
|
||||
public static void escape(FileObject fo)
|
||||
{
|
||||
fo.setDescription(escape(fo.getDescription()));
|
||||
fo.setName(fo.getName());
|
||||
fo.setPath(fo.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param changeset
|
||||
*/
|
||||
public static void escape(Changeset changeset)
|
||||
{
|
||||
changeset.setDescription(escape(changeset.getDescription()));
|
||||
escape(changeset.getAuthor());
|
||||
changeset.setBranches(escapeList(changeset.getBranches()));
|
||||
changeset.setTags(escapeList(changeset.getTags()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param person
|
||||
* @since 1.17
|
||||
*/
|
||||
public static void escape(Person person)
|
||||
{
|
||||
if (person != null)
|
||||
{
|
||||
person.setName(escape(person.getName()));
|
||||
person.setMail(escape(person.getMail()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param result
|
||||
*/
|
||||
public static void escape(ChangesetPagingResult result)
|
||||
{
|
||||
for (Changeset c : result)
|
||||
{
|
||||
escape(c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String escape(String value)
|
||||
{
|
||||
return StringEscapeUtils.escapeHtml(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param values
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<String> escapeList(List<String> values)
|
||||
{
|
||||
if (Util.isNotEmpty(values))
|
||||
{
|
||||
List<String> newList = Lists.newArrayList();
|
||||
|
||||
for (String v : values)
|
||||
{
|
||||
newList.add(StringEscapeUtils.escapeHtml(v));
|
||||
}
|
||||
|
||||
values = newList;
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
public static void escape(Modifications modifications) {
|
||||
modifications.setAdded(escapeList(modifications.getAdded()));
|
||||
modifications.setModified(escapeList(modifications.getModified()));
|
||||
modifications.setRemoved(escapeList(modifications.getRemoved()));
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,6 @@ public class PreProcessorUtil
|
||||
blameLine.getLineNumber(), repository.getName());
|
||||
}
|
||||
|
||||
EscapeUtil.escape(blameLine);
|
||||
handlePreProcess(repository,blameLine,blameLinePreProcessorFactorySet, blameLinePreProcessorSet);
|
||||
}
|
||||
|
||||
@@ -123,22 +122,6 @@ public class PreProcessorUtil
|
||||
* @param blameResult
|
||||
*/
|
||||
public void prepareForReturn(Repository repository, BlameResult blameResult)
|
||||
{
|
||||
prepareForReturn(repository, blameResult, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param blameResult
|
||||
* @param escape
|
||||
*
|
||||
* @since 1.35
|
||||
*/
|
||||
public void prepareForReturn(Repository repository, BlameResult blameResult,
|
||||
boolean escape)
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
@@ -146,10 +129,6 @@ public class PreProcessorUtil
|
||||
repository.getName());
|
||||
}
|
||||
|
||||
if (escape)
|
||||
{
|
||||
EscapeUtil.escape(blameResult);
|
||||
}
|
||||
handlePreProcessForIterable(repository, blameResult.getBlameLines(),blameLinePreProcessorFactorySet, blameLinePreProcessorSet);
|
||||
}
|
||||
|
||||
@@ -162,32 +141,12 @@ public class PreProcessorUtil
|
||||
*/
|
||||
public void prepareForReturn(Repository repository, Changeset changeset)
|
||||
{
|
||||
prepareForReturn(repository, changeset, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param changeset
|
||||
* @param escape
|
||||
*
|
||||
* @since 1.35
|
||||
*/
|
||||
public void prepareForReturn(Repository repository, Changeset changeset, boolean escape){
|
||||
logger.trace("prepare changeset {} of repository {} for return", changeset.getId(), repository.getName());
|
||||
if (escape) {
|
||||
EscapeUtil.escape(changeset);
|
||||
}
|
||||
handlePreProcess(repository, changeset, changesetPreProcessorFactorySet, changesetPreProcessorSet);
|
||||
}
|
||||
|
||||
public void prepareForReturn(Repository repository, Modifications modifications, boolean escape) {
|
||||
public void prepareForReturn(Repository repository, Modifications modifications) {
|
||||
logger.trace("prepare modifications {} of repository {} for return", modifications, repository.getName());
|
||||
if (escape) {
|
||||
EscapeUtil.escape(modifications);
|
||||
}
|
||||
handlePreProcess(repository, modifications, modificationsPreProcessorFactorySet, modificationsPreProcessorSet);
|
||||
}
|
||||
|
||||
@@ -199,22 +158,6 @@ public class PreProcessorUtil
|
||||
* @param result
|
||||
*/
|
||||
public void prepareForReturn(Repository repository, BrowserResult result)
|
||||
{
|
||||
prepareForReturn(repository, result, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param result
|
||||
* @param escape
|
||||
*
|
||||
* @since 1.35
|
||||
*/
|
||||
public void prepareForReturn(Repository repository, BrowserResult result,
|
||||
boolean escape)
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
@@ -222,10 +165,6 @@ public class PreProcessorUtil
|
||||
repository.getName());
|
||||
}
|
||||
|
||||
if (escape)
|
||||
{
|
||||
EscapeUtil.escape(result);
|
||||
}
|
||||
handlePreProcessForIterable(repository, result,fileObjectPreProcessorFactorySet, fileObjectPreProcessorSet);
|
||||
}
|
||||
|
||||
@@ -235,12 +174,8 @@ public class PreProcessorUtil
|
||||
*
|
||||
* @param repository
|
||||
* @param result
|
||||
* @param escape
|
||||
*
|
||||
* @since 1.35
|
||||
*/
|
||||
public void prepareForReturn(Repository repository,
|
||||
ChangesetPagingResult result, boolean escape)
|
||||
public void prepareForReturn(Repository repository, ChangesetPagingResult result)
|
||||
{
|
||||
if (logger.isTraceEnabled())
|
||||
{
|
||||
@@ -248,27 +183,9 @@ public class PreProcessorUtil
|
||||
repository.getName());
|
||||
}
|
||||
|
||||
if (escape)
|
||||
{
|
||||
EscapeUtil.escape(result);
|
||||
}
|
||||
handlePreProcessForIterable(repository,result,changesetPreProcessorFactorySet, changesetPreProcessorSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repository
|
||||
* @param result
|
||||
*/
|
||||
public void prepareForReturn(Repository repository,
|
||||
ChangesetPagingResult result)
|
||||
{
|
||||
prepareForReturn(repository, result, true);
|
||||
}
|
||||
|
||||
|
||||
private <T, F extends PreProcessorFactory<T>, P extends PreProcessor<T>> void handlePreProcess(Repository repository, T processedObject,
|
||||
Collection<F> factories,
|
||||
Collection<P> preProcessors) {
|
||||
|
||||
@@ -185,7 +185,7 @@ public final class BlameCommandBuilder
|
||||
|
||||
if (!disablePreProcessors && (result != null))
|
||||
{
|
||||
preProcessorUtil.prepareForReturn(repository, result, !disableEscaping);
|
||||
preProcessorUtil.prepareForReturn(repository, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -210,24 +210,6 @@ public final class BlameCommandBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable html escaping for the returned blame lines. By default all
|
||||
* blame lines are html escaped.
|
||||
*
|
||||
*
|
||||
* @param disableEscaping true to disable the html escaping
|
||||
*
|
||||
* @return {@code this}
|
||||
*
|
||||
* @since 1.35
|
||||
*/
|
||||
public BlameCommandBuilder setDisableEscaping(boolean disableEscaping)
|
||||
{
|
||||
this.disableEscaping = disableEscaping;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the execution of pre processors.
|
||||
*
|
||||
@@ -362,9 +344,6 @@ public final class BlameCommandBuilder
|
||||
/** the cache */
|
||||
private final Cache<CacheKey, BlameResult> cache;
|
||||
|
||||
/** disable escaping */
|
||||
private boolean disableEscaping = false;
|
||||
|
||||
/** disable change */
|
||||
private boolean disableCache = false;
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ public final class BrowseCommandBuilder
|
||||
|
||||
if (!disablePreProcessors && (result != null))
|
||||
{
|
||||
preProcessorUtil.prepareForReturn(repository, result, !disableEscaping);
|
||||
preProcessorUtil.prepareForReturn(repository, result);
|
||||
|
||||
List<FileObject> fileObjects = result.getFiles();
|
||||
|
||||
@@ -212,24 +212,6 @@ public final class BrowseCommandBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable html escaping for the returned file objects. By default all
|
||||
* file objects are html escaped.
|
||||
*
|
||||
*
|
||||
* @param disableEscaping true to disable the html escaping
|
||||
*
|
||||
* @return {@code this}
|
||||
*
|
||||
* @since 1.35
|
||||
*/
|
||||
public BrowseCommandBuilder setDisableEscaping(boolean disableEscaping)
|
||||
{
|
||||
this.disableEscaping = disableEscaping;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disabling the last commit means that every call to
|
||||
* {@link FileObject#getDescription()} and
|
||||
@@ -433,9 +415,6 @@ public final class BrowseCommandBuilder
|
||||
/** cache */
|
||||
private final Cache<CacheKey, BrowserResult> cache;
|
||||
|
||||
/** disable escaping */
|
||||
private boolean disableEscaping = false;
|
||||
|
||||
/** disables the cache */
|
||||
private boolean disableCache = false;
|
||||
|
||||
|
||||
@@ -132,8 +132,7 @@ public final class HookChangesetBuilder
|
||||
try
|
||||
{
|
||||
copy = DeepCopy.copy(c);
|
||||
preProcessorUtil.prepareForReturn(repository, copy,
|
||||
!disableEscaping);
|
||||
preProcessorUtil.prepareForReturn(repository, copy);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@@ -156,24 +155,6 @@ public final class HookChangesetBuilder
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Disable html escaping for the returned changesets. By default all
|
||||
* changesets are html escaped.
|
||||
*
|
||||
*
|
||||
* @param disableEscaping true to disable the html escaping
|
||||
*
|
||||
* @return {@code this}
|
||||
*
|
||||
* @since 1.35
|
||||
*/
|
||||
public HookChangesetBuilder setDisableEscaping(boolean disableEscaping)
|
||||
{
|
||||
this.disableEscaping = disableEscaping;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the execution of pre processors.
|
||||
*
|
||||
@@ -192,9 +173,6 @@ public final class HookChangesetBuilder
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** disable escaping */
|
||||
private boolean disableEscaping = false;
|
||||
|
||||
/** disable pre processors marker */
|
||||
private boolean disablePreProcessors = false;
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ public final class LogCommandBuilder
|
||||
|
||||
if (!disablePreProcessors && (cpr != null))
|
||||
{
|
||||
preProcessorUtil.prepareForReturn(repository, cpr, !disableEscaping);
|
||||
preProcessorUtil.prepareForReturn(repository, cpr);
|
||||
}
|
||||
|
||||
return cpr;
|
||||
@@ -306,24 +306,6 @@ public final class LogCommandBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable html escaping for the returned changesets. By default all
|
||||
* changesets are html escaped.
|
||||
*
|
||||
*
|
||||
* @param disableEscaping true to disable the html escaping
|
||||
*
|
||||
* @return {@code this}
|
||||
*
|
||||
* @since 1.35
|
||||
*/
|
||||
public LogCommandBuilder setDisableEscaping(boolean disableEscaping)
|
||||
{
|
||||
this.disableEscaping = disableEscaping;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the execution of pre processors.
|
||||
*
|
||||
@@ -545,9 +527,6 @@ public final class LogCommandBuilder
|
||||
/** repository to query */
|
||||
private final Repository repository;
|
||||
|
||||
/** disable escaping */
|
||||
private boolean disableEscaping = false;
|
||||
|
||||
/** disable cache */
|
||||
private boolean disableCache = false;
|
||||
|
||||
|
||||
@@ -43,9 +43,6 @@ public final class ModificationsCommandBuilder {
|
||||
|
||||
private final PreProcessorUtil preProcessorUtil;
|
||||
|
||||
@Setter
|
||||
private boolean disableEscaping = false;
|
||||
|
||||
@Setter
|
||||
private boolean disableCache = false;
|
||||
|
||||
@@ -90,7 +87,7 @@ public final class ModificationsCommandBuilder {
|
||||
}
|
||||
}
|
||||
if (!disablePreProcessors && (modifications != null)) {
|
||||
preProcessorUtil.prepareForReturn(repository, modifications, !disableEscaping);
|
||||
preProcessorUtil.prepareForReturn(repository, modifications);
|
||||
}
|
||||
return modifications;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,6 @@ public class GitRepositoryViewer
|
||||
{
|
||||
//J-
|
||||
ChangesetPagingResult cpr = service.getLogCommand()
|
||||
.setDisableEscaping(true)
|
||||
.setBranch(name)
|
||||
.setPagingLimit(CHANGESET_PER_BRANCH)
|
||||
.getChangesets();
|
||||
|
||||
Reference in New Issue
Block a user