Skip to content

Commit

Permalink
ACS-6188 Remove usage of deprecated constructors (#2295)
Browse files Browse the repository at this point in the history
* Apply org.openrewrite.staticanalysis.PrimitiveWrapperClassConstructorToValueOf recipe

* ACS-6188 Update copyright headers

* ACS-6188 Update copyright header

* ACS-6188 Clean-up

---------

Co-authored-by: dsibilio <[email protected]>
Co-authored-by: Domenico Sibilio <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2023
1 parent a386dac commit 1984056
Show file tree
Hide file tree
Showing 92 changed files with 274 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private Serializable convertValue(String stringValue, String type)
Serializable value = stringValue;
if (type.equals("boolean"))
{
value = new Boolean(stringValue);
value = Boolean.valueOf(stringValue);
}
return value;
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/test/java/org/alfresco/query/CannedQueryTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
* Copyright (C) 2005-2023 Alfresco Software Limited.
*
* This file is part of Alfresco
*
Expand Down Expand Up @@ -55,11 +55,11 @@ public class CannedQueryTest extends TestCase
RESULTS_TWO = new ArrayList<Long>(10);
for (int i = 0; i < 10; i++)
{
RESULTS_TWO.add(new Long(i));
RESULTS_TWO.add(Long.valueOf(i));
}
ANTI_RESULTS = new HashSet<Object>();
ANTI_RESULTS.add("ONE_5");
ANTI_RESULTS.add(new Long(5));
ANTI_RESULTS.add(Long.valueOf(5));
}

@SuppressWarnings("rawtypes")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Data model classes
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -121,7 +121,7 @@ public AssociationRef(String assocRefStr)
String targetNodeRefStr = tokenizer.nextToken();
String assocTypeQNameStr = tokenizer.nextToken();

