Examples of BadWidgetZipFileException


Examples of org.apache.wookie.w3c.exceptions.BadWidgetZipFileException

      BadManifestException, InsecuredWidgetContentException {
    ZipFile zip;
    try {
      zip = new ZipFile(zipFile);
    } catch (IOException e) {
      throw new BadWidgetZipFileException();
    }
    if (WidgetPackageUtils.hasManifest(zip)){
      try {
        // build the model
        WidgetManifestModel widgetModel = new WidgetManifestModel(WidgetPackageUtils.extractManifest(zip), locales, features, encodings, zip, defaultIdentifier);                             

        // get the widget identifier
        String manifestIdentifier = widgetModel.getIdentifier();           
        // create the folder structure to unzip the zip into
        unzippedWidgetDirectory = WidgetPackageUtils.createUnpackedWidgetFolder(outputDirectory, manifestIdentifier);
        // now unzip it into that folder
        WidgetPackageUtils.unpackZip(zip, unzippedWidgetDirectory);
        // checks for validity of widget using digital signatures
        if (digitalSignatureParser != null) {
          digitalSignatureParser
              .processDigitalSignatures(unzippedWidgetDirectory
                  .getAbsolutePath());
        }
        // Iterate over all start files and update paths
        for (IContent content: widgetModel.getContentList()){
          // now update the js links in the start page
          File startFile = new File(unzippedWidgetDirectory.getCanonicalPath() + File.separator + content.getSrc());
          String relativestartUrl = (WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, content.getSrc()));          
          content.setSrc(relativestartUrl);
          if(startFile.exists() && startPageProcessor != null){   
            startPageProcessor.processStartFile(startFile, widgetModel, content);
          }
        }
        if (widgetModel.getContentList().isEmpty()){
          throw new InvalidStartFileException("Widget has no start page");
        }
       
        // get the path to the root of the unzipped folder
        String thelocalPath = WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, "");
        // now pass this to the model which will prepend the path to local resources (not web icons)
        widgetModel.updateIconPaths(thelocalPath);
       
        // check to see if this widget already exists in the DB - using the ID (guid) key from the manifest
        return widgetModel;

      }catch(InsecuredWidgetContentException ex){
        throw ex;
      }catch (InvalidStartFileException e) {
        throw e;
      } catch (BadManifestException e) {
        throw e;
      } catch (Exception e){
        throw new BadManifestException(e);
      } finally
          try {
            zip.close();
          } catch (IOException e) {
            _logger.error("Unable to close wgt file:" + e.getMessage());
          }
      }
     
    }
    else{
        try {
                zip.close();
            } catch (IOException e) {
                _logger.error("Unable to close wgt file (without manifest):" + e.getMessage());
            }
      // no manifest file found in zip archive
      throw new BadWidgetZipFileException(); //$NON-NLS-1$
    }
  }
View Full Code Here

Examples of org.apache.wookie.w3c.exceptions.BadWidgetZipFileException

  private W3CWidget processWidgetPackage(File zipFile, String defaultIdentifier) throws BadWidgetZipFileException, BadManifestException{
    ZipFile zip;
    try {
      zip = new ZipFile(zipFile);
    } catch (IOException e) {
      throw new BadWidgetZipFileException();
    }
    if (WidgetPackageUtils.hasManifest(zip)){
      try {
        // build the model
        WidgetManifestModel widgetModel = new WidgetManifestModel(WidgetPackageUtils.extractManifest(zip), locales, features, encodings, zip, defaultIdentifier);                             

        // get the widget identifier
        String manifestIdentifier = widgetModel.getIdentifier();           
        // create the folder structure to unzip the zip into
        unzippedWidgetDirectory = WidgetPackageUtils.createUnpackedWidgetFolder(outputDirectory, manifestIdentifier);
        // now unzip it into that folder
        WidgetPackageUtils.unpackZip(zip, unzippedWidgetDirectory)
       
        // Iterate over all start files and update paths
        for (IContentEntity content: widgetModel.getContentList()){
          // now update the js links in the start page
          File startFile = new File(unzippedWidgetDirectory.getCanonicalPath() + File.separator + content.getSrc());
          String relativestartUrl = (WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, content.getSrc()));          
          content.setSrc(relativestartUrl);
          if(startFile.exists() && startPageProcessor != null){   
            startPageProcessor.processStartFile(startFile, widgetModel, content);
         
        }
        if (widgetModel.getContentList().isEmpty()){
          throw new InvalidStartFileException("Widget has no start page");
        }
       
        // get the path to the root of the unzipped folder
        String thelocalPath = WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, "");
        // now pass this to the model which will prepend the path to local resources (not web icons)
        widgetModel.updateIconPaths(thelocalPath);       
       
        // check to see if this widget already exists in the DB - using the ID (guid) key from the manifest
        return widgetModel;
      } catch (InvalidStartFileException e) {
        throw e;
      } catch (BadManifestException e) {
        throw e;
      } catch (Exception e){
        throw new BadManifestException(e);
      }
    }
    else{
      // no manifest file found in zip archive
      throw new BadWidgetZipFileException(); //$NON-NLS-1$
    }
  }
