Adds encryption metadata to the StorageObjectMetadata object
8421
@Override
  public void addEncryptionMetadata(StorageObjectMetadata meta,
                                    MatDesc matDesc,
                                    byte[] ivData,
                                    byte[] encKeK,
                                    long contentLength)
  {
    meta.addUserMetadata(getMatdescKey(),
                         matDesc.toString());
    meta.addUserMetadata(AZ_ENCRYPTIONDATAPROP, buildEncryptionMetadataJSON(
        Base64.encodeAsString(ivData),
        Base64.encodeAsString(encKeK))
    );
    meta.setContentLength(contentLength);
  }
1180815
public function setMetadata(\AgentSIB\Diadoc\Api\Proto\Events\EncryptedDocumentMetadata $value)
    {
        $this->Metadata = $value;
    }
327082
public static void populateMetadata(AbstractComputeInstanceMetadata instanceMetadata, Map<?, ?> metadata) {
        if (metadata != null) {
            Map<String, String> finalMetadata = new HashMap<>(metadata.size());
            for (Map.Entry<?, ?> entry : metadata.entrySet()) {
                Object key = entry.getKey();
                Object value = entry.getValue();
                if (value instanceof String) {
                    finalMetadata.put(key.toString(), value.toString());
                }
            }
            instanceMetadata.setMetadata(finalMetadata);
        }
    }
711404
@Override
    public PutObjectResult putObjectSecurely(PutObjectRequest req) {
        // TODO: consider cloning req before proceeding further to reduce side
        // effects
        appendUserAgent(req, USER_AGENT);
        return cryptoConfig.getStorageMode() == InstructionFile
               ? putObjectUsingInstructionFile(req)
               : putObjectUsingMetadata(req);
    }
542263
public void setAccessKeyMetadata(java.util.Collection<AccessKeyMetadata> accessKeyMetadata) {
        if (accessKeyMetadata == null) {
            this.accessKeyMetadata = null;
            return;
        }

        this.accessKeyMetadata = new com.amazonaws.internal.SdkInternalList<AccessKeyMetadata>(accessKeyMetadata);
    }
897832
@NonNull
    public SourceParams setMetaData(@NonNull Map<String, String> metaData) {
        mMetaData = metaData;
        return this;
    }
749123
private static ObjectMetadata getObjectMetadataForKey(Key k) {
    String[] bk = decodeKey(k);
    assert (bk.length == 2);
    return getClient().getObjectMetadata(bk[0], bk[1]);
  }
233675
def add_metadata_to_archive(self, metadata, meta_path):
        '''
        
        '''
        archive_path = self.get_full_archive_path(meta_path.lstrip('/'))
        write_data_to_file(metadata, archive_path)
