Nullable attributes are sent as null in the request
559765
def nullable_attributes(*attrs)
      @nullable_attributes ||= []
      if attrs.any?
        @nullable_attributes.map!(&:to_sym).concat(attrs).uniq! if attrs.any?
      end
      @nullable_attributes
    end
1008551
def serialize(self, null_values=False):
    
    ret = {}
    property_dict = dict(self.__class__.__dict__)  # contain view definition defaults
    property_dict.update(self.__dict__)  # overrides done at runtime

    for k in property_dict.keys():
      if k[:1] == "_" or (property_dict[k] is None and not null_values):
        continue

      v = property_dict[k]

      if isinstance(v, list):
        v_items = []
        for v_item in v:
          if self._isclass(v_item.__class__, BaseView):
            v_item_val = v_item.serialize(null_values=null_values)
            if not null_values and len(v_item_val) == 0:
              continue
            v_items.append(v_item_val)
          elif self._isclass(v_item, BaseView):  # when were passed Class instead of instance
            pass
          else:
            v_items.append(v_item)

        ret[k] = v_items
      elif self._isclass(v.__class__, BaseView):
        ret[k] = v.serialize(null_values=null_values)
      elif self._isclass(v, BaseView):  # when were passed Class instead of instance
        pass
      else:
        ret[k] = v

    return ret
8574
@Internal
    public static Optional<NettyMutableHttpResponse> get(NettyHttpRequest<?> request) {
        NettyMutableHttpResponse nettyHttpResponse = request.attr(KEY).get();
        return Optional.ofNullable(nettyHttpResponse);
    }
51592
@Override
	public <T> T getAttribute(String name, Class<T> clazz) {
		return null;
	}
874453
private void checkSerialize(final HttpServletRequest request) {
    String reqpar = request.getParameter("serialize");

    if (reqpar == null) {
      return;
    }

    HttpSession sess = request.getSession(false);
    Enumeration en = sess.getAttributeNames();

    while (en.hasMoreElements()) {
      String attrname = (String)en.nextElement();
      ObjectOutputStream oo = null;

      info("Attempt to serialize attr " + attrname);
      Object o = sess.getAttribute(attrname);

      try {
        ByteArrayOutputStream bo = new ByteArrayOutputStream();
        oo = new ObjectOutputStream(bo);
        oo.writeObject(o);
        oo.flush();

        info("Serialized object " + attrname + " has size: " + bo.size());
      } catch (Throwable t) {
        t.printStackTrace();
      } finally {
        if (oo != null) {
          try {
            oo.close();
          } catch (Throwable t) {}
        }
      }
    }
  }
184352
public static void fetchAttributes(RequestAdapter requestAdapter, ProcessResult processResult) {
        if (processResult != null) {
            for (ContentResult contentResult : processResult) {
                for (ActionResult actionResult : contentResult) {
                    Object actionResultValue = actionResult.getResultValue();
                    if (actionResultValue instanceof ProcessResult) {
                        fetchAttributes(requestAdapter, (ProcessResult)actionResultValue);
                    } else {
                        String actionId = actionResult.getActionId();
                        if (actionId != null) {
                            requestAdapter.setAttribute(actionId, actionResultValue);
                        }
                    }
                }
            }
        }
    }
519831
@Override
    public Object getAttribute(String name) {
        if (name == null) {
            logger.logp(Level.SEVERE, CLASS_NAME, "getAttribute", servlet40NLS.getString("name.is.null"));
            throw new java.lang.NullPointerException(servlet40NLS.getString("name.is.null"));
        }

        return super.getAttribute(name);
    }
