@Inject
protected ConnectorConnectionPool[] ccPools;
@Override
public void execute(AdminCommandContext context) {
ActionReporter report = (ActionReporter) context.getActionReport();
SecurityMap map = getSpecifiedSecurityMapForPool(ccPools, poolName, mapName);
if (map == null) {
report.setMessage(localStrings.getLocalString("create.principal.invalid.map",
"A security map named {0} could not be found for connector connection pool {1}. Please check the" +
" map and pool names.", mapName, poolName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
try {
ConfigSupport.apply(new SingleConfigCode<SecurityMap>() {
@Override
public Object run(SecurityMap map) throws PropertyVetoException, TransactionFailure {
if (principals != null) {
for (String p : principals) {
map.getPrincipal().add(p);
}
}
return "";
}
}, map);
} catch (TransactionFailure tfe) {
Object params[] = {mapName, poolName};
report.setMessage(localStrings.getLocalString("create.connector.security.map.fail",
"Unable to create connector security map {0} for connector connection pool {1} ", params) +
" " + tfe.getLocalizedMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(tfe);
return;
}
report.setActionExitCode(ExitCode.SUCCESS);
}