194369
private static Object deepCopyUsingMetadata(Object source, Map<Object, Object> copiedObjectMap,
            final KunderaMetadata kunderaMetadata)
    {
        Object target = null;
        try
        {
            if (source == null)
            {
                return null;
            }
            Class<?> sourceObjectClass = source.getClass();
            EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, sourceObjectClass);
            if (metadata == null)
            {
                return source;
            }

            MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                    metadata.getPersistenceUnit());

            EntityType entityType = metaModel.entity(sourceObjectClass);

            // May break for mapped super class.

            Object id = null;
            if (metadata.getRelations() != null && !metadata.getRelations().isEmpty())
            {

                id = PropertyAccessorHelper.getId(source, metadata);

                StringBuilder keyBuilder = new StringBuilder(sourceObjectClass.getName());
                keyBuilder.append("#");
                keyBuilder.append(id);
                Object copiedObjectInMap = copiedObjectMap.get(keyBuilder.toString());
                if (copiedObjectInMap != null)
                {
                    return copiedObjectInMap;
                }
            }
            // Copy Columns (in a table that doesn't have any embedded objects

            target = KunderaCoreUtils.createNewInstance(sourceObjectClass);

            Iterator<Attribute> iter = entityType.getAttributes().iterator();
            while (iter.hasNext())
            {
                Attribute attrib = iter.next();

                Field columnField = (Field) attrib.getJavaMember();
                if (attrib.getPersistentAttributeType().equals(PersistentAttributeType.EMBEDDED)
                        || attrib.getPersistentAttributeType().equals(PersistentAttributeType.ELEMENT_COLLECTION))
                {
                    EmbeddableType embeddedColumn = metaModel.embeddable(((AbstractAttribute) attrib)
                            .getBindableJavaType());

                    Object sourceEmbeddedObj = PropertyAccessorHelper.getObject(source, columnField);
                    if (sourceEmbeddedObj != null)
                    {
                        if (metaModel.isEmbeddable(((AbstractAttribute) attrib).getBindableJavaType()))
                        {
                            if (attrib.isCollection())
                            {
                                Class<?> ecDeclaredClass = columnField.getType();
                                Class<?> actualEcObjectClass = sourceEmbeddedObj.getClass();

                                Object targetCollectionObject = actualEcObjectClass.newInstance();

                                // Copy element collections for List and Set
                                if (sourceEmbeddedObj instanceof Collection)
                                {
                                    Class<?> genericClass = PropertyAccessorHelper.getGenericClass(columnField);

                                    for (Object sourceEcObj : (Collection) sourceEmbeddedObj)
                                    {
                                        Object targetEcObj = null;
                                        if (sourceEcObj != null
                                                && PersistenceType.BASIC.equals(embeddedColumn.getPersistenceType()))
                                        {
                                            PropertyAccessor accessor = PropertyAccessorFactory
                                                    .getPropertyAccessor(sourceEcObj.getClass());
                                            if (accessor != null)
                                            {
                                                targetEcObj = accessor.getCopy(sourceEcObj);
                                            }
                                        }
                                        else if (sourceEcObj != null
                                                && PersistenceType.EMBEDDABLE.equals(embeddedColumn
                                                        .getPersistenceType()))
                                        {
                                            targetEcObj = genericClass.newInstance();

                                            for (Field f : genericClass.getDeclaredFields())
                                            {
                                                if (f != null && !Modifier.isStatic(f.getModifiers()))
                                                {
                                                    PropertyAccessorHelper.set(targetEcObj, f,
                                                            PropertyAccessorHelper.getObjectCopy(sourceEcObj, f));
                                                }
                                            }
                                        }
                                        if (List.class.isAssignableFrom(ecDeclaredClass))
                                        {
                                            Method m = actualEcObjectClass.getMethod("add", Object.class);
                                            m.invoke(targetCollectionObject, targetEcObj);

                                        }
                                        else if (Set.class.isAssignableFrom(ecDeclaredClass))
                                        {
                                            Method m = actualEcObjectClass.getMethod("add", Object.class);
                                            m.invoke(targetCollectionObject, targetEcObj);
                                        }
                                    }
                                }

                                // Copy element collection for Map
                                else if (sourceEmbeddedObj instanceof Map)
                                {
                                    for (Object sourceKey : ((Map) sourceEmbeddedObj).keySet())
                                    {
                                        Object targetKey = null;
                                        Object targetValue = null;
                                        if (PersistenceType.BASIC.equals(embeddedColumn.getPersistenceType())
                                                || PersistenceType.EMBEDDABLE.equals(embeddedColumn
                                                        .getPersistenceType()))
                                        {
                                            // Create copy of map key
                                            if (sourceKey != null)
                                            {
                                                PropertyAccessor keyAccessor = PropertyAccessorFactory
                                                        .getPropertyAccessor(sourceKey.getClass());
                                                if (keyAccessor != null)
                                                {
                                                    targetKey = keyAccessor.getCopy(sourceKey);
                                                }
                                            }
                                            else
                                            {
                                                targetKey = null;
                                            }

                                            // Create copy of map value
                                            Object sourceValue = ((Map) sourceEmbeddedObj).get(sourceKey);
                                            if (sourceValue != null)
                                            {
                                                PropertyAccessor valueAccessor = PropertyAccessorFactory
                                                        .getPropertyAccessor(sourceValue.getClass());
                                                if (valueAccessor != null)
                                                {
                                                    targetValue = valueAccessor.getCopy(sourceValue);
                                                }
                                            }
                                            else
                                            {
                                                targetValue = null;
                                            }

                                            if (Map.class.isAssignableFrom(ecDeclaredClass))
                                            {
                                                Method m = actualEcObjectClass.getMethod("put", new Class[] {
                                                        Object.class, Object.class });
                                                m.invoke(targetCollectionObject,
                                                        new Object[] { targetKey, targetValue });
                                            }
                                        }
                                    }
                                }
                                PropertyAccessorHelper.set(target, columnField, targetCollectionObject);
                            }
                            else
                            {
                                // Copy embedded objects
                                Class<?> embeddedColumnClass = columnField.getType();
                                Object targetEmbeddedObj = embeddedColumnClass.newInstance();

                                Set<Attribute> columns = embeddedColumn.getAttributes();
                                for (Attribute column : columns)
                                {
                                    PropertyAccessorHelper.set(
                                            targetEmbeddedObj,
                                            (Field) column.getJavaMember(),
                                            PropertyAccessorHelper.getObjectCopy(sourceEmbeddedObj,
                                                    (Field) column.getJavaMember()));
                                }

                                PropertyAccessorHelper.set(target, columnField, targetEmbeddedObj);
                            }
                        }
                        else if (((AbstractAttribute) attrib).getJPAColumnName() != null)
                        {
                            // Copy columns
                            PropertyAccessorHelper.set(target, columnField, sourceEmbeddedObj);
                        }
                    }

                }
                else if (attrib.getPersistentAttributeType().equals(PersistentAttributeType.BASIC))
                {

                    PropertyAccessorHelper.set(target, columnField,
                            PropertyAccessorHelper.getObjectCopy(source, columnField));
                }
            }

            // Put this object into copied object map
            if (id != null)
            {
                StringBuilder keyBuilder = new StringBuilder(sourceObjectClass.getName());
                keyBuilder.append("#");
                keyBuilder.append(id);
                copiedObjectMap.put(keyBuilder.toString(), target);
            }
            // Copy Relationships recursively
            for (Relation relation : metadata.getRelations())
            {
                if (relation != null)
                {
                    Field relationField = relation.getProperty();
                    Object sourceRelationObject = PropertyAccessorHelper.getObject(source, relationField);

                    if (sourceRelationObject != null)
                    {
                        if (sourceRelationObject instanceof KunderaProxy)
                        {
                            PropertyAccessorHelper.set(target, relationField, sourceRelationObject);
                            continue;
                        }
                        else if (ProxyHelper.isPersistentCollection(sourceRelationObject))
                        {
                            PropertyAccessorHelper.set(target, relationField, sourceRelationObject);
                            continue;
                        }
                        else if (ProxyHelper.isKunderaProxyCollection(sourceRelationObject))
                        {
                            ProxyCollection pc = ((ProxyCollection) sourceRelationObject).getCopy();
                            pc.setOwner(target);
                            PropertyAccessorHelper.set(target, relationField, pc);
                            continue;
                        }

                        Object targetRelationObject = null;

                        Class<?> relationObjectClass = relation.getProperty().getType();
                        Class<?> actualRelationObjectClass = sourceRelationObject.getClass();

                        if (Collection.class.isAssignableFrom(relationObjectClass))
                        {
                            targetRelationObject = actualRelationObjectClass.newInstance();
                            Method m = actualRelationObjectClass.getMethod("add", Object.class);

                            for (Object obj : (Collection) sourceRelationObject)
                            {
                                Object copyTargetRelObj = searchInCacheThenCopy(copiedObjectMap, obj, kunderaMetadata);
                                m.invoke(targetRelationObject, copyTargetRelObj);
                            }
                        }
                        else if (Map.class.isAssignableFrom(relationObjectClass))
                        {
                            targetRelationObject = actualRelationObjectClass.newInstance();
                            Method m = actualRelationObjectClass.getMethod("put", new Class<?>[] { Object.class,
                                    Object.class });

                            for (Object keyObj : ((Map) sourceRelationObject).keySet())
                            {
                                Object valObj = ((Map) sourceRelationObject).get(keyObj);

                                Object copyTargetKeyObj = searchInCacheThenCopy(copiedObjectMap, keyObj,
                                        kunderaMetadata);

                                Object copyTargetValueObj = searchInCacheThenCopy(copiedObjectMap, valObj,
                                        kunderaMetadata);

                                m.invoke(targetRelationObject, new Object[] { copyTargetKeyObj, copyTargetValueObj });
                            }
                        }
                        else
                        {
                            targetRelationObject = searchInCacheThenCopy(copiedObjectMap, sourceRelationObject,
                                    kunderaMetadata);
                        }
                        PropertyAccessorHelper.set(target, relationField, targetRelationObject);
                    }
                }
            }
        }
        catch (InstantiationException e)
        {
            log.warn("Error while instantiating entity/ embeddable class, did you define no-arg constructor?, Caused by:"
                    + e.getMessage());
            return null;
        }
        catch (Exception e)
        {
            log.warn("Returning null as error during clone, Caused by:" + e.getMessage());
            return null;
        }

        return target;
    }
