Skip to content

Commit

Permalink
Converted project to 6.0.1, updated community commons module in project.
Browse files Browse the repository at this point in the history
  • Loading branch information
RoelandSalij committed Nov 10, 2016
1 parent 59b80d4 commit 80c2d00
Show file tree
Hide file tree
Showing 111 changed files with 181 additions and 342 deletions.
Binary file modified src/UnitTesting.mpr
Binary file not shown.
209 changes: 29 additions & 180 deletions src/javasource/com/mendix/core/Core.java

Large diffs are not rendered by default.

71 changes: 52 additions & 19 deletions src/javasource/communitycommons/Misc.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,33 @@ public static String retrieveURL(String url, String postdata) throws Exception
}

public static Boolean duplicateFileDocument(IContext context, IMendixObject toClone, IMendixObject target) throws Exception
{
if (toClone == null || target == null)
throw new Exception("No file to clone or to clone into provided");
MendixBoolean hasContents = (MendixBoolean) toClone.getMember(context, FileDocument.MemberNames.HasContents.toString());
{
if (toClone == null || target == null)
throw new Exception("No file to clone or to clone into provided");

MendixBoolean hasContents = (MendixBoolean) toClone.getMember(context, FileDocument.MemberNames.HasContents.toString());
if (!hasContents.getValue(context))
return false;
return false;

InputStream inputStream = Core.getFileDocumentContent(context, toClone);

try {
Core.storeFileDocumentContent(context, target, (String) toClone.getValue(context, system.proxies.FileDocument.MemberNames.Name.toString()), inputStream);
return true;
} catch (Exception e) {
e.printStackTrace();
}
finally{
try {
if(inputStream != null)
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return true;
}

InputStream inputStream = Core.getFileDocumentContent(context, toClone);

Core.storeFileDocumentContent(context, target, (String) toClone.getValue(context, system.proxies.FileDocument.MemberNames.Name.toString()), inputStream);
return true;
}

public static Boolean duplicateImage(IContext context, IMendixObject toClone, IMendixObject target, int thumbWidth, int thumbHeight) throws Exception
{
if (toClone == null || target == null)
Expand All @@ -168,8 +181,21 @@ public static Boolean duplicateImage(IContext context, IMendixObject toClone, IM

InputStream inputStream = Core.getImage(context, toClone, false);

Core.storeImageDocumentContent(context, target, inputStream, thumbWidth, thumbHeight);
try {
Core.storeImageDocumentContent(context, target, inputStream, thumbWidth, thumbHeight);

return true;
} catch (Exception e) {
e.printStackTrace();
}
finally {
try {
if(inputStream!= null)
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return true;
}

Expand Down Expand Up @@ -242,14 +268,21 @@ public static IContext getContextFor(IContext context, String username, boolean
throw new RuntimeException("Assertion: No username provided");
}

ISession session = getSessionFor(context, username);

IContext c = session.createContext();
if (sudoContext) {
return c.getSudoContext();
if (username.equals(context.getSession().getUser().getName()))
{
return context;
}
else
{
ISession session = getSessionFor(context, username);

return c;
IContext c = session.createContext();
if (sudoContext) {
return c.getSudoContext();
}

return c;
}
}

private static ISession getSessionFor(IContext context, String username) {
Expand Down
1 change: 0 additions & 1 deletion src/javasource/communitycommons/ORM.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ public static Boolean cloneObject(IContext c, IMendixObject source,
public static synchronized Boolean acquireLock(IContext context, IMendixObject item)
{
if (!isLocked(item)) {
if (!context.getSession().getUser().getName().equals(getLockOwner(item)))
locks.put(item.getId().toLong(), context.getSession());
return true;
}
Expand Down
9 changes: 8 additions & 1 deletion src/javasource/communitycommons/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ public class StringUtils

public static String hash(String value, int length) throws NoSuchAlgorithmException, DigestException
{
return String.valueOf(MessageDigest.getInstance(HASH_ALGORITHM).digest(value.getBytes(), 0, length));
byte[] inBytes = value.getBytes();
byte[] outBytes = new byte[length];

MessageDigest alg=MessageDigest.getInstance(HASH_ALGORITHM);
alg.update(inBytes);

alg.digest(outBytes, 0, length);
return String.valueOf(outBytes);
}

public static String regexReplaceAll(String haystack, String needleRegex,
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/Base64Decode.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/Base64Encode.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/Clone.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/DecryptString.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/DeepClone.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/Delay.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/EncryptString.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/EscapeHTML.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/HTMLEncode.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/Hash.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/Log.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand All @@ -10,8 +10,8 @@
package communitycommons.actions;

import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;
import com.mendix.systemwideinterfaces.core.IMendixObject;
import com.mendix.webui.CustomJavaAction;
import communitycommons.Misc;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/RandomHash.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/RandomString.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/RegexQuote.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/RegexTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/SimpleLog.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/StringLeftPad.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
2 changes: 1 addition & 1 deletion src/javasource/communitycommons/actions/StringLength.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was generated by Mendix Business Modeler.
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
Expand Down
Loading

0 comments on commit 80c2d00

Please sign in to comment.