/** @see org.displaytag.util.RequestHelper#getHref() */ public Href getHref() { String requestURI = this.request.getRequestURI(); // call encodeURL to preserve session id when cookies are disabled Href href = new DefaultHref(this.response.encodeURL(requestURI)); href.setParameterMap(getParameterMap()); return href; }
/** * @param meta * @param attributesSet set of lowercase attribute names to include in response * @param attributeExpandsSet set of lowercase attribute names to expand in response */ public EntityMetaDataResponse( EntityMetaData meta, Set<String> attributesSet, Map<String, Set<String>> attributeExpandsSet, MolgenisPermissionService permissionService, DataService dataService) { String name = meta.getName(); this.href = Href.concatMetaEntityHref(RestController.BASE_URI, name); this.hrefCollection = String.format("%s/%s", RestController.BASE_URI, name); // FIXME apply Href escaping fix if (attributesSet == null || attributesSet.contains("name".toLowerCase())) { this.name = name; } else this.name = null; if (attributesSet == null || attributesSet.contains("description".toLowerCase())) { this.description = meta.getDescription(); } else this.description = null; if (attributesSet == null || attributesSet.contains("label".toLowerCase())) { label = meta.getLabel(); } else this.label = null; if (attributesSet == null || attributesSet.contains("attributes".toLowerCase())) { this.attributes = new LinkedHashMap<String, Object>(); for (AttributeMetaData attr : meta.getAttributes()) { if (!attr.getName().equals("__Type")) { if (attributeExpandsSet != null && attributeExpandsSet.containsKey("attributes".toLowerCase())) { Set<String> subAttributesSet = attributeExpandsSet.get("attributes".toLowerCase()); this.attributes.put( attr.getName(), new AttributeMetaDataResponse( name, attr, subAttributesSet, Collections.singletonMap( "refEntity".toLowerCase(), Sets.newHashSet("idattribute")), permissionService, dataService)); } else { String attrHref = Href.concatMetaAttributeHref(RestController.BASE_URI, name, attr.getName()); this.attributes.put(attr.getName(), Collections.singletonMap("href", attrHref)); } } } } else this.attributes = null; if (attributesSet == null || attributesSet.contains("labelAttribute".toLowerCase())) { AttributeMetaData labelAttribute = meta.getLabelAttribute(); this.labelAttribute = labelAttribute != null ? labelAttribute.getName() : null; } else this.labelAttribute = null; if (attributesSet == null || attributesSet.contains("idAttribute".toLowerCase())) { AttributeMetaData idAttribute = meta.getIdAttribute(); this.idAttribute = idAttribute != null ? idAttribute.getName() : null; } else this.idAttribute = null; if (attributesSet == null || attributesSet.contains("lookupAttributes".toLowerCase())) { Iterable<AttributeMetaData> lookupAttributes = meta.getLookupAttributes(); this.lookupAttributes = lookupAttributes != null ? Lists.newArrayList( Iterables.transform( lookupAttributes, new Function<AttributeMetaData, String>() { @Override public String apply(AttributeMetaData attribute) { return attribute.getName(); } })) : null; } else this.lookupAttributes = null; if (attributesSet == null || attributesSet.contains("abstract".toLowerCase())) { isAbstract = meta.isAbstract(); } else this.isAbstract = null; this.writable = permissionService.hasPermissionOnEntity(name, Permission.WRITE) && dataService.getCapabilities(name).contains(RepositoryCapability.WRITABLE); }