Build JSON metadata for one rendition as image source.
@param media Media
@param rendition Rendition
@return JSON metadata
355945
@SuppressWarnings("null")
  protected JSONObject toReponsiveImageSource(Media media, Rendition rendition) {
    try {
      JSONObject source = new JSONObject();
      MediaFormat mediaFormat = rendition.getMediaFormat();
      source.put(MediaNameConstants.PROP_BREAKPOINT, mediaFormat.getProperties().get(MediaNameConstants.PROP_BREAKPOINT));
      source.put(PROP_SRC, rendition.getUrl());
      return source;
    }
    catch (JSONException ex) {
      throw new RuntimeException("Error building JSON source.", ex);
    }
  }
399388
public GetMediaSourceDownloadResponse getMediaSourceDownload(GetMediaSourceDownloadRequest request) {

        checkStringNotEmpty(request.getMediaId(), "Media ID should not be null or empty!");

        InternalRequest internalRequest =
                createRequest(HttpMethodName.GET, request, PATH_MEDIA, request.getMediaId());
        internalRequest.addParameter(PARA_DOWNLOAD, null);
        internalRequest.addParameter(PARA_EXPIREDINSECONDS, String.valueOf(request.getExpiredInSeconds()));

        return invokeHttpClient(internalRequest, GetMediaSourceDownloadResponse.class);
    }
767540
public static String serializeMetaData(Map<String, List<String>> metaData) {
        StringBuilder buf = new StringBuilder();
        if (metaData != null && metaData.size() > 0) {
            buf.append("<metadata xmlns=\"http://jivesoftware.com/protocol/workgroup\">");
            for (String key : metaData.keySet()) {
                List<String> value = metaData.get(key);
                for (String v : value) {
                    buf.append("<value name=\"").append(key).append("\">");
                    buf.append(StringUtils.escapeForXmlText(v));
                    buf.append("</value>");
                }
            }
            buf.append("</metadata>");
        }
        return buf.toString();
    }
63173
public void setMetadata(com.google.api.ads.admanager.axis.v201805.VideoMetadata metadata) {
        this.metadata = metadata;
    }
1324292
private String buildScaledMediaUrl(Dimension dimension, CropDimension cropDimension) {
    String resourcePath = this.resource.getPath();

    // if parent resource is a nt:file resource, use this one as path for scaled image
    Resource parentResource = this.resource.getParent();
    if (JcrBinary.isNtFile(parentResource)) {
      resourcePath = parentResource.getPath();
    }

    // URL to render scaled image via {@link InlineRenditionServlet}
    String path = resourcePath + "." + ImageFileServlet.SELECTOR
        + "." + dimension.getWidth() + "." + dimension.getHeight()
        + (cropDimension != null ? "." + cropDimension.getCropString() : "")
        + (this.mediaArgs.isContentDispositionAttachment() ? "." + MediaFileServlet.SELECTOR_DOWNLOAD : "")
        + "." + MediaFileServlet.EXTENSION + "/"
        // replace extension based on the format supported by ImageFileServlet for rendering for this rendition
        + ImageFileServlet.getImageFileName(getFileName());

    // build externalized URL
    UrlHandler urlHandler = AdaptTo.notNull(this.adaptable, UrlHandler.class);
    return urlHandler.get(path).urlMode(this.mediaArgs.getUrlMode()).buildExternalResourceUrl(this.resource);
  }
409674
public RequestContext renderJSONPretty(final JSONObject json) {
        final JsonRenderer jsonRenderer = new JsonRenderer();
        jsonRenderer.setJSONObject(json);
        jsonRenderer.setPretty(true);

        this.renderer = jsonRenderer;

        return this;
    }
928586
def c_metadata(api, args, verbose=False):
    
    obj = api.get_object(args['<URL>'].split('/')[-1])
    if not set_metadata(args['<JSON>'], obj):
        return json.dumps(obj.metadata.read(), indent=4)
