Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add er.rest.format16BytesDataAsUUID property to encode 16 byte #965

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions Frameworks/EOF/ERRest/Resources/Properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Properies Info
er.extensions.load.Properties.framework.ERRest=load
er.extensions.ERRest.hasLocalization=false

er.rest.rfcDateFormat=rfc822
er.rest.format16BytesDataAsUUID=false
10 changes: 8 additions & 2 deletions Frameworks/EOF/ERRest/Sources/er/rest/ERXRestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import er.extensions.crypting.ERXCryptoString;
import er.extensions.foundation.ERXProperties;
import er.extensions.foundation.ERXValueUtilities;
import er.extensions.foundation.UUIDUtilities;

/**
* Miscellaneous rest-related utility methods.
Expand Down Expand Up @@ -174,13 +175,18 @@ else if (value instanceof NSData && ((NSData)value).length() == 24) {
formattedValue = NSPropertyListSerialization.stringFromPropertyList(value);
}
else if (value instanceof NSData) {
formattedValue = Base64.getEncoder().encodeToString(((NSData) value).bytes());
NSData valueData = (NSData) value;
if (valueData.length() == 16 && ERXProperties.booleanForKeyWithDefault("er.rest.format16BytesDataAsUUID", false)) {
formattedValue = UUIDUtilities.encodeAsPrettyString(valueData);
}
else {
formattedValue = Base64.getEncoder().encodeToString(((NSData) value).bytes());
}
}
else {
formattedValue = value.toString();
}
return formattedValue;

}

// this "spaces" attribute is stupid, i know ... this whole api is stupid. it's a quick hack for now to accommodate someone very near and dear to my heart ... yes i'm talking to you.
Expand Down