Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private synchronized void startPingThread()
// Make sure we always have at least one ping thread.
if (this.executorService == null) {
// Start a thread to regularly send pings to the active installs server.
BasicThreadFactory factory = new BasicThreadFactory.Builder()
BasicThreadFactory factory = BasicThreadFactory.builder()
.namingPattern("Active Installs 2 Ping Thread")
.daemon(true)
.priority(Thread.MIN_PRIORITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.Strings;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.TimeoutException;
Expand Down Expand Up @@ -113,7 +114,7 @@ public void setColorTheme(String colorThemeName)
getColorThemeOptionElement(colorThemeName).click();

// Waiting to be sure the change is effective
getDriver().waitUntilCondition(driver -> StringUtils.equals(getCurrentColorTheme(), colorThemeName));
getDriver().waitUntilCondition(driver -> Strings.CS.equals(getCurrentColorTheme(), colorThemeName));
}

private WebElement getColorThemeOptionElement(String colorThemeName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import javax.ws.rs.core.Response.Status;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.xwiki.annotation.AnnotationServiceException;
import org.xwiki.annotation.rest.model.jaxb.AnnotationAddRequest;
import org.xwiki.annotation.rest.model.jaxb.AnnotationField;
Expand Down Expand Up @@ -76,14 +77,14 @@ protected Response getAnnotatedContent(DocumentReference documentReference)
AnnotationRequest.Request requestedFields = new AnnotationRequest.Request();
for (Map.Entry<String, List<String>> entry : parameters.entrySet()) {
String name = entry.getKey();
if (StringUtils.startsWith(name, ANNOTATION_REQUEST_FILTER_PARAMETER_PREFIX)) {
if (Strings.CS.startsWith(name, ANNOTATION_REQUEST_FILTER_PARAMETER_PREFIX)) {
for (String value : entry.getValue()) {
AnnotationField field = new AnnotationField();
field.setName(StringUtils.substringAfter(name, ANNOTATION_REQUEST_FILTER_PARAMETER_PREFIX));
field.setValue(value);
annotationFields.add(field);
}
} else if (StringUtils.equals(name, ANNOTATION_REQUEST_REQUESTED_FIELD_PARAMETER)) {
} else if (Strings.CS.equals(name, ANNOTATION_REQUEST_REQUESTED_FIELD_PARAMETER)) {
requestedFields.getFields().addAll(entry.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.io.Serializable;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;

/**
* Base class for all action execution related events.
Expand Down Expand Up @@ -80,7 +80,7 @@ public int hashCode()
public boolean equals(Object object)
{
if (object != null && getClass().isAssignableFrom(object.getClass())) {
return StringUtils.equals(getActionName(), ((ActionExecutionEvent) object).getActionName());
return Strings.CS.equals(getActionName(), ((ActionExecutionEvent) object).getActionName());
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import jakarta.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.xwiki.container.servlet.filters.SavedRequestManager;
import org.xwiki.container.servlet.filters.SavedRequestManager.SavedRequest;

Expand Down Expand Up @@ -252,7 +253,7 @@ protected SavedRequest getSavedRequest(HttpServletRequest request)
SavedRequest savedRequest = savedRequests.get(savedRequestId);
// Only reuse this request if the new request is for the same resource (URL)
if (savedRequest != null
&& StringUtils.equals(savedRequest.getRequestUrl(), request.getRequestURL().toString())) {
&& Strings.CS.equals(savedRequest.getRequestUrl(), request.getRequestURL().toString())) {
// Remove the saved request from the session
savedRequests.remove(savedRequestId);
// Return the SavedRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import javax.inject.Named;
import javax.inject.Singleton;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.slf4j.Logger;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.manager.ComponentLookupException;
Expand Down Expand Up @@ -92,7 +92,7 @@ protected BlockRenderer getGadgetContentRenderer()

// Get the annotated syntax corresponding to the current target syntax
String annotatedTargetSyntax = currentTargetSyntax.toIdString();
if (!StringUtils.startsWith(annotatedTargetSyntax, ANNOTATED_SYNTAXES_PREFIX)) {
if (!Strings.CS.startsWith(annotatedTargetSyntax, ANNOTATED_SYNTAXES_PREFIX)) {
annotatedTargetSyntax = ANNOTATED_SYNTAXES_PREFIX + annotatedTargetSyntax;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.BoundedInputStream;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
Expand Down Expand Up @@ -134,7 +135,7 @@ private DownloadResult handleResponse(URI uri, ClassicHttpResponse response) thr
String contentType = entity.getContentType();
contentType = StringUtils.substringBefore(contentType, ";");

if (!StringUtils.startsWith(contentType, "image/")) {
if (!Strings.CS.startsWith(contentType, "image/")) {
throw new IOException(String.format("The content of [%s] is not an image.", uri));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import javax.inject.Inject;
import javax.inject.Provider;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.InstantiationStrategy;
import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
Expand Down Expand Up @@ -70,7 +70,7 @@ public String stop()
StringBuilder requiredSkinExtensions = new StringBuilder();
for (Map.Entry<String, String> entry : this.requiredSkinExtensionsMap.entrySet()) {
requiredSkinExtensions
.append(StringUtils.removeStart(getImportString(entry.getKey()), entry.getValue()).trim());
.append(Strings.CS.removeStart(getImportString(entry.getKey()), entry.getValue()).trim());
}
return requiredSkinExtensions.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import javax.inject.Named;
import javax.inject.Singleton;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.xwiki.bridge.event.DocumentCreatedEvent;
import org.xwiki.bridge.event.DocumentDeletedEvent;
import org.xwiki.bridge.event.DocumentUpdatedEvent;
Expand Down Expand Up @@ -174,7 +174,7 @@ private void checkXARHandler(Event event, XWikiDocument document)
Request request = this.jobContext.getCurrentJob().getRequest();

// It's a job started by the Distribution Wizard
if (StringUtils.equals(request.<String>getProperty("context.action"), "distribution")) {
if (Strings.CS.equals(request.<String>getProperty("context.action"), "distribution")) {
String distributionWiki = request.getProperty("context.wiki");

if (distributionWiki != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.concurrent.ConcurrentHashMap;

import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.xwiki.extension.ExtensionId;
import org.xwiki.extension.distribution.internal.DistributionManager.DistributionState;
import org.xwiki.extension.distribution.internal.job.step.DistributionStep;
Expand Down Expand Up @@ -105,7 +105,7 @@ public List<DistributionStep> getSteps()
public DistributionStep getStep(String stepId)
{
for (DistributionStep step : getSteps()) {
if (StringUtils.equals(step.getId(), stepId)) {
if (Strings.CS.equals(step.getId(), stepId)) {
return step;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import org.apache.commons.lang3.Strings;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
Expand All @@ -44,7 +45,6 @@
import org.xwiki.extension.version.Version;
import org.xwiki.extension.version.internal.DefaultVersion;

import static org.apache.commons.lang3.StringUtils.startsWith;
import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCauseMessage;

/**
Expand Down Expand Up @@ -115,7 +115,7 @@ private Optional<String> resolveId(VulnObject vulnObject)
{
Optional<String> first = vulnObject.getAliases()
.stream()
.filter(it -> startsWith(it, "CVE-"))
.filter(it -> Strings.CS.startsWith(it, "CVE-"))
.findFirst();
if (first.isEmpty()) {
// We fall back to the first id if no CVE id is found.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Vector;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xwiki.cache.Cache;
Expand Down Expand Up @@ -596,7 +597,7 @@ private void prepareFeedEntryDocument(XWikiDocument document, XWikiContext conte
if (StringUtils.isBlank(context.getWiki().Param("xwiki.plugins.feed.entryContent"))) {
// If entry content is not configured, we do the best guess between XWiki syntaxes 1 and 2
content =
StringUtils.equals(Syntax.XWIKI_1_0.toIdString(), syntaxId)
Strings.CS.equals(Syntax.XWIKI_1_0.toIdString(), syntaxId)
? "#includeForm(\"XWiki.FeedEntryClassSheet\")"
: "{{include reference=\"XWiki.FeedEntryClassSheet\" /}}";
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import javax.inject.Named;
import javax.inject.Singleton;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.slf4j.Logger;
import org.xwiki.component.annotation.Component;
import org.xwiki.model.reference.DocumentReference;
Expand Down Expand Up @@ -66,7 +66,7 @@ public void onEvent(Event event, Object source, Object data)
XWikiDocument sourceDoc = (XWikiDocument) source;
DocumentReference expectedReference = new DocumentReference("xwiki", "XWiki", "XWikiPreferences");
if (userEvent.getUserReference() != null
&& StringUtils.equals(userEvent.getUserReference().getName(), "DeleteVersionTestUserCancelEvent")
&& Strings.CS.equals(userEvent.getUserReference().getName(), "DeleteVersionTestUserCancelEvent")
&& sourceDoc.getDocumentReference().equals(expectedReference)) {
logger.info("Cancelling user event on purpose");
userEvent.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.xwiki.model.EntityType;
import org.xwiki.model.reference.DocumentReference;
Expand Down Expand Up @@ -111,7 +111,7 @@ protected EntityReference getParent(DocumentReference documentReference) throws
protected EntityReference resolve(String nodeId)
{
String prefix = getType() + ':';
if (StringUtils.startsWith(nodeId, prefix)) {
if (Strings.CS.startsWith(nodeId, prefix)) {
return super.resolve("document:" + nodeId.substring(prefix.length()));
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.inject.Named;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.annotation.InstantiationStrategy;
import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
Expand All @@ -42,7 +43,7 @@ public class TranslationTreeNode extends AbstractTreeNode
@Override
public String getParent(String nodeId)
{
if (StringUtils.startsWith(nodeId, "translation:")) {
if (Strings.CS.startsWith(nodeId, "translation:")) {
String reference = StringUtils.substringBeforeLast(nodeId.substring(12), "/");
return "translations:" + reference;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import javax.inject.Provider;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -210,8 +210,8 @@ public void compileWhenError() throws Exception
String result = mocker.getComponentUnderTest().compile(lessResourceReference, false, false, false);

// Asserts
assertTrue(StringUtils.startsWith(result, "/* org.xwiki.lesscss.compiler.LESSCompilerException: an exception"));
assertTrue(StringUtils.endsWith(result, "*/"));
assertTrue(Strings.CS.startsWith(result, "/* org.xwiki.lesscss.compiler.LESSCompilerException: an exception"));
assertTrue(Strings.CS.endsWith(result, "*/"));
verify(cache).set(eq(lessResourceReference), eq(skinReference), eq(colorThemeReference), eq(result));
verify(mocker.getMockedLogger()).error(eq("Error during the compilation of the resource [{}]."),
eq(lessResourceReference), eq(expectedException));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.xwiki.notifications.NotificationFormat;
import org.xwiki.stability.Unstable;

Expand Down Expand Up @@ -168,9 +169,9 @@ default boolean isFromWiki(String wikiId)
{
String wikiIdWithPrefix = wikiId + DB_SPACE_SEP;
return Objects.equals(getWiki(), wikiId)
|| StringUtils.startsWith(getPage(), wikiIdWithPrefix)
|| StringUtils.startsWith(getPageOnly(), wikiIdWithPrefix)
|| StringUtils.startsWith(getUser(), wikiIdWithPrefix);
|| Strings.CS.startsWith(getPage(), wikiIdWithPrefix)
|| Strings.CS.startsWith(getPageOnly(), wikiIdWithPrefix)
|| Strings.CS.startsWith(getUser(), wikiIdWithPrefix);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import javax.inject.Named;
import javax.inject.Singleton;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.slf4j.Logger;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.manager.ComponentLifecycleException;
Expand Down Expand Up @@ -156,7 +156,7 @@ private void performCleanup(CleanUpFilterData data)
this.notificationFilterPreferenceManager.getFilterPreferences(user)
// We only clean up the filters matching exactly the page reference
// we never clean up filters for space / wiki there
.stream().filter(pref -> StringUtils.equals(pref.getPageOnly(), serializedReference))
.stream().filter(pref -> Strings.CS.equals(pref.getPageOnly(), serializedReference))
.collect(Collectors.toSet());
if (!matchingPreferences.isEmpty()) {
CleaningFilterEvent cleaningFilterEvent = new CleaningFilterEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import javax.inject.Singleton;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Strings;
import org.xwiki.component.annotation.Component;
import org.xwiki.model.reference.DocumentReference;
import org.xwiki.model.reference.EntityReferenceSerializer;
Expand Down Expand Up @@ -211,7 +212,7 @@ private boolean isPageOnly(ScopeNotificationFilterPreference pref)
// filterExpression(Collection<NotificationFilterPreference> filterPreferences, NotificationFormat format,
// NotificationFilterType type, DocumentReference user).
return StringUtils.isNotBlank(pref.getPageOnly())
&& StringUtils.startsWith(pref.getId(), NotificationFilterPreference.DB_ID_FILTER_PREFIX)
&& Strings.CS.startsWith(pref.getId(), NotificationFilterPreference.DB_ID_FILTER_PREFIX)
&& pref.getEventTypes().isEmpty();
}

Expand Down Expand Up @@ -310,7 +311,7 @@ private boolean isEnabledAndStoredScopeNotificationFilterPreference(Notification
{
// This optimization can only works on preferences stored by the user, that's why we add the final condition
return nfp.isEnabled() && ScopeNotificationFilter.FILTER_NAME.equals(nfp.getFilterName())
&& StringUtils.startsWith(nfp.getId(), NotificationFilterPreference.DB_ID_FILTER_PREFIX);
&& Strings.CS.startsWith(nfp.getId(), NotificationFilterPreference.DB_ID_FILTER_PREFIX);
}

private boolean doesFilterTypeAndFormatMatch(NotificationFilterPreference nfp, NotificationFormat format,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import org.apache.commons.lang3.Strings;
import org.slf4j.Logger;
import org.xwiki.component.annotation.Component;
import org.xwiki.notifications.NotificationFormat;
import org.xwiki.notifications.filters.NotificationFilterPreference;
import org.xwiki.notifications.filters.NotificationFilterType;
import org.xwiki.text.StringUtils;

/**
* Helper to get user preferences for the {@link EventUserFilter}.
Expand All @@ -56,7 +56,7 @@ public boolean isUserExcluded(String testUser, Collection<NotificationFilterPref
NotificationFormat format)
{
return getPreferences(filterPreferences, format, NotificationFilterType.EXCLUSIVE).anyMatch(
pref -> StringUtils.equals(pref.getUser(), testUser)
pref -> Strings.CS.equals(pref.getUser(), testUser)
);
}

Expand All @@ -72,7 +72,7 @@ public boolean isUserFollowed(String testUser, Collection<NotificationFilterPref
NotificationFormat format)
{
return getPreferences(filterPreferences, format, NotificationFilterType.INCLUSIVE).anyMatch(
pref -> StringUtils.equals(pref.getUser(), testUser)
pref -> Strings.CS.equals(pref.getUser(), testUser)
);
}

Expand Down
Loading