atom feed2 messages in net.java.dev.mirage.devdiffs for templating
FromSent OnAttachments
joshnaDec 11, 2007 2:10 am 
Prakash Reddy K. L. V.Dec 11, 2007 2:24 am 
Subject:diffs for templating
From:joshna (Josh@Sun.COM)
Date:Dec 11, 2007 2:10:06 am
List:net.java.dev.mirage.dev

Index: mirage-api/src/java/com/sun/portal/cms/mirage/model/custom/Template.java ===================================================================

--- mirage-api/src/java/com/sun/portal/cms/mirage/model/custom/Template.java (revision 83) +++ mirage-api/src/java/com/sun/portal/cms/mirage/model/custom/Template.java (working copy) @@ -120,6 +120,10 @@ public void setUuid(String uuid) { this.uuid = uuid; } + + public String getUuid(){ + return this.uuid; + }

public String getVersionNumber() { return versionNumber; Index: mirage-jcr-impl/src/java/com/sun/portal/cms/mirage/service/custom/impl/ContentTypeServiceImpl.java ===================================================================

--- mirage-jcr-impl/src/java/com/sun/portal/cms/mirage/service/custom/impl/ContentTypeServiceImpl.java (revision 83) +++ mirage-jcr-impl/src/java/com/sun/portal/cms/mirage/service/custom/impl/ContentTypeServiceImpl.java (working copy) @@ -50,6 +50,7 @@ import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.PathNotFoundException; +import javax.jcr.Property; import javax.jcr.RepositoryException; import javax.jcr.Session;

@@ -535,14 +536,27 @@ } else { String templateName = templateNode.getProperty(NodeNameConsts.TEMPLATE_NAME).getString(); String templateMarkup = templateNode.getProperty(NodeNameConsts.TEMPLATE_MARKUP).getString(); - template = new Template(templateNode.getUUID(), templateName, templateMarkup); + String createdBy = templateNode.getProperty(NodeNameConsts.CREATOR_NAME).getString(); + String lastModifiedBy = null; + if(templateNode.isModified()){ + Property lastUpdatedBy = templateNode.getProperty(NodeNameConsts.VERSION_CREATOR_NAME); + + if (lastUpdatedBy != null) { + lastModifiedBy = lastUpdatedBy.getString(); + } + } + String checkedOutBy = null; + if (templateNode.isCheckedOut()) { + checkedOutBy = templateNode.getProperty(NodeNameConsts.LOCK_OWNER).getString(); + } + template = new Template(templateNode.getUUID(), templateName, templateMarkup,new User(createdBy),new User(lastModifiedBy),templateNode.getBaseVersion().getName(),templateNode.isCheckedOut(),new User(checkedOutBy)); templates.add(template); } if (template.getUUID().equals(defaultTemplateUUID)) { contentType.setDefaultTemplate(template); } } - } catch (RepositoryException ex) { + } catch (Exception ex) {

Logger.getLogger(ContentTypeServiceImpl.class.getName()).log(Level.SEVERE, null, ex); throw new CMSException(ex); } Index: mirage-portlets/customContentDefinitions/pom.xml =================================================================== --- mirage-portlets/customContentDefinitions/pom.xml (revision 83) +++ mirage-portlets/customContentDefinitions/pom.xml (working copy) @@ -50,14 +50,14 @@ <groupId>com.sun.portal.cms</groupId> <artifactId>mirage-api</artifactId> <version>0.1</version> - <scope>provided</scope> + <scope>compile</scope> </dependency>

<dependency> <groupId>com.sun.portal.cms</groupId> <artifactId>mirage-jcr-impl</artifactId> <version>0.1</version> - <scope>provided</scope> + <scope>compile</scope> </dependency>

<dependency> Index: mirage-portlets/customContentDefinitions/src/conf/com/sun/portal/cms/portlet/ccd/resources/messages.properties ===================================================================

