Search in sources :

Example 66 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class AdminModule method initializeSystemTokenProperty.

/**
 * Check if system property for maintenance message exists, create one if it
 * doesn't
 * This generated token is used by the remote http maintenance message
 * setting mechanism, see method below
 * @param tokenPropertyName
 */
private void initializeSystemTokenProperty(String tokenPropertyName) {
    Property p = propertyManager.findProperty(null, null, null, SYSTEM_PROPERTY_CATEGORY, tokenPropertyName);
    if (p == null) {
        String token = RandomStringUtils.randomAlphanumeric(8);
        p = propertyManager.createPropertyInstance(null, null, null, SYSTEM_PROPERTY_CATEGORY, tokenPropertyName, null, null, token, null);
        propertyManager.saveProperty(p);
    }
}
Also used : Property(org.olat.properties.Property)

Example 67 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class QuotaManagerImpl method deleteCustomQuota.

/**
 * @param quota to be deleted
 * @return true if quota successfully deleted or no such quota, false if quota
 *         not deleted because it was a default quota that can not be deleted
 */
@Override
public boolean deleteCustomQuota(Quota quota) {
    if (defaultQuotas == null) {
        throw new OLATRuntimeException(QuotaManagerImpl.class, "Quota manager has not been initialized properly! Must call init() first.", null);
    }
    // do not allow to delete default quotas!
    if (quota.getPath().startsWith(QuotaConstants.IDENTIFIER_DEFAULT)) {
        return false;
    }
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, quotaResource, QUOTA_CATEGORY, quota.getPath());
    if (p != null)
        pm.deleteProperty(p);
    return true;
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) PropertyManager(org.olat.properties.PropertyManager) Property(org.olat.properties.Property)

Example 68 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class QuotaManagerImpl method initDefaultQuota.

/**
 * @param quotaIdentifier
 * @param factor Multiplier for some long running resources as blogs
 * @return
 */
private Quota initDefaultQuota(String quotaIdentifier) {
    Quota q = null;
    Property p = propertyManager.findProperty(null, null, quotaResource, QUOTA_CATEGORY, quotaIdentifier);
    if (p != null)
        q = parseQuota(p);
    if (q != null)
        return q;
    // initialize default quota
    q = createQuota(quotaIdentifier, new Long(FolderConfig.getDefaultQuotaKB()), new Long(FolderConfig.getLimitULKB()));
    setCustomQuotaKB(q);
    return q;
}
Also used : Quota(org.olat.core.util.vfs.Quota) Property(org.olat.properties.Property)

Example 69 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class QuotaManagerImpl method setCustomQuotaKB.

/**
 * Sets or updates the quota (in KB) for this path. Important: Must provide a
 * path with a valid base.
 *
 * @param quota
 */
@Override
public void setCustomQuotaKB(Quota quota) {
    if (defaultQuotas == null) {
        throw new OLATRuntimeException(QuotaManagerImpl.class, "Quota manager has not been initialized properly! Must call init() first.", null);
    }
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, quotaResource, QUOTA_CATEGORY, quota.getPath());
    if (p == null) {
        // create new entry
        p = pm.createPropertyInstance(null, null, quotaResource, QUOTA_CATEGORY, quota.getPath(), null, null, assembleQuota(quota), null);
        pm.saveProperty(p);
    } else {
        p.setStringValue(assembleQuota(quota));
        pm.updateProperty(p);
    }
    // if the quota is a default quota, rebuild the default quota list
    if (quota.getPath().startsWith(QuotaConstants.IDENTIFIER_DEFAULT)) {
        initDefaultQuotas();
    }
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) PropertyManager(org.olat.properties.PropertyManager) Property(org.olat.properties.Property)

Example 70 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class QuotaManagerImpl method listCustomQuotasKB.

/**
 * Get a list of all objects which have an individual quota.
 *
 * @return list of quotas.
 */
@Override
public List<Quota> listCustomQuotasKB() {
    if (defaultQuotas == null) {
        throw new OLATRuntimeException(QuotaManagerImpl.class, "Quota manager has not been initialized properly! Must call init() first.", null);
    }
    List<Quota> results = new ArrayList<Quota>();
    PropertyManager pm = PropertyManager.getInstance();
    List<Property> props = pm.listProperties(null, null, quotaResource, QUOTA_CATEGORY, null);
    if (props == null || props.size() == 0)
        return results;
    for (Iterator<Property> iter = props.iterator(); iter.hasNext(); ) {
        Property prop = iter.next();
        results.add(parseQuota(prop));
    }
    return results;
}
Also used : Quota(org.olat.core.util.vfs.Quota) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) PropertyManager(org.olat.properties.PropertyManager) ArrayList(java.util.ArrayList) Property(org.olat.properties.Property)

Aggregations

Property (org.olat.properties.Property)270 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)62 PropertyManager (org.olat.properties.PropertyManager)48 Identity (org.olat.core.id.Identity)36 NarrowedPropertyManager (org.olat.properties.NarrowedPropertyManager)36 ArrayList (java.util.ArrayList)24 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)22 BusinessGroup (org.olat.group.BusinessGroup)18 File (java.io.File)16 ICourse (org.olat.course.ICourse)16 Translator (org.olat.core.gui.translator.Translator)14 AssertException (org.olat.core.logging.AssertException)14 CourseNode (org.olat.course.nodes.CourseNode)14 Forum (org.olat.modules.fo.Forum)14 ForumManager (org.olat.modules.fo.manager.ForumManager)14 Test (org.junit.Test)12 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)12 XStream (com.thoughtworks.xstream.XStream)10 HashMap (java.util.HashMap)10 List (java.util.List)10