@SuppressWarnings("unchecked") private Record decodeRecord(final GenericRecord generic, @Nullable final Set<URI> propertiesToDecode) { final Record record = Record.create(); final GenericRecord encodedID = (GenericRecord) generic.get(0); if (encodedID != null) { record.setID((URI) decodeIdentifier(encodedID)); } for (final GenericRecord prop : (Iterable<GenericRecord>) generic.get(1)) { final URI property = (URI) decodeIdentifier((GenericRecord) prop.get(0)); final List<Object> values = decodeNodes(prop.get(1)); if (propertiesToDecode == null || propertiesToDecode.contains(property)) { record.set(property, values); } } return record; }
private void preprocess(final Record record) throws Throwable { // Ignore ks:storedAs possibly supplied by clients, as it is computed with file upload if (KS.RESOURCE.equals(record.getSystemType())) { record.set(KS.STORED_AS, null); } // TODO: add here filtering logic to be applied to records coming from the client }
resource.set(KS.STORED_AS, null); } catch (final IllegalArgumentException ex) { metadata.set(NIE.MIME_TYPE, null); metadata.set(NFO.FILE_NAME, fileName); metadata.set(NIE.MIME_TYPE, fileType); hash.set(NFO.HASH_ALGORITHM, "MD5"); hash.set(NFO.HASH_VALUE, hos.hash().toString()); metadata.set(NFO.HAS_HASH, hash); metadata.set(NFO.FILE_SIZE, cos.getCount()); if (metadata.isNull(NFO.FILE_LAST_MODIFIED)) { metadata.set(NFO.FILE_LAST_MODIFIED, new Date()); resource.set(KS.STORED_AS, Record.create(metadata, true));
final Record record = Record.create(); for (final Map.Entry<String, ? extends Object> entry : properties.entrySet()) { record.set(Data.getValueFactory().createURI("java:" + entry.getKey()), entry.getValue());
final Record meta = representation.getMetadata(); meta.setID(metadata.getID()); meta.set(NIE.MIME_TYPE, transformToType); meta.set(NFO.FILE_NAME, name); meta.set(NFO.FILE_LAST_MODIFIED, metadata.getUnique(NFO.FILE_LAST_MODIFIED)); return representation; representation.getMetadata().setID(metadata.getID()); for (final URI property : metadata.getProperties()) { representation.getMetadata().set(property, metadata.get(property));