+ private void getI18nValues(Binary fileBinary, Attributes attrs)
+ throws IOException {
+ JarInputStream jarIn = null;
+ try {
+ jarIn = new JarInputStream(fileBinary.getStream());
+ String bundleLocalization = null;
+
+ String blKey = Constants.BUNDLE_LOCALIZATION; //"Bundle-Localization";
+ Name blkName = new Name(blKey);
+
+ browse: for (Object obj : attrs.keySet()) {
+ String value = attrs.getValue((Attributes.Name) obj);
+ if (value.startsWith("%")) {
+ if (attrs.containsKey(blkName)) {
+ bundleLocalization = attrs.getValue(blkName);
+ break browse;
+ }
+ }
+ }
+
+ JarEntry jarEntry = null;
+ byte[] propBytes = null;
+ ByteArrayOutputStream baos = null;
+ browse: if (bundleLocalization != null) {
+ JarEntry entry = jarIn.getNextJarEntry();
+ while (entry != null) {
+ if (entry.getName().equals(
+ bundleLocalization + ".properties")) {
+ jarEntry = entry;
+
+ // if(je.getSize() != -1){
+ // propBytes = new byte[(int)je.getSize()];
+ // int len = (int) je.getSize();
+ // int offset = 0;
+ // while (offset != len)
+ // offset += jarIn.read(propBytes, offset, len -
+ // offset);
+ // } else {
+ baos = new ByteArrayOutputStream();
+ while (true) {
+ int qwe = jarIn.read();
+ if (qwe == -1)
+ break;
+ baos.write(qwe);
+ }
+ propBytes = baos.toByteArray();
+ break browse;
+ }
+ entry = jarIn.getNextJarEntry();
+ }
+ }
+
+ if (jarEntry != null) {
+ Properties prop = new Properties();
+ InputStream is = new ByteArrayInputStream(propBytes);
+ prop.load(is);
+
+ for (Object obj : attrs.keySet()) {
+ String value = attrs.getValue((Attributes.Name) obj);
+ if (value.startsWith("%")) {
+ String newVal = prop.getProperty(value.substring(1));
+ if (newVal != null)
+ attrs.put(obj, newVal);
+ }
+ }
+ }
+ } catch (RepositoryException e) {
+ throw new SlcException(
+ "Error while reading the jar binary content " + fileBinary,
+ e);
+ } catch (IOException ioe) {
+ throw new SlcException("unable to get internationalized values",
+ ioe);
+ } finally {
+ IOUtils.closeQuietly(jarIn);
+ }
+ }
+