All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.inteligr8.alfresco.attrclean.ClearBootstrapService Maven / Gradle / Ivy

/*
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see .
 */
package com.inteligr8.alfresco.attrclean;

import java.io.Serializable;
import java.util.Map.Entry;

import org.alfresco.service.cmr.attributes.AttributeService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(value = -10)  // higher than average
public class ClearBootstrapService extends AbstractBootstrapService {
	
	private final Logger logger = LoggerFactory.getLogger(ClearBootstrapService.class);
	
	@Autowired
	@Qualifier("attributeService")
	private AttributeService attributeService;
	
	@Value("${inteligr8.attrcleaner.feature.clear.scope}")
	private String scopeRaw;
	
	@Value("${inteligr8.attrcleaner.feature.clear.keys}")
	private String keysRaw;
	
	@Override
	public String getRawScope() {
		return this.scopeRaw;
	}
	
	@Override
	public String getRawKeys() {
		return this.keysRaw;
	}
	
	@Override
	public void execute(Entry entry) {
		String keysAsStr = StringUtils.join(entry.getKey(), "/");
		this.logger.debug("  Removing: {}", keysAsStr);
		this.attributeService.removeAttribute(entry.getKey());
		this.logger.warn("  Removed: {}", keysAsStr);
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy