Search in sources :

Example 1 with LabelExtractor

use of org.wso2.carbon.apimgt.core.api.LabelExtractor in project carbon-apimgt by wso2.

the class APIStoreImpl method getLabelInfo.

@Override
public List<Label> getLabelInfo(List<String> labels, String username) throws LabelException {
    List<Label> filteredLabels;
    String labelExtractorClassName = getConfig().getLabelExtractorImplClass();
    try {
        List<Label> availableLabels = getLabelDAO().getLabelsByName(labels);
        LabelExtractor labelExtractor = (LabelExtractor) Class.forName(labelExtractorClassName).newInstance();
        filteredLabels = labelExtractor.filterLabels(username, availableLabels);
    } catch (APIMgtDAOException e) {
        String errorMsg = "Error occurred while retrieving label information";
        log.error(errorMsg, e);
        throw new LabelException(errorMsg, e, ExceptionCodes.LABEL_EXCEPTION);
    } catch (ClassNotFoundException e) {
        String errorMsg = "Error occurred while loading the class [class name] " + labelExtractorClassName;
        log.error(errorMsg, e);
        throw new LabelException(errorMsg, e, ExceptionCodes.LABEL_EXCEPTION);
    } catch (IllegalAccessException | InstantiationException e) {
        String errorMsg = "Error occurred while creating an instance of the class [class name] " + labelExtractorClassName;
        log.error(errorMsg, e);
        throw new LabelException(errorMsg, e, ExceptionCodes.LABEL_EXCEPTION);
    }
    return filteredLabels;
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) LabelExtractor(org.wso2.carbon.apimgt.core.api.LabelExtractor) Label(org.wso2.carbon.apimgt.core.models.Label) LabelException(org.wso2.carbon.apimgt.core.exception.LabelException)

Aggregations

LabelExtractor (org.wso2.carbon.apimgt.core.api.LabelExtractor)1 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)1 LabelException (org.wso2.carbon.apimgt.core.exception.LabelException)1 Label (org.wso2.carbon.apimgt.core.models.Label)1