1020085
public JSONObject convertToJson() {
        JSONObject buoJsonModel = new JSONObject();
        try {
            // Add all keys in plane format  initially. All known keys will be replaced with corresponding data type in the following section
            JSONObject metadataJsonObject = metadata_.convertToJson();
            Iterator<String> keys = metadataJsonObject.keys();
            while (keys.hasNext()) {
                String key = keys.next();
                buoJsonModel.put(key, metadataJsonObject.get(key));
            }
            if (!TextUtils.isEmpty(title_)) {
                buoJsonModel.put(Defines.Jsonkey.ContentTitle.getKey(), title_);
            }
            if (!TextUtils.isEmpty(canonicalIdentifier_)) {
                buoJsonModel.put(Defines.Jsonkey.CanonicalIdentifier.getKey(), canonicalIdentifier_);
            }
            if (!TextUtils.isEmpty(canonicalUrl_)) {
                buoJsonModel.put(Defines.Jsonkey.CanonicalUrl.getKey(), canonicalUrl_);
            }
            if (keywords_.size() > 0) {
                JSONArray keyWordJsonArray = new JSONArray();
                for (String keyword : keywords_) {
                    keyWordJsonArray.put(keyword);
                }
                buoJsonModel.put(Defines.Jsonkey.ContentKeyWords.getKey(), keyWordJsonArray);
            }
            if (!TextUtils.isEmpty(description_)) {
                buoJsonModel.put(Defines.Jsonkey.ContentDesc.getKey(), description_);
            }
            if (!TextUtils.isEmpty(imageUrl_)) {
                buoJsonModel.put(Defines.Jsonkey.ContentImgUrl.getKey(), imageUrl_);
            }
            if (expirationInMilliSec_ > 0) {
                buoJsonModel.put(Defines.Jsonkey.ContentExpiryTime.getKey(), expirationInMilliSec_);
            }
            buoJsonModel.put(Defines.Jsonkey.PublicallyIndexable.getKey(), isPublicallyIndexable());
            buoJsonModel.put(Defines.Jsonkey.LocallyIndexable.getKey(), isLocallyIndexable());
            buoJsonModel.put(Defines.Jsonkey.CreationTimestamp.getKey(), creationTimeStamp_);
            
        } catch (JSONException ignore) {
        }
        return buoJsonModel;
    }
1041267
public static Map<String, Map<String, Metadata>> parseAndPopulateMetadataMap(JsonObject jsonObject) {
        Map<String, Map<String, Metadata>> metadataMap = new HashMap<String, Map<String, Metadata>>();
        //Parse all templates
        for (JsonObject.Member templateMember : jsonObject) {
            if (templateMember.getValue().isNull()) {
                continue;
            } else {
                String templateName = templateMember.getName();
                Map<String, Metadata> scopeMap = metadataMap.get(templateName);
                //If templateName doesn't yet exist then create an entry with empty scope map
                if (scopeMap == null) {
                    scopeMap = new HashMap<String, Metadata>();
                    metadataMap.put(templateName, scopeMap);
                }
                //Parse all scopes in a template
                for (JsonObject.Member scopeMember : templateMember.getValue().asObject()) {
                    String scope = scopeMember.getName();
                    Metadata metadataObject = new Metadata(scopeMember.getValue().asObject());
                    scopeMap.put(scope, metadataObject);
                }
            }

        }
        return metadataMap;
    }
1115840
@VisibleForTesting
  static Map<String, byte[]> decodeMetadata(Map<String, String> metadata) {
    return Maps.transformValues(metadata, DECODE_METADATA_VALUES);
  }
996786
def artifact_mime_type(instance):
    
    for key, obj in instance['objects'].items():
        if ('type' in obj and obj['type'] == 'artifact' and 'mime_type' in obj):
            if enums.media_types():
                if obj['mime_type'] not in enums.media_types():
                    yield JSONError("The 'mime_type' property of object '%s' "
                                    "('%s') must be an IANA registered MIME "
                                    "Type of the form 'type/subtype'."
                                    % (key, obj['mime_type']), instance['id'])

            else:
                info("Can't reach IANA website; using regex for mime types.")
                mime_re = re.compile(r'^(application|audio|font|image|message|model'
                                     '|multipart|text|video)/[a-zA-Z0-9.+_-]+')
                if not mime_re.match(obj['mime_type']):
                    yield JSONError("The 'mime_type' property of object '%s' "
                                    "('%s') should be an IANA MIME Type of the"
                                    " form 'type/subtype'."
                                    % (key, obj['mime_type']), instance['id'])
