use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class PoliciesController method addPolicy.
/*********************************
*
* Add Policy Method
*
*********************************/
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/addPolicy", method = RequestMethod.POST)
@ResponseBody
public String addPolicy(@RequestParam("id") String id, @RequestParam("policyName") String policyName, @RequestParam("policyContent") String policyContent, @RequestParam("policyLexicon") String policyLexicon) {
// Debug Statement
if (log.isDebugEnabled()) {
log.debug("Adding New Policy");
}
if (log.isDebugEnabled()) {
log.debug("Beginning to add new policy");
}
try {
URL configURL = new URL("http://localhost:8081/config-service/ConfigurationService");
} catch (MalformedURLException ue) {
}
final CertPolicy newPolicy = new CertPolicy();
newPolicy.setPolicyName(policyName);
// Set policy lexicon type
final String lexiconName = policyLexicon;
if (lexiconName.equalsIgnoreCase("XML")) {
newPolicy.setLexicon(PolicyLexicon.XML);
} else if (lexiconName.equalsIgnoreCase("JAVA_SER")) {
newPolicy.setLexicon(PolicyLexicon.JAVA_SER);
} else if (lexiconName.equalsIgnoreCase("SIMPLE_TEXT_V1")) {
newPolicy.setLexicon(PolicyLexicon.SIMPLE_TEXT_V1);
}
// Get lexicon file from form
//CommonsMultipartFile lexiconFile = policyForm.getFileData();
newPolicy.setPolicyData(policyContent.getBytes());
// Debug
log.error(newPolicy);
try {
policyService.addPolicy(newPolicy);
} catch (ServiceException cse) {
cse.printStackTrace();
}
return "test";
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class SettingsController method removeAnchors.
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/removesettings", method = RequestMethod.POST)
public ModelAndView removeAnchors(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, HttpSession session, @ModelAttribute SimpleForm simpleForm, Model model, @RequestParam(value = "submitType") String actionPath) {
ModelAndView mav = new ModelAndView();
if (log.isDebugEnabled())
log.debug("Enter domain/removesettings");
if (simpleForm.getRemove() != null) {
if (log.isDebugEnabled())
log.debug("the list of checkboxes checked or not is: " + simpleForm.getRemove().toString());
}
String strid = "" + simpleForm.getId();
if (settingsService != null && simpleForm != null && actionPath != null && (actionPath.equalsIgnoreCase("delete") || actionPath.equalsIgnoreCase("remove selected")) && simpleForm.getRemove() != null) {
int cnt = simpleForm.getRemove().size();
try {
Collection<String> settingstoberemovedlist = simpleForm.getRemove();
if (log.isDebugEnabled())
log.debug(" Trying to remove settings from database");
for (String toRemove : settingstoberemovedlist) settingsService.deleteSetting(toRemove);
settingsService.getSettings();
if (log.isDebugEnabled())
log.debug(" SUCCESS Trying to remove settings");
} catch (ServiceException e) {
if (log.isDebugEnabled())
log.error(e);
}
}
try {
model.addAttribute("settingsResults", settingsService.getSettings());
} catch (ServiceException e) {
e.printStackTrace();
}
mav.setViewName("settings");
String action = "Update";
model.addAttribute("settingsForm", new SettingsForm());
model.addAttribute("action", action);
model.addAttribute("ajaxRequest", AjaxUtils.isAjaxRequest(requestedWith));
model.addAttribute("simpleForm", simpleForm);
strid = "" + simpleForm.getId();
return mav;
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class DNSController method addSOASetting.
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/addSOADNSRecord", method = RequestMethod.POST)
public ModelAndView addSOASetting(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, HttpSession session, @ModelAttribute("SoadnsForm") DNSEntryForm SoadnsForm, Model model, @RequestParam(value = "submitType") String actionPath) {
if (log.isDebugEnabled())
log.debug("Enter");
// A records
if (SoadnsForm != null && !SoadnsForm.getName().equalsIgnoreCase("") && SoadnsForm.getTtl() != 0L) {
final DNSRecord rec = DNSEntryForm.entityToModelRecord(DNSRecordUtils.createSOARecord(SoadnsForm.getName(), SoadnsForm.getTtl(), SoadnsForm.getDomain(), SoadnsForm.getAdmin(), (int) SoadnsForm.getSerial(), SoadnsForm.getRefresh(), SoadnsForm.getRetry(), SoadnsForm.getExpire(), SoadnsForm.getMinimum()));
try {
dnsService.addDNSRecord(rec);
} catch (ServiceException e) {
e.printStackTrace();
}
}
final ModelAndView mav = new ModelAndView("dns");
refreshModelFromService(model);
mav.setViewName("dns");
if (log.isDebugEnabled())
log.debug("Exit");
return mav;
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class DNSController method addCertSetting.
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/addCertDNSRecord", method = RequestMethod.POST)
public ModelAndView addCertSetting(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, HttpSession session, @ModelAttribute("CertdnsForm") DNSEntryForm CertdnsForm, Model model, @RequestParam(value = "submitType") String actionPath) {
if (log.isDebugEnabled())
log.debug("Enter");
// CERT records
if (CertdnsForm != null && !CertdnsForm.getName().equalsIgnoreCase("") && CertdnsForm.getTtl() != 0L) {
X509Certificate tcert = null;
byte[] certbytes = null;
try {
if (!CertdnsForm.getFileData().isEmpty()) {
byte[] bytes = CertdnsForm.getFileData().getBytes();
certbytes = bytes;
if (bytes != null) {
// get the owner from the certificate information
// first transform into a certificate
final CertContainer cont = toCertContainer(bytes);
if (cont != null && cont.getCert() != null) {
final Certificate cert2 = new Certificate();
cert2.setData(bytes);
tcert = cont.getCert();
}
}
}
} catch (ConfigurationServiceException ed) {
if (log.isDebugEnabled())
log.error(ed);
} catch (Exception e) {
if (log.isDebugEnabled())
log.error(e.getMessage());
e.printStackTrace();
}
CertdnsForm.setType("CERT");
CertdnsForm.setCertificate(tcert);
CertdnsForm.setCertificateData(certbytes);
try {
dnsService.addDNSRecord(DNSEntryForm.createCertRecord(CertdnsForm));
} catch (ServiceException e) {
e.printStackTrace();
}
}
model.addAttribute("AdnsForm", new DNSEntryForm());
model.addAttribute("AAdnsForm", new DNSEntryForm());
model.addAttribute("CdnsForm", new DNSEntryForm());
model.addAttribute("MXdnsForm", new DNSEntryForm());
model.addAttribute("CertdnsForm", new DNSEntryForm());
model.addAttribute("SrvdnsForm", new DNSEntryForm());
ModelAndView mav = new ModelAndView("dns");
refreshModelFromService(model);
if (log.isDebugEnabled())
log.debug("Exit");
return mav;
}
use of org.nhindirect.common.rest.exceptions.ServiceException in project nhin-d by DirectProject.
the class DNSController method addCNAMESetting.
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "/addCNAMEDNSRecord", method = RequestMethod.POST)
public ModelAndView addCNAMESetting(@RequestHeader(value = "X-Requested-With", required = false) String requestedWith, HttpSession session, @ModelAttribute("CdnsForm") DNSEntryForm CdnsForm, Model model, @RequestParam(value = "submitType") String actionPath) {
if (log.isDebugEnabled())
log.debug("Enter");
// A records
if (CdnsForm != null && !CdnsForm.getName().equalsIgnoreCase("") && CdnsForm.getTtl() != 0L && !CdnsForm.getDest().equalsIgnoreCase("")) {
try {
dnsService.addDNSRecord(DNSEntryForm.toDNSRecord(CdnsForm));
} catch (ServiceException e) {
e.printStackTrace();
}
}
model.addAttribute("AdnsForm", new DNSEntryForm());
model.addAttribute("AAdnsForm", new DNSEntryForm());
model.addAttribute("CdnsForm", new DNSEntryForm());
model.addAttribute("MXdnsForm", new DNSEntryForm());
model.addAttribute("CertdnsForm", new DNSEntryForm());
model.addAttribute("SrvdnsForm", new DNSEntryForm());
ModelAndView mav = new ModelAndView("dns");
refreshModelFromService(model);
if (log.isDebugEnabled())
log.debug("Exit");
return mav;
}
Aggregations