diff --git a/.mvn/maven.config b/.mvn/maven.config deleted file mode 100644 index 3944d880ef2..00000000000 --- a/.mvn/maven.config +++ /dev/null @@ -1 +0,0 @@ --T1C diff --git a/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminAction.java b/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminAction.java index f28707dac42..36beb2cd7a0 100644 --- a/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminAction.java +++ b/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminAction.java @@ -117,6 +117,12 @@ * bounces the application (starts a few instances per hosts, set the rest to refusing sessions and auto-recover) * * + * setAdditionalArgs + * 'OK' or
+ * error message + * updates the instances' additional command line arguments + * + * * info * JSON or
* error message @@ -191,6 +197,21 @@ * *

*

+ * The direct action setAdditionalArgs must be invoked with the following argument: + * + * + * + * + * + * + * + * + * + * + * + *
ArgumentValueDescription
argsstringthe additional arguments to be passed to the instance on startup
+ *

+ *

* Possible status codes: * * @@ -478,6 +499,12 @@ public void weeklyScheduleRangeAction() { applicationsPage().weeklyStartHours(instances, Integer.parseInt(beginScheduleWindow), Integer.parseInt(endScheduleWindow), Integer.parseInt(weekDay)); } + public void setAdditionalArgsAction() { + String arguments = (String) context().request().formValueForKey("args"); + if (arguments != null) + applicationsPage().setAdditionalArgs(instances, arguments); + } + public void turnScheduledOnAction() { applicationsPage().turnScheduledOn(instances); } @@ -635,4 +662,4 @@ public WOActionResults performActionNamed(String s) { public Session mySession() { return (Session) session(); } -} \ No newline at end of file +} diff --git a/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminApplicationsPage.java b/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminApplicationsPage.java index 4c070c229e5..9af11af5e9f 100644 --- a/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminApplicationsPage.java +++ b/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminApplicationsPage.java @@ -168,6 +168,18 @@ public void turnScheduledOff(NSArray nsarray) { sendUpdateInstancesToWotaskds(); } + public void setAdditionalArgs(NSArray instances, String arguments) { + for(Enumeration enumeration = instances.objectEnumerator(); enumeration.hasMoreElements();) { + MInstance instance = (MInstance) enumeration.nextElement(); + String instArgs = instance.additionalArgs(); + if (instArgs == null || !arguments.equals(instArgs)) { + instance.setAdditionalArgs(arguments); + processedInstance(instance); + } + } + sendUpdateInstancesToWotaskds(); + } + public void turnRefuseNewSessionsOn(NSArray nsarray) { for(Enumeration enumeration = nsarray.objectEnumerator(); enumeration.hasMoreElements();) { MInstance minstance = (MInstance) enumeration.nextElement(); diff --git a/Frameworks/Ajax/Ajax/Components/AjaxAutoComplete.wo/AjaxAutoComplete.html b/Frameworks/Ajax/Ajax/Components/AjaxAutoComplete.wo/AjaxAutoComplete.html index 31cc846ae0e..3c874366416 100644 --- a/Frameworks/Ajax/Ajax/Components/AjaxAutoComplete.wo/AjaxAutoComplete.html +++ b/Frameworks/Ajax/Ajax/Components/AjaxAutoComplete.wo/AjaxAutoComplete.html @@ -1 +1,16 @@ - \ No newline at end of file + + + + + + + + + + \ No newline at end of file diff --git a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxAutoComplete.java b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxAutoComplete.java index e28928e674a..dcd54eb1546 100644 --- a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxAutoComplete.java +++ b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxAutoComplete.java @@ -77,7 +77,7 @@ * @binding minChars Look at the scriptaculous documentation. * @binding indicator Look at the scriptaculous documentation. * @binding updateElement Look at the scriptaculous documentation. - * @binding afterUpdateElement Look at the scriptaculous documentation. + * @binding afterUpdateElement Look at the scriptaculous documentation. Also, a value of "observe" will generate javascript to submit change to server when item selected from list. Provided because {@link AjaxObserveField} doesn't work on {@link AjaxAutoComplete} fields. * @binding select Look at the scriptaculous documentation. * @binding onShow Look at the scriptaculous documentation. * @binding fullSearch Look at the scriptaculous documentation. @@ -159,7 +159,7 @@ protected NSDictionary createAjaxOptions() { ajaxOptionsArray.addObject(new AjaxOption("tokens", AjaxOption.STRING_ARRAY)); ajaxOptionsArray.addObject(new AjaxOption("frequency", AjaxOption.NUMBER)); ajaxOptionsArray.addObject(new AjaxOption("minChars", AjaxOption.NUMBER)); - ajaxOptionsArray.addObject(new AjaxOption("indicator", indicator(), AjaxOption.SCRIPT)); + ajaxOptionsArray.addObject(new AjaxOption("indicator", indicator(), AjaxOption.STRING)); ajaxOptionsArray.addObject(new AjaxOption("updateElement", AjaxOption.SCRIPT)); ajaxOptionsArray.addObject(new AjaxOption("afterUpdateElement", AjaxOption.SCRIPT)); ajaxOptionsArray.addObject(new AjaxOption("onShow", AjaxOption.SCRIPT)); @@ -183,6 +183,17 @@ public void appendToResponse(WOResponse res, WOContext ctx) { super.appendToResponse(res, ctx); boolean isDisabled = booleanValueForBinding("disabled", false); if ( !isDisabled ) { + String actionUrl = AjaxUtils.ajaxComponentActionUrl(ctx); + NSMutableDictionary options = createAjaxOptions().mutableClone(); + if ("observe".equalsIgnoreCase(options.get("afterUpdateElement"))) { + // Javascript to simulate AjaxObserveField on this AjaxAutocomplete when an item has been selected from the list + String afterUpdateElement = "function (text, li) { " + + "var options = new Array();" + + "options.parameters = encodeURIComponent('"+fieldName+"') + '=' + encodeURIComponent(text.value);" + + "new Ajax.Request('"+actionUrl+"', options);" + + "}"; + options.put("afterUpdateElement", afterUpdateElement); + } boolean isLocal = booleanValueForBinding("isLocal", false); if (isLocal) { StringBuilder str = new StringBuilder(); @@ -208,14 +219,13 @@ public void appendToResponse(WOResponse res, WOContext ctx) { str.append("',"); str.append(listJS); str.append(','); - AjaxOptions.appendToBuffer(createAjaxOptions(), str, ctx); + AjaxOptions.appendToBuffer(options, str, ctx); str.append(");\n// ]]>\n\n"); res.appendContentString(String.valueOf(str)); } else { - String actionUrl = AjaxUtils.ajaxComponentActionUrl(ctx); AjaxUtils.appendScriptHeader(res); res.appendContentString("new Ajax.Autocompleter('" + fieldName + "', '" + divName + "', '" + actionUrl + "', "); - AjaxOptions.appendToResponse(createAjaxOptions(), res, ctx); + AjaxOptions.appendToResponse(options, res, ctx); res.appendContentString(");"); AjaxUtils.appendScriptFooter(res); } diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEOControlUtilities.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEOControlUtilities.java index 33fda213e33..a9cb3e000cc 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEOControlUtilities.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEOControlUtilities.java @@ -1871,15 +1871,16 @@ public static EOQualifier localInstancesInQualifier(EOEditingContext ec, EOQuali * @param eos the NSArray of EOEnterpriseObjects * @return a NSArray of EOGlobalIDs */ - public static NSArray globalIDsForObjects(NSArray eos) { - int c = eos != null ? eos.count() : 0; - NSMutableArray ids = new NSMutableArray(c); - for (int i = 0; i < c; i++) { - EOEnterpriseObject eo = (EOEnterpriseObject)eos.objectAtIndex(i); + public static NSArray globalIDsForObjects(NSArray eos) { + if (eos == null) { + return new NSArray<>(); + } + NSMutableArray ids = new NSMutableArray(eos.count()); + for (EOEnterpriseObject eo : eos) { EOEditingContext ec = eo.editingContext(); EOGlobalID gid = ec.globalIDForObject(eo); ids.addObject(gid); - } + } return ids; } @@ -1887,18 +1888,21 @@ public static NSArray globalIDsForObjects(NSArray eos) { * Aggregate method for EOEditingContext.objectForGlobalID(). * NOTE: this only returns objects that are already registered, if you * need all objects from the GIDs, use {@link #faultsForGlobalIDs(EOEditingContext, NSArray)}. + * @param ec the EOEditingContext in which the EOEnterpriseObjects should be faulted + * @param globalIDs the EOGlobalIDs + * @return a NSArray of EOEnterpriseObjects * @see com.webobjects.eocontrol.EOEditingContext#objectForGlobalID(EOGlobalID) */ - public static NSArray objectsForGlobalIDs(final EOEditingContext ec, final NSArray globalIDs) { - NSArray result = null; + public static NSArray objectsForGlobalIDs(final EOEditingContext ec, final NSArray globalIDs) { + NSArray result = null; if ( globalIDs != null && globalIDs.count() > 0 ) { - final NSMutableArray a = new NSMutableArray(); - final Enumeration e = globalIDs.objectEnumerator(); + final NSMutableArray a = new NSMutableArray<>(); + final Enumeration e = globalIDs.objectEnumerator(); while ( e.hasMoreElements() ) { - final EOGlobalID theGID = (EOGlobalID)e.nextElement(); - final EOEnterpriseObject theObject = ec.faultForGlobalID(theGID, ec); + final EOGlobalID theGID = e.nextElement(); + final T theObject = (T) ec.faultForGlobalID(theGID, ec); if ( theObject != null ) a.addObject(theObject); @@ -1915,23 +1919,23 @@ public static NSArray objectsForGlobalIDs(final EOEditingContext ec, final NSArr * @param gids the EOGlobalIDs * @return a NSArray of EOEnterpriseObjects */ - public static NSArray faultsForGlobalIDs(EOEditingContext ec, NSArray gids) { + public static NSArray faultsForGlobalIDs(EOEditingContext ec, NSArray gids) { int c = gids.count(); - NSMutableArray a = new NSMutableArray(c); + NSMutableArray a = new NSMutableArray<>(c); for (int i = 0; i < c; i++) { - EOGlobalID gid = (EOGlobalID)gids.objectAtIndex(i); - EOEnterpriseObject eo = ec.faultForGlobalID(gid, ec); + EOGlobalID gid = gids.objectAtIndex(i); + T eo = (T) ec.faultForGlobalID(gid, ec); a.addObject(eo); } return a; } - public static NSArray faultsForRawRowsFromEntity(EOEditingContext ec, NSArray primKeys, String entityName) { + public static NSArray faultsForRawRowsFromEntity(EOEditingContext ec, NSArray primKeys, String entityName) { int c = primKeys.count(); - NSMutableArray a = new NSMutableArray(c); + NSMutableArray a = new NSMutableArray<>(c); for (int i = 0; i < c; i++) { NSDictionary pkDict = (NSDictionary)primKeys.objectAtIndex(i); - EOEnterpriseObject eo = ec.faultForRawRow(pkDict, entityName); + T eo = (T) ec.faultForRawRow(pkDict, entityName); a.addObject(eo); } return a; diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXFetchResultCache.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXFetchResultCache.java index 3880beff60a..4b3c86fb7f1 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXFetchResultCache.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXFetchResultCache.java @@ -117,7 +117,7 @@ protected long cacheTime(NSArray eos, EOFetchSpecification fs) { * @param eos * @param fs */ - public void setObjectsForFetchSpecification(EODatabaseContext dbc, EOEditingContext ec, NSArray eos, EOFetchSpecification fs) { + public void setObjectsForFetchSpecification(EODatabaseContext dbc, EOEditingContext ec, NSArray eos, EOFetchSpecification fs) { String identifier = ERXFetchSpecification.identifierForFetchSpec(fs); synchronized (cache) { currentDatabase = dbc.database(); diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXQuery.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXQuery.java index e08a2b1b566..ef44c54ad3f 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXQuery.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXQuery.java @@ -4,6 +4,7 @@ import java.lang.reflect.InvocationTargetException; import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Date; import java.util.Enumeration; import java.util.StringTokenizer; import java.util.regex.Matcher; @@ -28,6 +29,7 @@ import com.webobjects.eocontrol.EOQualifier; import com.webobjects.eocontrol.EOSortOrdering; import com.webobjects.foundation.NSArray; +import com.webobjects.foundation.NSData; import com.webobjects.foundation.NSDictionary; import com.webobjects.foundation.NSForwardException; import com.webobjects.foundation.NSKeyValueCoding; @@ -43,6 +45,7 @@ import er.extensions.eof.ERXEOAccessUtilities.ChannelAction; import er.extensions.foundation.ERXProperties; +import er.extensions.foundation.ERXStringUtilities; import er.extensions.jdbc.ERXSQLHelper; /** @@ -851,6 +854,18 @@ protected static void setupAdaptorChannelEOAttributes(EOAdaptorChannel adaptorCh if (externalType != null) adaptorSelectAttribute.setExternalType(externalType); if (className != null) adaptorSelectAttribute.setClassName(className); if (valueType != null) adaptorSelectAttribute.setValueType(valueType); + + adaptorSelectAttribute.setAdaptorValueConversionClassName(selectAttribute.adaptorValueConversionClassName()); + adaptorSelectAttribute.setAdaptorValueConversionMethodName(selectAttribute.adaptorValueConversionMethodName()); + adaptorSelectAttribute.setFactoryMethodArgumentType(selectAttribute.factoryMethodArgumentType()); + adaptorSelectAttribute.setValueFactoryMethodName(selectAttribute.valueFactoryMethodName()); + // Defined in the ERXAttributeExtension EOAttribute but not visible by the compiler we use a runtime trick... + // adaptorSelectAttribute.setValueFactoryClassName(selectAttribute.valueFactoryClassName()); + try { + String valueFactoryClassName = (String) NSKeyValueCoding.DefaultImplementation.valueForKey(selectAttribute, "valueFactoryClassName"); + NSKeyValueCoding.DefaultImplementation.takeValueForKey(adaptorSelectAttribute, valueFactoryClassName, "valueFactoryClassName"); + } + catch (Exception e) {} // Fail if ERXAttributeExtension is not loaded but you cannot use factory class anyway } adaptorChannel.setAttributesToFetch(adaptorSelectAttributes); } @@ -1812,24 +1827,19 @@ protected String formatValueForAttributeForInlineUse(EOSQLExpression sqlExpressi // If the formattedValue is "NULL" then the formatValueForAttribute() did not // do its job and we'll do the best we can here if (formattedValue == null || formattedValue.equals("NULL")) { - if (value instanceof String) { - formattedValue = sqlExpression.formatStringValue((String)value); - } else if (value instanceof NSTimestamp) { - NSTimestamp timestamp = (NSTimestamp) value; - formattedValue = formattedTimestampForInlineUse(sqlExpression, timestamp, attribute); - } else if (value instanceof Boolean) { - boolean boolValue = (Boolean) value; - // If stored in the database as a string then format as string - // otherwise format as a number 1 or 0. - if (attribute.externalType().toLowerCase().contains("char")) { - formattedValue = "'" + boolValue +"'"; - } else if (boolValue) { - formattedValue = EOSQLExpression.sqlStringForNumber(1); - } else { - formattedValue = EOSQLExpression.sqlStringForNumber(0); - } + // Ask the attribute to convert the value to adaptor type, this reduce the number of cases. + // Possible value type are now String, Date, Number or NSData + Object attributeValue = attribute.adaptorValueByConvertingAttributeValue(value); + if (attributeValue instanceof String) { + formattedValue = sqlExpression.formatStringValue((String)attributeValue); + } else if (attributeValue instanceof Date) { + Date date = (Date) attributeValue; + formattedValue = formattedTimestampForInlineUse(sqlExpression, date, attribute); + } else if (value instanceof NSData) { + NSData data = (NSData) value; + formattedValue = "X'" + ERXStringUtilities.byteArrayToHexString(data._bytesNoCopy()) + "'"; } else { - formattedValue = value.toString(); + formattedValue = attributeValue.toString(); } } } @@ -1845,7 +1855,7 @@ protected String databaseProductName(EOEntity entity) { return plugin.databaseProductName().toLowerCase(); } - protected String formattedTimestampForInlineUse(EOSQLExpression sqlExpression, NSTimestamp timestamp, EOAttribute attribute) { + protected String formattedTimestampForInlineUse(EOSQLExpression sqlExpression, Date timestamp, EOAttribute attribute) { EOEntity entity = attribute.entity(); String databaseProductName = databaseProductName(entity); //NSTimestampFormatter formatter = new NSTimestampFormatter("%Y-%m-%d %H:%M:%S"); diff --git a/Frameworks/EOF/ERRest/Sources/er/rest/ERXRestUtils.java b/Frameworks/EOF/ERRest/Sources/er/rest/ERXRestUtils.java index a70d230078b..2442a8d16de 100644 --- a/Frameworks/EOF/ERRest/Sources/er/rest/ERXRestUtils.java +++ b/Frameworks/EOF/ERRest/Sources/er/rest/ERXRestUtils.java @@ -10,6 +10,7 @@ import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalQuery; +import java.util.Base64; import java.util.Calendar; import java.util.Date; @@ -172,6 +173,9 @@ else if (value instanceof OffsetDateTime) { 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()); + } else { formattedValue = value.toString(); } @@ -445,7 +449,7 @@ else if (valueType != null && TemporalAccessor.class.isAssignableFrom(valueType) } else { TemporalQuery query = null; - Class valueTypeClass = valueType.getClass(); + Class valueTypeClass = valueType; if (valueTypeClass.equals(LocalDate.class)) { query = LocalDate::from; } diff --git a/Frameworks/Mail/ERCMail/.gitignore b/Frameworks/Mail/ERCMail/.gitignore new file mode 100644 index 00000000000..378eac25d31 --- /dev/null +++ b/Frameworks/Mail/ERCMail/.gitignore @@ -0,0 +1 @@ +build diff --git a/Utilities/WOInstall/Sources/er/woinstaller/WebObjectsInstaller.java b/Utilities/WOInstall/Sources/er/woinstaller/WebObjectsInstaller.java index 12a3b07bf2e..2fc82f7d1c9 100644 --- a/Utilities/WOInstall/Sources/er/woinstaller/WebObjectsInstaller.java +++ b/Utilities/WOInstall/Sources/er/woinstaller/WebObjectsInstaller.java @@ -5,8 +5,11 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.zip.GZIPInputStream; @@ -113,13 +116,16 @@ else if (!destinationFolder.mkdirs()) { protected InputStream getInputStream(IWOInstallerProgressMonitor progressMonitor) throws IOException { File woDmgFile = null; + InputStream woDmgIs = null; if ("file".equals(woDmgUri.getScheme())) { woDmgFile = new File(woDmgUri); if (!woDmgFile.exists()) { throw new IllegalStateException("The file " + woDmgFile.getName() + " was not found"); } + woDmgIs = new BufferedInputStream(new FileInputStream(woDmgFile)); + } else { + woDmgIs = new BufferedInputStream(urlToInputStream(woDmgUri.toURL())); } - InputStream woDmgIs = new BufferedInputStream(woDmgFile == null ? woDmgUri.toURL().openStream() : new FileInputStream(woDmgFile)); InputStream woPaxGZIs; if (woVersion == 53) { @@ -132,7 +138,32 @@ protected InputStream getInputStream(IWOInstallerProgressMonitor progressMonitor } return new GZIPInputStream(woPaxGZIs); } - + + private InputStream urlToInputStream(URL url) { + HttpURLConnection connection = null; + try { + connection = (HttpURLConnection) url.openConnection(); + connection.setConnectTimeout(15000); + connection.setReadTimeout(15000); + connection.connect(); + int responseCode = connection.getResponseCode(); + if (responseCode < 400 && responseCode > 299) { + String redirectUrl = connection.getHeaderField("Location"); + try { + URL newUrl = new URL(redirectUrl); + return urlToInputStream(newUrl); + } catch (MalformedURLException e) { + URL newUrl = new URL(url.getProtocol() + "://" + url.getHost() + redirectUrl); + return urlToInputStream(newUrl); + } + } + + return connection.getInputStream(); + } catch (Exception e) { + throw new RuntimeException(e); + } +} + protected long getLength() { return rawLength; }