Search in sources :

Example 1 with LicenseModule

use of org.olat.core.commons.services.license.LicenseModule in project OpenOLAT by OpenOLAT.

the class ListRenderer method render.

/**
 * Render contents of directory to a html table.
 *
 * @param dir
 * @param secCallback
 * @param ubu
 * @param translator
 * @param iframePostEnabled
 * @return Render results.
 */
public void render(FolderComponent fc, StringOutput sb, URLBuilder ubu, Translator translator, boolean iframePostEnabled) {
    if (lockManager == null) {
        lockManager = CoreSpringFactory.getImpl(VFSLockManager.class);
    }
    if (userManager == null) {
        userManager = CoreSpringFactory.getImpl(UserManager.class);
    }
    LicenseModule licenseModule = CoreSpringFactory.getImpl(LicenseModule.class);
    LicenseHandler licenseHandler = CoreSpringFactory.getImpl(FolderLicenseHandler.class);
    licensesEnabled = licenseModule.isEnabled(licenseHandler);
    List<VFSItem> children = fc.getCurrentContainerChildren();
    // folder empty?
    if (children.size() == 0) {
        sb.append("<div class=\"o_bc_empty\"><i class='o_icon o_icon_warn'></i> ").append(translator.translate("NoFiles")).append("</div>");
        return;
    }
    boolean canVersion = FolderConfig.versionsEnabled(fc.getCurrentContainer());
    String sortOrder = fc.getCurrentSortOrder();
    boolean sortAsc = fc.isCurrentSortAsc();
    String sortCss = (sortAsc ? "o_orderby_asc" : "o_orderby_desc");
    sb.append("<table class=\"table table-condensed table-striped table-hover o_bc_table\">").append("<thead><tr><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_NAME.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_NAME)).append(">").append(translator.translate("header.Name")).append("</a>").append("</th>");
    sb.append("<th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_SIZE.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_SIZE)).append(">").append(translator.translate("header.Size")).append("</a>").append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_DATE.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_DATE)).append(">").append(translator.translate("header.Modified")).append("</a>");
    if (licensesEnabled) {
        sb.append("<th>").append(translator.translate("header.license")).append("</th>");
    }
    if (canVersion) {
        sb.append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_REV.equals(sortOrder)).append("' ");
        // file size column
        ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_REV)).append("><i class=\"o_icon o_icon_version  o_icon-lg\" title=\"").append(translator.translate("versions")).append("\"></i></a>");
    }
    sb.append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_LOCK.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_LOCK)).append("><i class=\"o_icon o_icon_locked  o_icon-lg\" title=\"").append(translator.translate("lock.title")).append("\"></i></a>").append("</th><th><i class=\"o_icon o_icon_edit_metadata o_icon-lg\" title=\"").append(translator.translate("mf.edit")).append("\"></i></th></tr></thead>");
    // render directory contents
    String currentContainerPath = fc.getCurrentContainerPath();
    if (currentContainerPath.length() > 0 && currentContainerPath.charAt(0) == '/') {
        currentContainerPath = currentContainerPath.substring(1);
    }
    sb.append("<tbody>");
    for (int i = 0; i < children.size(); i++) {
        VFSItem child = children.get(i);
        appendRenderedFile(fc, child, currentContainerPath, sb, ubu, translator, iframePostEnabled, canVersion, i);
    }
    sb.append("</tbody></table>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) FolderLicenseHandler(org.olat.core.commons.modules.bc.FolderLicenseHandler) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) UserManager(org.olat.user.UserManager) VFSItem(org.olat.core.util.vfs.VFSItem) VFSLockManager(org.olat.core.util.vfs.VFSLockManager) LicenseModule(org.olat.core.commons.services.license.LicenseModule)

Example 2 with LicenseModule

use of org.olat.core.commons.services.license.LicenseModule in project OpenOLAT by OpenOLAT.

the class VFSResourceRoot method addLicense.

private void addLicense(MetaInfo meta, Identity identity) {
    LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
    LicenseModule licenseModule = CoreSpringFactory.getImpl(LicenseModule.class);
    FolderLicenseHandler licenseHandler = CoreSpringFactory.getImpl(FolderLicenseHandler.class);
    if (licenseModule.isEnabled(licenseHandler)) {
        License license = licenseService.createDefaultLicense(licenseHandler, identity);
        meta.setLicenseTypeKey(String.valueOf(license.getLicenseType().getKey()));
        meta.setLicenseTypeName(license.getLicenseType().getName());
        meta.setLicensor(license.getLicensor());
        meta.setLicenseText(LicenseUIFactory.getLicenseText(license));
    }
}
Also used : FolderLicenseHandler(org.olat.core.commons.modules.bc.FolderLicenseHandler) LicenseService(org.olat.core.commons.services.license.LicenseService) License(org.olat.core.commons.services.license.License) LicenseModule(org.olat.core.commons.services.license.LicenseModule)

Example 3 with LicenseModule

use of org.olat.core.commons.services.license.LicenseModule in project openolat by klemens.

the class ListRenderer method render.

/**
 * Render contents of directory to a html table.
 *
 * @param dir
 * @param secCallback
 * @param ubu
 * @param translator
 * @param iframePostEnabled
 * @return Render results.
 */
public void render(FolderComponent fc, StringOutput sb, URLBuilder ubu, Translator translator, boolean iframePostEnabled) {
    if (lockManager == null) {
        lockManager = CoreSpringFactory.getImpl(VFSLockManager.class);
    }
    if (userManager == null) {
        userManager = CoreSpringFactory.getImpl(UserManager.class);
    }
    LicenseModule licenseModule = CoreSpringFactory.getImpl(LicenseModule.class);
    LicenseHandler licenseHandler = CoreSpringFactory.getImpl(FolderLicenseHandler.class);
    licensesEnabled = licenseModule.isEnabled(licenseHandler);
    List<VFSItem> children = fc.getCurrentContainerChildren();
    // folder empty?
    if (children.size() == 0) {
        sb.append("<div class=\"o_bc_empty\"><i class='o_icon o_icon_warn'></i> ").append(translator.translate("NoFiles")).append("</div>");
        return;
    }
    boolean canVersion = FolderConfig.versionsEnabled(fc.getCurrentContainer());
    String sortOrder = fc.getCurrentSortOrder();
    boolean sortAsc = fc.isCurrentSortAsc();
    String sortCss = (sortAsc ? "o_orderby_asc" : "o_orderby_desc");
    sb.append("<table class=\"table table-condensed table-striped table-hover o_bc_table\">").append("<thead><tr><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_NAME.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_NAME)).append(">").append(translator.translate("header.Name")).append("</a>").append("</th>");
    sb.append("<th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_SIZE.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_SIZE)).append(">").append(translator.translate("header.Size")).append("</a>").append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_DATE.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_DATE)).append(">").append(translator.translate("header.Modified")).append("</a>");
    if (licensesEnabled) {
        sb.append("<th>").append(translator.translate("header.license")).append("</th>");
    }
    if (canVersion) {
        sb.append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_REV.equals(sortOrder)).append("' ");
        // file size column
        ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_REV)).append("><i class=\"o_icon o_icon_version  o_icon-lg\" title=\"").append(translator.translate("versions")).append("\"></i></a>");
    }
    sb.append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_LOCK.equals(sortOrder)).append("' ");
    ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_LOCK)).append("><i class=\"o_icon o_icon_locked  o_icon-lg\" title=\"").append(translator.translate("lock.title")).append("\"></i></a>").append("</th><th><i class=\"o_icon o_icon_edit_metadata o_icon-lg\" title=\"").append(translator.translate("mf.edit")).append("\"></i></th></tr></thead>");
    // render directory contents
    String currentContainerPath = fc.getCurrentContainerPath();
    if (currentContainerPath.length() > 0 && currentContainerPath.charAt(0) == '/') {
        currentContainerPath = currentContainerPath.substring(1);
    }
    sb.append("<tbody>");
    for (int i = 0; i < children.size(); i++) {
        VFSItem child = children.get(i);
        appendRenderedFile(fc, child, currentContainerPath, sb, ubu, translator, iframePostEnabled, canVersion, i);
    }
    sb.append("</tbody></table>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) FolderLicenseHandler(org.olat.core.commons.modules.bc.FolderLicenseHandler) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) UserManager(org.olat.user.UserManager) VFSItem(org.olat.core.util.vfs.VFSItem) VFSLockManager(org.olat.core.util.vfs.VFSLockManager) LicenseModule(org.olat.core.commons.services.license.LicenseModule)

Example 4 with LicenseModule

use of org.olat.core.commons.services.license.LicenseModule in project openolat by klemens.

the class VFSResourceRoot method addLicense.

private void addLicense(MetaInfo meta, Identity identity) {
    LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
    LicenseModule licenseModule = CoreSpringFactory.getImpl(LicenseModule.class);
    FolderLicenseHandler licenseHandler = CoreSpringFactory.getImpl(FolderLicenseHandler.class);
    if (licenseModule.isEnabled(licenseHandler)) {
        License license = licenseService.createDefaultLicense(licenseHandler, identity);
        meta.setLicenseTypeKey(String.valueOf(license.getLicenseType().getKey()));
        meta.setLicenseTypeName(license.getLicenseType().getName());
        meta.setLicensor(license.getLicensor());
        meta.setLicenseText(LicenseUIFactory.getLicenseText(license));
    }
}
Also used : FolderLicenseHandler(org.olat.core.commons.modules.bc.FolderLicenseHandler) LicenseService(org.olat.core.commons.services.license.LicenseService) License(org.olat.core.commons.services.license.License) LicenseModule(org.olat.core.commons.services.license.LicenseModule)

Aggregations

FolderLicenseHandler (org.olat.core.commons.modules.bc.FolderLicenseHandler)4 LicenseModule (org.olat.core.commons.services.license.LicenseModule)4 License (org.olat.core.commons.services.license.License)2 LicenseHandler (org.olat.core.commons.services.license.LicenseHandler)2 LicenseService (org.olat.core.commons.services.license.LicenseService)2 NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSLockManager (org.olat.core.util.vfs.VFSLockManager)2 UserManager (org.olat.user.UserManager)2