Woonsan Ko pushed to branch feature/spaplus at cms-community / 
hippo-site-toolkit


Commits:
33a93b5b by Woonsan Ko at 2018-03-12T16:05:58-04:00
HSTTWO-4265: restoring componentRendering valve and add copmonentRendering link 
in preview

- - - - -


3 changed files:

- api/src/main/java/org/hippoecm/hst/core/container/ContainerConstants.java
- 
components/core/src/main/java/org/hippoecm/hst/core/pagemodel/container/PageModelAggregationValve.java
- 
components/core/src/main/resources/org/hippoecm/hst/site/container/SpringComponentManager-pagemodel.xml


Changes:

=====================================
api/src/main/java/org/hippoecm/hst/core/container/ContainerConstants.java
=====================================
--- a/api/src/main/java/org/hippoecm/hst/core/container/ContainerConstants.java
+++ b/api/src/main/java/org/hippoecm/hst/core/container/ContainerConstants.java
@@ -188,4 +188,9 @@ public interface ContainerConstants {
      */
     String LINK_NAME_SITE = "site";
 
+    /**
+     * Generic Link Name for the component rendering.
+     */
+    String LINK_NAME_COMPONENT_RENDERING = "componentRendering";
+
 }


=====================================
components/core/src/main/java/org/hippoecm/hst/core/pagemodel/container/PageModelAggregationValve.java
=====================================
--- 
a/components/core/src/main/java/org/hippoecm/hst/core/pagemodel/container/PageModelAggregationValve.java
+++ 
b/components/core/src/main/java/org/hippoecm/hst/core/pagemodel/container/PageModelAggregationValve.java
@@ -30,6 +30,7 @@ import org.hippoecm.hst.container.RequestContextProvider;
 import org.hippoecm.hst.content.beans.standard.HippoBean;
 import org.hippoecm.hst.core.component.HstRequest;
 import org.hippoecm.hst.core.component.HstResponse;
+import org.hippoecm.hst.core.component.HstURL;
 import org.hippoecm.hst.core.container.AggregationValve;
 import org.hippoecm.hst.core.container.ContainerConstants;
 import org.hippoecm.hst.core.container.ContainerException;
@@ -192,6 +193,8 @@ public class PageModelAggregationValve extends 
AggregationValve {
     protected AggregatedPageModel createAggregatedPageModel(final 
HstComponentWindow[] sortedComponentWindows,
             final Map<HstComponentWindow, HstRequest> requestMap,
             final Map<HstComponentWindow, HstResponse> responseMap) throws 
ContainerException {
+        final HstRequestContext requestContext = RequestContextProvider.get();
+        final boolean isPreviewOrCmsRequest = requestContext.isPreview() || 
requestContext.isCmsRequest();
 
         // root component (page component) is the first item in the 
sortedComponentWindows.
         final HstComponentWindow rootWindow = sortedComponentWindows[0];
@@ -218,6 +221,9 @@ public class PageModelAggregationValve extends 
AggregationValve {
                 curContainerWindowModel = new 
ComponentContainerWindowModel(window.getReferenceNamespace(),
                         window.getName());
                 addParameterMapMetadata(window, curContainerWindowModel);
+                if (isPreviewOrCmsRequest) {
+                    addComponentRenderingURLLink(hstResponse, 
curContainerWindowModel);
+                }
                 decorateComponentWindowMetadata(hstRequest, hstResponse, 
curContainerWindowModel);
                 pageModel.addContainerWindow(curContainerWindowModel);
             } else if (window.getComponentInfo().isContainerItem()) {
@@ -231,6 +237,9 @@ public class PageModelAggregationValve extends 
AggregationValve {
                         window.getReferenceNamespace(), window.getName(), 
window.getComponentName());
                 
componentWindowModel.setLabel(window.getComponentInfo().getLabel());
                 addParameterMapMetadata(window, componentWindowModel);
+                if (isPreviewOrCmsRequest) {
+                    addComponentRenderingURLLink(hstResponse, 
curContainerWindowModel);
+                }
                 decorateComponentWindowMetadata(hstRequest, hstResponse, 
componentWindowModel);
                 
curContainerWindowModel.addComponentWindow(componentWindowModel);
             } else {
@@ -266,6 +275,17 @@ public class PageModelAggregationValve extends 
AggregationValve {
     }
 
     /**
+     * Adding componentRendering URL link to the linkable model.
+     * @param hstResponse HstResponse
+     * @param linkableModel linkable model
+     */
+    private void addComponentRenderingURLLink(HstResponse hstResponse,
+            IdentifiableLinkableMetadataBaseModel linkableModel) {
+        HstURL compRenderURL = hstResponse.createComponentRenderingURL();
+        
linkableModel.putLink(ContainerConstants.LINK_NAME_COMPONENT_RENDERING, 
compRenderURL.toString());
+    }
+
+    /**
      * Convert content representation identifier (e.g, handle ID or node ID) 
to a safe JSON property/variable name.
      * @param uuid content identifier
      * @return a safe JSON property/variable name converted from the handle ID 
or node ID


=====================================
components/core/src/main/resources/org/hippoecm/hst/site/container/SpringComponentManager-pagemodel.xml
=====================================
--- 
a/components/core/src/main/resources/org/hippoecm/hst/site/container/SpringComponentManager-pagemodel.xml
+++ 
b/components/core/src/main/resources/org/hippoecm/hst/site/container/SpringComponentManager-pagemodel.xml
@@ -81,6 +81,7 @@
         <ref bean="localizationValve" />
         <ref bean="pageInfoRenderingValve" />
         <ref bean="pageCachingValve"/>
+        <ref bean="componentRenderingValve" />
         <ref bean="pageModelAggregationValve" />
       </list>
     </property>



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-site-toolkit/commit/33a93b5b151847bf548cdb00e7627f83460f5061

---
View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-site-toolkit/commit/33a93b5b151847bf548cdb00e7627f83460f5061
You're receiving this email because of your account on code.onehippo.org.
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to