org.springframework.extensions.config.ConfigElement Java Examples

The following examples show how to use org.springframework.extensions.config.ConfigElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiTenantShareMapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Initialize the share mapper
 * 
 * @param config ServerConfiguration
 * @param params ConfigElement
 * @exception InvalidConfigurationException
 */
public void initializeMapper(ServerConfiguration config, ConfigElement params)
	throws InvalidConfigurationException 
{
    if(logger.isDebugEnabled())
    {
        logger.debug("initialiseMapper");
    }
	
	//	Save the server configuration
	
    setServerConfiguration(config);
	
	// Complete initialization
	afterPropertiesSet();
}
 
Example #2
Source File: FTPAuthenticatorBase.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
   * Initialize the authenticator
   * 
* @param config ServerConfiguration
* @param params ConfigElement
   * @exception InvalidConfigurationException
   */
  public void initialize(ServerConfiguration config, ConfigElement params) throws InvalidConfigurationException
  {
      setConfig(config);

      // Get the alfresco configuration section, required to get hold of various services/components
      
      AlfrescoConfigSection alfrescoConfig = (AlfrescoConfigSection) config.getConfigSection( AlfrescoConfigSection.SectionName);
      
      // Copy over relevant bean properties for backward compatibility
      setAuthenticationComponent(alfrescoConfig.getAuthenticationComponent());
      setAuthenticationService(alfrescoConfig.getAuthenticationService());
      setTransactionService(alfrescoConfig.getTransactionService());
      setAuthorityService(alfrescoConfig.getAuthorityService());

      // Complete initialization
      initialize();
  }
 
Example #3
Source File: MimetypeMap.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean readConfig()
{
    // Config in XML
    Config config = configService.getConfig(CONFIG_CONDITION, new ConfigLookupContext(CONFIG_AREA));
    ConfigElement mimetypesElement = config.getConfigElement(ELEMENT_MIMETYPES);
    List<ConfigElement> mimetypes = mimetypesElement.getChildren();
    registerMimetypes(mimetypes);
    Data data = getData();
    data.xmlCount = mimetypes.size();

    // Config in JSON
    boolean successReadingConfig = true;
    if (jsonConfigFileFinder != null)
    {
        // This should not be "alfresco/mimetype" which is used for the in JVM jodconverter
        successReadingConfig &= jsonConfigFileFinder.readFiles("alfresco/mimetypes", logger);
        if (mimetypeJsonConfigDir != null && !mimetypeJsonConfigDir.isBlank())
        {
            successReadingConfig &= jsonConfigFileFinder.readFiles(mimetypeJsonConfigDir, logger);
        }
    }

    data.makeCollectionsReadOnly();

    return successReadingConfig;
}
 
Example #4
Source File: LegacyFileStateDriver.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public DeviceContext createContext(String shareName, ConfigElement args)
        throws DeviceContextException
{
    
    return diskInterface.createContext(shareName, args);
}
 
Example #5
Source File: FileServerDebugInterface.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void initialize(ConfigElement params, ServerConfiguration config)
        throws Exception
{
    // TODO Auto-generated method stub
}
 
Example #6
Source File: NonTransactionalRuleContentDiskDriver.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public DeviceContext createContext(String shareName, ConfigElement args)
        throws DeviceContextException
{
    return diskInterface.createContext(shareName, args);
}
 
Example #7
Source File: BufferedContentDiskDriver.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public DeviceContext createContext(String shareName, ConfigElement args)
        throws DeviceContextException
{
    return diskInterface.createContext(shareName, args);
}
 
Example #8
Source File: ContentFilterLanguagesMap.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Initialises the map using the configuration service provided
 */
public void init()
{
    ConfigLookupContext clContext = new ConfigLookupContext(CONFIG_AREA);

    // get which standart is defined by the user (ISO 639-1 by default)
    String standard = DEFAULT_LANGUAGE_LIST_STANDARD;

    Config configStandard  = configService.getConfig(USED_STANDARD_CONFIG_CONDITION, clContext);

    if(configStandard != null
            && configStandard.getConfigElement(USED_STANDARD_ELEMENT) != null)
    {
        standard = configStandard.getConfigElement(USED_STANDARD_ELEMENT).getValue();
    }
    else
    {
        logger.warn("No standard configured, use by default : " + DEFAULT_LANGUAGE_LIST_STANDARD);
    }


    Config configConditions    = configService.getConfig(CONFIG_CONDITION, clContext);
    Map<String, ConfigElement> configElements = configConditions.getConfigElements();

    ConfigElement configLanguages = null;

    // get the list of languages of the matched standard
    if(configElements.containsKey(standard))
    {
        configLanguages = configElements.get(standard);
    }

    // if the santard is not matched, get the first list
    else
    {
        configLanguages = configElements.values().iterator().next();
        logger.warn("Ignoring prefered standard doesn't found, choose : " + configLanguages.getName());
    }

    List<ConfigElement> languages = configLanguages.getChildren();

    // get the size of the lists
    int listSize = languages.size();
    this.orderedLangCodes = new ArrayList<String>(listSize);
    this.languagesByCode  = new HashMap<String, String>(listSize);

    // construct the languages map and list
    for (ConfigElement langElem : languages)
    {
        String code  = convertToOldISOCode(langElem.getAttribute(ATTR_CODE));
        String value = langElem.getValue();
        String def   = langElem.getAttribute(ATTR_DEFAULT);

        languagesByCode.put(code, value);

        boolean isDefault = (def != null && Boolean.parseBoolean(def));
        if(isDefault)
        {
            if(defaultLanguage != null)
            {
                logger.warn("Content filter default language is not unique: " + code);
            }
            else
            {
                this.defaultLanguage = code;
            }
        }
        if (EqualsHelper.nullSafeEquals(defaultLanguage, code))
        {
            orderedLangCodes.add(0, code);
        }
        else
        {
            orderedLangCodes.add(code);
        }

    }

    // make the collections read-only
    this.orderedLangCodes = Collections.unmodifiableList(this.orderedLangCodes);
    this.languagesByCode  = Collections.unmodifiableMap(this.languagesByCode);
}
 