1168310
public Metadata createMetadata(String typeName, Metadata metadata) {
        String scope = Metadata.scopeBasedOnType(typeName);
        return this.createMetadata(typeName, scope, metadata);
    }
1188513
protected void generateRecordingMetadataFile(Recording recording) {
		String folder = this.openviduConfig.getOpenViduRecordingPath() + recording.getId();
		boolean newFolderCreated = this.fileWriter.createFolderIfNotExists(folder);

		if (newFolderCreated) {
			log.info(
					"New folder {} created. This means the recording started for a session with no publishers or no media type compatible publishers",
					folder);
		} else {
			log.info("Folder {} already existed. Some publisher is already being recorded", folder);
		}

		String filePath = this.openviduConfig.getOpenViduRecordingPath() + recording.getId() + "/"
				+ RecordingManager.RECORDING_ENTITY_FILE + recording.getId();
		String text = recording.toJson().toString();
		this.fileWriter.createAndWriteFile(filePath, text);
		log.info("Generated recording metadata file at {}", filePath);
	}
654249
@Override
    public JSONObject toJSONObject()
    {
        final JSONObject object = new JSONObject();

        object.put("type", new JSONString(getNodeType().getValue()));

        if (hasMetaData())
        {
            final MetaData meta = getMetaData();

            if (false == meta.isEmpty())
            {
                object.put("meta", new JSONObject(meta.getJSO()));
            }
        }
        object.put("attributes", new JSONObject(getAttributes().getJSO()));

        final NFastArrayList<IPrimitive<?>> list = getChildNodes();

        final JSONArray children = new JSONArray();

        if (null != list)
        {
            final int size = list.size();

            for (int i = 0; i < size; i++)
            {
                final IPrimitive<?> prim = list.get(i);

                if (null != prim)
                {
                    final JSONObject make = prim.toJSONObject();

                    if (null != make)
                    {
                        children.set(children.size(), make);
                    }
                }
            }
        }
        object.put("children", children);

        object.put("storage", getStorageEngine().toJSONObject());

        return object;
    }
1053877
public ResponseBuilder initialize(final Resource resource) {

        if (MISSING_RESOURCE.equals(resource)) {
            throw new NotFoundException();
        } else if (DELETED_RESOURCE.equals(resource)) {
            throw new ClientErrorException(GONE);
        }

        LOGGER.debug("Acceptable media types: {}", getRequest().getAcceptableMediaTypes());

        this.syntax = getSyntax(getServices().getIOService(),
            getRequest().getAcceptableMediaTypes(), resource.getBinaryMetadata()
                .filter(b -> !DESCRIPTION.equals(getRequest().getExt()))
                .map(b -> b.getMimeType().orElse(APPLICATION_OCTET_STREAM)).orElse(null));

        if (ACL.equals(getRequest().getExt()) && !resource.hasAcl()) {
            throw new NotFoundException();
        }

        setResource(resource);
        return ok();
    }
859323
def media(request):
    """"""
    return {
        'PAGES_MEDIA_URL': settings.PAGES_MEDIA_URL,
        'PAGES_STATIC_URL': settings.PAGES_STATIC_URL,
        'PAGE_USE_SITE_ID': settings.PAGE_USE_SITE_ID,
        'PAGE_HIDE_SITES': settings.PAGE_HIDE_SITES,
        'PAGE_LANGUAGES': settings.PAGE_LANGUAGES,
    }
1361358
def metadata_index_json(self):
        """"""
        try:
            return op.join(self.metadata_dir, 'INDEX.json')
        except FileNotFoundError:
            return op.join(self.metadata_dir, 'INDEX_JSON')