This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
412 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...sample.app/src/main/java/com/ibm/sbt/provisioning/sample/app/services/GRTESubscriber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* © Copyright IBM Corp. 2014 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
package com.ibm.sbt.provisioning.sample.app.services; | ||
|
||
import com.ibm.sbt.provisioning.sample.app.task.BSSProvisioning; | ||
/** | ||
* This class represents a singleton that encapsulate an instance of | ||
* the class <code>com.ibm.sbt.services.client.smartcloud.bss.GRTESubscriberManagementService</code> | ||
* */ | ||
|
||
|
||
//TODO Temp class Subscriber can be used when rest of code moved to SocialSDK | ||
public class GRTESubscriber { | ||
|
||
private static GRTESubscriber instance = null; | ||
private GRTESubscriberManagementService service; | ||
|
||
private GRTESubscriber() { | ||
this.service = new GRTESubscriberManagementService(BSSProvisioning.getBasicEndpoint()); | ||
} | ||
|
||
public static synchronized GRTESubscriber getInstance() { | ||
if (instance == null) | ||
instance = new GRTESubscriber(); | ||
return instance; | ||
} | ||
|
||
public GRTESubscriberManagementService getService() { | ||
return service; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...in/java/com/ibm/sbt/provisioning/sample/app/services/GRTESubscriberManagementService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.ibm.sbt.provisioning.sample.app.services; | ||
|
||
import java.io.IOException; | ||
|
||
import com.ibm.commons.util.io.json.JsonException; | ||
import com.ibm.commons.util.io.json.JsonJavaFactory; | ||
import com.ibm.commons.util.io.json.JsonJavaObject; | ||
import com.ibm.commons.util.io.json.JsonParser; | ||
import com.ibm.sbt.services.client.ClientService; | ||
import com.ibm.sbt.services.client.Response; | ||
import com.ibm.sbt.services.client.smartcloud.bss.BssException; | ||
import com.ibm.sbt.services.client.smartcloud.bss.SubscriberJsonBuilder; | ||
import com.ibm.sbt.services.client.smartcloud.bss.SubscriberManagementService; | ||
import com.ibm.sbt.services.endpoints.Endpoint; | ||
|
||
// TODO Move to SubscriberManagementService when code can be merged to SocialSDK | ||
|
||
|
||
public class GRTESubscriberManagementService extends | ||
SubscriberManagementService { | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param endpointName | ||
*/ | ||
public GRTESubscriberManagementService(Endpoint endpoint) { | ||
super(endpoint); | ||
} | ||
|
||
private static final long serialVersionUID = 2L; | ||
|
||
/** | ||
* Add a subscriber w/ suppressing emails either to the vendor's organization or to the organization of one of the vendor's customers. | ||
* | ||
* @param subscriber | ||
* @return {JsonJavaObject} | ||
* @throws BssException | ||
* @throws JsonException | ||
* @throws IOException | ||
*/ | ||
public JsonJavaObject addSubscriberSuppressEmail(SubscriberJsonBuilder subscriber) throws BssException, IOException, JsonException { | ||
return addSubscriberSuppressEmail(subscriber.toJson()); | ||
} | ||
|
||
/** | ||
* Add a subscriber w/ suppressing emails either to the vendor's organization or to the organization of one of the vendor's customers. | ||
* | ||
* @param subscriberJson | ||
* @return {JsonJavaObject} | ||
* @throws BssException | ||
* @throws JsonException | ||
* @throws IOException | ||
*/ | ||
public JsonJavaObject addSubscriberSuppressEmail(String subscriberJson) throws BssException, JsonException, IOException { | ||
JsonJavaObject jsonObject = (JsonJavaObject)JsonParser.fromJson(JsonJavaFactory.instanceEx, subscriberJson); | ||
return addSubscriberSuppressEmail(jsonObject); | ||
} | ||
|
||
/** | ||
* Add a subscriber w/ suppressing emails either to the vendor's organization or to the organization of one of the vendor's customers. | ||
* | ||
* @param subscriberJson | ||
* @return JSON object containing | ||
* @throws BssException | ||
* @throws IOException | ||
*/ | ||
public JsonJavaObject addSubscriberSuppressEmail(JsonJavaObject subscriberJson) throws BssException { | ||
try { | ||
// TODO add url to BSSUrls when moving to SocialSDK | ||
String serviceUrl = "/api/bss/resource/subscriber?suppressEmail=true"; | ||
Response serverResponse = createData(serviceUrl, null, JsonHeader, subscriberJson, ClientService.FORMAT_JSON); | ||
return (serverResponse == null) ? null : (JsonJavaObject)serverResponse.getData(); | ||
} catch (Exception e) { | ||
throw new BssException(e, "Error adding subscriber {0} caused by {1}", subscriberJson, e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.