Example usage for com.liferay.portal.plugin ModuleId toString

List of usage examples for com.liferay.portal.plugin ModuleId toString

Introduction

In this page you can find the example usage for com.liferay.portal.plugin ModuleId toString.

Prototype

public static String toString(String groupId, String artifactId, String version, String type) 

Source Link

Usage

From source file:com.liferay.portlet.softwarecatalog.service.impl.SCProductEntryLocalServiceImpl.java

License:Open Source License

protected void populatePluginPackageElement(Element el, SCProductEntry productEntry,
        SCProductVersion productVersion, String baseImageURL) throws SystemException {

    DocUtil.add(el, "name", productEntry.getName());

    String moduleId = ModuleId.toString(productEntry.getRepoGroupId(), productEntry.getRepoArtifactId(),
            productVersion.getVersion(), "war");

    DocUtil.add(el, "module-id", moduleId);

    DocUtil.add(el, "modified-date", Time.getRFC822(productVersion.getModifiedDate()));

    Element typesEl = el.addElement("types");

    DocUtil.add(typesEl, "type", productEntry.getType());

    Element tagsEl = el.addElement("tags");

    String[] tags = StringUtil.split(productEntry.getTags());

    for (int i = 0; i < tags.length; i++) {
        DocUtil.add(tagsEl, "tag", tags[i]);
    }//from   w  w  w. ja  v  a2 s . c om

    DocUtil.add(el, "short-description", productEntry.getShortDescription());

    if (Validator.isNotNull(productEntry.getLongDescription())) {
        DocUtil.add(el, "long-description", productEntry.getLongDescription());
    }

    if (Validator.isNotNull(productVersion.getChangeLog())) {
        DocUtil.add(el, "change-log", productVersion.getChangeLog());
    }

    if (Validator.isNotNull(productVersion.getDirectDownloadURL())) {
        DocUtil.add(el, "download-url", productVersion.getDirectDownloadURL());
    }

    DocUtil.add(el, "author", productEntry.getAuthor());

    Element screenshotsEl = el.addElement("screenshots");

    for (SCProductScreenshot screenshot : productEntry.getScreenshots()) {
        long thumbnailId = screenshot.getThumbnailId();
        long fullImageId = screenshot.getFullImageId();

        Element screenshotEl = screenshotsEl.addElement("screenshot");

        DocUtil.add(screenshotEl, "thumbnail-url", baseImageURL + "?img_id=" + thumbnailId + "&t="
                + WebServerServletTokenUtil.getToken(thumbnailId));
        DocUtil.add(screenshotEl, "large-image-url", baseImageURL + "?img_id=" + fullImageId + "&t="
                + WebServerServletTokenUtil.getToken(fullImageId));
    }

    Element licensesEl = el.addElement("licenses");

    for (SCLicense license : productEntry.getLicenses()) {
        Element licenseEl = licensesEl.addElement("license");

        licenseEl.addText(license.getName());
        licenseEl.addAttribute("osi-approved", String.valueOf(license.isOpenSource()));
    }

    Element liferayVersionsEl = el.addElement("liferay-versions");

    for (SCFrameworkVersion frameworkVersion : productVersion.getFrameworkVersions()) {

        DocUtil.add(liferayVersionsEl, "liferay-version", frameworkVersion.getName());
    }
}