use of org.xdi.model.TrustContact in project oxTrust by GluuFederation.
the class TrustRelationshipWebService method setContacts.
@POST
@Path("/set_contacts/{inum}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "set contacts for TrustRelationship", notes = "Find TrustRelationship by inum and set contacts. Contacts parameter is List<TrustContact>")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Server error") })
public void setContacts(@PathParam("inum") String trustRelationshipInum, String contacts, @Context HttpServletResponse response) {
try {
GluuSAMLTrustRelationship trustRelationship = trustService.getRelationshipByInum(trustRelationshipInum);
List<TrustContact> contactsList = objectMapper.readValue(contacts, new TypeReference<List<TrustContact>>() {
});
trustService.saveContacts(trustRelationship, contactsList);
} catch (Exception e) {
logger.error("setContacts() Exception", e);
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
} catch (Exception ex) {
}
}
}
use of org.xdi.model.TrustContact in project oxTrust by GluuFederation.
the class TrustContactsAction method removeEmptyContacts.
private void removeEmptyContacts() {
TrustContact emptyContact = new TrustContact();
emptyContact.setMail("");
emptyContact.setName("");
emptyContact.setPhone("");
emptyContact.setTitle("");
List<TrustContact> trustContacts = new ArrayList<TrustContact>(contacts);
for (TrustContact contact : trustContacts) {
if (contact.equals(emptyContact)) {
contacts.remove(contact);
}
}
}
use of org.xdi.model.TrustContact in project oxTrust by GluuFederation.
the class TrustService method saveContacts.
public void saveContacts(GluuSAMLTrustRelationship trustRelationship, List<TrustContact> contacts) {
if (contacts != null && !contacts.isEmpty()) {
List<String> gluuTrustContacts = new ArrayList<String>();
for (TrustContact contact : contacts) {
gluuTrustContacts.add(xmlService.getXMLFromTrustContact(contact));
}
trustRelationship.setGluuTrustContact(gluuTrustContacts);
}
}
use of org.xdi.model.TrustContact in project oxTrust by GluuFederation.
the class TrustRelationshipWebService method getContacts.
@GET
@Path("/get_contacts/{inum}")
@Produces(MediaType.TEXT_PLAIN)
public String getContacts(@PathParam("inum") String trustRelationshipInum, @Context HttpServletResponse response) {
try {
GluuSAMLTrustRelationship trustRelationship = trustService.getRelationshipByInum(trustRelationshipInum);
List<TrustContact> list = trustService.getContacts(trustRelationship);
// convert to JSON
return objectMapper.writeValueAsString(list);
} catch (Exception e) {
logger.error("getContacts() Exception", e);
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
} catch (Exception ex) {
}
return OxTrustConstants.RESULT_FAILURE;
}
}
Aggregations