View Full Code Here

Examples of org.apache.wookie.w3c.exceptions.BadWidgetZipFileException

  private W3CWidget processWidgetPackage(File zipFile, String defaultIdentifier) throws BadWidgetZipFileException, BadManifestException{
    ZipFile zip;
    try {
      zip = new ZipFile(zipFile);
    } catch (IOException e) {
      throw new BadWidgetZipFileException();
    }
    if (WidgetPackageUtils.hasManifest(zip)){
      try {
        // build the model
        WidgetManifestModel widgetModel = new WidgetManifestModel(WidgetPackageUtils.extractManifest(zip), locales, features, encodings, zip, defaultIdentifier);                             

        // get the widget identifier
        String manifestIdentifier = widgetModel.getIdentifier();           
        // create the folder structure to unzip the zip into
        unzippedWidgetDirectory = WidgetPackageUtils.createUnpackedWidgetFolder(outputDirectory, manifestIdentifier);
        // now unzip it into that folder
        WidgetPackageUtils.unpackZip(zip, unzippedWidgetDirectory)
       
        // Iterate over all start files and update paths
        for (IContentEntity content: widgetModel.getContentList()){
          // now update the js links in the start page
          File startFile = new File(unzippedWidgetDirectory.getCanonicalPath() + File.separator + content.getSrc());
          String relativestartUrl = (WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, content.getSrc()));          
          content.setSrc(relativestartUrl);
          if(startFile.exists() && startPageProcessor != null){   
            startPageProcessor.processStartFile(startFile, widgetModel, content);
         
        }
        if (widgetModel.getContentList().isEmpty()){
          throw new InvalidStartFileException("Widget has no start page");
        }
       
        // get the path to the root of the unzipped folder
        String thelocalPath = WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, "");
        // now pass this to the model which will prepend the path to local resources (not web icons)
        widgetModel.updateIconPaths(thelocalPath);       
       
        // check to see if this widget already exists in the DB - using the ID (guid) key from the manifest
        return widgetModel;
      } catch (InvalidStartFileException e) {
        throw e;
      } catch (BadManifestException e) {
        throw e;
      } catch (Exception e){
        throw new BadManifestException(e);
      } finally
          try {
            zip.close();
          } catch (IOException e) {
            _logger.error("Unable to close wgt file:" + e.getMessage());
          }
      }
     
    }
    else{
      // no manifest file found in zip archive
      throw new BadWidgetZipFileException(); //$NON-NLS-1$
    }
  }
View Full Code Here

Examples of org.apache.wookie.w3c.exceptions.BadWidgetZipFileException

  BadManifestException, InsecuredWidgetContentException {
    ZipFile zip;
    try {
      zip = new ZipFile(zipFile);
    } catch (IOException e) {
      throw new BadWidgetZipFileException();
    }
    if (WidgetPackageUtils.hasManifest(zip)){
      try {
       
        //
        // If locales is set to "*" then look in the package and process all locales found
        //
       
        if (locales.length == 1 && locales[0].equals("*")){
          locales = WidgetPackageUtils.getLocalesFromZipFile(zip);
        }
       
        // build the model
        WidgetManifestModel widgetModel = new WidgetManifestModel(WidgetPackageUtils.extractManifest(zip), locales, features, encodings, zip, defaultIdentifier);                             

        // get the widget identifier
        String manifestIdentifier = widgetModel.getIdentifier();           
        // create the folder structure to unzip the zip into
        unzippedWidgetDirectory = WidgetPackageUtils.createUnpackedWidgetFolder(outputDirectory, manifestIdentifier);
        // now unzip it into that folder
        WidgetPackageUtils.unpackZip(zip, unzippedWidgetDirectory);
        // checks for validity of widget using digital signatures
        if (digitalSignatureParser != null) {
          digitalSignatureParser
          .processDigitalSignatures(unzippedWidgetDirectory
              .getAbsolutePath());
        }
        // Iterate over all start files and update paths
        for (IContent content: widgetModel.getContentList()){
          // now update the js links in the start page
          File startFile = new File(unzippedWidgetDirectory.getCanonicalPath() + File.separator + content.getSrc());
          String relativestartUrl = (WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, content.getSrc()));          
          content.setSrc(relativestartUrl);
          if(startFile.exists() && startPageProcessor != null){   
            startPageProcessor.processStartFile(startFile, widgetModel, content);
          }
        }
        if (widgetModel.getContentList().isEmpty()){
          throw new InvalidStartFileException("Widget has no start page");
        }

        // get the path to the root of the unzipped folder
        String thelocalPath = WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, "");
        // now pass this to the model which will prepend the path to local resources (not web icons)
        widgetModel.updateIconPaths(thelocalPath);

        // check to see if this widget already exists in the DB - using the ID (guid) key from the manifest
        return widgetModel;

      }catch(InsecuredWidgetContentException ex){
        throw ex;
      }catch (InvalidStartFileException e) {
        throw e;
      } catch (BadManifestException e) {
        throw e;
      } catch (Exception e){
        throw new BadManifestException(e);
      } finally
        try {
          zip.close();
        } catch (IOException e) {
          _logger.error("Unable to close wgt file:" + e.getMessage());
        }
      }

    }
    else{
      try {
        zip.close();
      } catch (IOException e) {
        _logger.error("Unable to close wgt file (without manifest):" + e.getMessage());
      }
      // no manifest file found in zip archive
      throw new BadWidgetZipFileException(); //$NON-NLS-1$
    }
  }
