예제 #1
0
 public void testGetConfig() {
   ConfigEntity config = getDao().getConfigDao().getConfig();
   assertNull(config.getId());
   config.setEditExt("gif");
   getDao().getConfigDao().save(config);
   config = getDao().getConfigDao().getConfig();
   assertEquals("gif", config.getEditExt());
 }
예제 #2
0
 public void readConfigs(Element configElement) throws DaoTaskException {
   ConfigEntity config = getBusiness().getConfigBusiness().getConfig();
   for (Iterator<Element> i = configElement.elementIterator(); i.hasNext(); ) {
     Element element = i.next();
     if (element.getName().equals("google-analytics")) {
       config.setGoogleAnalyticsId(element.getText());
     }
     if (element.getName().equals("email")) {
       config.setSiteEmail(element.getText());
     }
     if (element.getName().equals("domain")) {
       config.setSiteDomain(element.getText());
     }
     if (element.getName().equals("edit-ext")) {
       config.setEditExt(element.getText());
     }
     if (element.getName().equals("recaptchaPrivateKey")) {
       config.setRecaptchaPrivateKey(element.getText());
     }
     if (element.getName().equals("recaptchaPublicKey")) {
       config.setRecaptchaPublicKey(element.getText());
     }
     if (element.getName().equals("commentsEmail")) {
       config.setCommentsEmail(element.getText());
     }
     if (element.getName().equals("commentsTemplate")) {
       config.setCommentsTemplate(element.getText());
     }
     if (element.getName().equals("languages")) {
       readLanguages(element);
     }
     if (element.getName().equals("enableRecaptcha")) {
       config.setEnableRecaptcha(XmlUtil.readBooleanText(element, false));
     }
     if (element.getName().equals("siteUserLoginUrl")) {
       config.setSiteUserLoginUrl(element.getText());
     }
   }
   getDaoTaskAdapter().configSave(config);
 }
예제 #3
0
 private void createConfigXML(Element configElement) {
   ConfigEntity config = getBusiness().getConfigBusiness().getConfig();
   configElement.addElement("google-analytics").setText(notNull(config.getGoogleAnalyticsId()));
   configElement.addElement("email").setText(notNull(config.getSiteEmail()));
   configElement.addElement("domain").setText(notNull(config.getSiteDomain()));
   configElement.addElement("edit-ext").setText(notNull(config.getEditExt()));
   configElement
       .addElement("recaptchaPrivateKey")
       .setText(notNull(config.getRecaptchaPrivateKey()));
   configElement.addElement("recaptchaPublicKey").setText(notNull(config.getRecaptchaPublicKey()));
   configElement.addElement("commentsEmail").setText(notNull(config.getCommentsEmail()));
   configElement.addElement("commentsTemplate").setText(notNull(config.getCommentsTemplate()));
   configElement.addElement("enableRecaptcha").setText(String.valueOf(config.isEnableRecaptcha()));
   configElement.addElement("version").setText(notNull(config.getVersion()));
   configElement.addElement("siteUserLoginUrl").setText(notNull(config.getSiteUserLoginUrl()));
   createLanguagesXML(configElement);
 }
 private void initConfigs() {
   ConfigEntity config = getBusiness().getConfigBusiness().getConfig();
   if (config.getId() == null || config.getId() == 0) {
     config.setVersion(VERSION);
     config.setGoogleAnalyticsId("");
     config.setSiteEmail("");
     config.setSiteDomain("");
     config.setEditExt("css,js,xml");
     config.setSiteUserLoginUrl("/login");
     config.setCommentsTemplate(loadResource(COMMENTS_TEMPLATE_FILE));
     config.setSessionKey(CipherUtils.generateKey());
     getDao().getConfigDao().save(config);
   }
 }