Package org.vosao.entity

Examples of org.vosao.entity.ConfigEntity


  public TimeZone getTimeZone() {
    if (getUser() != null
        && !StringUtils.isEmpty(getUser().getTimezone())) {
      return TimeZone.getTimeZone(getUser().getTimezone());
    }
    ConfigEntity config = VosaoContext.getInstance().getConfig();
    if (!StringUtils.isEmpty(config.getDefaultTimezone())) {
      return TimeZone.getTimeZone(config.getDefaultTimezone());
    }
    return TimeZone.getDefault();
  }
View Full Code Here


  public static final String COMMENTS_TEMPLATE_FILE =
      "org/vosao/resources/html/comments.html";
 
  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));
          getDao().getConfigDao().save(config);
    }
  }
View Full Code Here

import org.vosao.entity.ConfigEntity;

public class ConfigDaoTest extends AbstractDaoTest {

  public void testGetConfig() {
    ConfigEntity config = getDao().getConfigDao().getConfig();
    assertNull(config.getId());
    config.setEditExt("gif");
    config.setAttribute("host", "test");
    getDao().getConfigDao().save(config);
    config = getDao().getConfigDao().getConfig();
    assertEquals("gif", config.getEditExt());   
    assertEquals("test", config.getAttribute("host"));   
  }
View Full Code Here

public class GoogleAnalyticsFragment implements ContentFragment {

  @Override
  public String get(Business business, PageEntity page) {
    ConfigEntity config = business.getConfigBusiness().getConfig();
    if (!StringUtils.isEmpty(config.getGoogleAnalyticsId())) {
      String id = config.getGoogleAnalyticsId();
      return getGoogleAnalyticsCode(id);
    }
    return "";
  }
View Full Code Here

public class JavaScriptFragment  implements ContentFragment {

  @Override
  public String get(Business business, PageEntity page) {
    ConfigEntity config = VosaoContext.getInstance().getConfig();
    StringBuffer code = new StringBuffer(
        "<script src=\"/static/js/jquery.js\" type=\"text/javascript\"></script>\n"
        //"<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\" type=\"text/javascript\"></script>\n"
        "<script src=\"/static/js/jquery.form.js\" type=\"text/javascript\"></script>\n"
            "<script src=\"/static/js/jsonrpc.js\" type=\"text/javascript\"></script>\n"
            "<script src=\"/static/js/vosao.js\" type=\"text/javascript\"></script>\n");
    if (config.isEnableRecaptcha()) {
            code.append("<script src=\"http://api.recaptcha.net/js/recaptcha_ajax.js\" type=\"text/javascript\" ></script>\n");
    }
    if (VosaoContext.getInstance().getUser() != null) {
      code.append("<script src=\"/static/js/jquery.cookie.js\" type=\"text/javascript\"></script>\n");
    }
View Full Code Here

    return page;
  }
 
  private void readContents(Element pageElement, PageEntity page)
      throws DaoTaskException {
    ConfigEntity config = VosaoContext.getInstance().getConfig();
    for (Iterator<Element> i = pageElement.elementIterator(); i.hasNext();) {
      Element element = i.next();
      if (element.getName().equals("content")) {
        String content = element.getText();
        String language = element.attributeValue("language");
        if (language == null) {
          language = config.getDefaultLanguage();
        }
        getDaoTaskAdapter().setPageContent(page.getId(), language,
            content);
      }
    }
View Full Code Here

    createConfigXML(configElement);
    return doc.asXML();
  }   
 
  private void createConfigXML(Element configElement) {
    ConfigEntity config = 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()));
    configElement.addElement("enableCkeditor").setText(
        String.valueOf(config.isEnableCkeditor()));
    configElement.addElement("attributes").setText(notNull(
        config.getAttributesJSON()));
    configElement.addElement("defaultTimezone").setText(notNull(
        config.getDefaultTimezone()));
    configElement.addElement("defaultLanguage").setText(notNull(
        config.getDefaultLanguage()));
    configElement.addElement("site404Url").setText(notNull(
        config.getSite404Url()));
    createLanguagesXML(configElement);
  }
View Full Code Here

