Example usage for org.apache.solr.common.params CollectionAdminParams COLLECTION

List of usage examples for org.apache.solr.common.params CollectionAdminParams COLLECTION

Introduction

In this page you can find the example usage for org.apache.solr.common.params CollectionAdminParams COLLECTION.

Prototype

String COLLECTION

To view the source code for org.apache.solr.common.params CollectionAdminParams COLLECTION.

Click Source Link

Usage

From source file:org.apache.sentry.binding.solr.authz.SolrAuthzUtil.java

License:Apache License

/**
 * This method extracts the {@linkplain org.apache.sentry.core.model.solr.Collection} entities
 * associated with this admin request and return a mapping of entity_name -> expected_auth_action.
 * This is used by Solr/Sentry authorization plugin to further restrict Solr admin operations.
 */// www .j av  a  2s  .c o m
static Map<String, SolrModelAction> getCollectionsForAdminOp(AuthorizationContext ctx) {
    String actionName = ctx.getParams().get(CoreAdminParams.ACTION);
    CollectionAction action = CollectionAction.get(actionName);
    if (action != null) {
        switch (action) {
        case LISTSNAPSHOTS:
        case BACKUP: {
            String name = ctx.getParams().get(CollectionAdminParams.COLLECTION);
            return (name != null) ? Collections.singletonMap(name, SolrModelAction.QUERY)
                    : Collections.emptyMap();
        }

        case MIGRATE: {
            Map<String, SolrModelAction> result = new HashMap<>();
            String source = ctx.getParams().get(CollectionAdminParams.COLLECTION);
            String target = ctx.getParams().get("target." + CollectionAdminParams.COLLECTION);
            if (source != null) {
                result.put(source, SolrModelAction.QUERY);
            }
            if (target != null) {
                result.put(source, SolrModelAction.UPDATE);
            }
            return result;
        }

        case DELETE:
        case DELETEALIAS:
        case CREATESHARD:
        case DELETESHARD:
        case SPLITSHARD:
        case RELOAD:
        case CREATE: {
            String name = ctx.getParams().get(CommonParams.NAME);
            return (name != null) ? Collections.singletonMap(name, SolrModelAction.UPDATE)
                    : Collections.emptyMap();
        }

        case DELETESNAPSHOT:
        case CREATESNAPSHOT:
        case SYNCSHARD:
        case MOVEREPLICA:
        case RESTORE:
        case MIGRATESTATEFORMAT:
        case FORCELEADER:
        case REBALANCELEADERS:
        case BALANCESHARDUNIQUE:
        case ADDREPLICAPROP:
        case DELETEREPLICAPROP:
        case ADDREPLICA:
        case DELETEREPLICA:
        case MODIFYCOLLECTION: {
            String name = ctx.getParams().get(CollectionAdminParams.COLLECTION);
            return (name != null) ? Collections.singletonMap(name, SolrModelAction.UPDATE)
                    : Collections.emptyMap();
        }

        case MOCK_COLL_TASK:
        case MOCK_REPLICA_TASK:
        case MOCK_SHARD_TASK:
        case REPLACENODE:
        case DELETENODE:
        case ADDROLE:
        case REMOVEROLE:
        case CREATEALIAS:
        case REQUESTSTATUS:
        case DELETESTATUS:
        case LIST:
        case LISTALIASES:
        case CLUSTERPROP:
        case OVERSEERSTATUS:
        case CLUSTERSTATUS: {
            return Collections.emptyMap();
        }
        }
    }

    return Collections.emptyMap();
}