1086805
function (requestV1) {
        var modes = {
                urlencoded: 'urlencoded',
                params: 'formdata',
                raw: 'raw',
                binary: 'file'
            },
            data = {},
            rawModeData,
            dataMode = modes[requestV1.dataMode],
            retainEmpty = this.options.retainEmptyValues;

        // set null body if neither data|rawModeData nor dataMode is set, or if the dataMode is explicitly set to null
        // The explicit null check is added to ensure that body is not set in case the dataMode was set to null by the
        // app, but `data` or `rawModeData` was not empty
        if ((!dataMode && _.isEmpty(requestV1.data) && _.isEmpty(requestV1.rawModeData)) ||
            requestV1.dataMode === null) {
            return retainEmpty ? null : undefined;
        }

        // set `rawModeData` if its a string
        if (_.isString(requestV1.rawModeData)) {
            rawModeData = requestV1.rawModeData;
        }
        // check if `rawModeData` is an array like: ['rawModeData']
        else if (Array.isArray(requestV1.rawModeData) &&
            requestV1.rawModeData.length === 1 &&
            _.isString(requestV1.rawModeData[0])) {
            rawModeData = requestV1.rawModeData[0];
        }

        // set data.mode.
        // if dataMode is not set, infer from data or rawModeData
        // at this point either data or rawModeData is set
        if (dataMode) {
            data.mode = dataMode;
        }
        // set `formdata` if rawModeData is not set and data is an array
        // `data` takes higher precedence over `rawModeData`.
        else if (!rawModeData && Array.isArray(requestV1.data || requestV1.rawModeData)) {
            data.mode = 'formdata';
        }
        // set `raw` mode as default
        else {
            data.mode = 'raw';
        }

        if (data.mode === 'raw') {
            if (rawModeData) {
                data[data.mode] = rawModeData;
            }
            else if (_.isString(requestV1.data)) {
                data[data.mode] = requestV1.data;
            }
            else {
                data[data.mode] = ''; // empty string instead of retainEmpty check to have parity with other modes.
            }
        }
        else if (data.mode === 'file') {
            data[data.mode] = { src: rawModeData }; // rawModeData can be string or undefined.
        }
        else {
            // parse data for formdata or urlencoded data modes.
            // `rawModeData` is checked in case its of type `data`.
            data[data.mode] = parseFormData(requestV1.data || requestV1.rawModeData, retainEmpty);
        }

        if (requestV1.dataDisabled) { data.disabled = true; }
        else if (retainEmpty) { data.disabled = false; }

        return data;
    }
948067
function handleAttributeContext(attrNode, context) {
    if (!attrNode.type && attrNode.inherit !== 'inherit') attrNode.type = 'string';

    if (attrNode.map) {
        Object.keys(attrNode.map).forEach(mappingName => {
            const mapping = attrNode.map[mappingName];

            Object.keys(mapping).forEach(dataSourceName => {
                if (!context.dataSourceAttributes[dataSourceName]) {
                    throw new ImplementationError(
                        `Unknown DataSource "${dataSourceName}" in map${context.errorContext}`
                    );
                }

                context.dataSourceAttributes[dataSourceName].push(mapping[dataSourceName]);
            });
        });

        if ('value' in attrNode) {
            throw new ImplementationError(
                'Static "value" in combination with "map" makes no sense' + context.errorContext
            );
        }
    }
}
514157
private void addPostParams(final Request request) {
        if (friendlyName != null) {
            request.addPostParam("FriendlyName", friendlyName);
        }

        if (activitySid != null) {
            request.addPostParam("ActivitySid", activitySid);
        }

        if (attributes != null) {
            request.addPostParam("Attributes", attributes);
        }
    }
