Package net.rim.tumbler.exception

Examples of net.rim.tumbler.exception.ValidationException


                else if (entry.isDirectory()) {
                    // Check for reservedDirs
                    for (String reserved : RESERVED_DIRS) {
                        // The dir entry name has a trailing / like "dir/"
                        if (entryName.equals(reserved + "/")) {
                            throw new ValidationException("EXCEPTION_ARCHIVE_RESERVED_DIR");
                        }
                    }
                }
                // Validate the resource name
                Pattern patternEntryName = Pattern.compile("[a-zA-Z-_0-9][a-zA-Z-_0-9\\.]*");;
                String entity;
                String fullEntryName = entryName;
                boolean noMoreEntity = false;
               
                while (!noMoreEntity) {
                    if (entryName.charAt(entryName.length() - 1) == '/') {
                      entryName = entryName.substring(0, entryName.length() - 1); // Remove the ending '/'
                    }
                 
                  if (entryName.lastIndexOf('/') >= 0) {
                    entity = entryName.substring(entryName.lastIndexOf('/') + 1);
                    entryName = entryName.substring(0, entryName.lastIndexOf('/'));
                  } else {
                    entity = entryName;
                    noMoreEntity = true;
                  }
                 
                    if (!patternEntryName.matcher(entity).matches()) {
                        throw new ValidationException("EXCEPTION_INVALID_RESOURCE_NAME", fullEntryName);                           
                    }
                }
            }
           
            if (_configXML.length == 0) {
View Full Code Here


    private void checkSignatureKeys() throws Exception {
        String keyPath = _bbwpJarFolder + WidgetPackager.SIGNATURE_KEY_FILE;

        // Check for file's existence
        if( !( new File( keyPath ) ).exists() ) {
            throw new ValidationException( "EXCEPTION_MISSING_SIGNING_KEYS" );
        }
    }
View Full Code Here

        try {
            _uri = URI.create(uri);
            // Check for a protocol
            if (!(_uri.toString().equals("WidgetConfig.WIDGET_LOCAL_DOMAIN")) &&
                    (_uri.getScheme() == null || _uri.getScheme().length() == 0)) {
                throw new ValidationException (
                        "EXCEPTION_ACCESSURI_NO_PROTOCOL", uri.toString());
            }
            _allowSubDomain = allowSubDomain;
           
            String host = _uri.getHost();
            if (host != null
                    && SessionManager.getInstance().getTLD().indexOf(
                            "$$" + host.toLowerCase().trim() + "$$") != -1 && _allowSubDomain) {
                // Throw exception - exit compilation
                throw new ValidationException( "EXCEPTION_CONFIGXML_TLD", uri );
            }
        } catch (IllegalArgumentException e) {
            throw new ValidationException("EXCEPTION_ACCESSURI_BADURI", uri.toString());
        }
    }
View Full Code Here

    }

    private void validate() throws Exception {
        // Check template and archive
        if( !( new File( _templateDir ) ).exists() ) {
            throw new ValidationException( "EXCEPTION_TEMPLATES_NOT_FOUND" );
        }

        // Check rapc path
        if( _rapc.length() == 0 ) {
            throw new ValidationException( "EXCEPTION_RAPC_NOT_FOUND" );
        } else {
            if( OSUtils.isWindows() ) {
                if( !_rapc.equals( RAPC_EXE ) && !_rapc.equals( NODE_RAPC ) ) {
                    if( !( new File( _rapc ) ).exists() ) {
                        throw new ValidationException( "EXCEPTION_RAPC_NOT_FOUND" );
                    }
                }
            } else {
                if( !_rapc.equals( RAPC_JAR ) && !_rapc.equals( NODE_RAPC ) ) {
                    if( !( new File( _rapc ) ).exists() ) {
                        throw new ValidationException( "EXCEPTION_RAPC_NOT_FOUND" );
                    }
                }
            }
        }

        // Check javac path
        if( _javac == null || _javac.length() == 0 ) {
            // For tooling, they will set _javac to empty if they find javac.exe in "Path" environment variable
            // Rapc doesn't depend on this value to locate javac.exe, either
            // throw new ValidationException("EXCEPTION_JAVAC_NOT_FOUND");
        } else {
            if( !_javac.equals( "javac.exe" ) && !_javac.equals( "javac" ) ) {
                String javac = _javac;

                if( javac.startsWith( "\"" ) && javac.endsWith( "\"" ) ) {
                    javac = javac.substring( 1, javac.length() - 1 );
                }

                if( !( new File( javac ) ).exists() ) {
                    throw new ValidationException( "EXCEPTION_JAVAC_NOT_FOUND" );
                }
            }
        }
    }
View Full Code Here

    _author = author;
  }

  public void setName(String name) throws ValidationException {
    if (name == null || name.length() == 0) {
      throw new ValidationException(
          "EXCEPTION_CONFIGXML_MISSING_WIDGET_NAME");
    } else if ( name.indexOf(",") != -1 ) {
      throw new ValidationException(
          "EXCEPTION_CONFIGXML_INVALID_WIDGET_NAME" );
    }
    _name = name;
  }
