h1. How to create new publication in WCM


{info}
*Since WCM 1.2.2*
{info}


h2. Create new Java project

* Create new Java project with the structured like this:

!publication.png!

* *Note*: src/main/java and src/main/resources are source folders

h2. Configuration

* In configuration.xml, there is two required mandatory configurations:
For the publication plugin
{code:xml}
<external-component-plugins>
 <target-component>org.exoplatform.services.wcm.publication.WCMPublicationService</target-component>
 <component-plugin>
  <name>Date time publication</name>
  <set-method>addPublicationPlugin</set-method>
  <type>org.exoplatform.services.wcm.publication.lifecycle.datetime.DateTimePublicationPlugin</type>
  <description>This publication lifecycle publish a web content or DMS document to a portal page with more states, version and date time.</description>
  <init-params>
   <values-param>
    <name>repository</name>
    <value>repository</value>
   </values-param>
   <values-param>
    <name>workspace</name>
    <value>collaboration</value>
   </values-param>
  </init-params>
 </component-plugin>
</external-component-plugins>
{code}

* *Note*:
** target-component: always is org.exoplatform.services.wcm.publication.WCMPublicationService.
** name: your publication's name.
** description: your publication's description.
** set-method: always is addPublicationPlugin.
** type: your publication's class.
** init-params: not required, you can use it for your publication plugin or not.

And for the publication nodetype
{code:xml}
<external-component-plugins>
 <target-component>org.exoplatform.services.jcr.RepositoryService</target-component>		
 <component-plugin>
  <name>add.nodeType</name>
  <set-method>addPlugin</set-method>
  <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
  <priority>99</priority>
  <init-params>
   <values-param>
    <name>autoCreatedInNewRepository</name>
    <description>Node types configuration file</description>
    <value>jar:/conf/wcm-datetime-publication-nodetypes.xml</value>
   </values-param>
  </init-params>
 </component-plugin>
</external-component-plugins>
{code}

* *Note*: Just change the name of the xml file to match with your nodetype's configuration file.

h2. Extends or implement the publication plugin

* If you want to re-use the existing publication in WCM, you can extend one of these plugins:
** org.exoplatform.services.wcm.publication.lifecycle.stageversion.StageAndVersionPublicationPlugin
** org.exoplatform.services.wcm.publication.lifecycle.simple.SimplePublicationPlugin

* If you want to create a new publication, you have to extend *org.exoplatform.services.wcm.publicationWebpagePublicationPlugin*, and you have to overwrite all abstract methods. Important method:
** *getLifecycleType()*: return the nodetype of the publication


h2. Create new User interface (UI) for new publication

* All UI classes of the new publication are put in src/main/java, and all groovy templates are put in src/main/resources. If you want to use the template, use "classpath:path/in/src/main/resource/to/the/templates" (without quote) in ComponentConfig.