this.id = new Long(idStr);
this.id = Long.valueOf(idStr);
this.sourceRef = new NodeRef(sourceNodeRefStr);
this.targetRef = new NodeRef(targetNodeRefStr);
this.assocTypeQName = QName.createQName(assocTypeQNameStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Data model classes
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -391,7 +391,7 @@ public String convert(Class source)
{
public Boolean convert(Number source)
{
return new Boolean(source.longValue() > 0);
return Boolean.valueOf(source.longValue() > 0);
}
});
addConverter(Number.class, Byte.class, new TypeConverter.Converter<Number, Byte>()
Expand Down Expand Up @@ -549,8 +549,8 @@ public GregorianCalendar convert(Date source)
//
// Boolean ->
//
final Long LONG_FALSE = new Long(0L);
final Long LONG_TRUE = new Long(1L);
final Long LONG_FALSE = Long.valueOf(0L);
final Long LONG_TRUE = Long.valueOf(1L);
addConverter(Boolean.class, Long.class, new TypeConverter.Converter<Boolean, Long>()
{
public Long convert(Boolean source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Data model classes
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -190,7 +190,7 @@ public Duration(String duration)
{
if (token == StreamTokenizer.TT_NUMBER)
{
nval = new Double(tok.nval);
nval = Double.valueOf(tok.nval);
}
else if (token == StreamTokenizer.TT_EOF)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Data model classes
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -57,8 +57,8 @@ public DefaultTypeConverterTest(String arg0)

public void testPrimitives()
{
assertEquals(Boolean.valueOf(false), DefaultTypeConverter.INSTANCE.convert(Boolean.class, false));
assertEquals(Boolean.valueOf(true), DefaultTypeConverter.INSTANCE.convert(Boolean.class, true));
assertEquals(Boolean.FALSE, DefaultTypeConverter.INSTANCE.convert(Boolean.class, false));
assertEquals(Boolean.TRUE, DefaultTypeConverter.INSTANCE.convert(Boolean.class, true));
assertEquals(Character.valueOf('a'), DefaultTypeConverter.INSTANCE.convert(Character.class, 'a'));
assertEquals(Byte.valueOf("3"), DefaultTypeConverter.INSTANCE.convert(Byte.class, (byte) 3));
assertEquals(Short.valueOf("4"), DefaultTypeConverter.INSTANCE.convert(Short.class, (short) 4));
Expand All @@ -70,8 +70,8 @@ public void testPrimitives()

public void testNoConversion()
{
assertEquals(Boolean.valueOf(false), DefaultTypeConverter.INSTANCE.convert(Boolean.class, Boolean.valueOf(false)));
assertEquals(Boolean.valueOf(true), DefaultTypeConverter.INSTANCE.convert(Boolean.class, Boolean.valueOf(true)));
assertEquals(Boolean.FALSE, DefaultTypeConverter.INSTANCE.convert(Boolean.class, Boolean.FALSE));
assertEquals(Boolean.TRUE, DefaultTypeConverter.INSTANCE.convert(Boolean.class, Boolean.TRUE));
assertEquals(Character.valueOf('w'), DefaultTypeConverter.INSTANCE.convert(Character.class, Character.valueOf('w')));
assertEquals(Byte.valueOf("3"), DefaultTypeConverter.INSTANCE.convert(Byte.class, Byte.valueOf("3")));
assertEquals(Short.valueOf("4"), DefaultTypeConverter.INSTANCE.convert(Short.class, Short.valueOf("4")));
Expand All @@ -90,8 +90,8 @@ public void testNoConversion()

public void testToString()
{
assertEquals("true", DefaultTypeConverter.INSTANCE.convert(String.class, new Boolean(true)));
assertEquals("false", DefaultTypeConverter.INSTANCE.convert(String.class, new Boolean(false)));
assertEquals("true", DefaultTypeConverter.INSTANCE.convert(String.class, Boolean.TRUE));
assertEquals("false", DefaultTypeConverter.INSTANCE.convert(String.class, Boolean.FALSE));
assertEquals("v", DefaultTypeConverter.INSTANCE.convert(String.class, Character.valueOf('v')));
assertEquals("3", DefaultTypeConverter.INSTANCE.convert(String.class, Byte.valueOf("3")));
assertEquals("4", DefaultTypeConverter.INSTANCE.convert(String.class, Short.valueOf("4")));
Expand Down Expand Up @@ -132,8 +132,8 @@ public void testToString()

public void testFromString()
{
assertEquals(Boolean.valueOf(true), DefaultTypeConverter.INSTANCE.convert(Boolean.class, "True"));
assertEquals(Boolean.valueOf(false), DefaultTypeConverter.INSTANCE.convert(Boolean.class, "woof"));
assertEquals(Boolean.TRUE, DefaultTypeConverter.INSTANCE.convert(Boolean.class, "True"));
assertEquals(Boolean.FALSE, DefaultTypeConverter.INSTANCE.convert(Boolean.class, "woof"));
assertEquals(Character.valueOf('w'), DefaultTypeConverter.INSTANCE.convert(Character.class, "w"));
assertEquals(Byte.valueOf("3"), DefaultTypeConverter.INSTANCE.convert(Byte.class, "3"));
assertEquals(Short.valueOf("4"), DefaultTypeConverter.INSTANCE.convert(Short.class, "4"));
Expand Down Expand Up @@ -316,8 +316,8 @@ public void testMultiValue()
private ArrayList<Object> makeList()
{
ArrayList<Object> list = new ArrayList<Object>();
list.add(Boolean.valueOf(true));
list.add(Boolean.valueOf(false));
list.add(Boolean.TRUE);
list.add(Boolean.FALSE);
list.add(Character.valueOf('q'));
list.add(Byte.valueOf("1"));
list.add(Short.valueOf("2"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -57,7 +57,7 @@ public void execute(WebScriptRequest req, WebScriptResponse res) throws IOExcept
// hence providing ability for subsystem to be disabled (whilst still supporting ability to check status and/or dynamically start via JMX)
String isEnabled = (String)subsystem.getProperty("imap.server.enabled");

if (new Boolean(isEnabled).booleanValue())
if (Boolean.valueOf(isEnabled).booleanValue())
{
res.getWriter().write("enabled");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -109,7 +109,7 @@ protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
int startPage = 1;
try
{
startPage = new Integer(startPageArg);
startPage = Integer.valueOf(startPageArg);
}
catch(NumberFormatException e)
{
Expand All @@ -119,7 +119,7 @@ protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
int itemsPerPage = DEFAULT_ITEMS_PER_PAGE;
try
{
itemsPerPage = new Integer(itemsPerPageArg);
itemsPerPage = Integer.valueOf(itemsPerPageArg);
}
catch(NumberFormatException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ else if (c.equals("force"))
String phString = req.getParameter("ph");
if (phString != null)
{
ph = new Boolean(phString);
ph = Boolean.valueOf(phString);
}

Scriptable scope = new BaseScopableProcessorExtension().getScope(); // note: required for ValueConverter (collection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -149,7 +149,7 @@ public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cach
}

Map<String, Object> model = new HashMap<String, Object>();
model.put("patchedNodeCount", new Long(patchedNodeRefs));
model.put("patchedNodeCount", Long.valueOf(patchedNodeRefs));

return model;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -165,7 +165,7 @@ public Page createPageOrWindow(Map<String, String> args)
{
try
{
pageNo = new Integer(strPageNo);
pageNo = Integer.valueOf(strPageNo);
}
catch(NumberFormatException e) {};
}
Expand All @@ -177,7 +177,7 @@ public Page createPageOrWindow(Map<String, String> args)
{
try
{
pageSize = new Integer(strPageSize);
pageSize = Integer.valueOf(strPageSize);
}
catch(NumberFormatException e) {};
}
Expand All @@ -189,7 +189,7 @@ public Page createPageOrWindow(Map<String, String> args)
{
try
{
skipCount = new Integer(strSkipCount);
skipCount = Integer.valueOf(strSkipCount);
}
catch(NumberFormatException e) {};
}
Expand All @@ -201,7 +201,7 @@ public Page createPageOrWindow(Map<String, String> args)
{
try
{
maxItems = new Integer(strMaxItems);
maxItems = Integer.valueOf(strMaxItems);
}
catch(NumberFormatException e) {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public static Object getDAVPropertyValue( Map<QName, Serializable> props, String
}
else if (davPropName.equals(WebDAV.XML_GET_CONTENT_LENGTH))
{
value = new Long(contentData.getSize());
value = Long.valueOf(contentData.getSize());
}
}
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -56,7 +56,7 @@ public SearchSQLQuery(@JsonProperty("stmt") String stmt,
this.stmt = stmt;
this.format = format != null ? format : "default";
this.locales = locales != null ? locales : Collections.emptyList();
this.itemLimit = itemLimit == null || itemLimit < 1 ? new Integer(1000) : itemLimit;
this.itemLimit = itemLimit == null || itemLimit < 1 ? Integer.valueOf(1000) : itemLimit;
this.includeMetadata = includeMetadata;
this.timezone = timezone;
this.filterQueries = filterQueries != null ? filterQueries : Collections.emptyList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void initCORS(ServletContext servletContext)
WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);

Properties gP = (Properties) wc.getBean(BEAN_GLOBAL_PROPERTIES);
Boolean corsEnabled = new Boolean(gP.getProperty(CORS_ENABLED));
Boolean corsEnabled = Boolean.valueOf(gP.getProperty(CORS_ENABLED));

if(logger.isDebugEnabled())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -146,7 +146,7 @@ public void testGetUsage() throws Exception
RepoUsage usage = usageStatus.getUsage();
LicenseDescriptor licenseDescriptor = descriptorService.getLicenseDescriptor();
Date validUntil = (licenseDescriptor == null) ? null : licenseDescriptor.getValidUntil(); // might be null
Integer checkLevel = new Integer(usageStatus.getLevel().ordinal());
Integer checkLevel = Integer.valueOf(usageStatus.getLevel().ordinal());

String url = "/api/admin/usage";
TestWebScriptServer.GetRequest req = new TestWebScriptServer.GetRequest(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -445,7 +445,7 @@ public void testQueryAuditRepo() throws Exception
Thread.sleep(1000);
}
assertTrue("Expected at least one entry", jsonEntries.length() > 0);
assertEquals("Entry count and physical count don't match", new Long(jsonEntries.length()), entryCount);
assertEquals("Entry count and physical count don't match", Long.valueOf(jsonEntries.length()), entryCount);
JSONObject jsonEntry = jsonEntries.getJSONObject(0);
Long entryId = jsonEntry.getLong(AbstractAuditWebScript.JSON_KEY_ENTRY_ID);
assertNotNull("No entry ID", entryId);
Expand Down Expand Up @@ -483,7 +483,7 @@ public void testQueryAuditRepo() throws Exception
assertTrue("Should have found entries", jsonEntries.length() > 0);

// Now login with failure using a GUID and ensure that we can find it
String missingUser = new Long(System.currentTimeMillis()).toString();
String missingUser = Long.valueOf(System.currentTimeMillis()).toString();

// Query for event that has not happened
url = "/api/audit/query/" + APP_REPOTEST_NAME + "/repositorytest/login/error/user" + "?value=" + missingUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -147,7 +147,7 @@ protected void setUp() throws Exception
userOneHome = repositoryHelper.getUserHome(personService.getPerson(USER_ONE));
// no pun intended
quickFile = AbstractContentTransformerTest.loadQuickTestFile("jpg");
TEST_CONTENT = new byte[new Long(quickFile.length()).intValue()];
TEST_CONTENT = new byte[Long.valueOf(quickFile.length()).intValue()];
new FileInputStream(quickFile).read(TEST_CONTENT);
testNode = createTestFile(userOneHome, TEST_NAME, quickFile);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* Copyright (C) 2005 - 2023 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
Expand Down Expand Up @@ -913,8 +913,8 @@ protected String updateFileVersions(String userId, String contentNodeId, int cnt
{
String[] parts = currentVersionLabel.split("\\.");

int majorVer = new Integer(parts[0]).intValue();
int minorVer = new Integer(parts[1]).intValue();
int majorVer = Integer.valueOf(parts[0]).intValue();
int minorVer = Integer.valueOf(parts[1]).intValue();

Map<String, String> params = new HashMap<>();
params.put(Nodes.PARAM_OVERWRITE, "true");
Expand Down
Loading

0 comments on commit 1984056

Please sign in to comment.