      langElem.addAttribute("title", lang.getTitle());
    }
  }
 
  public void readConfigs(Element configElement) throws DaoTaskException {
    ConfigEntity config = 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("attributes")) {
              config.setAttributesJSON(element.getText());
            }
            if (element.getName().equals("enableRecaptcha")) {
              config.setEnableRecaptcha(XmlUtil.readBooleanText(
                  element, false));
            }
            if (element.getName().equals("siteUserLoginUrl")) {
              config.setSiteUserLoginUrl(element.getText());
            }
            if (element.getName().equals("enableCkeditor")) {
              config.setEnableCkeditor(XmlUtil.readBooleanText(
                  element, false));
            }
            if (element.getName().equals("defaultTimezone")) {
              config.setDefaultTimezone(element.getText());
            }
            if (element.getName().equals("defaultLanguage")) {
              config.setDefaultLanguage(element.getText());
            }
            if (element.getName().equals("site404Url")) {
              config.setSite404Url(element.getText());
            }
    }
    getDaoTaskAdapter().configSave(config);
  }
View Full Code Here

 
  @Override
  public void configSave(ConfigEntity entity) throws DaoTaskException {
    if (isSkip()) {
      if (entity.getId() == null) {
        ConfigEntity config = VosaoContext.getInstance().getConfig();
        entity.setId(config.getId());
      }
    }
    else {
      getDao().getConfigDao().save(entity);
    }
View Full Code Here

    return getBusiness().getConfigBusiness().getConfig();
  }

  @Override
  public ServiceResponse saveConfig(Map<String, String> vo) {
    ConfigEntity config = getBusiness().getConfigBusiness().getConfig();
    if (vo.get("commentsEmail") != null) {
      config.setCommentsEmail(vo.get("commentsEmail"));
    }
    if (vo.get("commentsTemplate") != null) {
      config.setCommentsTemplate(vo.get("commentsTemplate"));
    }
    if (vo.get("editExt") != null) {
      config.setEditExt(vo.get("editExt"));
    }
    if (vo.get("googleAnalyticsId") != null) {
      config.setGoogleAnalyticsId(vo.get("googleAnalyticsId"));
    }
    if (vo.get("enableRecaptcha") != null) {
      config.setEnableRecaptcha(Boolean.valueOf(vo.get("enableRecaptcha")));
    }
    if (vo.get("recaptchaPrivateKey") != null) {
      config.setRecaptchaPrivateKey(vo.get("recaptchaPrivateKey"));
    }
    if (vo.get("recaptchaPublicKey") != null) {
      config.setRecaptchaPublicKey(vo.get("recaptchaPublicKey"));
    }
    if (vo.get("siteDomain") != null) {
      config.setSiteDomain(vo.get("siteDomain"));
    }
    if (vo.get("siteEmail") != null) {
      config.setSiteEmail(vo.get("siteEmail"));
    }
    if (vo.get("siteUserLoginUrl") != null) {
      config.setSiteUserLoginUrl(vo.get("siteUserLoginUrl"));
    }
    if (vo.get("site404Url") != null) {
      config.setSite404Url(vo.get("site404Url"));
    }
    if (vo.get("enablePicasa") != null) {
      config.setEnablePicasa(Boolean.valueOf(vo.get("enablePicasa")));
    }
    if (vo.get("picasaUser") != null) {
      config.setPicasaUser(vo.get("picasaUser"));
    }
    if (vo.get("picasaPassword") != null) {
      config.setPicasaPassword(vo.get("picasaPassword"));
    }
    if (vo.get("enableCkeditor") != null) {
      config.setEnableCkeditor(Boolean.valueOf(vo.get("enableCkeditor")));
    }
    if (vo.get("defaultTimezone") != null) {
      config.setDefaultTimezone(vo.get("defaultTimezone"));
    }
    if (vo.get("defaultLanguage") != null) {
      config.setDefaultLanguage(vo.get("defaultLanguage"));
    }
    List<String> errors = getBusiness().getConfigBusiness()
        .validateBeforeUpdate(config);
    if (errors.isEmpty()) {
      getDao().getConfigDao().save(config);
View Full Code Here

TOP

Related Classes of org.vosao.entity.ConfigEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.