String first = slash == -1 ? path : path.substring(0, slash); for (Schema schema : schemaManager.getSchemas()) { if (!schema.getNamespace().hasPrefix()) {
if (path == null) { if (!schema.getNamespace().hasPrefix()) { fieldPath = schema.getName() + ":" + fieldPath;
protected void registerSchema(Schema schema) { schemas.put(schema.getName(), schema); Namespace ns = schema.getNamespace(); uriToSchema.put(ns.uri, schema); if (!StringUtils.isBlank(ns.prefix)) { prefixToSchema.put(ns.prefix, schema); } }
protected void writeSchemaObject(JsonGenerator jg, Schema schema) throws IOException { jg.writeStartObject(); jg.writeStringField("name", schema.getName()); jg.writeStringField("@prefix", schema.getNamespace().prefix); jg.writeObjectFieldStart("fields"); for (Field field : schema.getFields()) { writeField(jg, field); } jg.writeEndObject(); jg.writeEndObject(); }
@Override protected void writeEntityBody(Schema schema, JsonGenerator jg) throws IOException { jg.writeStringField("name", schema.getName()); String prefix = schema.getNamespace().prefix; if (StringUtils.isNotBlank(prefix)) { jg.writeStringField("prefix", prefix); // backward compat for old schema writers jg.writeStringField("@prefix", prefix); } jg.writeObjectFieldStart("fields"); for (Field field : schema.getFields()) { writeField(jg, field); } jg.writeEndObject(); }
String prefix = schema.getNamespace().prefix; if (prefix.isEmpty()) { for (Entry<String, ModelProperty> e : propertyInfoByPath.entrySet()) {
protected void writeSchema(JsonGenerator jg, Schema schema) throws IOException { jg.writeObjectFieldStart(schema.getName()); jg.writeStringField("@prefix", schema.getNamespace().prefix); for (Field field : schema.getFields()) { writeField(jg, field); } jg.writeEndObject(); }
protected Object getDataModelField(DocumentRef docRef, String schema, String field) { Document doc = resolveReference(docRef); if (doc != null) { checkPermission(doc, READ); Schema docSchema = doc.getType().getSchema(schema); if (docSchema != null) { String prefix = docSchema.getNamespace().prefix; if (prefix != null && prefix.length() > 0) { field = prefix + ':' + field; } return doc.getPropertyValue(field); } else { log.warn("Cannot find schema with name=" + schema); } } else { log.warn("Cannot resolve docRef=" + docRef); } return null; }
public void walkSchema(Schema schema) { String addPrefix = schema.getNamespace().hasPrefix() ? null : schema.getName(); walkComplexType(schema, null, addPrefix); }
String first = slash == -1 ? path : path.substring(0, slash); for (Schema schema : schemaManager.getSchemas()) { if (!schema.getNamespace().hasPrefix()) {
String first = slash == -1 ? path : path.substring(0, slash); for (Schema schema : schemaManager.getSchemas()) { if (!schema.getNamespace().hasPrefix()) {
private void writeSchemaProperties(JsonGenerator jg, DocumentModel doc, String schemaName) throws IOException { Writer<Property> propertyWriter = registry.getWriter(ctx, Property.class, APPLICATION_JSON_TYPE); // provides the current document to the property marshaller try (Closeable resource = ctx.wrap().with(ENTITY_TYPE, doc).open()) { Schema schema = schemaManager.getSchema(schemaName); String prefix = schema.getNamespace().prefix; if (prefix == null || prefix.length() == 0) { prefix = schemaName; } prefix = prefix + ":"; for (Field field : schema.getFields()) { String prefixedName = prefix + field.getName().getLocalName(); jg.writeFieldName(prefixedName); Property property = doc.getProperty(prefixedName); OutputStream out = new OutputStreamWithJsonWriter(jg); propertyWriter.write(property, Property.class, Property.class, APPLICATION_JSON_TYPE, out); } } }
for (Property prop : searchDocumentModel.getPropertyObjects(schema)) { if (prop.getValue() != null && !SKIPPED_SCHEMAS_FOR_SEARCHFIELD.contains(prop.getSchema().getNamespace().prefix)) { if (prop.isList()) { if (ArrayUtils.isNotEmpty(prop.getValue(Object[].class))) {
if (!StringUtils.isBlank(schema.getNamespace().prefix)) {
private void writeSchemaProperties(JsonGenerator jg, DocumentModel doc, String schemaName) throws IOException { Writer<Property> propertyWriter = registry.getWriter(ctx, Property.class, APPLICATION_JSON_TYPE); // provides the current document to the property marshaller try (Closeable resource = ctx.wrap().with(ENTITY_TYPE, doc).open()) { Schema schema = schemaManager.getSchema(schemaName); String prefix = schema.getNamespace().prefix; if (prefix == null || prefix.length() == 0) { prefix = schemaName; } prefix = prefix + ":"; for (Field field : schema.getFields()) { String prefixedName = prefix + field.getName().getLocalName(); jg.writeFieldName(prefixedName); Property property = doc.getProperty(prefixedName); OutputStream out = new OutputStreamWithJsonWriter(jg); propertyWriter.write(property, Property.class, Property.class, APPLICATION_JSON_TYPE, out); } } } }
protected static void writeProperties(JsonGenerator jg, DocumentModel doc, String schema, ServletRequest request) throws IOException { Collection<Property> properties = doc.getPropertyObjects(schema); if (properties.isEmpty()) { return; } SchemaManager schemaManager = Framework.getService(SchemaManager.class); String prefix = schemaManager.getSchema(schema).getNamespace().prefix; if (prefix == null || prefix.length() == 0) { prefix = schema; } JSONPropertyWriter writer = JSONPropertyWriter.create().writeNull(false).writeEmpty(false).prefix(prefix); if (request != null) { DownloadService downloadService = Framework.getService(DownloadService.class); String blobUrlPrefix = VirtualHostHelper.getBaseURL(request) + downloadService.getDownloadUrl(doc, null, null) + "/"; writer.filesBaseUrl(blobUrlPrefix); } for (Property p : properties) { writer.writeProperty(jg, p); } }
protected void readDocumentSchemas(Element element, DocumentModel doc, boolean inlineBlobs) throws IOException { SchemaManager schemaManager = Framework.getService(SchemaManager.class); String[] schemaNames = doc.getSchemas(); for (String schemaName : schemaNames) { Element schemaElement = element.addElement(ExportConstants.SCHEMA_TAG).addAttribute("name", schemaName); Schema schema = schemaManager.getSchema(schemaName); Namespace targetNs = schema.getNamespace(); // If namespace prefix is empty, use schema name if (StringUtils.isEmpty(targetNs.prefix)) { targetNs = new Namespace(targetNs.uri, schema.getName()); } schemaElement.addNamespace(targetNs.prefix, targetNs.uri); DataModel dataModel = doc.getDataModel(schemaName); for (Field field : schema.getFields()) { Object value = dataModel.getData(field.getName().getLocalName()); readProperty(schemaElement, targetNs, field, value, inlineBlobs); } } }