1177141
@Override
    public RequestCtx handleRequest(HttpServletRequest request,
                                    HttpServletResponse response)
            throws IOException, ServletException {
        if (logger.isDebugEnabled()) {
            logger.debug("{}/handleRequest!", this.getClass().getName());
        }

        String state = request.getParameter("state");
        String ownerId = request.getParameter("ownerId");

        RequestCtx req = null;
        Map<URI, AttributeValue> actions = new HashMap<URI, AttributeValue>();
        Map<URI, AttributeValue> resAttr;
        try {
            String[] parts = getPathParts(request);
            resAttr = ResourceAttributes.getResources(parts);
            if (state != null && !state.isEmpty()) {
                resAttr.put(Constants.OBJECT.STATE.getURI(),
                            new StringAttribute(state));
            }
            if (ownerId != null && !ownerId.isEmpty()) {
                resAttr.put(Constants.OBJECT.OWNER.getURI(),
                            new StringAttribute(state));
            }

            if (state != null && state.equals("A")) {
                actions.put(Constants.ACTION.ID.getURI(),
                            new StringAttribute("publish"));
            } else if (state != null && state.equals("I")) {
                actions.put(Constants.ACTION.ID.getURI(),
                            new StringAttribute("unpublish"));
            } else {
                actions.put(Constants.ACTION.ID.getURI(),
                            Constants.ACTION.MODIFY_OBJECT
                                    .getStringAttribute());
            }
            actions.put(Constants.ACTION.API.getURI(),
                        Constants.ACTION.APIM.getStringAttribute());

            req =
                    getContextHandler().buildRequest(getSubjects(request),
                                                     actions,
                                                     resAttr,
                                                     getEnvironment(request));

            LogUtil.statLog(request.getRemoteUser(),
                            Constants.ACTION.MODIFY_OBJECT.uri,
                            parts[1],
                            null);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            throw new ServletException(e.getMessage(), e);
        }

        return req;
    }
841860
public function nullableTimestamps()
	{
		$timestamp = $this->timestamp('created_at');

		if(is_object($timestamp))
			$timestamp->nullable();

		$timestamp = $this->timestamp('updated_at');

		if(is_object($timestamp))
			$timestamp->nullable();
	}
1346815
@SuppressWarnings("unchecked")
    private <A> A getRequestAttribute(String name) {

        Object attribute = m_request.getAttribute(name);

        return attribute != null ? (A)attribute : null;
    }
398016
@SuppressWarnings("unchecked")
	public void init() throws ServletException {
		Map<String, Object> config = null;
		String type = getServletConfig().getInitParameter("type");

		ServletContext servletContext = getServletContext();
		configHash = (Integer) servletContext
				.getAttribute(JawrGrailsConstant.JAWR_GRAILS_CONFIG_HASH);

		if (JawrConstant.CSS_TYPE.equals(type))
			config = (Map<String, Object>) servletContext
					.getAttribute(JawrGrailsConstant.JAWR_GRAILS_CSS_CONFIG);
		else if (JawrConstant.BINARY_TYPE.equals(type))
			config = (Map<String, Object>) servletContext
					.getAttribute(JawrGrailsConstant.JAWR_GRAILS_BINARY_CONFIG);
		else
			config = (Map<String, Object>) servletContext
					.getAttribute(JawrGrailsConstant.JAWR_GRAILS_JS_CONFIG);

		Properties jawrProps = (Properties) config
				.get(JawrGrailsConstant.JAWR_GRAILS_CONFIG_PROPERTIES_KEY);
		try {
			if (JawrConstant.BINARY_TYPE.equals(type)) {
				this.requestHandler = new JawrBinaryResourceRequestHandler(
						servletContext, config, jawrProps);
			} else {
				this.requestHandler = new JawrRequestHandler(servletContext,
						config, jawrProps);
			}

			if (JawrConstant.JS_TYPE.equals(type)) {
				servletContext.setAttribute(
						JawrGrailsConstant.JAWR_GRAILS_JS_REQUEST_HANDLER,
						requestHandler);
			} else if (JawrConstant.CSS_TYPE.equals(type)) {
				servletContext.setAttribute(
						JawrGrailsConstant.JAWR_GRAILS_CSS_REQUEST_HANDLER,
						requestHandler);
			} else if (JawrConstant.BINARY_TYPE.equals(type)) {
				servletContext.setAttribute(
						JawrGrailsConstant.JAWR_GRAILS_BINARY_CONFIG,
						requestHandler);
			}
		} catch (ServletException e) {
			LOGGER.error("Jawr servlet with name"
					+ getServletConfig().getServletName()
					+ " failed to initialize properly. ");
			LOGGER.error("Cause:");
			LOGGER.error(e.getMessage(), e);
			throw e;
		} catch (RuntimeException e) {
			LOGGER.error("Jawr servlet with name"
					+ getServletConfig().getServletName()
					+ " failed to initialize properly. ");
			LOGGER.error("Cause: ");
			LOGGER.error(e.getMessage(), e);
			throw new ServletException(e);
		}
	}