104148
def generate_metadata(self):
        # type: (Descriptor) -> dict
        
        genmeta = {}
        encmeta = {}
        # page align md5
        if (self.must_compute_md5 and
                self._ase.mode == blobxfer.models.azure.StorageModes.Page):
            aligned = blobxfer.util.page_align_content_length(self._offset)
            diff = aligned - self._offset
            if diff > 0:
                with self._hasher_lock:
                    self.md5.update(b'\0' * diff)
        # generate encryption metadata
        if self._ase.is_encrypted:
            if self.must_compute_md5:
                md5digest = blobxfer.util.base64_encode_as_string(
                    self.md5.digest())
            else:
                md5digest = None
            if self.hmac is not None:
                hmacdigest = blobxfer.util.base64_encode_as_string(
                    self.hmac.digest())
            else:
                hmacdigest = None
            encmeta = self._ase.encryption_metadata.convert_to_json_with_mac(
                md5digest, hmacdigest)
        # generate file attribute metadata
        if self._store_file_attr and not self.local_path.use_stdin:
            merged = blobxfer.models.metadata.generate_fileattr_metadata(
                self.local_path, genmeta)
            if merged is not None:
                genmeta = merged
        # generate vectored io metadata
        if self.local_path.view.mode == VectoredIoDistributionMode.Stripe:
            merged = blobxfer.models.metadata.\
                generate_vectored_io_stripe_metadata(self.local_path, genmeta)
            if merged is not None:
                genmeta = merged
        if len(encmeta) > 0:
            metadata = encmeta
        else:
            metadata = {}
        if len(genmeta) > 0:
            metadata[blobxfer.models.metadata.JSON_KEY_BLOBXFER_METADATA] = \
                json.dumps(genmeta, ensure_ascii=False, sort_keys=True)
        if len(metadata) == 0:
            return None
        return metadata