--- mirage-portlets/customContentDefinitions/src/conf/com/sun/portal/cms/portlet/ccd/resources/messages.properties (revision 83) +++ mirage-portlets/customContentDefinitions/src/conf/com/sun/portal/cms/portlet/ccd/resources/messages.properties (working copy) @@ -63,6 +63,13 @@

templateName=Template Name

+#listTemplates.jsp +createNewTemplate=Create new Template +templateNames=TemplateNames +templateListHeading=Template list for content type:

+#templateVersions.jsp +templateVersionListHeading=Version list for template: +lastModifiedBy=Last ModifiedBy

Index: mirage-portlets/customContentDefinitions/src/java/com/sun/portal/cms/portlet/ccd/beans/ContentCreationBean.java ===================================================================

--- mirage-portlets/customContentDefinitions/src/java/com/sun/portal/cms/portlet/ccd/beans/ContentCreationBean.java (revision 83) +++ mirage-portlets/customContentDefinitions/src/java/com/sun/portal/cms/portlet/ccd/beans/ContentCreationBean.java (working copy) @@ -302,6 +302,7 @@ return "editDoc"; }

+ public boolean isVersionButtonsDisplayed(){ boolean result = false; if(currentContentType.isVersionable()){ Index: mirage-portlets/customContentDefinitions/src/java/com/sun/portal/cms/portlet/ccd/beans/ContentTypeBean.java ===================================================================

--- mirage-portlets/customContentDefinitions/src/java/com/sun/portal/cms/portlet/ccd/beans/ContentTypeBean.java (revision 83) +++ mirage-portlets/customContentDefinitions/src/java/com/sun/portal/cms/portlet/ccd/beans/ContentTypeBean.java (working copy) @@ -444,7 +444,8 @@ contentTypeService.createContentType(contentType); resetFields(); contentTypes = contentTypeService.getAvailableContentTypes(user); - FacesUtil.setSessionAttribute(Constants.CREATED_CONTENT_TYPE,contentType); + contentTypeName=contentType.getContentTypeName(); + FacesUtil.setPortletSessionAttribute(Constants.CREATED_CONTENT_TYPE,contentType); } catch (Exception e) { e.printStackTrace(); result = "docTypeCreationFailed"; Index: mirage-portlets/customContentDefinitions/src/java/com/sun/portal/cms/portlet/ccd/beans/TemplateBean.java ===================================================================

--- mirage-portlets/customContentDefinitions/src/java/com/sun/portal/cms/portlet/ccd/beans/TemplateBean.java (revision 83) +++ mirage-portlets/customContentDefinitions/src/java/com/sun/portal/cms/portlet/ccd/beans/TemplateBean.java (working copy) @@ -22,7 +22,7 @@ * * Copyright 2006 Sun Microsystems Inc. All Rights Reserved * CDDL HEADER END -*/ + */

@@ -46,106 +46,300 @@ * @author admin */ public class TemplateBean { - + private Session jcrSession; - + private String templateName; - + private String templateMarkup;

- private String templateUuid; - + private String templateSelected; + + private boolean editMode; + private int firstRowIndex = 0; - + private int noOfRows = 5; - + private String contentTypeName; - + private String username; - + private ContentTypeService contentTypeService; - + private ContentType currentContentType; - + private Template currentTemplate; - + private List<Template> templates; - + + private List<Template> templateVersions; + private User user; - + /** Creates a new instance of TemplateBean */ public TemplateBean()throws Exception { PortletSession pSession = FacesUtil.getSession(); jcrSession = SessionProvider.getJCRSession(pSession); contentTypeService = new ContentTypeServiceImpl(jcrSession); - currentContentType=(ContentType)pSession.getAttribute(Constants.CREATED_CONTENT_TYPE,PortletSession.APPLICATION_SCOPE); user = new User(FacesUtil.getLoggedUserName()); } - + public void setCurrentContentType(ContentType currentContentType){ this.currentContentType=currentContentType; } - + public ContentType getCurrentContentType(){ return this.currentContentType; } - + + public void setCurrentTemplate(Template currentTemplate){ + this.currentTemplate=currentTemplate; + } + + public Template getCurrentTemplate(){ + return this.currentTemplate; + } public void setTemplateName(String templateName){ this.templateName=templateName; } - + public String getTemplateName(){ return this.templateName; } - + public void setTemplateMarkup(String templateMarkup){ this.templateMarkup=templateMarkup; } - + public String getTemplateMarkup(){ return this.templateMarkup; } - + + public void setTemplateVersions(List<Template> templateVersions){ + this.templateVersions=templateVersions; + } + + public List getTemplateVersions(){ + return this.templateVersions; + } + public List<Template> getTemplates(){ return this.templates; } - + + public void setTemplate(List<Template> templates){ + this.templates=templates; + } + public String getUsername(){ + return this.user.getUsername(); + } + + public void setUsername(String username){ + this.username=username; + } + + public boolean isEditMode(){ + return editMode; + } + + public void setEditMode(boolean editMode){ + this.editMode=editMode; + } public int getFirstRowIndex() { return firstRowIndex; } - + public void setFirstRowIndex(int firstRowIndex) { this.firstRowIndex = firstRowIndex; } - + public int getNoOfRows() { return noOfRows; } - + public void setNoOfRows(int noOfRows) { this.noOfRows = noOfRows; } - - - - public String saveTemplate()throws Exception{ + + public String listTemplates(){ + contentTypeName = FacesUtil.getRequestParameter("contentTypeSelected"); try{ - Template template =new Template(templateName,templateMarkup); + if (contentTypeName != null && contentTypeName.length() > 0) { + currentContentType = contentTypeService.getContentType(contentTypeName,user); + templates=currentContentType.getTemplates(); + } + + }catch(Exception e){ + FacesUtil.addMessage(e.getMessage(),e.getMessage()); + return "failed"; + } + return "listTemplates"; + } + + + + public String checkOutTemplate(){ + templateSelected = FacesUtil.getRequestParameter("templateSelected"); + try{ + if(templateSelected!= null && templateSelected.length() > 0 ){ + currentTemplate = contentTypeService.getTemplateWithUUID(templateSelected); + contentTypeService.checkOutTemplate(currentTemplate, currentContentType,user); + } + currentContentType = contentTypeService.getContentType(contentTypeName,user); + templates=currentContentType.getTemplates(); + + + }catch(Exception e){ + FacesUtil.addMessage(e.getMessage(),e.getMessage()); + return "failed"; + } + return "listTemplates"; + } + public String deleteSelectedTemplate(){ + templateSelected = FacesUtil.getRequestParameter("templateSelected"); + try{ + if(templateSelected!= null && templateSelected.length() > 0 ){ + currentTemplate=contentTypeService.getTemplateWithUUID(templateSelected); + contentTypeService.deleteTemplateOfContentType(currentContentType,currentTemplate); + } + + }catch(Exception e){ + FacesUtil.addMessage(e.getMessage(),e.getMessage()); + return "failed"; + } + return "listTemplates"; + } + + public String showTemplateVersions() { + try { + templateSelected = FacesUtil.getRequestParameter("templateSelected"); + if(templateSelected!= null && templateSelected.length() > 0 ){ + currentTemplate = contentTypeService.getTemplateWithUUID(templateSelected); + currentContentType = contentTypeService.getContentType(contentTypeName,user); + List<Template> templateVersions = contentTypeService.getAllVersionsOfTemplate(currentTemplate,currentContentType); + setTemplateVersions(templateVersions); + } + + } catch (Exception e) { + FacesUtil.addMessage(e.getMessage(), e.getMessage()); + return "failed"; + } + return "versionsRetrieved"; + + } + public String uncheckoutTemplate(){ + templateSelected = FacesUtil.getRequestParameter("templateSelected"); + try{ + if(templateSelected!= null && templateSelected.length() > 0 ){ + currentTemplate = contentTypeService.getTemplateWithUUID(templateSelected); + contentTypeService.revertChangesTemplateForTemplate(currentTemplate,currentContentType,user); + } + + }catch(Exception e){ + FacesUtil.addMessage(e.getMessage(), e.getMessage()); + return "failed"; + } + return "listTemplates"; + } + + + public String updateTemplate(){ + try{ + currentTemplate.setName(templateName); + currentTemplate.setTemplateMarkup(templateMarkup); + contentTypeService.updateTemplateOfContentType(currentTemplate,currentContentType,user); + resetFields(); + + } catch(Exception e){ + FacesUtil.addMessage(e.getMessage(), e.getMessage()); + return "failed"; + } + return "templateUpdated"; + + } + public String editTemplate()throws Exception{ + templateSelected = FacesUtil.getRequestParameter("templateSelected"); + try{ + if(templateSelected!= null && templateSelected.length() > 0 ){ + currentTemplate = contentTypeService.getTemplateWithUUID(templateSelected); + templateName=currentTemplate.getName(); + templateMarkup=currentTemplate.getTemplateMarkup(); + FacesUtil.setPortletSessionAttribute(Constants.CREATED_CONTENT_TYPE,currentContentType); + setEditMode(true); + } + + }catch(Exception e){ + FacesUtil.addMessage(e.getMessage(), e.getMessage()); + return "failed"; + } + return "createTemplate"; + } + + + public String createNewTemplate(){ + contentTypeName=FacesUtil.getRequestParameter("contentTypeSelected"); + try{ + if (contentTypeName != null && contentTypeName.length() > 0) { + currentContentType = contentTypeService.getContentType(contentTypeName,user); + FacesUtil.setPortletSessionAttribute(Constants.CREATED_CONTENT_TYPE,currentContentType); + resetFields(); + } + }catch(Exception e){ + FacesUtil.addMessage(e.getMessage(), e.getMessage()); + return "failed"; + } + return "createTemplate"; + } + + + public String saveTemplate(){ + + Template template =new Template(templateName,templateMarkup); + + if(FacesUtil.getPortletSessionAttribute(Constants.CREATED_CONTENT_TYPE)!=null){ + currentContentType=(ContentType)FacesUtil.getPortletSessionAttribute(Constants.CREATED_CONTENT_TYPE); + FacesUtil.removePortletSessionAttribute(Constants.CREATED_CONTENT_TYPE); + } + try{ + contentTypeService.addTemplateToContentType(template, currentContentType, user); - + resetFields(); + + }catch(Exception e){ FacesUtil.addMessage(e.getMessage(), e.getMessage()); - return "templateCreationFailed"; + return "failed"; } return "templateCreated"; } - - + + public String saveNewVersion(){ + + currentTemplate.setName(templateName); + currentTemplate.setTemplateMarkup(templateMarkup); + try{ + contentTypeService.saveNewVersionOfTemplate(currentTemplate,currentContentType,user); + resetFields(); + currentContentType = contentTypeService.getContentType(contentTypeName,user); + templates=currentContentType.getTemplates(); + }catch(Exception e){ + FacesUtil.addMessage(e.getMessage(), e.getMessage()); + return "failed"; + } + return "templateSaved"; + } + private void resetFields(){ + templateName=null; + templateMarkup=null; + editMode=false; + } + public String scrollFirst() { firstRowIndex = 0; return "success"; } - + public String scrollPrevious() { firstRowIndex -= noOfRows; if (firstRowIndex < 0) { @@ -153,7 +347,7 @@ } return "success"; } - + public String scrollNext() { firstRowIndex += noOfRows; if (firstRowIndex >= templates.size()) { @@ -162,22 +356,22 @@ } return "success"; } - + public String scrollLast() { firstRowIndex = templates.size() - templates.size() % noOfRows; return "success"; } - + public boolean getBackDisabled() { return firstRowIndex == 0; } - + public boolean getForwardDisabled() { if (templates == null) { return true; } return firstRowIndex >= templates.size() - noOfRows; } - - + + } Index: mirage-portlets/customContentDefinitions/web/createTemplate.jsp =================================================================== --- mirage-portlets/customContentDefinitions/web/createTemplate.jsp (revision 83) +++ mirage-portlets/customContentDefinitions/web/createTemplate.jsp (working copy) @@ -6,7 +6,7 @@ <%@ page import="javax.portlet.*" %> <%@ page import="com.sun.portal.cms.mirage.model.custom.ContentType" %> <%@ page import="com.sun.portal.cms.mirage.model.custom.FormField" %> -<%@ page import="com.sun.portal.cms.mirage.ocm.utils.Constants" %> +<%@ page import="com.sun.portal.cms.mirage.utils.Constants" %>

<%@ taglib uri="http://java.sun.com/jsf/portlet/components" prefix="p" %> <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %> @@ -114,7 +114,8 @@

keywrds1['-- Insert snippet --'] = ''; <% - ContentType contentType=(ContentType)session.getAttribute(Constants.CREATED_CONTENT_TYPE); + PortletSession pSession=renderRequest.getPortletSession(true); + ContentType contentType=(ContentType)pSession.getAttribute(Constants.CREATED_CONTENT_TYPE); List<FormField> fieldList=contentType.getFieldList(); String fieldValue; for(FormField field:fieldList){ @@ -187,15 +188,15 @@ </div>

<br></br> - + <h:messages globalOnly="true"></h:messages>

- <h:commandButton value="Save" action="#{templateBean.saveTemplate}"> + <h:commandButton value="Save" action="#{templateBean.saveTemplate}" rendered="#{!templateBean.editMode}">

</h:commandButton>

- + <h:commandButton value="SaveAsNewVersion" action="#{templateBean.saveNewVersion}" rendered="#{templateBean.editMode}" />

- + <h:commandButton value="Update" action="#{templateBean.updateTemplate}" rendered="#{templateBean.editMode}" /> </h:form> </body> </html> Index: mirage-portlets/customContentDefinitions/web/customContent/editContent.jsp ===================================================================

--- mirage-portlets/customContentDefinitions/web/customContent/editContent.jsp (revision 83) +++ mirage-portlets/customContentDefinitions/web/customContent/editContent.jsp (working copy) @@ -35,7 +35,7 @@ <br/> <h:form> <h:commandLink action="back" > - <h:outputText value="#{msgs.goBack}" /> + <h:outputText value="#{msgs.goBack}" /> </h:commandLink> </h:form> </p:portletPage> Index: mirage-portlets/customContentDefinitions/web/WEB-INF/faces-config.xml ===================================================================

--- mirage-portlets/customContentDefinitions/web/WEB-INF/faces-config.xml (revision 83) +++ mirage-portlets/customContentDefinitions/web/WEB-INF/faces-config.xml (working copy) @@ -15,8 +15,6 @@ </locale-config> </application>

- <!-- Navigation rules for ccd portlet --> - <navigation-rule> <from-view-id>/createContentType.jsp</from-view-id> <navigation-case> @@ -75,12 +73,20 @@ <from-outcome>back</from-outcome> <to-view-id>/index.jsp</to-view-id> </navigation-case> + <navigation-case> + <from-outcome>docUpdated</from-outcome> + <to-view-id>/index.jsp</to-view-id> + </navigation-case> + <navigation-case> + <from-outcome>failed</from-outcome> + <to-view-id>/viewContent.jsp</to-view-id> + </navigation-case> </navigation-rule>

<navigation-rule> <from-view-id>/index.jsp</from-view-id> <navigation-case> - <from-outcome>template</from-outcome> + <from-outcome>listTemplates</from-outcome> <to-view-id>/listTemplates.jsp</to-view-id> </navigation-case> <navigation-case> @@ -166,24 +172,67 @@ <navigation-case> <from-outcome>docUpdated</from-outcome> <to-view-id>/index.jsp</to-view-id> - </navigation-case> - <navigation-case> - <from-outcome>failed</from-outcome> - <to-view-id>/editContent.jsp</to-view-id> - </navigation-case> + </navigation-case> </navigation-rule>

- <navigation-rule> + <navigation-rule> <from-view-id>/createTemplate.jsp</from-view-id> <navigation-case> <from-outcome>templateCreated</from-outcome> <to-view-id>/index.jsp</to-view-id> </navigation-case> + <navigation-case> + <from-outcome>templateUpdated</from-outcome> + <to-view-id>/listTemplates.jsp</to-view-id> + </navigation-case> + <navigation-case> + <from-outcome>templateSaved</from-outcome> + <to-view-id>/listTemplates.jsp</to-view-id> + </navigation-case> + <navigation-case> + <from-outcome>failed</from-outcome> + <to-view-id>/createTemplate.jsp</to-view-id> + </navigation-case> </navigation-rule> -

- <!-- Navigation rules for custom content portlet --> +<navigation-rule> + <from-view-id>/listTemplates.jsp</from-view-id> + <navigation-case> + <from-outcome>listTemplates</from-outcome> + <to-view-id>/listTemplates.jsp</to-view-id> + </navigation-case> + <navigation-case> + <from-outcome>editTemplate</from-outcome> + <to-view-id>/createTemplate.jsp</to-view-id> + </navigation-case> + <navigation-case> + <from-outcome>createTemplate</from-outcome> + <to-view-id>/createTemplate.jsp</to-view-id> + </navigation-case> + <navigation-case> + <from-outcome>back</from-outcome> + <to-view-id>/index.jsp</to-view-id> + </navigation-case> + <navigation-case> + <from-outcome>versionsRetrieved</from-outcome> + <to-view-id>/templateVersions.jsp</to-view-id> + </navigation-case> + <navigation-case> + <from-outcome>failed</from-outcome> + <to-view-id>/listTemplates.jsp</to-view-id> + </navigation-case> + </navigation-rule>

+ +<navigation-rule> + <from-view-id>/templateVersions.jsp</from-view-id> + <navigation-case> + <from-outcome>back</from-outcome> + <to-view-id>/listTemplates.jsp</to-view-id> + </navigation-case> + </navigation-rule> + <!-- Navigation rules for custom content portlet --> + <navigation-rule> <from-view-id>/customContent/index.jsp</from-view-id> <navigation-case> @@ -287,9 +336,7 @@ <to-view-id>/customContent/listVersions.jsp</to-view-id> </navigation-case> </navigation-rule> - - <!-- Beans for the ccd portlet --> - + <!-- Beans for the ccd portlet --> <managed-bean> <managed-bean-name>contentType</managed-bean-name>

<managed-bean-class>com.sun.portal.cms.portlet.ccd.beans.ContentTypeBean</managed-bean-class> @@ -307,15 +354,13 @@

<managed-bean-class>com.sun.portal.cms.portlet.ccd.beans.ContentVersionBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> - - <managed-bean> + <managed-bean> <managed-bean-name>templateBean</managed-bean-name>

<managed-bean-class>com.sun.portal.cms.portlet.ccd.beans.TemplateBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> + <!-- Beans for the custom content portlet -->

- <!-- Beans for the custom content portlet --> - <managed-bean> <managed-bean-name>contentManagement</managed-bean-name>

<managed-bean-class>com.sun.portal.cms.portlet.custom.content.beans.ContentManagementBean</managed-bean-class> @@ -327,5 +372,4 @@

<managed-bean-class>com.sun.portal.cms.portlet.custom.content.beans.VersionManagementBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> - </faces-config>