Skip to content

Library that allows to setup a number of Liferay Portal artifacts in the DB. It uses xml configuration and Liferay APIs to add all configured artifacts.

License

Notifications You must be signed in to change notification settings

ktor/liferay-db-setup-core-lunde

 
 

Repository files navigation

Artifact Javadocs

Liferay Portal DB Setup core

Library that allows to setup a number of Liferay artifacts in a DB. It uses xml configuration and Liferay APIs to add all configured artifacts. Artifacts in the database are created by Liferay common upgrade process. Each step of the upgrade process consists of one or more xml files, in which you can define artifacts to create or update.

Usage

First add this dependency into your OSGi module project's pom.xml.

<dependency>
    <groupId>eu.lundegaard.liferay</groupId>
    <artifactId>liferay-db-setup-core</artifactId>
    <version>3.1.0</version>
</dependency>

and specify the dependency in your bnd.bnd file as a resource to include.

Include-Resource: @liferay-db-setup-core-3.1.0.jar

Second create UpgradeStepRegistrator component to register your upgrade steps, e.g.

@Component(immediate = true, service = UpgradeStepRegistrator.class)
public class MyPortalUpgrade implements UpgradeStepRegistrator {

    @Override
    public void register(Registry registry) {
        String packageName = MyPortalUpgrade.class.getPackage().getName();
        registry.register(packageName, "1.0.0", "1.0.1", new GenericUpgradeStep("v1_0_1"));
    }
    
}

You can also call one of the LiferaySetup.setup methods directly to setup the database.

XML File content

XML file of an upgrade step has usually this structure:

<?xml version="1.0" encoding="UTF-8" ?>
<setup xmlns="http://www.lundegaard.eu/liferay/setup">
    <configuration>
        <runasuser>test@liferay.com</runasuser>
    </configuration>

    <!-- Artifacts to manage --> 
</setup>

runasuser defines under which user artifacts will be created. Then you can specify as many artifacts to setup as you want.

For instance, this will create Role with Publisher as a name.

<?xml version="1.0" encoding="UTF-8" ?>
<setup xmlns="http://www.lundegaard.eu/liferay/setup">
    <configuration>
        <runasuser>test@liferay.com</runasuser>
    </configuration>
 
    <roles>
        <role name="Publisher"/>
    </roles>
</setup>

Features

In Artifacts to manage section you can specify a lot of artifacts.

Role

<roles>
    <role name="Publisher"/>
</roles>

Expando attribute

This will create expando attribute canonical-url with permissions to view by guest user.

<customFields>
    <field name="canonical-url" type="string" className="com.liferay.portal.kernel.model.Layout">
        <role-permission role-name="Guest">
            <permission-action action-name="VIEW"/>
        </role-permission>
    </field>
</customFields>

Site

Site element must always have site-friendly-url filled. Guest site is determined by default attribute with true value. Other sites are specified by name attribute.

<sites>
    <site default="true" site-friendly-url="/guest">
    </site>
    <site name="My web" default="false" >
    </site>
</sites>

Document

Document's file itself is determined by file-system-name attribute which defines resource on classpath.

<document file-system-name="my-project/documents/icons/icon-home.svg"
          document-folder-name="/Icons"
          document-filename="icon-home.svg"
          document-title="icon-home.svg"/>

Articles

Article's content is determined by path attribute which defines resource on classpath. The resource contains article content in the form of XML.

<article title="Footer"
         path="my-project/articles/homepage/web_content/footer.xml"
         article-structure-key="BASIC-WEB-CONTENT"
         article-template-key="BASIC-WEB-CONTENT"
         articleId="FOOTER"
         article-folder-path="/Footer">
</article>

<article-structure key="BANNER-MAIN"
                   path="my-project/articles/homepage/structures/banner-main.json"
                   name="Banner - main"/>

<article-template key="BANNER-MAIN"
                  path="my-project/articles/homepage/templates/banner-main.ftl"
                  article-structure-key="BANNER-MAIN" name="Banner - main" cacheable="true"/>

Others

You can create/update/set many other artifacts like User, Organization, Page, Portlet placement, Permission, ... See source code.

Compatibility

|| Liferay Portal Version || Version || | 7.3.x | 3.1.x | | 7.2.x | 3.0.x | | older | use original Mimacom library |

About

Library that allows to setup a number of Liferay Portal artifacts in the DB. It uses xml configuration and Liferay APIs to add all configured artifacts.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.0%
  • Other 1.0%