Checks and sets the supported content types configuration value.
485366
def _set_supported_content_type(self, content_types_supported):
        
        if not isinstance(content_types_supported, list):
            raise TypeError(("Settings 'READTIME_CONTENT_SUPPORT' must be"
                             "a list of content types."))

        self.content_type_supported = content_types_supported
935586
def set_content_type_and_size_in_model
      model.content_type = file.content_type if file.content_type
      model.file_size = file.size
    end
848328
public static void put(String extension, String contentType) {
        if (extension != null && extension.length() != 0
                && contentType != null && contentType.length() != 0) {

            contentTypes.put(extension, contentType);
        }
    }
1304641
public void setContentType(String contentType)
  {
    _contentType = contentType;

    if (_contentType.equals("text/xml"))
      _strategy = XML;
    if (_contentType.equals("application/xml"))
      _strategy = XML;
    else if (_contentType.equals("text/xhtml"))
      _strategy = XHTML;
    else if (_contentType.equals("application/xhtml+xml"))
      _strategy = XHTML;
    else if (_contentType.equals("text/html"))
      _strategy = HTML;
    else
      _strategy = XML;
  }
309434
def _validate_configuration_type(self, configuration_type):
        

        if configuration_type.lower() != 'running' and configuration_type.lower() != 'startup':
            raise Exception(self.__class__.__name__, 'Configuration Type is invalid. Should be startup or running')
