/** * @return <code>true</code> if the request payload should be included in the proxy call, <code>false</code> * otherwise. The default implementation returns <code>true</code> for POST and PUT requests. */ protected boolean shouldIncludeRequestPayload(HttpServletRequest req) { return ObjectUtility.isOneOf(req.getMethod(), "POST", "PUT"); }
@SuppressWarnings("squid:S1149") protected Hashtable<Object, Object> createContextEnvironment(final Map<Object, Object> properties) throws NamingException { Hashtable<Object, Object> env = new Hashtable<>(); if (properties != null) { for (Entry<Object, Object> entry : properties.entrySet()) { if (entry.getKey() == null || entry.getValue() == null) { LOG.info("ignoring property having null key or value [key={}, value={}]", entry.getKey(), entry.getValue()); } else if (ObjectUtility.isOneOf(entry.getKey(), CONNECTION_FACTORY, SYMBOLIC_NAME, MARSHALLER, REQUEST_REPLY_ENABLED, REQUEST_REPLY_CANCELLATION_TOPIC, JMS_CLIENT_ID)) { // Don't pass MOM-specific properties to the initial context to prevent problems with non-standard values. // For example, some containers throw an error if it finds an unserializable value. } else { env.put(entry.getKey(), entry.getValue()); } } } return env; }
protected void validate(final RequestType requestType, JSONObject request) { // Ensure request contains an UI session ID, except for the startup and the ping request if (!ObjectUtility.isOneOf(requestType, RequestType.STARTUP_REQUEST, RequestType.PING_REQUEST)) { Assertions.assertTrue(request.has(PROP_UI_SESSION_ID), "Missing property '{}' in request {}", PROP_UI_SESSION_ID, request); } // Only normal /json requests may send events. if (requestType != RequestType.REQUEST && request.has(PROP_EVENTS)) { request.remove(PROP_EVENTS); String requestAsString = request.toString(); if (requestAsString.length() > 10000) { // Truncate the message to prevent log inflation by malicious requests requestAsString = requestAsString.substring(0, 10000) + "..."; } LOG.info("Request contains unexpected attribute '{}': {}", PROP_EVENTS, requestAsString); } }
@Override protected String parse(String value) { if (ObjectUtility.isOneOf(value, "small", "medium", "large")) { return value; } throw new PlatformException("Invalid value for property '" + getKey() + "': '" + value + "'. Valid values are small, medium or large"); }
@Override protected void handleModelPropertyChange(String propertyName, Object oldValue, Object newValue) { if (ObjectUtility.isOneOf(propertyName, IImageField.PROP_IMAGE, IImageField.PROP_IMAGE_ID, IImageField.PROP_IMAGE_URL)) { handleModelImageSourceChanged(); } else { super.handleModelPropertyChange(propertyName, oldValue, newValue); } }
if (ObjectUtility.isOneOf(c, AbstractCompositeField.class, AbstractGroupBox.class,
@Override public List<ITableRow> findRows(Collection<? extends VALUE> values) { if (values != null) { List<ITableRow> foundRows = new ArrayList<>(); for (int i = 0; i < m_table.getRowCount(); i++) { ITableRow row = m_table.getRow(i); if (ObjectUtility.isOneOf(getValue(row), values)) { foundRows.add(row); } } return foundRows; } return CollectionUtility.emptyArrayList(); }
protected ScriptOutput processLibrary(String pathInfo, ScriptSource script, boolean compileAndMinify) throws IOException { if (!ObjectUtility.isOneOf(script.getNodeType(), NodeType.LIBRARY, NodeType.LIBRARY_MINIFIED)) { throw new IOException(script.getRequestPath() + " / " + script.getURL() + ": expected " + NodeType.LIBRARY + " or " + NodeType.LIBRARY_MINIFIED + ", but got " + script.getNodeType()); } long lastModified = script.getURL().openConnection().getLastModified(); String libraryContent = new String(IOUtility.readFromUrl(script.getURL()), StandardCharsets.UTF_8); // only minfy if not already minified if (compileAndMinify && script.getNodeType() != NodeType.LIBRARY_MINIFIED) { libraryContent = compileAndMinifyContent(script.getFileType(), libraryContent); } return new ScriptOutput(pathInfo, libraryContent.getBytes(StandardCharsets.UTF_8), lastModified); }
@Override protected void handleModelTreeEvent(TreeEvent event) { if (!acceptModelTreeEvent(event)) { return; } super.handleModelTreeEvent(event); // When nodes are deleted, immediately detach the detail table from the deleted nodes. If we would do // this later when the event buffer is processed, there could have been other events in the meantime // (e.g. table events) which fail when the nodes (and everything that is attached to them, namely detail // tables) are still existing. (Disposing the detail table right away is correct, because no matter what // the event buffer does, the nodes are definitively deleted.) if (ObjectUtility.isOneOf(event.getType(), TreeEvent.TYPE_NODES_DELETED, TreeEvent.TYPE_ALL_CHILD_NODES_DELETED)) { detachDetailTables(event.getNodes(), true); } }
protected boolean acceptModelTreeEvent(TreeEvent event) { // this is a HACK due to the hack to handle initial expansion of nodes (see org.eclipse.scout.rt.client.ui.basic.tree.AbstractTreeNode.setTreeInternal(ITree, boolean)) // where the node expansion is set to the tree to enforce a expansion event. Both of the hacks are obsolete once the JS Tree refactoring is done to calculate after every // change the new visible node list. if (event.getType() == OutlineEvent.TYPE_PAGE_CHANGED && !event.getNode().isVisible()) { return false; } // Don't fill the event buffer with events that are currently not relevant for the UI if (event instanceof OutlineEvent && ObjectUtility.isOneOf(event.getType(), OutlineEvent.TYPE_PAGE_BEFORE_DATA_LOADED, OutlineEvent.TYPE_PAGE_AFTER_DATA_LOADED, OutlineEvent.TYPE_PAGE_AFTER_TABLE_INIT, OutlineEvent.TYPE_PAGE_AFTER_PAGE_INIT, OutlineEvent.TYPE_PAGE_AFTER_SEARCH_FORM_START, OutlineEvent.TYPE_PAGE_AFTER_DISPOSE, OutlineEvent.TYPE_PAGE_ACTIVATED)) { return false; } return true; }
@Override protected void handleUiPropertyChange(String propertyName, JSONObject data) { if (IBooleanField.PROP_VALUE.equals(propertyName)) { Object o = data.opt(propertyName); Boolean uiValue = null; if (ObjectUtility.isOneOf(o, Boolean.TRUE, Boolean.FALSE)) { uiValue = (Boolean) o; } addPropertyEventFilterCondition(propertyName, uiValue); getModel().getUIFacade().setValueFromUI(uiValue); // In some cases the widget in the UI is clicked, which causes the check-box to be de-/selected, but the model rejects the value-change. // in that case we must "revert" the click in the UI, so that UI and model are in-sync again. This may happen, when the model-field throws // a VetoExeception in its execValidateValue() method. Boolean modelValue = getModel().getValue(); if (ObjectUtility.notEquals(uiValue, modelValue)) { addPropertyChangeEvent(propertyName, modelValue); } } else { super.handleUiPropertyChange(propertyName, data); } } }