1 package org
.argeo
.publishing
.ui
;
3 import static org
.argeo
.suite
.ui
.SuiteApp
.DEFAULT_THEME_ID_PROPERTY
;
4 import static org
.argeo
.suite
.ui
.SuiteApp
.DEFAULT_UI_NAME_PROPERTY
;
6 import java
.util
.HashSet
;
10 import javax
.jcr
.Node
;
11 import javax
.jcr
.Session
;
13 import org
.apache
.commons
.logging
.Log
;
14 import org
.apache
.commons
.logging
.LogFactory
;
15 import org
.argeo
.cms
.ui
.AbstractCmsApp
;
16 import org
.argeo
.cms
.ui
.CmsApp
;
17 import org
.argeo
.cms
.ui
.CmsUiProvider
;
18 import org
.argeo
.docbook
.ui
.DocumentPage
;
19 import org
.argeo
.jcr
.Jcr
;
20 import org
.argeo
.suite
.ui
.SuiteApp
;
21 import org
.argeo
.util
.LangUtils
;
22 import org
.eclipse
.swt
.layout
.GridLayout
;
23 import org
.eclipse
.swt
.widgets
.Composite
;
24 import org
.eclipse
.swt
.widgets
.Control
;
25 import org
.osgi
.framework
.Constants
;
26 import org
.osgi
.service
.event
.Event
;
27 import org
.osgi
.service
.event
.EventHandler
;
30 * A {@link CmsApp} dedicated to publishing, typically a public or internal web
33 public class PublishingApp
extends AbstractCmsApp
implements EventHandler
{
34 private final static Log log
= LogFactory
.getLog(PublishingApp
.class);
37 private String defaultThemeId
;
38 private String defaultUiName
= "";
40 private String publicBasePath
= null;
42 private CmsUiProvider landingPage
;
43 private CmsUiProvider defaultProvider
= new DocumentUiProvider();
45 public void init(Map
<String
, String
> properties
) {
46 if (properties
.containsKey(DEFAULT_UI_NAME_PROPERTY
))
47 defaultUiName
= LangUtils
.get(properties
, DEFAULT_UI_NAME_PROPERTY
);
48 if (properties
.containsKey(DEFAULT_THEME_ID_PROPERTY
))
49 defaultThemeId
= LangUtils
.get(properties
, DEFAULT_THEME_ID_PROPERTY
);
50 publicBasePath
= LangUtils
.get(properties
, SuiteApp
.PUBLIC_BASE_PATH_PROPERTY
);
51 pid
= properties
.get(Constants
.SERVICE_PID
);
53 if (log
.isDebugEnabled())
54 log
.info("Publishing App " + pid
+ " started");
57 public void destroy(Map
<String
, String
> properties
) {
58 if (log
.isDebugEnabled())
59 log
.info("Publishing App " + pid
+ " stopped");
64 public Set
<String
> getUiNames() {
65 Set
<String
> uiNames
= new HashSet
<>();
66 uiNames
.add(defaultUiName
);
71 public Composite
initUi(Composite parent
) {
72 // Session adminSession = NodeUtils.openDataAdminSession(getRepository(), null);
73 Session session
= Jcr
.login(getRepository(), null);
74 parent
.setLayout(new GridLayout());
75 Node indexNode
= Jcr
.getNode(session
, publicBasePath
+ "/index");
77 // indexNode = JcrUtils.getOrAdd(Jcr.getRootNode(adminSession), DocumentPage.WWW, DbkType.article.get());
78 // adminSession.save();
79 // } catch (RepositoryException e) {
80 // throw new IllegalStateException(e);
84 if (landingPage
!= null) {
85 page
= landingPage
.createUiPart(parent
, indexNode
);
87 page
= defaultProvider
.createUiPart(parent
, indexNode
);
89 return (Composite
) page
;
93 public void refreshUi(Composite parent
, String state
) {
94 parent
.setLayout(new GridLayout());
95 if (landingPage
!= null)
96 landingPage
.createUiPart(parent
, null);
98 defaultProvider
.createUiPart(parent
, null);
102 public void setState(Composite parent
, String state
) {
107 protected String
getThemeId(String uiName
) {
108 return defaultThemeId
;
111 public void setLandingPage(CmsUiProvider landingPage
) {
112 this.landingPage
= landingPage
;
116 public void handleEvent(Event event
) {
117 // TODO listen to some events