View Full Code Here

Examples of org.apache.wookie.w3c.exceptions.BadWidgetZipFileException

  private W3CWidget processWidgetPackage(File zipFile) throws BadWidgetZipFileException, BadManifestException{
    ZipFile zip;
    try {
      zip = new ZipFile(zipFile);
    } catch (IOException e) {
      throw new BadWidgetZipFileException();
    }
    if (WidgetPackageUtils.hasManifest(zip)){
      try {
        // build the model
        WidgetManifestModel widgetModel = new WidgetManifestModel(WidgetPackageUtils.extractManifest(zip), locales, features, encodings, zip);                             

        // get the widget identifier
        String manifestIdentifier = widgetModel.getIdentifier();           
        // create the folder structure to unzip the zip into
        unzippedWidgetDirectory = WidgetPackageUtils.createUnpackedWidgetFolder(outputDirectory, manifestIdentifier);
        // now unzip it into that folder
        WidgetPackageUtils.unpackZip(zip, unzippedWidgetDirectory)
       
        // Iterate over all start files and update paths
        for (IContentEntity content: widgetModel.getContentList()){
          // now update the js links in the start page
          File startFile = new File(unzippedWidgetDirectory.getCanonicalPath() + File.separator + content.getSrc());
          String relativestartUrl = (WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, content.getSrc()));          
          content.setSrc(relativestartUrl);
          if(startFile.exists() && startPageProcessor != null){   
            startPageProcessor.processStartFile(startFile, widgetModel);
         
        }
        if (widgetModel.getContentList().isEmpty()){
          throw new InvalidStartFileException("Widget has no start page");
        }
       
        // get the path to the root of the unzipped folder
        String thelocalPath = WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, "");
        // now pass this to the model which will prepend the path to local resources (not web icons)
        widgetModel.updateIconPaths(thelocalPath);       
       
        // check to see if this widget already exists in the DB - using the ID (guid) key from the manifest
        return widgetModel;
      } catch (InvalidStartFileException e) {
        throw e;
      } catch (BadManifestException e) {
        throw e;
      } catch (Exception e){
        throw new BadManifestException(e);
      }
    }
    else{
      // no manifest file found in zip archive
      throw new BadWidgetZipFileException(); //$NON-NLS-1$
    }
  }
View Full Code Here

Examples of org.apache.wookie.w3c.exceptions.BadWidgetZipFileException

  private W3CWidget processWidgetPackage(File zipFile, String defaultIdentifier) throws BadWidgetZipFileException, BadManifestException{
    ZipFile zip;
    try {
      zip = new ZipFile(zipFile);
    } catch (IOException e) {
      throw new BadWidgetZipFileException();
    }
    if (WidgetPackageUtils.hasManifest(zip)){
      try {
        // build the model
        WidgetManifestModel widgetModel = new WidgetManifestModel(WidgetPackageUtils.extractManifest(zip), locales, features, encodings, zip, defaultIdentifier);                             

        // get the widget identifier
        String manifestIdentifier = widgetModel.getIdentifier();           
        // create the folder structure to unzip the zip into
        unzippedWidgetDirectory = WidgetPackageUtils.createUnpackedWidgetFolder(outputDirectory, manifestIdentifier);
        // now unzip it into that folder
        WidgetPackageUtils.unpackZip(zip, unzippedWidgetDirectory)
       
        // Iterate over all start files and update paths
        for (IContent content: widgetModel.getContentList()){
          // now update the js links in the start page
          File startFile = new File(unzippedWidgetDirectory.getCanonicalPath() + File.separator + content.getSrc());
          String relativestartUrl = (WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, content.getSrc()));          
          content.setSrc(relativestartUrl);
          if(startFile.exists() && startPageProcessor != null){   
            startPageProcessor.processStartFile(startFile, widgetModel, content);
         
        }
        if (widgetModel.getContentList().isEmpty()){
          throw new InvalidStartFileException("Widget has no start page");
        }
       
        // get the path to the root of the unzipped folder
        String thelocalPath = WidgetPackageUtils.getURLForWidget(localPath, manifestIdentifier, "");
        // now pass this to the model which will prepend the path to local resources (not web icons)
        widgetModel.updateIconPaths(thelocalPath);       
       
        // check to see if this widget already exists in the DB - using the ID (guid) key from the manifest
        return widgetModel;
      } catch (InvalidStartFileException e) {
        throw e;
      } catch (BadManifestException e) {
        throw e;
      } catch (Exception e){
        throw new BadManifestException(e);
      } finally
          try {
            zip.close();
          } catch (IOException e) {
            _logger.error("Unable to close wgt file:" + e.getMessage());
          }
      }
     
    }
    else{
      // no manifest file found in zip archive
      throw new BadWidgetZipFileException(); //$NON-NLS-1$
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.