929948
public function setContentType($contentType)
    {
        $allowedValues = $this->getContentTypeAllowableValues();
        if (!is_null($contentType) && !in_array($contentType, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'contentType', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['contentType'] = $contentType;

        return $this;
    }
248026
public static <V> void validateConfiguredValueType(Class<V> valueType, V value) throws ClassCastException {
        if (Object.class != valueType) {
            // means that type checks is required
            if (!valueType.isAssignableFrom(value.getClass())) {
                throw new ClassCastException("Value '" + value + "' is not assignable to " + valueType);
            }
        }
    }
294108
public Part<T> setContentType(MediaType contentType) {
        headers.add(HttpHeaders.CONTENT_TYPE, contentType.toString());
        return this;
    }
1055742
public void setSupportedMediaTypes(List<MediaType> supportedMediaTypes) {
		Assert.notEmpty(supportedMediaTypes, "'supportedMediaTypes' must not be empty");
		this.supportedMediaTypes = new ArrayList<MediaType>(supportedMediaTypes);
	}
1370911
protected void updateTypeModeToggle() {

        m_typeModeToggle.setVisible(false);
        if (m_types != null) {
            for (CmsResourceTypeBean type : m_types.values()) {
                if (type.getVisibility() == TypeVisibility.showOptional) {
                    m_typeModeToggle.setVisible(true);
                    return;

                }
            }
        }
    }
497134
private MediaType acceptabePlainTextMediaType() {
        final List<MediaType> acceptable = headers.getAcceptableMediaTypes();
        if (acceptable == null || acceptable.size() == 0) {
            return TEXT_PLAIN_TYPE;
        }
        for (final MediaType type : acceptable) {
            if (type.isWildcardType() || (type.isCompatible(TEXT_PLAIN_TYPE) && type.isWildcardSubtype())) {
                return TEXT_PLAIN_TYPE;
            } else if (type.isCompatible(TEXT_PLAIN_TYPE)) {
                return type;
            }
        }
        return null;
    }
694267
@Override
    public boolean accepts(String mimeType) {
        String contentType = request.headers().get(HeaderNames.ACCEPT);
        if (contentType == null) {
            contentType = MimeTypes.HTML;
        }
        // For performance reason, we first try a full match:
        if (contentType.contains(mimeType)) {
            return true;
        }
        // Else check the media types:
        MediaType input = MediaType.parse(mimeType);
        for (MediaType type : mediaTypes()) {
            if (input.is(type)) {
                return true;
            }
        }
        return false;
    }
788315
private boolean canSetPropertyForType(int requiredType, Value value, String[] constraints)
   {

      if (requiredType == value.getType())
      {
         return checkValueConstraints(requiredType, constraints, value);
      }
      else if (requiredType == PropertyType.BINARY
               && (value.getType() == PropertyType.STRING || value.getType() == PropertyType.DATE
                        || value.getType() == PropertyType.LONG || value.getType() == PropertyType.DOUBLE
                        || value.getType() == PropertyType.NAME || value.getType() == PropertyType.PATH || value
                        .getType() == PropertyType.BOOLEAN))
      {
         return checkValueConstraints(requiredType, constraints, value);
      }
      else if (requiredType == PropertyType.BOOLEAN)
      {
         if (value.getType() == PropertyType.STRING)
         {
            return checkValueConstraints(requiredType, constraints, value);
         }
         else if (value.getType() == PropertyType.BINARY)
         {
            try
            {
               return isCharsetString(value.getString(), Constants.DEFAULT_ENCODING)
                  && checkValueConstraints(requiredType, constraints, value);
            }
            catch (Exception e)
            {
               // Hm, this is not string and not UTF-8 too
               return false;
            }
         }
         else
         {
            return false;
         }
      }
      else if (requiredType == PropertyType.DATE)
      {
         String likeDataString = null;
         try
         {
            if (value.getType() == PropertyType.STRING)
            {
               likeDataString = value.getString();
            }
            else if (value.getType() == PropertyType.BINARY)
            {
               likeDataString = getCharsetString(value.getString(), Constants.DEFAULT_ENCODING);
            }
            else if (value.getType() == PropertyType.DOUBLE || value.getType() == PropertyType.LONG)
            {
               return checkValueConstraints(requiredType, constraints, value);
            }
            else
            {
               return false;
            }
            // try parse...
            JCRDateFormat.parse(likeDataString);
            // validate
            return checkValueConstraints(requiredType, constraints, value);
         }
         catch (Exception e)
         {
            // Hm, this is not date format string
            return false;
         }
      }
      else if (requiredType == PropertyType.DOUBLE)
      {
         String likeDoubleString = null;
         try
         {
            if (value.getType() == PropertyType.STRING)
            {
               likeDoubleString = value.getString();
            }
            else if (value.getType() == PropertyType.BINARY)
            {
               likeDoubleString = getCharsetString(value.getString(), Constants.DEFAULT_ENCODING);
            }
            else if (value.getType() == PropertyType.DATE)
            {
               return true;
            }
            else if (value.getType() == PropertyType.LONG)
            {
               return checkValueConstraints(requiredType, constraints, value);
            }
            else
            {
               return false;
            }
            Double doubleValue = new Double(likeDoubleString);
            return doubleValue != null && checkValueConstraints(requiredType, constraints, value);
         }
         catch (Exception e)
         {
            // Hm, this is not double formated string
            return false;
         }
      }
      else if (requiredType == PropertyType.LONG)
      {
         String likeLongString = null;
         try
         {
            if (value.getType() == PropertyType.STRING)
            {
               likeLongString = value.getString();
            }
            else if (value.getType() == PropertyType.BINARY)
            {
               likeLongString = getCharsetString(value.getString(), Constants.DEFAULT_ENCODING);
            }
            else if (value.getType() == PropertyType.DATE)
            {
               return true;
            }
            else if (value.getType() == PropertyType.DOUBLE)
            {
               return true;
            }
            else
            {
               return false;
            }
            Long longValue = new Long(likeLongString);
            return longValue != null && checkValueConstraints(requiredType, constraints, value);
         }
         catch (Exception e)
         {
            // Hm, this is not long formated string
            return false;
         }
      }
      else if (requiredType == PropertyType.NAME)
      {
         String likeNameString = null;
         try
         {
            if (value.getType() == PropertyType.STRING)
            {
               likeNameString = value.getString();
            }
            else if (value.getType() == PropertyType.BINARY)
            {
               likeNameString = getCharsetString(value.getString(), Constants.DEFAULT_ENCODING);
            }
            else if (value.getType() == PropertyType.PATH)
            {
               String pathString = value.getString();
               String[] pathParts = pathString.split("\\/");
               if (pathString.startsWith("/") && (pathParts.length > 1 || pathString.indexOf("[") > 0))
               {
                  // Path is not relative - absolute
                  // FALSE if it is more than one element long
                  // or has an index
                  return false;
               }
               else if (!pathString.equals("/") && pathParts.length == 1 && pathString.indexOf("[") < 0)
               {
                  // Path is relative
                  // TRUE if it is one element long
                  // and has no index
                  return checkValueConstraints(requiredType, constraints, value);
               }
               else if (pathString.startsWith("/") && pathString.lastIndexOf("/") < 1 && pathString.indexOf("[") < 0)
               {
                  return checkValueConstraints(requiredType, constraints, value);
               }
               else
               {
                  return false;
               }
            }
            else
            {
               return false;
            }
            try
            {
               Value nameValue = valueFactory.createValue(likeNameString, requiredType);
               return nameValue != null && checkValueConstraints(requiredType, constraints, value);
            }
            catch (Exception e)
            {
               return false;
            }
         }
         catch (Exception e)
         {
            return false;
         }
      }
      else if (requiredType == PropertyType.PATH)
      {
         String likeNameString = null;
         try
         {
            if (value.getType() == PropertyType.STRING)
            {
               likeNameString = value.getString();
            }
            else if (value.getType() == PropertyType.BINARY)
            {
               likeNameString = getCharsetString(value.getString(), Constants.DEFAULT_ENCODING);
            }
            else if (value.getType() == PropertyType.NAME)
            {
               return checkValueConstraints(requiredType, constraints, value);
            }
            else
            {
               return false;
            }
            try
            {
               Value nameValue = valueFactory.createValue(likeNameString, requiredType);
               return nameValue != null && checkValueConstraints(requiredType, constraints, value);
            }
            catch (Exception e)
            {
               return false;
            }
         }
         catch (Exception e)
         {
            return false;
         }
      }
      else if (requiredType == PropertyType.STRING)
      {
         String likeStringString = null;
         try
         {
            if (value.getType() == PropertyType.BINARY)
            {
               likeStringString = getCharsetString(value.getString(), Constants.DEFAULT_ENCODING);
            }
            else if (value.getType() == PropertyType.DATE || value.getType() == PropertyType.LONG
               || value.getType() == PropertyType.BOOLEAN || value.getType() == PropertyType.NAME
               || value.getType() == PropertyType.PATH || value.getType() == PropertyType.DOUBLE)
            {
               likeStringString = value.getString();
            }
            else
            {
               return false;
            }
            return likeStringString != null && checkValueConstraints(requiredType, constraints, value);
         }
         catch (Exception e)
         {
            return false;
         }
      }
      else if (requiredType == PropertyType.UNDEFINED)
      {
         return checkValueConstraints(requiredType, constraints, value);
      }
      else
      {
         return false;
      }
   }
141250
private void setResourceTypes(Map<String, String[]> types) {

        if ((types == null) || (types.size() == 0)) {
            setValidConfiguration(false);
            LOG.error(Messages.get().getBundle().key(Messages.LOG_NO_RESOURCE_TYPES_0));
        }
        m_resTypes = types;
    }
14735
private static void checkContentType(String contentType, String accept, String ext, boolean strict) throws PageException {

	if (!StringUtil.isEmpty(ext, true)) {
	    ext = ext.trim().toLowerCase();
	    if (ext.startsWith("*.")) ext = ext.substring(2);
	    if (ext.startsWith(".")) ext = ext.substring(1);

		String blacklistedTypes = SystemUtil.getSystemPropOrEnvVar(
				SystemUtil.SETTING_UPLOAD_EXT_BLACKLIST, SystemUtil.DEFAULT_UPLOAD_EXT_BLACKLIST
		).toLowerCase();
		Array blacklist = ListUtil.listToArrayRemoveEmpty(blacklistedTypes, ',');

		for (int i=blacklist.size(); i > 0; i--) {
			if (ext.equals(Caster.toString(blacklist.getE(i)).trim())){
				throw new ApplicationException("Upload of files with extension [" + ext + "] is not permitted.  "
						+ "You can configure the "
						+ SystemUtil.SETTING_UPLOAD_EXT_BLACKLIST
						+ " System property or the "
						+ SystemUtil.convertSystemPropToEnvVar(SystemUtil.SETTING_UPLOAD_EXT_BLACKLIST)
						+ " Environment variable to allow that file type."
				);
			}
		}
	}
	else ext = null;

	if (StringUtil.isEmpty(accept, true)) return;

	MimeType mt = MimeType.getInstance(contentType), sub;

	Array whishedTypes = ListUtil.listToArrayRemoveEmpty(accept, ',');
	int len = whishedTypes.size();
	for (int i = 1; i <= len; i++) {
	    String whishedType = Caster.toString(whishedTypes.getE(i)).trim().toLowerCase();
	    if (whishedType.equals("*")) return;
	    // check mimetype
	    if (ListUtil.len(whishedType, "/", true) == 2) {
		sub = MimeType.getInstance(whishedType);
		if (mt.match(sub)) return;
	    }

	    // check extension
	    if (ext != null && !strict) {
		if (whishedType.startsWith("*.")) whishedType = whishedType.substring(2);
		if (whishedType.startsWith(".")) whishedType = whishedType.substring(1);
		if (ext.equals(whishedType)) return;
	    }
	}
	throw new ApplicationException("The MIME type of the uploaded file [" + contentType + "] was not accepted by the server.",
		"only this [" + accept + "] mime type are accepted");
    }
196748
public void setContent(Object content, String contentType)
			throws UnsupportedEncodingException {
		// https://code.google.com/p/sipservlets/issues/detail?id=202
		if(getSipSession().getProxy() == null) {
			checkMessageState();
		}
		checkContentType(contentType);
		checkCommitted();

		if(contentType != null && contentType.length() > 0) {
			this.addHeader(ContentTypeHeader.NAME, contentType);
			ContentTypeHeader contentTypeHeader = (ContentTypeHeader)this.message.getHeader(ContentTypeHeader.NAME);
			String charset = this.getCharacterEncoding();
			try {
			    // https://code.google.com/p/sipservlets/issues/detail?id=169
				if(contentType.contains(CONTENT_TYPE_MULTIPART) && content instanceof Multipart) {
					// Fix for Issue 2667 : Correct Handling of MimeMultipart
					Multipart multipart = (Multipart) content;
					OutputStream os = new ByteArrayOutputStream();
					multipart.writeTo(os);
					this.message.setContent(os.toString(), contentTypeHeader);
				} else {
					Object tmpContent = content;
					if(tmpContent instanceof String  && charset != null) {
						//test for unsupportedencoding exception
						new String("testEncoding".getBytes(charset));
						tmpContent = new String(((String)tmpContent).getBytes());
					}
					this.message.setContent(content, contentTypeHeader);
				}
			} catch (UnsupportedEncodingException uee) {
				throw uee;
			} catch (Exception e) {
				throw new IllegalArgumentException("Parse error reading content " + content + " with content type " + contentType, e);
			}
		}
	}
400262
public function verifySettings()
    {
        if ($this->type === null) {
            $this->setError("The type attribute is required");
        } elseif (!in_array($this->type, self::$types, true)) {
            $this->setError("Invalid type specified; must be one of (" . implode(self::$types) . ")");
        }
    }