diff options
| author | Jesse Morgan <jesse@jesterpm.net> | 2016-04-09 14:20:48 -0700 | 
|---|---|---|
| committer | Jesse Morgan <jesse@jesterpm.net> | 2016-04-09 14:20:48 -0700 | 
| commit | bbf907e51dfcf157bdee24dead1d531122aa25db (patch) | |
| tree | 86e8e100046ec3461d8d53e448107cf0145388e2 /src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java | |
| parent | 2e76039d4ecaff8d2ed40b67c309c2498ff4a1d5 (diff) | |
| parent | bddf96d0fdd60faa1905d374eef8a122771f57a3 (diff) | |
Merge pull request #9 from PuyallupFoursquare/ccb-support
Adding support for Church Community Builder
Diffstat (limited to 'src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java')
| -rw-r--r-- | src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java | 61 | 
1 files changed, 61 insertions, 0 deletions
| diff --git a/src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java b/src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java new file mode 100644 index 0000000..fc6148f --- /dev/null +++ b/src/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java @@ -0,0 +1,61 @@ +package com.p4square.grow.ccb; + +import com.codahale.metrics.MetricRegistry; +import com.p4square.ccbapi.CCBAPI; +import com.p4square.ccbapi.CCBAPIClient; +import com.p4square.grow.config.Config; +import com.p4square.grow.frontend.IntegrationDriver; +import com.p4square.grow.frontend.ProgressReporter; +import org.restlet.Context; +import org.restlet.security.Verifier; + +import java.net.URI; +import java.net.URISyntaxException; + +/** + * The ChurchCommunityBuilderIntegrationDriver is used to integrate Grow with Church Community Builder. + */ +public class ChurchCommunityBuilderIntegrationDriver implements IntegrationDriver { + +    private final Context mContext; +    private final MetricRegistry mMetricRegistry; +    private final Config mConfig; + +    private final CCBAPI mAPI; + +    private final CCBProgressReporter mProgressReporter; + +    public ChurchCommunityBuilderIntegrationDriver(final Context context) { +        mContext = context; +        mConfig = (Config) context.getAttributes().get("com.p4square.grow.config"); +        mMetricRegistry = (MetricRegistry) context.getAttributes().get("com.p4square.grow.metrics"); + +        try { +            CCBAPI api = new CCBAPIClient(new URI(mConfig.getString("CCBAPIURL", "")), +                                          mConfig.getString("CCBAPIUser", ""), +                                          mConfig.getString("CCBAPIPassword", "")); + +            if (mMetricRegistry != null) { +                api = new MonitoredCCBAPI(api, mMetricRegistry); +            } + +            mAPI = api; + +            final CustomFieldCache cache = new CustomFieldCache(mAPI); +            mProgressReporter = new CCBProgressReporter(mAPI, cache); + +        } catch (URISyntaxException e) { +            throw new RuntimeException(e); +        } +    } + +    @Override +    public Verifier newUserAuthenticationVerifier() { +        return new CCBUserVerifier(mAPI); +    } + +    @Override +    public ProgressReporter getProgressReporter() { +        return mProgressReporter; +    } +} | 
