Skip to content

Commit ade07dd

Browse files
authored
Merge pull request #154 from mendix/run/4597-upgrade-to-10.21
[RUN-4597][RUN-4565] Upgrade project to 10.21.0
2 parents bc222bb + dc1dee9 commit ade07dd

File tree

113 files changed

+3789
-3352
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3789
-3352
lines changed

build.gradle

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
plugins {
77
id 'java'
8-
id 'com.mendix.gradle.publish-module-plugin' version '1.20'
8+
id 'com.mendix.gradle.publish-module-plugin' version '1.21'
99
id 'net.researchgate.release' version '2.8.1'
1010
}
1111

12-
sourceCompatibility = '11'
12+
sourceCompatibility = '21'
1313
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
1414

1515
project.ext {
16-
mendixPublicApiVersion = '9.18.0'
16+
mendixPublicApiVersion = '10.21.0'
1717
}
1818

1919
def mprDir = "$projectDir/src/CommunityCommons"
@@ -25,11 +25,12 @@ mxMarketplace {
2525
moduleLicense = 'Apache V2'
2626
appDirectory = "src/CommunityCommons"
2727
versionPathPrefix = "_Version " // the path prefix within the module to the version folder
28-
createMigrationFile = true
29-
includeFiles = ["$mprDir/License.txt", "$mprDir/SiemensMendixCommunityCommons__10.1.3__READMEOSS.html"]
28+
includeFiles = ["$mprDir/License.txt", "$mprDir/SiemensMendixCommunityCommons__11.0.0__READMEOSS.html"]
29+
syncJavaDependenciesBeforeBuild = true
3030
}
3131

3232
def userLibDir = "$mprDir/userlib"
33+
def vendorLibDir = "$mprDir/vendorlib"
3334

