Bert Leunis pushed to branch feature/ESSENTIALS-1038 at cms-community / 
hippo-essentials


Commits:
e55c2c57 by Bert Leunis at 2017-01-23T14:30:49+01:00
ESSENTIALS-1038 deprecated the static method

- - - - -


3 changed files:

- 
components/hst/src/main/java/org/onehippo/cms7/essentials/components/CommonComponent.java
- 
components/hst/src/main/java/org/onehippo/cms7/essentials/components/EssentialsBlogAuthorPostsComponent.java
- 
components/hst/src/main/java/org/onehippo/cms7/essentials/components/EssentialsListComponent.java


Changes:

=====================================
components/hst/src/main/java/org/onehippo/cms7/essentials/components/CommonComponent.java
=====================================
--- 
a/components/hst/src/main/java/org/onehippo/cms7/essentials/components/CommonComponent.java
+++ 
b/components/hst/src/main/java/org/onehippo/cms7/essentials/components/CommonComponent.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014-2015 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2014-2017 Hippo B.V. (http://www.onehippo.com)
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -224,6 +224,7 @@ public abstract class CommonComponent extends 
BaseHstComponent {
      *
      * @param path document (or folder) path relative to site-root
      * @return bean identified by path. Site root bean if path empty or no 
corresponding bean.
+     * @deprecated use the non-static goGetScopeBean instead.
      */
     public static HippoBean getScopeBean(final String path) {
         final HstRequestContext context = RequestContextProvider.get();
@@ -241,8 +242,26 @@ public abstract class CommonComponent extends 
BaseHstComponent {
         return siteBean;
     }
 
+    /**
+     * Find HippoBean for given path. If path is null or empty, site root bean 
will be returned.
+     *
+     * @param path document (or folder) path relative to site-root.
+     * @return bean identified by path. Site root bean if path empty or no 
corresponding bean.
+     */
     public HippoBean doGetScopeBean(final String path) {
-        return getScopeBean(path);
+        final HstRequestContext context = RequestContextProvider.get();
+        final HippoBean siteBean = context.getSiteContentBaseBean();
+
+        if (!Strings.isNullOrEmpty(path)) {
+            final String myPath = PathUtils.normalizePath(path);
+            log.debug("Looking for bean {}", myPath);
+            HippoBean scope = siteBean.getBean(myPath);
+            if (scope != null) {
+                return scope;
+            }
+            log.warn("Bean was null for selected path:  {}", myPath);
+        }
+        return siteBean;
     }
 
     public int getAnyIntParameter(HstRequest request, String parameter, int 
defaultValue) {


=====================================
components/hst/src/main/java/org/onehippo/cms7/essentials/components/EssentialsBlogAuthorPostsComponent.java
=====================================
--- 
a/components/hst/src/main/java/org/onehippo/cms7/essentials/components/EssentialsBlogAuthorPostsComponent.java
+++ 
b/components/hst/src/main/java/org/onehippo/cms7/essentials/components/EssentialsBlogAuthorPostsComponent.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014-2015 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2014-2017 Hippo B.V. (http://www.onehippo.com)
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.


=====================================
components/hst/src/main/java/org/onehippo/cms7/essentials/components/EssentialsListComponent.java
=====================================
--- 
a/components/hst/src/main/java/org/onehippo/cms7/essentials/components/EssentialsListComponent.java
+++ 
b/components/hst/src/main/java/org/onehippo/cms7/essentials/components/EssentialsListComponent.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014-2015 Hippo B.V. (http://www.onehippo.com)
+ * Copyright 2014-2017 Hippo B.V. (http://www.onehippo.com)
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-essentials/commit/e55c2c5770786d27de977febf56101c8ac70fa0b
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to