Package org.olat.properties

Examples of org.olat.properties.PropertyManager


  /**
   * @see org.olat.user.UserManager#setUserCharset(org.olat.core.id.Identity, java.lang.String)
   */
  public void setUserCharset(Identity identity, String charset){
      PropertyManager pm = PropertyManager.getInstance();
      Property p = pm.findProperty(identity, null, null, null, CHARSET);
     
      if(p != null){
          p.setStringValue(charset);
          pm.updateProperty(p);
    } else {
          Property newP = pm.createUserPropertyInstance(identity, null, CHARSET, null, null, charset, null);
          pm.saveProperty(newP);
      }
  }
View Full Code Here


   * @see org.olat.user.UserManager#getUserCharset(org.olat.core.id.Identity)
   */
  public String getUserCharset(Identity identity){
     String charset;
     charset = WebappHelper.getDefaultCharset();
     PropertyManager pm = PropertyManager.getInstance();
     Property p = pm.findProperty(identity, null, null, null, CHARSET);
     if(p != null){
         charset = p.getStringValue();
      // if after migration the system does not support the charset choosen by a
      // user
         // (a rather rare case)
View Full Code Here

* This generated token is used by the remote http maintenance message
* setting mechanism, see method below
* @param tokenPropertyName
*/
  private void initializeSystemTokenProperty(String tokenPropertyName) {
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, null, SYSTEM_PROPERTY_CATEGORY, tokenPropertyName);
    if (p == null) {
      String token = RandomStringUtils.randomAlphanumeric(8);
      p = pm.createPropertyInstance(null, null, null, SYSTEM_PROPERTY_CATEGORY, tokenPropertyName, null, null, token, null);
      pm.saveProperty(p);
    }
  }
View Full Code Here

    if (submittedToken == null) {
      Tracing.logAudit("Trying to set maintenance message without using a token. Remote address::" + request.getRemoteAddr(), AdminModule.class);
      return false;
    }
    // get token and compate
    PropertyManager pm = PropertyManager.getInstance();
    Property p = pm.findProperty(null, null, null, AdminModule.SYSTEM_PROPERTY_CATEGORY, tokenPropertyName);
    String token = (p == null ? "" : p.getStringValue());
    if (token.matches(submittedToken)) { // limit access to token
      return true;
    } else {
      Tracing.logAudit("Trying to set maintenance message using a wrong token. Remote address::" + request.getRemoteAddr(), AdminModule.class);
View Full Code Here

      upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
  }

  private void addQTIEditorSessionLock(FileResource fr, Identity user){
    PropertyManager pm = PropertyManager.getInstance();
    String derivedLockString = OresHelper.createStringRepresenting(fr);
    Property newp = pm.createPropertyInstance(null, null, null, "o_lock", derivedLockString, null, user.getKey(), null, null);
    pm.saveProperty(newp);
  }
View Full Code Here

    String propertyKey2 = "testNonTransactional-2";
    String testValue2 = "testNonTransactional-2";
    String propertyKey3 = "testNonTransactional-3";
    String testValue3 = "testNonTransactional-3";
    try {
      PropertyManager pm = PropertyManager.getInstance();
      Property p1 = pm.createPropertyInstance(null, null, null, null, propertyKey1, null, null, testValue1, null);
      pm.saveProperty(p1);
      Property p2 = pm.createPropertyInstance(null, null, null, null, propertyKey2, null, null, testValue2, null);
      pm.saveProperty(p2);
      // name is null => generated DB error => rollback ?
      Property p3 = pm.createPropertyInstance(null, null, null, null, null, null, null, testValue3, null);
      pm.saveProperty(p3);
      fail("Should generate error for rollback.");
      db.closeSession();
    } catch (Exception ex) {
      db.closeSession();
    }
    // check if p1 & p2 is NOT rollbacked
    PropertyManager pm = PropertyManager.getInstance();
    Property p_1 =pm.findProperty(null, null, null, null, propertyKey1);
    this.assertNull("Property1 is NOT rollbacked", p_1);
    Property p_2 =pm.findProperty(null, null, null, null, propertyKey2);
    this.assertNull("Property2 is NOT rollbacked", p_2);
  }