3435
repositories {
3536
maven {
@@ -55,20 +56,13 @@ dependencies {
5556
[group: 'org.hamcrest', name: 'hamcrest', version: '2.2']
5657
)
5758

58-
compileOnly([group: 'com.mendix', name: 'public-api', version: "$mendixPublicApiVersion"])
59+
testImplementation fileTree(vendorLibDir) { include '*.jar' }
5960

60-
implementation(
61-
[group: 'com.google.guava', name: 'guava', version: '32.0.1-jre'],
62-
[group: 'com.googlecode.owasp-java-html-sanitizer', name: 'owasp-java-html-sanitizer', version: '20211018.2'],
63-
[group: 'commons-io', name: 'commons-io', version: '2.17.0'],
64-
[group: 'org.apache.pdfbox', name: 'pdfbox', version: '2.0.30'],
65-
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'],
66-
[group: 'org.apache.commons', name: 'commons-text', version: '1.10.0']
67-
)
61+
compileOnly([group: 'com.mendix', name: 'public-api', version: "$mendixPublicApiVersion"])
6862
}
6963

7064
tasks.withType(JavaCompile) {
71-
options.compilerArgs << "-Xlint:deprecation"
65+
options.deprecation = true
7266
}
7367

7468
sourceSets {
@@ -106,6 +100,7 @@ tasks.named('compileJava') {
106100

107101
clean {
108102
delete "$userLibDir"
103+
delete "$vendorLibDir"
109104
}
110105

111106
release {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=10.1.4-SNAPSHOT
1+
version=11.0.0-SNAPSHOT
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- We upgraded the Community Commons module to Mendix version 10.21.0.
2+
- We deprecated the Misc.getRuntimeVersion Java method, use Core.getRuntimeVersion instead.
3+
- We deprecated the Misc.getModelVersion Java method, use Core.getModelVersion instead.
-13 MB
Binary file not shown.

src/CommunityCommons/SiemensMendixCommunityCommons__10.1.3__READMEOSS.html renamed to src/CommunityCommons/SiemensMendixCommunityCommons__11.0.0__READMEOSS.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/CommunityCommons/javasource/communitycommons/Misc.java

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.mendix.core.Core;
44
import com.mendix.core.CoreException;
5-
import com.mendix.core.conf.RuntimeVersion;
65
import com.mendix.core.objectmanagement.member.MendixBoolean;
76
import com.mendix.integration.WebserviceException;
87
import com.mendix.systemwideinterfaces.core.IContext;
@@ -16,6 +15,8 @@
1615
import java.io.IOException;
1716
import java.io.InputStream;
1817
import java.io.OutputStream;
18+
import java.net.URI;
19+
import java.net.URISyntaxException;
1920
import java.net.URL;
2021
import java.net.URLConnection;
2122
import java.nio.charset.StandardCharsets;
@@ -141,11 +142,20 @@ public static String getApplicationURL() {
141142
return StringUtils.removeEnd(applicationURL, "/");
142143
}
143144

145+
/**
146+
* @return the runtime version
147+
* @deprecated since 11.0.0. Use {@link com.mendix.core.Core.getRuntimeVersion} instead
148+
*/
149+
@Deprecated
144150
public static String getRuntimeVersion() {
145-
RuntimeVersion runtimeVersion = RuntimeVersion.getInstance();
146-
return runtimeVersion.toString();
151+
return Core.getRuntimeVersion();
147152
}
148153

154+
/**
155+
* @return the model version
156+
* @deprecated since 11.0.0. Use {@link com.mendix.core.Core.getModelVersion} instead
157+
*/
158+
@Deprecated
149159
public static String getModelVersion() {
150160
return Core.getModelVersion();
151161
}
@@ -160,7 +170,7 @@ public static void throwWebserviceException(String faultstring) throws Webservic
160170

161171
public static String retrieveURL(String url, String postdata) throws Exception {
162172
// Send data, appname
163-
URLConnection conn = new URL(url).openConnection();
173+
URLConnection conn = new URI(url).toURL().openConnection();
164174

165175
conn.setDoInput(true);
166176
conn.setDoOutput(true);
@@ -188,7 +198,7 @@ public static Boolean duplicateFileDocument(IContext context, IMendixObject toCl
188198
throw new Exception("No file to clone or to clone into provided");
189199
}
190200

191-
MendixBoolean hasContents = (MendixBoolean) toClone.getMember(context, FileDocument.MemberNames.HasContents.toString());
201+
MendixBoolean hasContents = (MendixBoolean) toClone.getMember(FileDocument.MemberNames.HasContents.toString());
192202
if (!hasContents.getValue(context)) {
193203
return false;
194204
}
@@ -206,7 +216,7 @@ public static Boolean duplicateImage(IContext context, IMendixObject toClone, IM
206216
throw new Exception("No file to clone or to clone into provided");
207217
}
208218

209-
MendixBoolean hasContents = (MendixBoolean) toClone.getMember(context, FileDocument.MemberNames.HasContents.toString());
219+
MendixBoolean hasContents = (MendixBoolean) toClone.getMember(FileDocument.MemberNames.HasContents.toString());
210220
if (!hasContents.getValue(context)) {
211221
return false;
212222
}
@@ -220,14 +230,14 @@ public static Boolean duplicateImage(IContext context, IMendixObject toClone, IM
220230
return true;
221231
}
222232

223-
public static Boolean storeURLToFileDocument(IContext context, String url, IMendixObject __document, String filename) throws IOException {
233+
public static Boolean storeURLToFileDocument(IContext context, String url, IMendixObject __document, String filename) throws IOException, URISyntaxException {
224234
if (__document == null || url == null || filename == null) {
225235
throw new IllegalArgumentException("No document, filename or URL provided");
226236
}
227237

228238
final int MAX_REMOTE_FILESIZE = 1024 * 1024 * 200; //maximum of 200 MB
229239
try {
230-
URL imageUrl = new URL(url);
240+
URL imageUrl = new URI(url).toURL();
231241
URLConnection connection = imageUrl.openConnection();
232242
//we connect in 20 seconds or not at all
233243
connection.setConnectTimeout(20000);
@@ -255,9 +265,9 @@ public static Boolean storeURLToFileDocument(IContext context, String url, IMend
255265
}
256266
Core.storeFileDocumentContent(context, __document, filename, fileContentIS);
257267
}
258-
} catch (IOException ioe) {
259-
Logging.error(LOGNODE, String.format("A problem occurred while reading from URL %s: %s", url, ioe.getMessage()));
260-
throw ioe;
268+
} catch (IOException | URISyntaxException e) {
269+
Logging.error(LOGNODE, String.format("A problem occurred while reading from URL %s: %s", url, e.getMessage()));
270+
throw e;
261271
}
262272

263273
return true;
@@ -515,7 +525,7 @@ public void exec(IContext context, IMendixObject obj) throws Exception {
515525
public static Boolean executeInBatches(String xpathRaw, BatchState batchState, int batchsize, boolean waitUntilFinished, boolean asc) throws CoreException, InterruptedException {
516526
String xpath = xpathRaw.startsWith("//") ? xpathRaw : "//" + xpathRaw;
517527

518-
long count = Core.retrieveXPathQueryAggregate(Core.createSystemContext(), "count(" + xpath + ")");
528+
long count = Core.createXPathQuery("count(" + xpath + ")").executeAggregateLong(Core.createSystemContext());
519529
int loop = (int) Math.ceil(((float) count) / ((float) batchsize));
520530

521531
Logging.debug(LOGNODE,
@@ -549,15 +559,12 @@ public void run() {
549559
Thread.sleep(200);
550560
IContext c = Core.createSystemContext();
551561

552-
List<IMendixObject> objects = Core.retrieveXPathQuery(c, xpath + (last > 0 ? "[id " + (asc ? "> " : "< ") + last + "]" : ""),
553-
batchsize,
554-
0,
555-
new HashMap<String, String>() {
556-
{
557-
put("id", asc ? "asc" : "desc");
558-
}
559-
}
560-
);
562+
List<IMendixObject> objects =
563+
Core.createXPathQuery(xpath + (last > 0 ? "[id " + (asc ? "> " : "< ") + last + "]" : ""))
564+
.setAmount(batchsize)
565+
.setOffset(0)
566+
.addSort("id", asc ? true : false)
567+
.execute(c);
561568

562569
//no new objects found :)
563570
if (objects.isEmpty()) {

src/CommunityCommons/javasource/communitycommons/ORM.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.mendix.systemwideinterfaces.core.IMendixObject;
1313
import com.mendix.systemwideinterfaces.core.IMendixObject.ObjectState;
1414
import com.mendix.systemwideinterfaces.core.IMendixObjectMember;
15-
import com.mendix.systemwideinterfaces.core.IMendixObjectMember.MemberState;
1615
import com.mendix.systemwideinterfaces.core.meta.IMetaAssociation;
1716
import com.mendix.systemwideinterfaces.core.meta.IMetaAssociation.AssociationType;
1817
import com.mendix.systemwideinterfaces.core.meta.IMetaEnumValue;
@@ -37,7 +36,7 @@ public static Long getGUID(IMendixObject item) {
3736

3837
public static String getOriginalValueAsString(IContext context, IMendixObject item,
3938
String member) {
40-
return String.valueOf(item.getMember(context, member).getOriginalValue(context));
39+
return String.valueOf(item.getMember(member).getOriginalValue(context));
4140
}
4241

4342
public static boolean objectHasChanged(IMendixObject anyobject) {
@@ -63,7 +62,7 @@ public static boolean memberHasChanged(IContext context, IMendixObject item, Str
6362
if (!item.hasMember(member)) {
6463
throw new IllegalArgumentException("Unknown member: " + member);
6564
}
66-
return item.getMember(context, member).getState() == MemberState.CHANGED || item.getState() != ObjectState.NORMAL;
65+
return item.getMember(member).isChanged() || item.getState() != ObjectState.NORMAL;
6766
}
6867

6968
public static void deepClone(IContext c, IMendixObject source, IMendixObject target, String membersToSkip, String membersToKeep, String reverseAssociations, String excludeEntities, String excludeModules) throws CoreException {
@@ -195,7 +194,7 @@ public static Boolean commitWithoutEvents(IContext context, IMendixObject subjec
195194
public static String getValueOfPath(IContext context, IMendixObject substitute, String fullpath, String datetimeformat) throws Exception {
196195
String[] path = fullpath.split("/");
197196
if (path.length == 1) {
198-
IMendixObjectMember<?> member = substitute.getMember(context, path[0]);
197+
IMendixObjectMember<?> member = substitute.getMember(path[0]);
199198

200199
//special case, see ticket 9135, format datetime.
201200
if (member instanceof MendixDateTime) {
@@ -222,7 +221,7 @@ public static String getValueOfPath(IContext context, IMendixObject substitute,
222221
} else if (path.length == 0) {
223222
throw new Exception("communitycommons.ORM.getValueOfPath: Unexpected end of path.");
224223
} else {
225-
IMendixObjectMember<?> member = substitute.getMember(context, path[0]);
224+
IMendixObjectMember<?> member = substitute.getMember(path[0]);
226225
if (member instanceof MendixObjectReference) {
227226
MendixObjectReference ref = (MendixObjectReference) member;
228227
IMendixIdentifier id = ref.getValue(context);
@@ -260,7 +259,7 @@ public static String getValueOfPath(IContext context, IMendixObject substitute,
260259
}
261260

262261
private static boolean isFileDocument(IMendixObject object) {
263-
return Core.isSubClassOf(Core.getMetaObject(FileDocument.entityName), object.getMetaObject());
262+
return object.getMetaObject().isFileDocument();
264263
}
265264

266265
public static Boolean cloneObject(IContext c, IMendixObject source,
@@ -277,7 +276,7 @@ public static Boolean cloneObject(IContext c, IMendixObject source,
277276
}
278277
if ("__UUID__".equals(m.getName()) && (isFileDocument(source) || isFileDocument(target))) {
279278
continue;
280-
}
279+
}
281280
if (withAssociations || ((!(m instanceof MendixObjectReference) && !(m instanceof MendixObjectReferenceSet) && !(m instanceof MendixAutoNumber)))) {
282281
target.setValue(c, entry.getKey(), m.getValue(c));
283282
}
@@ -287,7 +286,12 @@ public static Boolean cloneObject(IContext c, IMendixObject source,
287286

288287
public static IMendixObject firstWhere(IContext c, String entityName,
289288
Object member, String value) throws CoreException {
290-
List<IMendixObject> items = Core.retrieveXPathQuery(c, String.format("//%s[%s = '%s']", entityName, member, value), 1, 0, new HashMap<String, String>());
289+
List<IMendixObject> items =
290+
Core.createXPathQuery(String.format("//%s[%s = '%s']", entityName, member, value))
291+
.setAmount(1)
292+
.setOffset(0)
293+
.execute(c);
294+
291295
if (items == null || items.size() == 0) {
292296
return null;
293297
}

src/CommunityCommons/javasource/communitycommons/XPath.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import com.mendix.core.Core;
3131
import com.mendix.core.CoreException;
32+
import com.mendix.datastorage.XPathQuery;
3233
import com.mendix.systemwideinterfaces.core.IContext;
3334
import com.mendix.systemwideinterfaces.core.IMendixIdentifier;
3435
import com.mendix.systemwideinterfaces.core.IMendixObject;
@@ -350,13 +351,17 @@ private void assertEmptyStack() throws IllegalStateException {
350351
public long count() throws CoreException {
351352
assertEmptyStack();
352353

353-
return Core.retrieveXPathQueryAggregate(context, "count(" + getXPath() + ")");
354+
return Core.createXPathQuery("count(" + getXPath() + ")").executeAggregateLong(context);
354355
}
355356

356357
public IMendixObject firstMendixObject() throws CoreException {
357358
assertEmptyStack();
358359

359-
List<IMendixObject> result = Core.retrieveXPathQuery(context, getXPath(), 1, offset, sorting);
360+
XPathQuery query = (XPathQuery) Core.createXPathQuery(getXPath()).setAmount(1).setOffset(offset);
361+
for (Map.Entry<String, String> sort : sorting.entrySet())
362+
query.addSort(sort.getKey(), sort.getValue() == "asc");
363+
List<IMendixObject> result = query.execute(context);
364+
360365
if (result.isEmpty())
361366
return null;
362367
return result.get(0);
@@ -541,7 +546,10 @@ public T firstOrWait(long timeoutMSecs) throws CoreException, InterruptedExcepti
541546
public List<IMendixObject> allMendixObjects() throws CoreException {
542547
assertEmptyStack();
543548

544-
return Core.retrieveXPathQuery(context, getXPath(), limit, offset, sorting);
549+
XPathQuery query = (XPathQuery) Core.createXPathQuery(getXPath()).setAmount(limit).setOffset(offset);
550+
for (Map.Entry<String, String> sort : sorting.entrySet())
551+
query.addSort(sort.getKey(), sort.getValue() == "asc");
552+
return query.execute(context);
545553
}
546554

547555
public List<T> all() throws CoreException {

src/CommunityCommons/javasource/communitycommons/actions/Base64Decode.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@
1111

1212
import communitycommons.StringUtils;
1313
import com.mendix.systemwideinterfaces.core.IContext;
14-
import com.mendix.webui.CustomJavaAction;
14+
import com.mendix.systemwideinterfaces.core.UserAction;
1515

1616
/**
1717
* Converts a base64 encoded string to the plain, original string
1818
*/
19-
public class Base64Decode extends CustomJavaAction<java.lang.String>
19+
public class Base64Decode extends UserAction<java.lang.String>
2020
{
21-
private java.lang.String encoded;
21+
private final java.lang.String encoded;
2222

23-
public Base64Decode(IContext context, java.lang.String encoded)
23+
public Base64Decode(
24+
IContext context,
25+
java.lang.String _encoded
26+
)
2427
{
2528
super(context);
26-
this.encoded = encoded;
29+
this.encoded = _encoded;
2730
}
2831

2932
@java.lang.Override

0 commit comments

Comments
 (0)