Package com.aaspring.util.file

Examples of com.aaspring.util.file.FileAccessor


    BaseSettings bs = ls.getBaseSettings();
    for (BasePath bp : bs.getBasePath()) {
      basePaths.put(bp.getId(), bp);
    }

    FileAccessor fac = new FileAccessorContainer();

    for (LanguageFile lf : ls.getLanguageFiles().getLanguageFile()) {
      Path path = lf.getPath();
      String basePathId = path.getBasePathId();
      Map<String, String> propsOfPath = getPropertiesOfPath(path,
          basePaths.get(basePathId));
      for (Locale locale : locales) {
        for (Locale currentLocale : getLocaleWithParents(locale)) {
          try {
            fac.addFile(new FileAccessorProperties(propsOfPath,
                path.getType(), currentLocale));
          } catch (InvalidStateException e) {
            throw new RuntimeException("Should never happen", e);
          }
        }
View Full Code Here


    BaseSettings bs = ls.getBaseSettings();
    for (BasePath bp : bs.getBasePath()) {
      basePaths.put(bp.getId(), bp);
    }

    FileAccessor fac = new FileAccessorContainer();

    for (String field : fieldKeyLocaleValueMap.keySet()) {

      LanguageFile lf = lfById.get(field);
      Path path = lf.getPath();
      String basePathId = path.getBasePathId();
      Map<String, String> propsOfPath = getPropertiesOfPath(path,
          basePaths.get(basePathId));
      for (Locale targetLocale : localeMapping.values()) {
        try {
          fac.addFile(new FileAccessorProperties(propsOfPath, path
              .getType(), targetLocale));
        } catch (InvalidStateException e) {
          // Should never happen
          e.printStackTrace();
        }
      }
    }

    Map<FileAccessorProperties, OutputStream> outStreamMap = fac
        .getOutputStreams();
    for (String field : fieldKeyLocaleValueMap.keySet()) {
      LanguageFile lf = lfById.get(field);
      Path path = lf.getPath();
      String basePathId = path.getBasePathId();
      Map<String, String> propsOfPath = getPropertiesOfPath(path,
          basePaths.get(basePathId));
      Map<Locale, Map<String, String>> localeKeyValueMap = fieldKeyLocaleValueMap
          .get(field);
      for (Locale sourceLocale : localeMapping.keySet()) {
        Map<String, String> keyValueMap = localeKeyValueMap
            .get(sourceLocale);
        FileAccessorProperties fap = new FileAccessorProperties(
            propsOfPath, path.getType(), localeMapping
                .get(sourceLocale));

        Bundle bundle = BundleFactory.createEmptyBundle(
            new BundleProps(fap), lf.getType().value());
        for (String key : keyValueMap.keySet()) {
          bundle.setValue(key, keyValueMap.get(key));
        }
        try {
          bundle.exportCurrent(outStreamMap.get(fap));
        } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
    try {
      fac.closeAndSetStatus2Modifiable();
    } catch (InvalidStateException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
View Full Code Here

TOP

Related Classes of com.aaspring.util.file.FileAccessor

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.