Package org.w3c.tools.resources.serialization

Examples of org.w3c.tools.resources.serialization.ResourceDescription


       if ( ! ( r instanceof FramedResource) )
     error(request, "can't add frame to non-framed resource");
       // Handle the request:
       try {
    InputStream in  = getInputStream(request);
    ResourceDescription rd =
        AdminReader.readResourceDescription(in);
    String cls = rd.getClassName();
    String id  = rd.getIdentifier();
    // Create the frame:
    ResourceFrame frame = null;
     try {
         frame = (ResourceFrame) Class.forName(cls).newInstance();
     } catch (Exception ex) {
View Full Code Here


     error(request, "Can't unregister frames from a non-framed" +
           " resource");
       }
       try {
    InputStream in = getInputStream(request);
    ResourceDescription rd =
        AdminReader.readResourceDescription(in);
    String identifier  = rd.getIdentifier();   
     // find the indentifier
     ResourceFrame f[] = ((FramedResource) r).getFrames();
     for (int i = 0 ; i < f.length ; i++)
         if (f[i].getIdentifier().equals(identifier)) {
       ((FramedResource) r).unregisterFrame(f[i]);
View Full Code Here

       if ( ! ( r instanceof ContainerInterface) )
     error(request, "can't add child in non-container");
       // Handle request:
       try {
    InputStream in = getInputStream(request);
    ResourceDescription rd =
        AdminReader.readResourceDescription(in);
    String cls = rd.getClassName();
    String id  = rd.getIdentifier();
     // Create the resource:
     Resource child = null;
     try {
         child = (Resource) Class.forName(cls).newInstance();
     } catch (Exception ex) {
View Full Code Here

    change = true;
    newId = (String) values[i];
      }
  }

  ResourceDescription descr = description.getClone(attrs);

  try {
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      OutputStream out;
      if (debug) {
View Full Code Here

     * @exception RemoteAccessException If somenetwork failure occured.
     */
    public RemoteResource registerResource(String id, String classname)
  throws RemoteAccessException
    {
  ResourceDescription   rd   = new EmptyDescription(classname, id);
  try {
      Request req = createRequest();
      // Prepare the request:
      req.setMethod("REGISTER-RESOURCE");
      req.setContentType(admin.conftype);
      req.setURL(url);
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      OutputStream out;
      if (debug) {
    out = bout;
      } else {
    out = new GZIPOutputStream(bout);
      }
      admin.writer.writeResourceDescription(rd, out);
      byte bits[] = bout.toByteArray();
      req.setContentLength(bits.length);
      if (!debug) {
    req.addTransferEncoding("gzip");
      }
      req.setOutputStream(new ByteArrayInputStream(bits));
      // Run it:
      Reply rep = admin.runRequest(req);

      // Decode the result:
      rd = admin.reader.readResourceDescription(getInputStream(rep));
      RemoteResource ret =
    new PlainRemoteResource(admin, url, rd.getIdentifier(), rd);
     
      return ret;
  } catch (RemoteAccessException rae) {
      throw rae;
  } catch (Exception ex) {
View Full Code Here

      // Prepare the request:
      req.setMethod("UNREGISTER-FRAME");
      req.setContentType(admin.conftype);
      req.setURL(url);

      ResourceDescription dframe = new EmptyDescription("", id);
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      OutputStream out;
      if (debug) {
    out = bout;
      } else {
View Full Code Here

      Request req = createRequest();
      // Prepare the request:
      req.setMethod("REGISTER-FRAME");
      req.setContentType(admin.conftype);

      ResourceDescription dframe = new EmptyDescription(classname, id);
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      OutputStream out;
      if (debug) {
    out = bout;
      } else {
    out = new GZIPOutputStream(bout);
      }
      admin.writer.writeResourceDescription(dframe, out);
      byte bits[] = bout.toByteArray();
      req.setContentLength(bits.length);
      if (!debug) {
    req.addTransferEncoding("gzip");
      }
      req.setOutputStream(new ByteArrayInputStream(bits));

      // Run it:
      Reply rep = admin.runRequest(req);
      dframe =
    admin.reader.readResourceDescription(getInputStream(rep));
      id = dframe.getIdentifier();
      URL url = null;
      if (isFrame()) {
    url = new URL(this.url, this.url.getFile()+"?" + id);
      } else {
    url = new URL(parent.toString() +
View Full Code Here

      throw new RemoteAccessException(ex.getMessage());
  }
    }

    protected void createRemoteFrames() {
  ResourceDescription dframes[] = description.getFrameDescriptions();
  int                 len       = dframes.length;
  this.frames                   = new RemoteResource[len];
  for (int i = 0 ; i < len ; i++) {
      ResourceDescription dframe     = dframes[i];
      String              frameid    = dframe.getIdentifier();
      URL url = null;
      try {
    if (isFrame()) {
        url = new URL(this.url, this.url.getFile()+"?" + frameid);
    } else {
View Full Code Here

    protected void  writeResourceDescription(ResourceDescription description,
               OutputStream out)
  throws IOException, AdminProtocolException
    {
  try {
      ResourceDescription descrs[] = { description };
      Writer writer = new OutputStreamWriter( out, "UTF-8");
      serializer.writeResourceDescriptions(descrs, writer);
  } catch (SerializationException ex) {
      throw new AdminProtocolException("Unable to serialize resource :"+
               ex.getMessage());
View Full Code Here

            InputStream in)
  throws IOException, AdminProtocolException
    {
  try {
      Reader reader = new BufferedReader(new InputStreamReader(in));
      ResourceDescription descriptions[] =
    serializer.readResourceDescriptions(reader);
      if (descriptions.length < 1)
    throw new AdminProtocolException("Unknown resource");
      return factory.createRemoteResource(parent,
            identifier,
View Full Code Here

TOP

Related Classes of org.w3c.tools.resources.serialization.ResourceDescription

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.