Example #9
Source File: ImmutableConfig.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public ConfigElement getConfigElement(String name)
{
    return configElements.get(name);
}
 
Example #10
Source File: ImmutableConfig.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public String getConfigElementValue(String name)
{
    ConfigElement ce = configElements.get(name);
    return ce != null ? ce.getValue() : null; 
}
 
Example #11
Source File: ImmutableConfig.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Map<String, ConfigElement> getConfigElements()
{
    return configElements;
}
 
Example #12
Source File: ImmutableConfig.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void putConfigElement(ConfigElement configElement)
{
    throw new UnsupportedOperationException("Configuration is immutable.");
}
 
Example #13
Source File: MimetypeMap.java    From alfresco-data-model with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Initialises the map using the configuration service provided
 */
public void init()
{
    PropertyCheck.mandatory(this, "configService", configService);
    PropertyCheck.mandatory(this, "contentCharsetFinder", contentCharsetFinder);

    // Do we have any properties that indicate we will read JSON?
    if (mimetypeJsonConfigDir != null || jsonObjectMapper != null || cronExpression != null || initialAndOnErrorCronExpression != null)
    {
        PropertyCheck.mandatory(this, "jsonObjectMapper", jsonObjectMapper);
        // If we have a cronExpression it indicates that we will schedule reading.
        if (cronExpression != null)
        {
            PropertyCheck.mandatory(this, "initialAndOnErrorCronExpression", initialAndOnErrorCronExpression);
        }
        jsonConfigFileFinder = new ConfigFileFinder(jsonObjectMapper)
        {
            @Override
            protected void readJson(JsonNode jsonNode, String readFromMessage, String baseUrl) throws IOException
            {
                try
                {
                    JsonNode mediaTypes = jsonNode.get("mediaTypes");
                    if (mediaTypes != null && mediaTypes.isArray())
                    {
                        List<ConfigElement> mimetypes = new ArrayList<>();
                        for (JsonNode mediaType : mediaTypes)
                        {
                            MediaTypeDef def = jsonObjectMapper.convertValue(mediaType, MediaTypeDef.class);
                            GenericConfigElement mimetype = new GenericConfigElement(ATTR_MIMETYPE);
                            mimetype.addAttribute(ATTR_DISPLAY, def.name);
                            mimetype.addAttribute(ATTR_MIMETYPE, def.mediaType);
                            if (def.text)
                            {
                                mimetype.addAttribute(ATTR_TEXT, Boolean.TRUE.toString());
                            }

                            GenericConfigElement ext = null;
                            int count = 0;
                            for (ExtensionDef extension : def.extensions)
                            {
                                ext = new GenericConfigElement(ATTR_EXTENSION);
                                ext.setValue(extension.extension);
                                if (extension.name != null && !extension.name.isBlank())
                                {
                                    ext.addAttribute(ATTR_DISPLAY, extension.name);
                                }
                                if (extension.isDefault)
                                {
                                    ext.addAttribute(ATTR_DEFAULT, Boolean.TRUE.toString());
                                }
                                mimetype.addChild(ext);
                                count++;
                            }
                            if (count == 1 && ext.getAttribute(ATTR_DEFAULT) == null)
                            {
                                ext.addAttribute(ATTR_DEFAULT, Boolean.TRUE.toString());
                            }
                            mimetypes.add(mimetype);
                        }
                        registerMimetypes(mimetypes);
                        Data data = getData();
                        data.fileCount++;
                    }
                }
                catch (IllegalArgumentException e)
                {
                    logger.error("Error reading "+readFromMessage+" "+e.getMessage());
                }
            }
        };
    }

    // TikaConfig should be given, but work around it if not
    if (tikaConfig == null)
    {
        logger.warn("TikaConfig spring parameter not supplied, using default config");
        setTikaConfig(TikaConfig.getDefaultConfig());
    }
    // Create our Tika mimetype detector up-front
    // We can then be sure we only have the one, so it's quick (ALF-10813)
    detector = new DefaultDetector(tikaConfig.getMimeRepository());

    // Work out the mappings - only runs once and straight away if cronExpression is null
    configScheduler.run(true, logger, cronExpression, initialAndOnErrorCronExpression);
}
 
Example #14
Source File: OpenSearchConfigElement.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @see ConfigElement#getChildren()
 */
public List<ConfigElement> getChildren()
{
    throw new ConfigException("Reading the open search config via the generic interfaces is not supported");
}
 
Example #15
Source File: FileServerDebugInterface.java    From alfresco-repository with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Initialize the debug interface using the specified named parameters.
 *
 * @param params ConfigElement
 * @exception Exception
 */
public void initialize(ConfigElement params)
   throws Exception 
{

}
 
Example #16
Source File: ContentDiskDriver2.java    From alfresco-repository with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Parse and validate the parameter string and create a device context object for this instance
 * of the shared device. The same DeviceInterface implementation may be used for multiple
 * shares.
 * <p>
 * @deprecated - no longer used.   Construction of context is via spring now. 
 * @param deviceName The name of the device
 * @param cfg ConfigElement the configuration of the device context.
 * @return DeviceContext
 * @exception DeviceContextException
 */
public DeviceContext createContext(String deviceName, ConfigElement cfg) throws DeviceContextException
{
    logger.error("Obsolete method called");
    throw new DeviceContextException("Obsolete Method called");
}