779642
public void addMetadata(Metadata meta) {
    for (String k : meta.keySet()) {
      for (TiffObject to : meta.getList(k)) {
        add(k, to, meta.getMetadataObject(k).isDublinCore(), meta.getMetadataObject(k).getPath());
      }
    }
  }
469945
private ObjectMetadata createMetadata(int length) {
        ObjectMetadata metadata = new ObjectMetadata();
        metadata.setContentLength(length);
        if (aes256Encryption)
            metadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
        return metadata;
    }
908351
@Override
    public void endMetaData(MetaData metadata)
    {
        this.builder.addBlock(new MetaDataBlock(this.builder.endBlockList(), metadata));
    }
95933
def _setMetadata(self, text):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")

        return _fitz.Document__setMetadata(self, text)
440173
def _load_metadata(self):
        """"""
        if self._synchronizer is None:
            self._load_metadata_nosync()
        else:
            mkey = self._key_prefix + array_meta_key
            with self._synchronizer[mkey]:
                self._load_metadata_nosync()
660271
@Override
  public void addUserMetadata(String key, String value)
  {
    userDefinedMetadata.put(key, value);
  }
525903
def add_custom_metadata(self, key, value, meta_type=None):
        
        self.metadata.append({'key': key, 'value': value, 'type': meta_type})