@Override
 public void updateModuleConfigDefaults(final boolean isNewNode) {
   final ModuleConfiguration config = getModuleConfiguration();
   if (isNewNode) {
     // use defaults for new course building blocks
     config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, false);
     config.setConfigurationVersion(1);
   }
 }
 @Override
 protected void formInnerEvent(
     final UserRequest ureq, final FormItem source, final FormEvent event) {
   if (config == null) {
     throw new AssertException("Try to do updateConfiguration() but module configuration is null");
   }
   config.set(
       DialogConfigForm.DIALOG_CONFIG_INTEGRATION,
       select.isSelected(0) ? CONFIG_INTEGRATION_VALUE_POPUP : CONFIG_INTEGRATION_VALUE_INLINE);
   config.setConfigurationVersion(1);
   fireEvent(ureq, Event.CHANGED_EVENT);
 }
Beispiel #3
0
  /**
   * Update the module configuration to have all mandatory configuration flags set to usefull
   * default values
   *
   * @param isNewNode true: an initial configuration is set; false: upgrading from previous node
   *     configuration version, set default to maintain previous behaviour
   */
  @Override
  public void updateModuleConfigDefaults(boolean isNewNode) {
    int CURRENTVERSION = 7;
    ModuleConfiguration config = getModuleConfiguration();
    if (isNewNode) {
      // use defaults for new course building blocks
      config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.FALSE.booleanValue());
      config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
      // how to render files (include jquery etc)
      DeliveryOptions nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
      nodeDeliveryOptions.setInherit(Boolean.TRUE);
      config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
      config.setConfigurationVersion(CURRENTVERSION);
    } else {
      config.remove(NodeEditController.CONFIG_INTEGRATION);
      if (config.getConfigurationVersion() < 2) {
        // update new configuration options using default values for existing
        // nodes
        config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.TRUE.booleanValue());
        Boolean componentMenu = config.getBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU);
        if (componentMenu == null) {
          config.setBooleanEntry(
              NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
        }
        config.setConfigurationVersion(2);
      }

      if (config.getConfigurationVersion() < 3) {
        config.set(
            NodeEditController.CONFIG_CONTENT_ENCODING,
            NodeEditController.CONFIG_CONTENT_ENCODING_AUTO);
        config.set(
            NodeEditController.CONFIG_JS_ENCODING, NodeEditController.CONFIG_JS_ENCODING_AUTO);
        config.setConfigurationVersion(3);
      }
      // Version 5 was ineffective since the delivery options were not set. We have to redo this and
      // save it as version 6
      if (config.getConfigurationVersion() < 7) {
        String contentEncoding = (String) config.get(NodeEditController.CONFIG_CONTENT_ENCODING);
        if (contentEncoding != null && contentEncoding.equals("auto")) {
          contentEncoding = null; // new style for auto
        }
        String jsEncoding = (String) config.get(NodeEditController.CONFIG_JS_ENCODING);
        if (jsEncoding != null && jsEncoding.equals("auto")) {
          jsEncoding = null; // new style for auto
        }

        CPPackageConfig reConfig = null;
        DeliveryOptions nodeDeliveryOptions =
            (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
        if (nodeDeliveryOptions == null) {
          // Update missing delivery options now, inherit from repo by default
          nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
          nodeDeliveryOptions.setInherit(Boolean.TRUE);

          RepositoryEntry re = getReferencedRepositoryEntry();
          // Check if delivery options are set for repo entry, if not create default
          if (re != null) {
            reConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
            if (reConfig == null) {
              reConfig = new CPPackageConfig();
            }
            DeliveryOptions repoDeliveryOptions = reConfig.getDeliveryOptions();
            if (repoDeliveryOptions == null) {
              // migrate existing config back to repo entry using the default as a base
              repoDeliveryOptions = DeliveryOptions.defaultWithGlossary();
              reConfig.setDeliveryOptions(repoDeliveryOptions);
              repoDeliveryOptions.setContentEncoding(contentEncoding);
              repoDeliveryOptions.setJavascriptEncoding(jsEncoding);
              CPManager.getInstance().setCPPackageConfig(re.getOlatResource(), reConfig);
            } else {
              // see if we have any different settings than the repo. if so, don't use inherit mode
              if (contentEncoding != repoDeliveryOptions.getContentEncoding()
                  || jsEncoding != repoDeliveryOptions.getJavascriptEncoding()) {
                nodeDeliveryOptions.setInherit(Boolean.FALSE);
                nodeDeliveryOptions.setContentEncoding(contentEncoding);
                nodeDeliveryOptions.setJavascriptEncoding(jsEncoding);
              }
            }
          }
          // remove old config parameters
          config.remove(NodeEditController.CONFIG_CONTENT_ENCODING);
          config.remove(NodeEditController.CONFIG_JS_ENCODING);
          // replace with new delivery options
          config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
        }
        config.setConfigurationVersion(7);
      }

      // else node is up-to-date - nothing to do
    }
    if (config.getConfigurationVersion() != CURRENTVERSION) {
      OLog logger = Tracing.createLoggerFor(CPCourseNode.class);
      logger.error(
          "CP course node version not updated to lastest version::"
              + CURRENTVERSION
              + ", was::"
              + config.getConfigurationVersion()
              + ". Check the code, programming error.");
    }
  }
Beispiel #4
0
 /**
  * Get the module configuration.
  *
  * @return ModuleConfiguration
  */
 public ModuleConfiguration getModuleConfiguration() {
   moduleConfig.setConfigurationVersion(2);
   return moduleConfig;
 }