Package org.osgi.impl.bundle.obr.resource

Examples of org.osgi.impl.bundle.obr.resource.Tag


        String s2 = getName((ResourceImpl) r2);
        return s1.compareTo(s2);
      }
    });

    Tag tag = doIndex(sorted);
    if (repositoryFileName != null) {
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      PrintWriter pw = new PrintWriter(new OutputStreamWriter(out,
          "UTF-8"));

      pw.println("<?xml version='1.0' encoding='utf-8'?>");
      pw
          .println("<?xml-stylesheet type='text/xsl' href='http://www2.osgi.org/www/obr2html.xsl'?>");

      tag.print(0, pw);
      pw.close();
      byte buffer[] = out.toByteArray();
      String name = "repository.xml";
      FileOutputStream fout = new FileOutputStream(repositoryFileName);

      if (repositoryFileName.endsWith(".zip")) {
        ZipOutputStream zip = new ZipOutputStream(fout);
        CRC32 checksum = new CRC32();
        checksum.update(buffer);
        ZipEntry ze = new ZipEntry(name);
        ze.setSize(buffer.length);
        ze.setCrc(checksum.getValue());
        zip.putNextEntry(ze);
        zip.write(buffer, 0, buffer.length);
        zip.closeEntry();
        zip.close();
      }
      else {
        fout.write(buffer);
      }
      fout.close();
    }

    if (!quiet) {
      PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
      pw.println("<?xml version='1.0' encoding='utf-8'?>");
      pw
          .println("<?xml-stylesheet type='text/xsl' href='http://www2.osgi.org/www/obr2html.xsl'?>");
      tag.print(0, pw);
      pw.close();
    }
  }
View Full Code Here


   * @param resources Set of resources
   * @param collected The output zip file
   * @throws java.io.IOException
   */
  static Tag doIndex(Collection resources) throws IOException {
    Tag repository = new Tag("repository");
    repository.addAttribute("lastmodified", new Date());
    repository.addAttribute("name", name);

    for (Iterator i = resources.iterator(); i.hasNext();) {
      ResourceImpl resource = (ResourceImpl) i.next();
      repository.addContent(resource.toXML());
    }
    return repository;
  }
View Full Code Here

                String s2 = getName(r2);
                return s1.compareTo(s2);
            }
        });

        Tag tag = doIndex(sorted);
        if (repositoryFileName != null) {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            PrintWriter pw = new PrintWriter(new OutputStreamWriter(out,
                "UTF-8"));

            pw.println("<?xml version='1.0' encoding='utf-8'?>");
            pw
                .println("<?xml-stylesheet type='text/xsl' href='http://www2.osgi.org/www/obr2html.xsl'?>");

            tag.print(0, pw);
            pw.close();
            byte buffer[] = out.toByteArray();
            String name = "repository.xml";
            FileOutputStream fout = new FileOutputStream(repositoryFileName);

            if (repositoryFileName.endsWith(".zip")) {
                ZipOutputStream zip = new ZipOutputStream(fout);
                CRC32 checksum = new CRC32();
                checksum.update(buffer);
                ZipEntry ze = new ZipEntry(name);
                ze.setSize(buffer.length);
                ze.setCrc(checksum.getValue());
                zip.putNextEntry(ze);
                zip.write(buffer, 0, buffer.length);
                zip.closeEntry();
                zip.close();
            }
            else {
                fout.write(buffer);
            }
            fout.close();
        }

        if (!quiet) {
            PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
            pw.println("<?xml version='1.0' encoding='utf-8'?>");
            pw
                .println("<?xml-stylesheet type='text/xsl' href='http://www2.osgi.org/www/obr2html.xsl'?>");
            tag.print(0, pw);
            pw.close();
        }
    }
View Full Code Here

     * @param collected
     *            The output zip file
     * @throws java.io.IOException
     */
    static Tag doIndex(Collection resources) throws IOException {
        Tag repository = new Tag("repository");
        repository.addAttribute("lastmodified", new Date());
        repository.addAttribute("name", name);

        for (Iterator i = resources.iterator(); i.hasNext();) {
            ResourceImpl resource = (ResourceImpl) i.next();
            repository.addContent(resource.toXML());
        }
        return repository;
    }
View Full Code Here

TOP

Related Classes of org.osgi.impl.bundle.obr.resource.Tag

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.