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

com.lonelystorm.air.component.sightly.BsonComponent Maven / Gradle / Ivy

Go to download

The LonelyStorm Air Component library provides additional features to help with component development.

There is a newer version: 0.1.8
Show newest version
package com.lonelystorm.air.component.sightly;

import static org.apache.commons.lang.ArrayUtils.isNotEmpty;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.adobe.cq.sightly.WCMUse;
import com.lonelystorm.air.component.model.BsonIdentifier;

public class BsonComponent extends WCMUse {

    private final static Logger LOGGER = LoggerFactory.getLogger(BsonComponent.class);

    private String property;

    @Override
    public void activate() throws Exception {
        property = get("property", String.class);
    }

    public String getName() {
        return property;
    }

    public List getRows() {
        List rows = new ArrayList<>();

        String[] elements = getProperties().get(property, String[].class);
        if (isNotEmpty(elements)) {
            for (String element : elements) {
                try {
                    BsonIdentifier bsonIdentifier = BsonIdentifier.fromProperty(element);
                    if (bsonIdentifier != null) {
                        rows.add(bsonIdentifier);
                    }
                } catch (IOException e) {
                    LOGGER.error("Error converting property to bson identifier", e);
                }
            }
        }

        return rows;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy