Skip to content

Commit 5ec63c2

Browse files
authored
DT-1143: Passthrough APIs for support requests and content uploads (#2448)
1 parent aef01da commit 5ec63c2

24 files changed

+402
-143
lines changed

src/main/java/org/broadinstitute/consent/http/ConsentApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import org.broadinstitute.consent.http.resources.SchemaResource;
7272
import org.broadinstitute.consent.http.resources.StatusResource;
7373
import org.broadinstitute.consent.http.resources.StudyResource;
74+
import org.broadinstitute.consent.http.resources.SupportResource;
7475
import org.broadinstitute.consent.http.resources.SwaggerResource;
7576
import org.broadinstitute.consent.http.resources.TDRResource;
7677
import org.broadinstitute.consent.http.resources.TosResource;
@@ -232,6 +233,7 @@ public void run(ConsentConfiguration config, Environment env) {
232233
env.jersey().register(new SchemaResource());
233234
env.jersey().register(new SwaggerResource(config.getGoogleAuthentication()));
234235
env.jersey().register(new StatusResource(env.healthChecks()));
236+
env.jersey().register(injector.getInstance(SupportResource.class));
235237
env.jersey().register(
236238
new UserResource(samService, userService, datasetService, acknowledgementService));
237239
env.jersey().register(new TosResource(samService));

src/main/java/org/broadinstitute/consent/http/enumeration/SupportRequestType.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
public enum SupportRequestType {
44

5-
QUESTION("question"), INCIDENT("incident"), PROBLEM("problem"), TASK("task");
5+
QUESTION, BUG, FEATURE_REQUEST, TASK
66

7-
private final String value;
8-
9-
SupportRequestType(String value) {
10-
this.value = value;
11-
}
12-
13-
public String getValue() {
14-
return value;
15-
}
167
}

src/main/java/org/broadinstitute/consent/http/filters/ClaimsCache.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ public class ClaimsCache {
1818

1919
private static ClaimsCache INSTANCE;
2020
public final Cache<String, Map<String, String>> cache;
21-
public final static String OAUTH2_CLAIM_email = "OAUTH2_CLAIM_email";
22-
public final static String OAUTH2_CLAIM_name = "OAUTH2_CLAIM_name";
23-
public final static String OAUTH2_CLAIM_access_token = "OAUTH2_CLAIM_access_token";
24-
public final static String OAUTH2_CLAIM_aud = "OAUTH2_CLAIM_aud";
21+
public static final String OAUTH2_CLAIM_email = "OAUTH2_CLAIM_email";
22+
public static final String OAUTH2_CLAIM_name = "OAUTH2_CLAIM_name";
23+
public static final String OAUTH2_CLAIM_access_token = "OAUTH2_CLAIM_access_token";
24+
public static final String OAUTH2_CLAIM_aud = "OAUTH2_CLAIM_aud";
2525

2626
private ClaimsCache() {
2727
cache = CacheBuilder

src/main/java/org/broadinstitute/consent/http/mail/message/DisabledDatasetMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
public class DisabledDatasetMessage extends MailMessage {
77

8-
private final static String MISSING_DATASET = "Datasets not available for Data Access Request Application id: %s.";
8+
private static final String MISSING_DATASET = "Datasets not available for Data Access Request Application id: %s.";
99

1010
public Mail disabledDatasetMessage(String toAddress, String fromAddress, Writer template,
1111
String referenceId, String type) {

src/main/java/org/broadinstitute/consent/http/models/dataset_registration_v1/AlternativeDataSharingPlanReason.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public enum AlternativeDataSharingPlanReason {
2121
OTHER_INFORMED_CONSENT_LIMITATIONS_OR_CONCERNS("Other informed consent limitations or concerns"),
2222
OTHER("Other");
2323
private final String value;
24-
private final static Map<String, AlternativeDataSharingPlanReason> CONSTANTS = new HashMap<String, AlternativeDataSharingPlanReason>();
24+
private static final Map<String, AlternativeDataSharingPlanReason> CONSTANTS = new HashMap<String, AlternativeDataSharingPlanReason>();
2525

2626
static {
2727
for (AlternativeDataSharingPlanReason c : values()) {

src/main/java/org/broadinstitute/consent/http/models/dataset_registration_v1/ConsentGroup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ public enum DataLocation {
775775
TDR_LOCATION("TDR Location"),
776776
NOT_DETERMINED("Not Determined");
777777
private final String value;
778-
private final static Map<String, ConsentGroup.DataLocation> CONSTANTS = new HashMap<String, ConsentGroup.DataLocation>();
778+
private static final Map<String, ConsentGroup.DataLocation> CONSTANTS = new HashMap<String, ConsentGroup.DataLocation>();
779779

780780
static {
781781
for (ConsentGroup.DataLocation c : values()) {
@@ -817,7 +817,7 @@ public enum AccessManagement {
817817
CONTROLLED("controlled"),
818818
EXTERNAL("external");
819819
private final String value;
820-
private final static Map<String, ConsentGroup.AccessManagement> CONSTANTS = new HashMap<String, ConsentGroup.AccessManagement>();
820+
private static final Map<String, ConsentGroup.AccessManagement> CONSTANTS = new HashMap<String, ConsentGroup.AccessManagement>();
821821

822822
static {
823823
for (ConsentGroup.AccessManagement c : values()) {

src/main/java/org/broadinstitute/consent/http/models/dataset_registration_v1/DatasetRegistrationSchemaV1.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ public enum AlternativeDataSharingPlanAccessManagement {
12731273
OPEN_ACCESS("Open Access"),
12741274
EXTERNAL_ACCESS("External Access");
12751275
private final String value;
1276-
private final static Map<String, DatasetRegistrationSchemaV1.AlternativeDataSharingPlanAccessManagement> CONSTANTS = new HashMap<String, DatasetRegistrationSchemaV1.AlternativeDataSharingPlanAccessManagement>();
1276+
private static final Map<String, DatasetRegistrationSchemaV1.AlternativeDataSharingPlanAccessManagement> CONSTANTS = new HashMap<String, DatasetRegistrationSchemaV1.AlternativeDataSharingPlanAccessManagement>();
12771277

12781278
static {
12791279
for (DatasetRegistrationSchemaV1.AlternativeDataSharingPlanAccessManagement c : values()) {
@@ -1320,7 +1320,7 @@ public enum AlternativeDataSharingPlanDataSubmitted {
13201320
BY_BATCHES_OVER_STUDY_TIMELINE_E_G_BASED_ON_CLINICAL_TRIAL_ENROLLMENT_BENCHMARKS(
13211321
"By batches over Study Timeline (e.g. based on clinical trial enrollment benchmarks)");
13221322
private final String value;
1323-
private final static Map<String, DatasetRegistrationSchemaV1.AlternativeDataSharingPlanDataSubmitted> CONSTANTS = new HashMap<String, DatasetRegistrationSchemaV1.AlternativeDataSharingPlanDataSubmitted>();
1323+
private static final Map<String, DatasetRegistrationSchemaV1.AlternativeDataSharingPlanDataSubmitted> CONSTANTS = new HashMap<String, DatasetRegistrationSchemaV1.AlternativeDataSharingPlanDataSubmitted>();
13241324

13251325
static {
13261326
for (DatasetRegistrationSchemaV1.AlternativeDataSharingPlanDataSubmitted c : values()) {
@@ -1371,7 +1371,7 @@ public enum NihAnvilUse {
13711371
I_AM_NOT_NHGRI_FUNDED_AND_DO_NOT_PLAN_TO_STORE_DATA_IN_AN_VIL(
13721372
"I am not NHGRI funded and do not plan to store data in AnVIL");
13731373
private final String value;
1374-
private final static Map<String, DatasetRegistrationSchemaV1.NihAnvilUse> CONSTANTS = new HashMap<String, DatasetRegistrationSchemaV1.NihAnvilUse>();
1374+
private static final Map<String, DatasetRegistrationSchemaV1.NihAnvilUse> CONSTANTS = new HashMap<String, DatasetRegistrationSchemaV1.NihAnvilUse>();
13751375

13761376
static {
13771377
for (DatasetRegistrationSchemaV1.NihAnvilUse c : values()) {
@@ -1439,7 +1439,7 @@ public enum NihInstitutionCenterSubmission {
14391439
NCATS("NCATS"),
14401440
NCCIH("NCCIH");
14411441
private final String value;
1442-
private final static Map<String, DatasetRegistrationSchemaV1.NihInstitutionCenterSubmission> CONSTANTS = new HashMap<String, DatasetRegistrationSchemaV1.NihInstitutionCenterSubmission>();
1442+
private static final Map<String, DatasetRegistrationSchemaV1.NihInstitutionCenterSubmission> CONSTANTS = new HashMap<String, DatasetRegistrationSchemaV1.NihInstitutionCenterSubmission>();
14431443

14441444
static {
14451445
for (DatasetRegistrationSchemaV1.NihInstitutionCenterSubmission c : values()) {
@@ -1491,7 +1491,7 @@ public enum StudyType {
14911491
CROSS_SECTIONAL("Cross-sectional"),
14921492
COHORT_STUDY("Cohort study");
14931493
private final String value;
1494-
private final static Map<String, DatasetRegistrationSchemaV1.StudyType> CONSTANTS = new HashMap<String, DatasetRegistrationSchemaV1.StudyType>();
1494+
private static final Map<String, DatasetRegistrationSchemaV1.StudyType> CONSTANTS = new HashMap<String, DatasetRegistrationSchemaV1.StudyType>();
14951495

14961496
static {
14971497
for (DatasetRegistrationSchemaV1.StudyType c : values()) {

src/main/java/org/broadinstitute/consent/http/models/dataset_registration_v1/FileTypeObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public enum FileType {
118118
SURVEY("Survey"),
119119
PHENOTYPE("Phenotype");
120120
private final String value;
121-
private final static Map<String, FileTypeObject.FileType> CONSTANTS = new HashMap<String, FileTypeObject.FileType>();
121+
private static final Map<String, FileTypeObject.FileType> CONSTANTS = new HashMap<String, FileTypeObject.FileType>();
122122

123123
static {
124124
for (FileTypeObject.FileType c : values()) {

src/main/java/org/broadinstitute/consent/http/models/dataset_registration_v1/NihICsSupportingStudy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public enum NihICsSupportingStudy {
3535
NCATS("NCATS"),
3636
NCCIH("NCCIH");
3737
private final String value;
38-
private final static Map<String, NihICsSupportingStudy> CONSTANTS = new HashMap<String, NihICsSupportingStudy>();
38+
private static final Map<String, NihICsSupportingStudy> CONSTANTS = new HashMap<String, NihICsSupportingStudy>();
3939

4040
static {
4141
for (NihICsSupportingStudy c : values()) {

src/main/java/org/broadinstitute/consent/http/models/support/TicketFactory.java

Lines changed: 5 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
import com.google.gson.Gson;
44
import com.google.gson.JsonObject;
5-
import java.util.List;
6-
import org.broadinstitute.consent.http.enumeration.SupportRequestType;
75
import org.broadinstitute.consent.http.util.gson.GsonUtil;
8-
import org.zendesk.client.v2.model.Comment;
9-
import org.zendesk.client.v2.model.CustomFieldValue;
106
import org.zendesk.client.v2.model.Request;
117
import org.zendesk.client.v2.model.Ticket;
128

@@ -18,7 +14,7 @@ public class TicketFactory {
1814
* @param response The response content from the Zendesk Request API
1915
* @return Parsed request.
2016
*/
21-
public Request parseRequestResponse(String response) {
17+
public static Request parseRequestResponse(String response) {
2218
Gson gson = GsonUtil.getInstance();
2319
JsonObject obj = gson.fromJson(response, JsonObject.class);
2420
JsonObject request = obj.get("request").getAsJsonObject();
@@ -28,68 +24,12 @@ public Request parseRequestResponse(String response) {
2824
/**
2925
* Constructs a DuosTicket with the proper structure to request support via Zendesk
3026
*
31-
* @param name The name of the user requesting support
32-
* @param type The type of request ("question", "incident", "problem", "task")
33-
* @param email The email of the user requesting support
34-
* @param subject Subject line of the request
35-
* @param description Description of the task or question
36-
* @param url The origin url of this request
37-
* @param uploads Optional list of attachment tokens
27+
* @param ticketFields TicketFields
3828
*/
39-
public DuosTicket createTicket(String name, SupportRequestType type, String email, String subject,
40-
String description, String url, List<String> uploads) {
41-
if (name == null || email == null) {
42-
throw new IllegalArgumentException("Name and email of user requesting support is required");
43-
}
44-
if (subject == null) {
45-
throw new IllegalArgumentException("Support ticket subject is required");
46-
}
47-
if (description == null) {
48-
throw new IllegalArgumentException("Support ticket description is required");
49-
}
50-
if (type == null) {
51-
throw new IllegalArgumentException("Support ticket type is required");
52-
}
53-
if (url == null) {
54-
throw new IllegalArgumentException("Support ticket url is required");
55-
}
56-
57-
Ticket ticket = new Ticket(
58-
new Ticket.Requester(name, email),
59-
subject,
60-
createComment(description, url, uploads));
61-
ticket.setCustomFields(createCustomFields(name, type, email, description));
62-
// This value specifies tickets as belonging to the DUOS group defined in Zendesk
63-
ticket.setTicketFormId(360000669472L);
29+
public static DuosTicket createTicket(TicketFields ticketFields) {
30+
ticketFields.validate();
31+
Ticket ticket = ticketFields.toTicket();
6432
return new DuosTicket(ticket);
6533
}
6634

67-
static private Comment createComment(String description, String url, List<String> uploads) {
68-
Comment comment = new Comment();
69-
comment.setBody(description + "\n\n------------------\nSubmitted from: " + url);
70-
if (uploads != null && !uploads.isEmpty()) {
71-
comment.setUploads(uploads);
72-
}
73-
return comment;
74-
}
75-
76-
/**
77-
* Custom fields represent a Zendesk ID that corresponds to a component of the created ticket.
78-
* These fields have IDs that are defined in the Zendesk administrative interface.
79-
*
80-
* @param name Name of user
81-
* @param type SupportRequestType Type of request, i.e. Question, Incident, etc.
82-
* @param email User's email address
83-
* @param description The contents of the support request
84-
* @return List of Custom Fields that are required by Zendesk
85-
*/
86-
static private List<CustomFieldValue> createCustomFields(String name, SupportRequestType type,
87-
String email, String description) {
88-
return List.of(new CustomFieldValue(360012744452L, new String[]{type.getValue()}),
89-
new CustomFieldValue(360007369412L, new String[]{description}),
90-
new CustomFieldValue(360012744292L, new String[]{name}),
91-
new CustomFieldValue(360012782111L, new String[]{email}),
92-
new CustomFieldValue(360018545031L, new String[]{email}));
93-
}
94-
9535
}

0 commit comments

Comments
 (0)