View Full Code Here

    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(version);

    if (!matcher.matches()) {
      throw new ValidationException("EXCEPTION_CONFIGXML_INVALID_VERSION");
    }
    _version = version;
  }
View Full Code Here

      // Color variable should look like: #000000
      String regex = "^#[A-Fa-f0-9]{6}$";
      Pattern pattern = Pattern.compile(regex);
      Matcher matcher = pattern.matcher(screenColour);
      if (!matcher.matches()) {
        throw new ValidationException(
            "EXCEPTION_CONFIGXML_LOADINGSCREEN_COLOUR");
      }
    }
   
    _loadingScreenColour = screenColour;
View Full Code Here

      Logger.logMessage(LogType.INFO,  "PROGRESS_VALIDATING_CONFIG_XML_WIDGET_AUTHOR");
    }
   
        // Validate that an application name/author was specified
        if (_widgetConfig.getName() == null) {
          throw new ValidationException("EXCEPTION_CONFIGXML_MISSING_WIDGET_NAME");
        }
       
        // Validation via logging
        if (_widgetConfig.getAuthor() == null) {
          // Just log warning
View Full Code Here

        NamedNodeMap attrs = widgetNode.getAttributes();

        // version       
        Node versionAttr = attrs.getNamedItem("version");
    if (versionAttr == null) {
      throw new ValidationException("VALIDATION_CONFIGXML_MISSING_VERSION");
    }
        _widgetConfig.setVersion(getTextValue(versionAttr));

        // id
        Node idAttr = attrs.getNamedItem("id");
        if (idAttr != null) {
            _widgetConfig.setID(getTextValue(idAttr));
        }

        // rim:header
        Node headerAttr = attrs.getNamedItem("rim:header");
        if (headerAttr != null) {
            String header = getTextValue(headerAttr);
            int index = header.indexOf(':');

            if (index > 0) {
                _widgetConfig.addHeader(
                        header.substring(0, index), header.substring(index + 1, header.length()));
            }
        }
       
        // rim:backButton
        Node backButtonAttr = attrs.getNamedItem("rim:backButton");
        if (backButtonAttr != null) {
            _widgetConfig.setBackButtonBehaviour(getTextValue(backButtonAttr));
        }

        // Parsing access nodes and feature nodes
        Hashtable<WidgetAccess, Vector<WidgetFeature>> accessTable = new Hashtable<WidgetAccess, Vector<WidgetFeature>>();

        // Populate "LOCAL" access list
        String localpath = "WidgetConfig.WIDGET_LOCAL_DOMAIN";
        boolean hasFeatures = false;
        WidgetAccess localAccess = new WidgetAccess(localpath, true);
        Vector<WidgetFeature> featureList = getFeatureListFromNode(widgetNode);
        if (featureList.size() > 0) {
            hasFeatures = true;
        }
        accessTable.put(localAccess, featureList);

        // Populate all "access" nodes access lists
        for (int i = 0; i < list.getLength(); i++) {
            Node node = list.item(i);
            if (node.getNodeName().equalsIgnoreCase("access")
                    && node.getNodeType() == Node.ELEMENT_NODE) {
                NamedNodeMap nodeAttributes = node.getAttributes();

                // uri information
                Node uriNode = nodeAttributes.getNamedItem("uri");
                String uri = "";
                if (uriNode != null) {
                    uri = uriNode.getNodeValue();
                }

                // subdomains information
                Node subdomainsNode = nodeAttributes.getNamedItem("subdomains");
                boolean subdomains = false;
                if (subdomainsNode != null) {
                    if (subdomainsNode.getNodeValue().equalsIgnoreCase("true")) {
                        subdomains = true;
                    }
                }

                if (!uri.trim().equals("*")) {
                    WidgetAccess access = new WidgetAccess(uri, subdomains);
                   
                    // Find all sub-feature nodes
                    if (uri.length() > 0) {
                        featureList = getFeatureListFromNode(node);
                        if (featureList.size() > 0) {
                            hasFeatures = true;
                        }
                        accessTable.put(access, featureList);
                    }
                } else {
                    _widgetConfig.setMultiAccess(true);
                    // no features allowed for *
                    if (getFeatureListFromNode(node).size() > 0) {
                        throw new ValidationException("EXCEPTION_CONFIGXML_FEATURES_NOT_ALLOWED");
                    }
                }
            }
        }
        if (!hasFeatures) {
View Full Code Here

                    if (name.length() > 0) {
                        WidgetFeature wf = new WidgetFeature(name, isRequired, version, null);
                        featureList.addElement(wf);
                    }
                } else {
                    throw new ValidationException("VALIDATION_MISSING_FEATURE_ID");
                }
            }
        }

        return featureList;
View Full Code Here

TOP

Related Classes of net.rim.tumbler.exception.ValidationException

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.