1083762
@Override
    public BaseJsonBo setAttribute(String attrName, Object value, boolean triggerChange) {
        if (value instanceof JsonNode) {
            if (value instanceof NullNode || value instanceof MissingNode) {
                super.setAttribute(attrName, null, triggerChange);
            } else {
                super.setAttribute(attrName, value.toString(), triggerChange);
            }
        } else {
            JsonNode node = null;
            if (value instanceof String) {
                node = tryParseJson(value.toString());
            }
            node = node != null ? node : SerializationUtils.toJson(value);
            super.setAttribute(attrName, node.toString(), triggerChange);
        }
        return this;
    }
1168799
protected void initMembers(HttpServletRequest req, Throwable t) {

        // get the status error attribute values from the request
        m_servletName = (String)req.getAttribute(ERROR_SERVLET_NAME);
        m_errorMessage = (String)req.getAttribute(ERROR_MESSAGE);
        m_requestUri = (String)req.getAttribute(ERROR_REQUEST_URI);
        m_statusCode = (Integer)req.getAttribute(ERROR_STATUS_CODE);

        if ((m_statusCode == null) || (m_requestUri == null)) {
            // check if the error request is invoked via Apache/HTTPd ErrorDocument and mod_jk

            // to use this you need to add the following to "jk.conf":

            // JkEnvVar REDIRECT_URL none
            // JkEnvVar REDIRECT_STATUS none
            // JkEnvVar REDIRECT_SERVLET_NAME OpenCmsServlet

            String jkUri = (String)req.getAttribute("REDIRECT_URL");
            String jkStatusCode = (String)req.getAttribute("REDIRECT_STATUS");
            String jkServletName = (String)req.getAttribute("REDIRECT_SERVLET_NAME");
            try {
                if (!"none".equals(jkStatusCode) && !"none".equals(jkUri)) {
                    m_servletName = jkServletName;
                    m_requestUri = jkUri;
                    m_statusCode = new Integer(jkStatusCode);
                }
            } catch (NullPointerException e) {
                // attibute not set, ignore
            } catch (NumberFormatException e) {
                // status code not a number, ignore
            }
        }

        // get the status code as String
        if (m_statusCode != null) {
            m_statusCodeMessage = String.valueOf(m_statusCode.intValue());
        } else {
            m_statusCodeMessage = UNKKNOWN_STATUS_CODE;
        }

        m_exception = t;

        // determine the best locale to use from the users browser settings
        CmsAcceptLanguageHeaderParser parser = new CmsAcceptLanguageHeaderParser(
            req,
            OpenCms.getWorkplaceManager().getDefaultLocale());
        List<Locale> acceptedLocales = parser.getAcceptedLocales();
        List<Locale> workplaceLocales = OpenCms.getWorkplaceManager().getLocales();
        m_locale = OpenCms.getLocaleManager().getFirstMatchingLocale(acceptedLocales, workplaceLocales);
        if (m_locale == null) {
            // no match found - use OpenCms default locale
            m_locale = OpenCms.getWorkplaceManager().getDefaultLocale();
        }
        getCmsObject().getRequestContext().setLocale(m_locale);

        // store the site root of the request
        m_siteRoot = OpenCms.getSiteManager().matchRequest(req).getSiteRoot();
    }
1073264
private static void exposeRequestAttributeIfNotPresent(ServletRequest request, String name, Object value) {
        if (request.getAttribute(name) == null) {
            request.setAttribute(name, value);
        }
    }