private JcrPath getJcrPath() { if (parameterName == null) { return null; } final HstComponentWindow window = (HstComponentWindow) pageContext.getRequest().getAttribute(HST_COMPONENT_WINDOW); final HstComponent component = window.getComponent(); final ComponentConfiguration componentConfig = component.getComponentConfiguration(); final ParametersInfo paramsInfo = ParametersInfoAnnotationUtils.getParametersInfoAnnotation(component, componentConfig); return ParameterUtils.getParameterAnnotation(paramsInfo, parameterName, JcrPath.class); }
/** * Returns the {@link Map} of annotated parameter name as key and annotated default value as value. Parameters with * empty default value are also represented in the returned map. * * @param componentItemNode the current container item componentItemNode * @return the Map of all {@link Parameter} names and their default value */ public static Map<String, String> getAnnotatedDefaultValues(final Node componentItemNode) throws RepositoryException, IllegalArgumentException { ParametersInfo parametersInfo = ParametersInfoAnnotationUtils.getParametersInfoAnnotation(componentItemNode); if (parametersInfo != null) { Class<?> classType = parametersInfo.type(); if (classType == null) { return Collections.emptyMap(); } Map<String, String> result = new HashMap<String, String>(); for (Method method : classType.getMethods()) { if (method.isAnnotationPresent(Parameter.class)) { Parameter annotation = method.getAnnotation(Parameter.class); result.put(annotation.name(), annotation.defaultValue()); } } return result; } return Collections.emptyMap(); } }
/** * Constructs a component node wrapper * * @param componentItemNode JcrNode for a component. * @param locale the locale to get localized names, can be null * @param prefix the parameter prefix * @throws RepositoryException Thrown if the repository exception occurred during reading of the properties. * @throws ClassNotFoundException thrown when this class can't instantiate the component class. */ private ContainerItemComponentRepresentation represent(final Node componentItemNode, final Locale locale, final String prefix) throws RepositoryException, ClassNotFoundException { final String contentPath = getContentPath(); ParametersInfo parametersInfo = ParametersInfoAnnotationUtils.getParametersInfoAnnotation(componentItemNode); if (parametersInfo == null) { parametersInfo = defaultMissingParametersInfo; } List<ContainerItemComponentPropertyRepresentation> properties = getPopulatedProperties(parametersInfo, locale, contentPath, prefix, componentItemNode, containerItemHelper, propertyPresentationFactories); ContainerItemComponentRepresentation representation = new ContainerItemComponentRepresentation(); representation.setProperties(properties); return representation; }
ParametersInfo info = ParametersInfoAnnotationUtils.getParametersInfoAnnotation(item);