View Full Code Here

    try {
      long startTime = System.currentTimeMillis();
      for (int loopCounter=0; loopCounter<loops; loopCounter++) {
        String propertyKey = "testDbPerfKey-" + loopCounter;
        DB db = DBFactory.getInstance();
        PropertyManager pm = PropertyManager.getInstance();
        String testValue = "testDbPerfValue-" + loopCounter;
        Property p = pm.createPropertyInstance(null, null, null, null, propertyKey, null, null, testValue, null);
        pm.saveProperty(p);
        // forget session cache etc.
        db.closeSession();
        pm.deleteProperty(p);
      }
      long endTime = System.currentTimeMillis();
      timeWithoutTransction = endTime - startTime;
      Tracing.logInfo("testDbPerf without transaction takes :" + timeWithoutTransction + "ms", this.getClass());
    } catch (Exception ex) {
      fail("Exception in testDbPerf without transaction ex="+ ex);
    }
   
    try {
      long startTime = System.currentTimeMillis();
      for (int loopCounter=0; loopCounter<loops; loopCounter++) { 
        String propertyKey = "testDbPerfKey-" + loopCounter;
        DB db = DBFactory.getInstance();
        PropertyManager pm = PropertyManager.getInstance();
        String testValue = "testDbPerfValue-" + loopCounter;
        Property p = pm.createPropertyInstance(null, null, null, null, propertyKey, null, null, testValue, null);
        pm.saveProperty(p);
        // forget session cache etc.
        db.closeSession();
        db = DBFactory.getInstance();
        pm.deleteProperty(p);
      }
      long endTime = System.currentTimeMillis();
      long timeWithTransction = endTime - startTime;
      Tracing.logInfo("testDbPerf with transaction takes :" + timeWithTransction + "ms", this.getClass());
      Tracing.logInfo("testDbPerf diff between transaction and without transaction :" + (timeWithTransction - timeWithoutTransction) + "ms", this.getClass());
View Full Code Here

  public void testDBUTF8capable() {
    //FIXME:fj: move this test to the db module
   
    DB db = DBFactory.getInstance();
    PropertyManager pm = PropertyManager.getInstance();
    String unicodetest = "a-greek a\u03E2a\u03EAa\u03E8 arab \u0630a\u0631 chinese:\u3150a\u3151a\u3152a\u3153a\u3173a\u3110-z";
    Property p = pm.createPropertyInstance(null, null, null, null, "superbluberkey", null, null, unicodetest, null);
    pm.saveProperty(p);
    // forget session cache etc.
    db.closeSession();
   
    Property p2 = pm.findProperty(null, null, null, null, "superbluberkey");
    String lStr = p2.getStringValue();
    assertEquals(unicodetest, lStr);
   
  }
View Full Code Here

    int loopCounter = 0;
    try {
      while (loopCounter++ < numberOfLoops ) {
        String propertyKey = "DbWorkerKey-" + workerId + "-" + loopCounter;
        DB db = DBFactory.getInstance();
        PropertyManager pm = PropertyManager.getInstance();
        String testValue = "DbWorkerValue-" + workerId + "-" + loopCounter;
        Property p = pm.createPropertyInstance(null, null, null, null, propertyKey, null, null, testValue, null);
        pm.saveProperty(p);
        // forget session cache etc.
        db.closeSession();
       
        db = DBFactory.getInstance();
        Property p2 = pm.findProperty(null, null, null, null, propertyKey);
        String lStr = p2.getStringValue();
        if (!testValue.equals(lStr)) {
          Tracing.logInfo("Property ERROR testValue=" + testValue + ": lStr=" + lStr, this.getClass());
          errorCounter++;
        }
View Full Code Here

      System.out.println("Cannot deploy course from file: " + exportedCourseZIPFile.getAbsolutePath());
      return null;
    }
    RepositoryEntry re = CourseFactory.deployCourseFromZIP(exportedCourseZIPFile, access)
    if (re != null) {
      PropertyManager pm = PropertyManager.getInstance();
      Property prop = pm.createPropertyInstance(null, null, null, "_o3_", "deployedCourses", null, re.getKey(), absOrRelPath, null);
      pm.saveProperty(prop);
    }
    return re;
  }
View Full Code Here

TOP

Related Classes of org.olat.properties.PropertyManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.