Search in sources :

Example 16 with PropertyManager

use of org.olat.properties.PropertyManager in project openolat by klemens.

the class InfoMessageManager method setInfoMessageNodeOnly.

/**
 * set info message on node level only, no need to sync
 * @param message
 */
public void setInfoMessageNodeOnly(String message) {
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, null, "_o3_", INFO_MSG_NODE_ONLY + nodeId);
    if (p == null) {
        p = pm.createPropertyInstance(null, null, null, "_o3_", INFO_MSG_NODE_ONLY + nodeId, null, null, null, "");
        pm.saveProperty(p);
    }
    p.setTextValue(message);
    // set Message in RAM
    InfoMessageManager.infoMessageNodeOnly = message;
    pm.updateProperty(p);
}
Also used : PropertyManager(org.olat.properties.PropertyManager) Property(org.olat.properties.Property)

Example 17 with PropertyManager

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

the class DBPersistentLockManager method aquirePersistentLock.

/**
 * @see org.olat.core.util.locks.PersistentLockManager#aquirePersistentLock(org.olat.core.id.OLATResourceable,
 *      org.olat.core.id.Identity, java.lang.String)
 */
@Override
public LockResult aquirePersistentLock(OLATResourceable ores, Identity ident, String locksubkey) {
    // synchronisation is solved in the LockManager
    LockResult lres;
    PropertyManager pm = PropertyManager.getInstance();
    String derivedLockString = OresHelper.createStringRepresenting(ores, locksubkey);
    long aqTime;
    Identity lockOwner;
    boolean success;
    Property p;
    p = pm.findProperty(null, null, null, CATEGORY_PERSISTENTLOCK, derivedLockString);
    if (p == null) {
        // no persistent lock acquired yet
        // save a property: cat = o_lock, key = derivedLockString, Longvalue = key
        // of identity acquiring the lock
        Property newp = pm.createPropertyInstance(null, null, null, CATEGORY_PERSISTENTLOCK, derivedLockString, null, ident.getKey(), null, null);
        pm.saveProperty(newp);
        aqTime = System.currentTimeMillis();
        lockOwner = ident;
        success = true;
    } else {
        // already acquired, but check on reaquiring
        aqTime = p.getLastModified().getTime();
        Long lockOwnerKey = p.getLongValue();
        if (ident.getKey().equals(lockOwnerKey)) {
            // reaquire ok
            success = true;
        } else {
            // already locked by an other person
            success = false;
        }
        // FIXME:fj:c find a better way to retrieve information about the
        // lock-holder
        lockOwner = BaseSecurityManager.getInstance().loadIdentityByKey(lockOwnerKey);
    }
    LockEntry le = new LockEntry(derivedLockString, aqTime, lockOwner);
    lres = new LockResultImpl(success, le);
    return lres;
}
Also used : PropertyManager(org.olat.properties.PropertyManager) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property)

Example 18 with PropertyManager

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

the class CourseNodePasswordManagerImpl method deleteAllPasswordsFor.

/**
 * @see de.bps.course.nodes.CourseNodePasswordManager#deleteAllPasswordsFor(java.lang.Long)
 */
public void deleteAllPasswordsFor(OLATResourceable ores) {
    PropertyManager pm = PropertyManager.getInstance();
    List<Property> properties = pm.listProperties(null, null, AdditionalConditionAnswerContainer.RESOURCE_NAME, null, null, AdditionalConditionAnswerContainer.RESOURCE_NAME, ores.getResourceableId(), null);
    for (Property p : properties) {
        Long nodeId = p.getResourceTypeId();
        Long courseId = p.getLongValue();
        removeAnswers(nodeId, courseId);
        pm.deleteProperty(p);
    }
}
Also used : PropertyManager(org.olat.properties.PropertyManager) Property(org.olat.properties.Property)

Example 19 with PropertyManager

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

the class InfoMessageManager method setInfoMessageNodeOnly.

/**
 * set info message on node level only, no need to sync
 * @param message
 */
public void setInfoMessageNodeOnly(String message) {
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, null, "_o3_", INFO_MSG_NODE_ONLY + nodeId);
    if (p == null) {
        p = pm.createPropertyInstance(null, null, null, "_o3_", INFO_MSG_NODE_ONLY + nodeId, null, null, null, "");
        pm.saveProperty(p);
    }
    p.setTextValue(message);
    // set Message in RAM
    InfoMessageManager.infoMessageNodeOnly = message;
    pm.updateProperty(p);
}
Also used : PropertyManager(org.olat.properties.PropertyManager) Property(org.olat.properties.Property)

Example 20 with PropertyManager

use of org.olat.properties.PropertyManager 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)

Aggregations

PropertyManager (org.olat.properties.PropertyManager)50 Property (org.olat.properties.Property)48 Test (org.junit.Test)10 Identity (org.olat.core.id.Identity)8 DBRuntimeException (org.olat.core.logging.DBRuntimeException)8 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)6 ArrayList (java.util.ArrayList)4 GET (javax.ws.rs.GET)4 Produces (javax.ws.rs.Produces)4 UserSession (org.olat.core.util.UserSession)4 NarrowedPropertyManager (org.olat.properties.NarrowedPropertyManager)4 OLATResourceable (org.olat.core.id.OLATResourceable)3 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)3 File (java.io.File)2 IOException (java.io.IOException)2 Calendar (java.util.Calendar)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2