diff options
Diffstat (limited to 'bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util')
24 files changed, 0 insertions, 8759 deletions
diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/ArtifactType.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/ArtifactType.java deleted file mode 100644 index 80bdd4c56..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/ArtifactType.java +++ /dev/null @@ -1,140 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -/** - * This class ... - * - * @version 1.0.1 - * @author Peter Brittenham (peterbr@us.ibm.com) - */ -public class ArtifactType -{ - /** - * This type. - */ - private String type; - - /** - * ReportArtifact types. - */ - public static final String TYPE_ENVELOPE = "envelope"; - public static final String TYPE_MESSAGE = "message"; - public static final String TYPE_DESCRIPTION = "description"; - public static final String TYPE_DISCOVERY = "discovery"; - - /** - * ReportArtifact types. - */ - public static final ArtifactType ARTIFACT_TYPE_ENVELOPE = - new ArtifactType(TYPE_ENVELOPE); - public static final ArtifactType ARTIFACT_TYPE_MESSAGE = - new ArtifactType(TYPE_MESSAGE); - public static final ArtifactType ARTIFACT_TYPE_DESCRIPTION = - new ArtifactType(TYPE_DESCRIPTION); - public static final ArtifactType ARTIFACT_TYPE_DISCOVERY = - new ArtifactType(TYPE_DISCOVERY); - - /** - * Create artifact type. - */ - private ArtifactType(String type) - { - this.type = type; - } - - /** - * Is artifact type envelope. - * @return true if artifact type envelope. - */ - public boolean isEnvelope() - { - return type.equals(TYPE_ENVELOPE); - } - - /** - * Is artifact type messages. - * @return true if artifact type messages. - */ - public boolean isMessages() - { - return type.equals(TYPE_MESSAGE); - } - - /** - * Is artifact type description. - * @return true if artifact type description. - */ - public boolean isDescription() - { - return type.equals(TYPE_DESCRIPTION); - } - - /** - * Is artifact type discovery. - * @return true if artifact type discovery. - */ - public boolean isDiscovery() - { - return type.equals(TYPE_DISCOVERY); - } - - /** - * Get artifact type. - * @return artifact type. - */ - public String getTypeName() - { - return type; - } - - /** - * Create artifact type. - * @param typeName artifact type name. - * @return newly created artifact type. - * @throws RuntimeException if artifact type name is invalid or inappropriate. - */ - public static final ArtifactType newArtifactType(String typeName) - throws RuntimeException - { - ArtifactType artifactType = null; - - if (typeName.equals(TYPE_DESCRIPTION)) - { - artifactType = ARTIFACT_TYPE_DESCRIPTION; - } - - else if (typeName.equals(TYPE_MESSAGE)) - { - artifactType = ARTIFACT_TYPE_MESSAGE; - } - - else if (typeName.equals(TYPE_ENVELOPE)) - { - artifactType = ARTIFACT_TYPE_ENVELOPE; - } - - else if (typeName.equals(TYPE_DISCOVERY)) - { - artifactType = ARTIFACT_TYPE_DISCOVERY; - } - - else - { - throw new RuntimeException( - "Could not create new artifact type using invalid type name: " - + typeName - + "."); - } - - return artifactType; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/BasicRules.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/BasicRules.java deleted file mode 100644 index d232b0e4b..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/BasicRules.java +++ /dev/null @@ -1,477 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -/** - * This class validates basic constructs of RFC 2616. - * - * @author Volodin - */ -public class BasicRules -{ - - public static final char CR = 13; - public static final char LF = 10; - public static final char SP = 32; - public static final char HT = 9; - public static final char DQ = 34; - public static final String CRLF = "" + CR + LF; - - public static final char[] SEPARATORS = - { - '(', - ')', - '<', - '>', - '@', - ',', - ';', - ':', - '\\', - '\"', - '/', - '[', - ']', - '?', - '=', - '{', - '}', - SP, - HT }; - - /** - * Checking rule. - * OCTET = <any 8-bit sequence of data> - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isOCTET(char ch) - { - return true; - } - - /** - * Checking rule: - * CHAR = <any US-ASCII character (octets 0 - 127)>. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isCHAR(char ch) - { - return (ch >= 0 && ch <= 127) ? true : false; - } - - /** - * Checking rule: - * UPALPHA = <any US-ASCII uppercase letter "A".."Z">. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isUPALPHA(char ch) - { - return (ch >= 'A' && ch <= 'Z') ? true : false; - } - - /** - * Checking rule: - * LOALPHA = <any US-ASCII lowercase letter "a".."z">. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isLOALPHA(char ch) - { - return (ch >= 'a' && ch <= 'z') ? true : false; - } - - /** - * Checking rule: - * ALPHA = UPALPHA | LOALPHA. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isALPHA(char ch) - { - return (isLOALPHA(ch) || isUPALPHA(ch)) ? true : false; - } - - /** - * Checking rule: - * DIGIT = <any US-ASCII digit "0".."9">. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isDIGIT(char ch) - { - return (ch >= '0' && ch <= '9') ? true : false; - } - - /** - * Checking rule: - * CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isCTL(char ch) - { - return ((ch >= 0 && ch <= 31) || ch == 127) ? true : false; - } - - /** - * Checking rule: - * CR = <US-ASCII CR, carriage return (13)>. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isCR(char ch) - { - return (ch == CR) ? true : false; - } - - /** - * Checking rule: - * LF = <US-ASCII LF, linefeed (10)>. - * @param ch character - * @return boolean true if ch is conform to rule, false otherwise - */ - public static boolean isLF(char ch) - { - return (ch == LF) ? true : false; - } - - /** - * Checking rule: - * SP = <US-ASCII SP, space (32)>. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isSP(char ch) - { - return (ch == SP) ? true : false; - } - - /** - * Checking rule: - * HT = <US-ASCII HT, horizontal-tab (9)>. - * @param ch character - * @return boolean true if ch is conform to rule, false otherwise - */ - public static boolean isHT(char ch) - { - return (ch == HT) ? true : false; - } - - /** - * Checking rule: - * <"> = <US-ASCII double-quote mark (34)>. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isDoubleQuote(char ch) - { - return (ch == DQ) ? true : false; - } - - /** - * Checking rule: - * CRLF = CR LF. - * @param str string. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isCRLF(String str) - { - return CRLF.equals(str); - } - - /** - * Checking rule: - * LWS = [CRLF] 1*( SP | HT ). - * @param str string. - * @return boolean true if str is conform to rule, false otherwise. - */ - public static boolean isLWS(String str) - { - - int index = getLastIndexLWS(str, 0); - if (index == -1 || index != str.length()) - return false; - - return true; - } - - /** - * Gets last index of the LWS string. - * @param str string. - * @param startIndex start index. - * @return int an index of the first symbol which isn't LWS. - */ - public static int getLastIndexLWS(String str, int startIndex) - { - int index = str.indexOf(CRLF, startIndex); - if (index == -1) - index = startIndex; - else if (index == startIndex) - index += CRLF.length(); - else - return -1; - - if (!isSP(str.charAt(index)) && isHT(str.charAt(index))) - return -1; - - index++; - for (; index < str.length(); index++) - if (!isSP(str.charAt(index)) && isHT(str.charAt(index))) - return index; - return index; - } - - /** - * Gets last index of the TEXT string. - * TEXT = <any OCTET except CTLs, but including LWS> - * @param str string. - * @param startIndex start index. - * @return int an index of the first symbol which isn't TEXT. - */ - public static int getLastTEXT(String str, int startIndex) - { - int index; - for (index = startIndex; index < str.length(); index++) - { - if (!isOCTET(str.charAt(index))) - return index; - if (isCTL(str.charAt(index))) - { - int lastLWS = getLastIndexLWS(str, index); - if (lastLWS == -1) - return index; - index = lastLWS - 1; - } - } - return index; - } - - /** - * Checking rule: - * HEX = "A" | "B" | "C" | "D" | "E" | "F" | "a" | "b" | "c" | "d" | "e" | "f" | DIGIT. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isHEX(char ch) - { - return ( - (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f') || isDIGIT(ch)) - ? true - : false; - } - - /** - * Checking rule: - * token = 1*<any CHAR except CTLs or separators>. - * @param str string. - * @return boolean true if str is conform to rule, false otherwise. - */ - public static boolean isToken(String str) - { - if (str.length() == 0) - return false; - - for (int index = 0; index < str.length(); index++) - { - char ch = str.charAt(index); - if (!isCHAR(ch) || isSEPARATOR(ch) || isCTL(ch)) - return false; - - } - - return true; - } - - /** - * Gets last index of the "token" string. - * @param str string. - * @param startIndex start index. - * @return int an index of the first symbol which isn't "token". - */ - public static int getLastToken(String str, int startIndex) - { - int index = startIndex; - for (; index < str.length(); index++) - { - char ch = str.charAt(index); - if (!isCHAR(ch) || isSEPARATOR(ch) || isCTL(ch)) - return index; - - } - return index; - } - - /** - * Checking rule: - * separators = "(" | ")" | "<" | ">" | "@" - * | "," | ";" | ":" | "\" | <"> - * | "/" | "[" | "]" | "?" | "=" - * | "{" | "}" | SP | HT. - * @param ch character. - * @return boolean true if ch is conform to rule, false otherwise. - */ - public static boolean isSEPARATOR(char ch) - { - for (int index = 0; index < SEPARATORS.length; index++) - { - if (ch == SEPARATORS[index]) - return true; - } - return false; - } - - /** - * Gets last index of the "comment" string. - * comment = "(" *( ctext | quoted-pair | comment ) ")". - * @param str string. - * @param startIndex start index. - * @return int an index of the first symbol which isn't "comment". - */ - public static int getLastComment(String str, int startIndex) - { - - int index = startIndex; - if (str.length() <= startIndex) - return startIndex; - if (str.charAt(index) != '(') - return startIndex; - - boolean bExit = false; - boolean bQuotedPair = false; - int idx = startIndex + 1; - while (bExit == false) - { - while (bQuotedPair == false) - { - idx = getLastCtext(str, idx); - if (idx == str.length()) - return idx; - if (!isQuotedPair(str, idx - 1)) - bQuotedPair = true; - else - idx++; - } - if (str.charAt(idx) == '(') - { - getLastComment(str, idx); - } - else if (str.charAt(idx) == ')') - { - return idx + 1; - } - } - - return idx; - } - - /** - * Gets last index of the "ctext" string. - * ctext = <any TEXT excluding "(" and ")"> - * @param str string. - * @param startIndex start index. - * @return int an index of the first symbol which isn't "ctext". - */ - private static int getLastCtext(String str, int startIndex) - { - int idx = getLastTEXT(str, startIndex); - int iBracket = startIndex; - for (; iBracket < idx; iBracket++) - { - if (str.charAt(iBracket) == '(' || str.charAt(iBracket) == ')') - break; - } - if (iBracket < idx) - idx = iBracket; - return idx; - } - - /** - * Gets last index of the "qdtext" string. - * qdtext = <any TEXT except <">> - * @param str string. - * @param startIndex start index. - * @return int an index of the first symbol which isn't "qdtext". - */ - private static int getLastQdtext(String str, int startIndex) - { - int idx = getLastTEXT(str, startIndex); - int iBracket = startIndex; - for (; iBracket < idx; iBracket++) - { - if (str.charAt(iBracket) == '\"') - break; - } - if (iBracket < idx) - idx = iBracket; - return idx; - } - - /** - * Checking rule: - * quoted-pair = "\" CHAR. - * @param str string. - * @param startIndex start index. - * @return boolean true if str is conform to rule, false otherwise. - */ - public static boolean isQuotedPair(String str, int startIndex) - { - if (str.length() >= startIndex + 2 - && str.charAt(startIndex) == '\\' - && isCHAR(str.charAt(startIndex + 1))) - return true; - else - return false; - } - - /** - * Gets last index of the "quoted-string" string. - * quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) - * @param str string. - * @param startIndex start index. - * @return int an index of the first symbol which isn't "quoted-string". - */ - public static int getLastQuotedString(String str, int startIndex) - { - int index = startIndex; - - // if end if the string - if (startIndex == str.length()) - return startIndex; - // if the begin is not '"' - if (str.charAt(index) != DQ) - return startIndex; - - index++; - while (true) - { - index = getLastQdtext(str, index); - if (index == str.length()) - return startIndex; - if (isQuotedPair(str, index - 1)) - { - index++; - if (index == str.length()) - return startIndex; - } - else - break; - } - // if the end is not '"' - if (str.charAt(index) != DQ) - return startIndex; - - index++; - return index; - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/EntryType.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/EntryType.java deleted file mode 100644 index 3b27731b0..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/EntryType.java +++ /dev/null @@ -1,278 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.util.TreeMap; -import java.util.Vector; - -/** - * This class ... - * - * @version 1.0.1 - * @author Peter Brittenham (peterbr@us.ibm.com) - */ -public class EntryType -{ - /** - * ReportArtifact type. - */ - private ArtifactType artifactType; - - /** - * This type. - */ - private String typeName; - - /** - * Entry types accessible by type name. - */ - protected static final TreeMap entryTypeMap = new TreeMap(); - - /** - * Entry type names accessible by artifact. - */ - protected static final TreeMap entryTypeNameMap = new TreeMap(); - static { - entryTypeNameMap.put(ArtifactType.TYPE_ENVELOPE, new Vector()); - entryTypeNameMap.put(ArtifactType.TYPE_MESSAGE, new Vector()); - entryTypeNameMap.put(ArtifactType.TYPE_DESCRIPTION, new Vector()); - entryTypeNameMap.put(ArtifactType.TYPE_DISCOVERY, new Vector()); - } - - /** - * Envelope entry types. - */ - public static final String TYPE_ENVELOPE_REQUEST = "requestEnvelope"; - public static final String TYPE_ENVELOPE_RESPONSE = "responseEnvelope"; - public static final String TYPE_ENVELOPE_ANY = "anyEnvelope"; - - /** - * Message entry types. - */ - public static final String TYPE_MESSAGE_REQUEST = "requestMessage"; - public static final String TYPE_MESSAGE_RESPONSE = "responseMessage"; - public static final String TYPE_MESSAGE_ANY = "anyMessage"; - - /** - * MIME entry types. - */ - public static final String TYPE_MIME_PART = "part"; - public static final String TYPE_MIME_ROOT_PART = "root-part"; - - /** - * Description entry types. - */ - public static final String TYPE_DESCRIPTION_DEFINITIONS = "definitions"; - public static final String TYPE_DESCRIPTION_IMPORT = "import"; - public static final String TYPE_DESCRIPTION_TYPES = "types"; - public static final String TYPE_DESCRIPTION_MESSAGE = "message"; - public static final String TYPE_DESCRIPTION_OPERATION = "operation"; - public static final String TYPE_DESCRIPTION_PORTTYPE = "portType"; - public static final String TYPE_DESCRIPTION_BINDING = "binding"; - public static final String TYPE_DESCRIPTION_PORT = "port"; - - /** - * Discovery entry types. - */ - public static final String TYPE_DISCOVERY_BINDINGTEMPLATE = "bindingTemplate"; - public static final String TYPE_DISCOVERY_TMODEL = "tModel"; - - /** - * Envelope entry types. - */ - public static final EntryType ENTRY_TYPE_REQUESTENV = - newEntryType(ArtifactType.ARTIFACT_TYPE_ENVELOPE, TYPE_ENVELOPE_REQUEST); - public static final EntryType ENTRY_TYPE_RESPONSEENV = - newEntryType(ArtifactType.ARTIFACT_TYPE_ENVELOPE, TYPE_ENVELOPE_RESPONSE); - - /** - * Message entry types. - */ - public static final EntryType ENTRY_TYPE_REQUEST = - newEntryType(ArtifactType.ARTIFACT_TYPE_MESSAGE, TYPE_MESSAGE_REQUEST); - public static final EntryType ENTRY_TYPE_RESPONSE = - newEntryType(ArtifactType.ARTIFACT_TYPE_MESSAGE, TYPE_MESSAGE_RESPONSE); - // public static final EntryType ENTRY_TYPE_ANYENTRY = - // new EntryType(ArtifactType.ARTIFACT_TYPE_MESSAGES, TYPE_MESSAGE_ANYENTRY); - - /** - * Description entry types. - */ - public static final EntryType ENTRY_TYPE_DEFINITIONS = - newEntryType( - ArtifactType.ARTIFACT_TYPE_DESCRIPTION, - TYPE_DESCRIPTION_DEFINITIONS); - public static final EntryType ENTRY_TYPE_IMPORT = - newEntryType( - ArtifactType.ARTIFACT_TYPE_DESCRIPTION, - TYPE_DESCRIPTION_IMPORT); - public static final EntryType ENTRY_TYPE_TYPES = - newEntryType( - ArtifactType.ARTIFACT_TYPE_DESCRIPTION, - TYPE_DESCRIPTION_TYPES); - public static final EntryType ENTRY_TYPE_MESSAGE = - newEntryType( - ArtifactType.ARTIFACT_TYPE_DESCRIPTION, - TYPE_DESCRIPTION_MESSAGE); - public static final EntryType ENTRY_TYPE_OPERATION = - newEntryType( - ArtifactType.ARTIFACT_TYPE_DESCRIPTION, - TYPE_DESCRIPTION_OPERATION); - public static final EntryType ENTRY_TYPE_PORTTYPE = - newEntryType( - ArtifactType.ARTIFACT_TYPE_DESCRIPTION, - TYPE_DESCRIPTION_PORTTYPE); - public static final EntryType ENTRY_TYPE_BINDING = - newEntryType( - ArtifactType.ARTIFACT_TYPE_DESCRIPTION, - TYPE_DESCRIPTION_BINDING); - public static final EntryType ENTRY_TYPE_PORT = - newEntryType(ArtifactType.ARTIFACT_TYPE_DESCRIPTION, TYPE_DESCRIPTION_PORT); - - /** - * Discovery entry types. - */ - public static final EntryType ENTRY_TYPE_BINDINGTEMPLATE = - newEntryType( - ArtifactType.ARTIFACT_TYPE_DISCOVERY, - TYPE_DISCOVERY_BINDINGTEMPLATE); - public static final EntryType ENTRY_TYPE_TMODEL = - newEntryType(ArtifactType.ARTIFACT_TYPE_DISCOVERY, TYPE_DISCOVERY_TMODEL); - - /** - * Create entry type. - */ - private EntryType(ArtifactType artifactType, String typeName) - { - this.artifactType = artifactType; - this.typeName = typeName; - } - - /** - * Is entry type equal to specified type. - * @param typeName entry type name. - * @return true if entry type equal to specified type. - */ - public boolean isType(String typeName) - { - return this.typeName.equals(typeName); - } - - /** - * Is entry type equal to specified type. - * @param entryType entry type. - * @return true if entry type equal to specified type. - */ - public boolean isType(EntryType entryType) - { - return typeName.equals(entryType.getTypeName()); - } - - /** - * Get artifact type. - * @return artifact type. - */ - public ArtifactType getArtifactType() - { - return artifactType; - } - - /** - * Get entry type name. - * @return entry type name. - */ - public String getTypeName() - { - return typeName; - } - - /** - * Is valid entry type. - * @param typeName entry type name. - * @return true if entry type name is valid. - */ - public static final boolean isValidEntryType(String typeName) - { - return (entryTypeMap.get(typeName) == null ? false : true); - } - - /** - * Create entry type. - * @param typeName entry type name. - * @return entry type. - * @throws RuntimeException if entry type name is invalid or inappropriate. - */ - public static final EntryType getEntryType(String typeName) - throws RuntimeException - { - // Get the entry type by type name - EntryType entryType = (EntryType) entryTypeMap.get(typeName); - - if (entryType == null) - { - throw new RuntimeException( - "Could not get entry type because type name is invalid: " - + typeName - + "."); - } - - return entryType; - } - - /** - * Get list of entry type names for a specified artifact type name. - * @param artifactTypeName artifact type name. - * @return list of entry type names for a specified artifact type name. - * @throws RuntimeException if entry type name is invalid or inappropriate. - */ - public static final Vector getEntryTypeNameList(String artifactTypeName) - throws RuntimeException - { - // Get list - Vector entryTypeNameList = (Vector) entryTypeNameMap.get(artifactTypeName); - - // If the list was not found, then throw an exception - if (entryTypeNameList == null) - { - throw new RuntimeException( - "Could not get entry type name list because artifact type name is invalid: " - + artifactTypeName - + "."); - } - - return entryTypeNameList; - } - - /** - * Get list of type names for a specified artifact type name. - */ - private static final EntryType newEntryType( - ArtifactType artifactType, - String typeName) - { - EntryType entryType = null; - - // Create entry type - entryType = new EntryType(artifactType, typeName); - - // Add to entry type map - entryTypeMap.put(typeName, entryType); - - // Get the entry type name vector for the artifact type - Vector entryTypeNameList = - (Vector) entryTypeNameMap.get(artifactType.getTypeName()); - - // Add the type name to the list - entryTypeNameList.add(typeName); - - return entryType; - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/ErrorList.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/ErrorList.java deleted file mode 100644 index e9597f4ef..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/ErrorList.java +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.text.FieldPosition; -import java.text.MessageFormat; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import javax.xml.namespace.QName; - -/** - * The class accumulates all error strings into string buffer. - * - * @author Kulik - */ -public final class ErrorList -{ - private Set errors = new HashSet(); - private MessageFormat format = new MessageFormat("{0}:{1}"); - private FieldPosition pos = new FieldPosition(0); - - /** - * Default constructor. - * @see java.lang.Object#Object() - */ - public ErrorList() - { - } - - /** - * Construct error list using contents of a list. - * @param list a List object. - * @see java.lang.Object#Object() - */ - public ErrorList(List list) - { - add(list); - } - - /** - * Constructor with the specified message format. - * @param f a message format. - */ - public ErrorList(MessageFormat f) - { - if (f != null) - format = f; - } - - /** - * Add list. - * @param list list of errors. - */ - public void add(List list) - { - Iterator iterator = list.iterator(); - while (iterator.hasNext()) - { - add((String) iterator.next()); - } - } - - /** - * Adds error description into the list. - * @param s1 a string. - * @param s2 a string. - */ - public void add(String s1, String s2) - { - errors.add(new Pair(s1, s2)); - } - - /** - * Adds error description into the list. - * @param q a QName object. - * @param s a string. - */ - public void add(QName q, String s) - { - errors.add(new Pair(NullUtil.toString(q), s)); - } - - /** - * Adds error description into the list. - * @param q1 a QName object. - * @param q2 a string. - */ - public void add(QName q1, QName q2) - { - errors.add(new Pair(NullUtil.toString(q1), NullUtil.toString(q2))); - } - - /** - * Adds error description into the list... - * @param q a QName object. - */ - public void add(QName q) - { - errors.add(new Pair(NullUtil.toString(q), null)); - } - - /** - * Adds error description into the list. - * @param s a string. - */ - public void add(String s) - { - errors.add(new Pair(s, null)); - } - - /** - * Returns the error list string representation. - * @return the error list string representation. - * @see java.lang.Object#toString() - */ - public String toString() - { - StringBuffer buf = new StringBuffer(); - - Iterator it = errors.iterator(); - while (it.hasNext()) - { - Pair p = (Pair) it.next(); - if (p.getFirst() != null && p.getSecond() != null) - format.format(new Object[] { p.getFirst(), p.getSecond()}, buf, pos); - else if (p.getFirst() != null) - buf.append(p.getFirst()); - else - buf.append(p.getSecond()); - if (it.hasNext()) - buf.append(",\n"); - } - - return buf.toString(); - } - - /** - * Indicates whether error list is empty or not. - * @return true if error list is empty. - */ - public boolean isEmpty() - { - return errors.size() == 0; - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/HTTPConstants.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/HTTPConstants.java deleted file mode 100644 index 34b053339..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/HTTPConstants.java +++ /dev/null @@ -1,600 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.util.Arrays; -import java.util.List; - -/** - * A set of HTTP values that are defined by Network Working Group. - * http://www.ietf.org/ - * - * @version 1.0 - * @author Ilya Kanonirov (kio@isg.axmor.com) - */ -public class HTTPConstants { - // The standardized HTTP Header field-names - // http://www.mnot.net/drafts/draft-nottingham-http-header-reg-00.txt - - // Hypertext Transfer Protocol -- HTTP/1.1 (obsoletes RFC2068) - public static final String HEADER_ACCEPT = "Accept"; - public static final String HEADER_ACCEPT_CHARSET = "Accept-Charset"; - public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding"; - public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language"; - public static final String HEADER_ACCEPT_RANGES = "Accept-Ranges"; - public static final String HEADER_AGE = "Age"; - public static final String HEADER_ALLOW = "Allow"; - public static final String HEADER_AUTHORIZATION = "Authorization"; - public static final String HEADER_CACHE_CONTROL = "Cache-Control"; - public static final String HEADER_CONNECT = "Connect"; - public static final String HEADER_CONTENT_ENCODING = "Content-Encoding"; - public static final String HEADER_CONTENT_LANGUAGE = "Content-Language"; - public static final String HEADER_CONTENT_LENGTH = "Content-Length"; - public static final String HEADER_CONTENT_LOCATION = "Content-Location"; - public static final String HEADER_CONTENT_MD5 = "Content-MD5"; - public static final String HEADER_CONTENT_RANGE = "Content-Range"; - public static final String HEADER_CONTENT_TYPE = "Content-Type"; - public static final String HEADER_DATE = "Date"; - public static final String HEADER_ETAG = "ETag"; - public static final String HEADER_EXPECT = "Expect"; - public static final String HEADER_EXPIRES = "Expires"; - public static final String HEADER_FROM = "From"; - public static final String HEADER_HOST = "Host"; - public static final String HEADER_IF_MATCH = "If-Match"; - public static final String HEADER_IF_MODIFIED_SINCE = "If-Modified-Since"; - public static final String HEADER_IF_NONE_MATCH = "If-None-Match"; - public static final String HEADER_IF_RANGE = "If-Range"; - public static final String HEADER_IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; - public static final String HEADER_LAST_MODIFIED = "Last-Modified"; - public static final String HEADER_LOCATION = "Location"; - public static final String HEADER_MAX_FORWARDS = "Max-Forwards"; - public static final String HEADER_PRAGMA = "Pragma"; - public static final String HEADER_PROXY_AUTHENTICATE = "Proxy-Authenticate"; - public static final String HEADER_PROXY_AUTHORIZATION = "Proxy-Authorization"; - public static final String HEADER_RANGE = "Range"; - public static final String HEADER_REFERER = "Referer"; - public static final String HEADER_RETRY_AFTER = "Retry-After"; - public static final String HEADER_SERVER = "Server"; - public static final String HEADER_TE = "TE"; - public static final String HEADER_TRAILER = "Trailer"; - public static final String HEADER_TRANSFER_ENCODING = "Transfer-Encoding"; - public static final String HEADER_UPGRADE = "Upgrade"; - public static final String HEADER_USER_AGENT = "User-Agent"; - public static final String HEADER_VARY = "Vary"; - public static final String HEADER_VIA = "Via"; - public static final String HEADER_WARNING = "Warning"; - public static final String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate"; - public static final String HEADER_MIME_VERSION = "MIME-Version"; - public static final String HEADER_CONTENT_DISPOSITION = "Content-Disposition"; - - // HTTP Authentication: Basic and Digest Access Authentication - public static final String HEADER_AUTHENTICATION_INFO = "Authentication-Info"; - - // HTTP State Management Mechanism - public static final String HEADER_SET_COOKIE = "Set-Cookie"; - - // HTTP State Management Mechanism (obsoletes RFC2109) - public static final String HEADER_COOKIE = "Cookie"; - public static final String HEADER_COOKIE2 = "Cookie2"; - public static final String HEADER_SET_COOKIE2 = "Set-Cookie2"; - - // Web Distributed Authoring and Versioning - public static final String HEADER_DAV = "DAV"; - public static final String HEADER_DEPTH = "Depth"; - public static final String HEADER_DESTINATION = "Destination"; - public static final String HEADER_IF = "If"; - public static final String HEADER_LOCK_TOKEN = "Lock-Token"; - public static final String HEADER_OVERWRITE = "Overwrite"; - public static final String HEADER_STATUS_URI = "Status-URI"; - public static final String HEADER_TIMEOUT = "Timeout"; - - // Hypertext Transfer Protocol -- HTTP/1.1 (Proposed Standard - these field-names are now considered obsolete) - public static final String HEADER_CONTENT_BASE = "Content-Base"; - public static final String HEADER_PUBLIC = "Public"; - public static final String HEADER_CONTENT_VERSION = "Content-Version"; - public static final String HEADER_DERIVED_FROM = "Derived-From"; - public static final String HEADER_LINK = "Link"; - public static final String HEADER_URI = "URI"; - public static final String HEADER_KEEP_ALIVE = "Keep-Alive"; - - // Delta Encoding in HTTP - public static final String HEADER_A_IM = "A-IM"; - public static final String HEADER_DELTA_BASE = "Delta-Base"; - public static final String HEADER_IM = "IM"; - - // Instance Digests in HTTP - public static final String HEADER_DIGEST = "Digest"; - public static final String HEADER_WANT_DIGEST = "Want-Digest"; - - // Simple Hit-Metering and Usage-Limiting for HTTP - public static final String HEADER_METER = "Meter"; - - // The Known Non-Standardized HTTP Header field-names - - // Transparent Content Negotiation in HTTP - public static final String HEADER_ACCEPT_FEATURES = "Accept-Features"; - public static final String HEADER_ALTERNATES = "Alternates"; - public static final String HEADER_NEGOTIATE = "Negotiate"; - public static final String HEADER_TCN = "TCN"; - public static final String HEADER_VARIANT_VARY = "Variant-Vary"; - - // The Safe Response Header Field - public static final String HEADER_SAFE = "Safe"; - - // Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0) - public static final String HEADER_ACCEPT_ADDITIONS = "Accept-Additions"; - - // The Secure HyperText Transfer Protocol - public static final String HEADER_CONTENT_PRIVACY_DOMAIN = "Content-Privacy-Domain"; - public static final String HEADER_MAC_INFO = "MAC-Info"; - public static final String HEADER_PREARRANGED_KEY_INFO = "Prearranged-Key-Info"; - - // An HTTP Extension Framework - public static final String HEADER_C_EXT = "C-Ext"; - public static final String HEADER_C_MAN = "C-Man"; - public static final String HEADER_C_OPT = "C-Opt"; - public static final String HEADER_EXT = "Ext"; - public static final String HEADER_MAN = "Man"; - public static final String HEADER_OPT = "Opt"; - - // PICS Label Distribution Label Syntax and Communication Protocols - public static final String HEADER_PICS_LABEL = "PICS-Label"; - - // Platform For Privacy Preferences 1.0 - public static final String HEADER_P3P = "P3P"; - - // PEP - an Extension Mechanism for HTTP - public static final String HEADER_C_PEP = "C-PEP"; - public static final String HEADER_C_PEP_INFO = "C-PEP-Info"; - public static final String HEADER_PEP = "PEP"; - public static final String HEADER_PEP_INFO = "Pep-Info"; - - // The HTTP Distribution and Replication Protocol - public static final String HEADER_CONTENT_ID = "Content-ID"; - public static final String HEADER_DIFFERENTIAL_ID = "Differential-ID"; - - // ESI Architecture - public static final String HEADER_SURROGATE_CAPABILITY = "Surrogate-Capability"; - public static final String HEADER_SURROGATE_CONTROL = "Surrogate-Control"; - - // Selecting Payment Mechanisms Over HTTP - public static final String HEADER_PROTOCOL = "Protocol"; - public static final String HEADER_PROTOCOL_INFO = "Protocol-Info"; - public static final String HEADER_PROTOCOL_QUERY = "Protocol-Query"; - public static final String HEADER_PROTOCOL_REQUEST = "Protocol-Request"; - - // Implementation of OPS Over HTTP - public static final String HEADER_GETPROFILE = "GetProfile"; - public static final String HEADER_PROFILEOBJECT = "ProfileObject"; - public static final String HEADER_SETPROFILE = "SetProfile"; - - // Notification for Proxy Caches - public static final String HEADER_PROXY_FEATURES = "Proxy-Features"; - public static final String HEADER_PROXY_INSTRUCTION = "Proxy-Instruction"; - - // Object Header lines in HTTP - public static final String HEADER_CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding"; - public static final String HEADER_COST = "Cost"; - public static final String HEADER_MESSAGE_ID = "Message-ID"; - public static final String HEADER_TITLE = "Title"; - public static final String HEADER_VERSION = "Version"; - - // A Proposed Extension Mechanism for HTTP - public static final String HEADER_EXTENSION = "Extension"; - - // WIRE - W3 Identifier Resolution Extensions - public static final String HEADER_OPTIONAL = "Optional"; - public static final String HEADER_RESOLUTION_HINT = "Resolution-Hint"; - - // Duplicate Suppression in HTTP - public static final String HEADER_SUBOK = "SubOK"; - public static final String HEADER_SUBST = "Subst"; - - // Specification of HTTP/1.1 OPTIONS messages - public static final String HEADER_COMPLIANCE = "Compliance"; - public static final String HEADER_NON_COMPLIANCE = "Non-Compliance"; - - // Widely-used undocumented headers - public static final String HEADER_REQUEST_RANGE = "Request-Range"; - public static final String HEADER_UA_COLOR = "UA-Color"; - public static final String HEADER_UA_CPU = "UA-CPU"; - public static final String HEADER_UA_OS = "UA-OS"; - public static final String HEADER_UA_PIXELS = "UA-Pixels"; - - // Implementation errors - public static final String HEADER_REFERRER = "Referrer"; - - // Private features - public static final String HEADER_COPYRIGHT = "Copyright"; - public static final String HEADER_CONTENT = "Content"; - public static final String HEADER_AUTHOR = "Author"; - public static final String HEADER_CONTACT = "Contact"; - public static final String HEADER_KEYWORDS = "Keywords"; - public static final String HEADER_GENERATOR = "Generator"; - public static final String HEADER_DESCRIPTION = "Description"; - public static final String HEADER_COMMAND = "Command"; - public static final String HEADER_SESSION = "Session"; - public static final String HEADER_TYPE = "Type"; - public static final String HEADER_MESSAGE = "Message"; - - // Abandoned proposals - public static final String HEADER_UNLESS_MODIFIED_SINCE = "Unless-Modified-Since"; - - /** - * Returns all the standardized HTTP header names presented as List - * @return The list of standardized HTTP header names - */ - public static List getStandardizedHeaderNames() { - return Arrays.asList(new Object[] { - HEADER_ACCEPT.toUpperCase(), - HEADER_ACCEPT_CHARSET.toUpperCase(), - HEADER_ACCEPT_ENCODING.toUpperCase(), - HEADER_ACCEPT_LANGUAGE.toUpperCase(), - HEADER_ACCEPT_RANGES.toUpperCase(), - HEADER_AGE.toUpperCase(), - HEADER_ALLOW.toUpperCase(), - HEADER_AUTHORIZATION.toUpperCase(), - HEADER_CACHE_CONTROL.toUpperCase(), - HEADER_CONNECT.toUpperCase(), - HEADER_CONTENT_ENCODING.toUpperCase(), - HEADER_CONTENT_LANGUAGE.toUpperCase(), - HEADER_CONTENT_LENGTH.toUpperCase(), - HEADER_CONTENT_LOCATION.toUpperCase(), - HEADER_CONTENT_MD5.toUpperCase(), - HEADER_CONTENT_RANGE.toUpperCase(), - HEADER_CONTENT_TYPE.toUpperCase(), - HEADER_DATE.toUpperCase(), - HEADER_ETAG.toUpperCase(), - HEADER_EXPECT.toUpperCase(), - HEADER_EXPIRES.toUpperCase(), - HEADER_FROM.toUpperCase(), - HEADER_HOST.toUpperCase(), - HEADER_IF_MATCH.toUpperCase(), - HEADER_IF_MODIFIED_SINCE.toUpperCase(), - HEADER_IF_NONE_MATCH.toUpperCase(), - HEADER_IF_RANGE.toUpperCase(), - HEADER_IF_UNMODIFIED_SINCE.toUpperCase(), - HEADER_LAST_MODIFIED.toUpperCase(), - HEADER_LOCATION.toUpperCase(), - HEADER_MAX_FORWARDS.toUpperCase(), - HEADER_PRAGMA.toUpperCase(), - HEADER_PROXY_AUTHENTICATE.toUpperCase(), - HEADER_PROXY_AUTHORIZATION.toUpperCase(), - HEADER_RANGE.toUpperCase(), - HEADER_REFERER.toUpperCase(), - HEADER_RETRY_AFTER.toUpperCase(), - HEADER_SERVER.toUpperCase(), - HEADER_TE.toUpperCase(), - HEADER_TRAILER.toUpperCase(), - HEADER_TRANSFER_ENCODING.toUpperCase(), - HEADER_UPGRADE.toUpperCase(), - HEADER_USER_AGENT.toUpperCase(), - HEADER_VARY.toUpperCase(), - HEADER_VIA.toUpperCase(), - HEADER_WARNING.toUpperCase(), - HEADER_WWW_AUTHENTICATE.toUpperCase(), - HEADER_MIME_VERSION.toUpperCase(), - HEADER_CONTENT_DISPOSITION.toUpperCase(), - - HEADER_AUTHENTICATION_INFO.toUpperCase(), - - HEADER_SET_COOKIE.toUpperCase(), - - HEADER_COOKIE.toUpperCase(), - HEADER_COOKIE2.toUpperCase(), - HEADER_SET_COOKIE2.toUpperCase(), - - HEADER_DAV.toUpperCase(), - HEADER_DEPTH.toUpperCase(), - HEADER_DESTINATION.toUpperCase(), - HEADER_IF.toUpperCase(), - HEADER_LOCK_TOKEN.toUpperCase(), - HEADER_OVERWRITE.toUpperCase(), - HEADER_STATUS_URI.toUpperCase(), - HEADER_TIMEOUT.toUpperCase(), - - HEADER_CONTENT_BASE.toUpperCase(), - HEADER_PUBLIC.toUpperCase(), - HEADER_CONTENT_VERSION.toUpperCase(), - HEADER_DERIVED_FROM.toUpperCase(), - HEADER_LINK.toUpperCase(), - HEADER_URI.toUpperCase(), - HEADER_KEEP_ALIVE.toUpperCase(), - - HEADER_A_IM.toUpperCase(), - HEADER_DELTA_BASE.toUpperCase(), - HEADER_IM.toUpperCase(), - - HEADER_DIGEST.toUpperCase(), - HEADER_WANT_DIGEST.toUpperCase(), - - HEADER_METER.toUpperCase() - }); - } - - /** - * Returns all the non-standardized HTTP header names presented as List - * @return The list of non-standardized HTTP header names - */ - public static List getNonStandardizedHeaderNames() { - return Arrays.asList(new Object[] { - HEADER_ACCEPT_FEATURES.toUpperCase(), - HEADER_ALTERNATES.toUpperCase(), - HEADER_NEGOTIATE.toUpperCase(), - HEADER_TCN.toUpperCase(), - HEADER_VARIANT_VARY.toUpperCase(), - - HEADER_SAFE.toUpperCase(), - - HEADER_ACCEPT_ADDITIONS.toUpperCase(), - - HEADER_CONTENT_PRIVACY_DOMAIN.toUpperCase(), - HEADER_MAC_INFO.toUpperCase(), - HEADER_PREARRANGED_KEY_INFO.toUpperCase(), - - HEADER_C_EXT.toUpperCase(), - HEADER_C_MAN.toUpperCase(), - HEADER_C_OPT.toUpperCase(), - HEADER_EXT.toUpperCase(), - HEADER_MAN.toUpperCase(), - HEADER_OPT.toUpperCase(), - - HEADER_PICS_LABEL.toUpperCase(), - HEADER_PROTOCOL.toUpperCase(), - HEADER_PROTOCOL_REQUEST.toUpperCase(), - - HEADER_P3P.toUpperCase(), - - HEADER_C_PEP.toUpperCase(), - HEADER_C_PEP_INFO.toUpperCase(), - HEADER_PEP.toUpperCase(), - HEADER_PEP_INFO.toUpperCase(), - - HEADER_CONTENT_ID.toUpperCase(), - HEADER_DIFFERENTIAL_ID.toUpperCase(), - - HEADER_SURROGATE_CAPABILITY.toUpperCase(), - HEADER_SURROGATE_CONTROL.toUpperCase(), - - HEADER_PROTOCOL.toUpperCase(), - HEADER_PROTOCOL_INFO.toUpperCase(), - HEADER_PROTOCOL_QUERY.toUpperCase(), - HEADER_PROTOCOL_REQUEST.toUpperCase(), - - HEADER_GETPROFILE.toUpperCase(), - HEADER_PROFILEOBJECT.toUpperCase(), - HEADER_SETPROFILE.toUpperCase(), - - HEADER_PROXY_FEATURES.toUpperCase(), - HEADER_PROXY_INSTRUCTION.toUpperCase(), - - HEADER_CONTENT_TRANSFER_ENCODING.toUpperCase(), - HEADER_COST.toUpperCase(), - HEADER_MESSAGE_ID.toUpperCase(), - HEADER_TITLE.toUpperCase(), - HEADER_VERSION.toUpperCase(), - - HEADER_EXTENSION.toUpperCase(), - - HEADER_OPTIONAL.toUpperCase(), - HEADER_RESOLUTION_HINT.toUpperCase(), - - HEADER_SUBOK.toUpperCase(), - HEADER_SUBST.toUpperCase(), - - HEADER_COMPLIANCE.toUpperCase(), - HEADER_NON_COMPLIANCE.toUpperCase(), - - HEADER_REQUEST_RANGE.toUpperCase(), - HEADER_UA_COLOR.toUpperCase(), - HEADER_UA_CPU.toUpperCase(), - HEADER_UA_OS.toUpperCase(), - HEADER_UA_PIXELS.toUpperCase(), - - HEADER_REFERRER.toUpperCase(), - - HEADER_COPYRIGHT.toUpperCase(), - HEADER_CONTENT.toUpperCase(), - HEADER_AUTHOR.toUpperCase(), - HEADER_CONTACT.toUpperCase(), - HEADER_KEYWORDS.toUpperCase(), - HEADER_GENERATOR.toUpperCase(), - HEADER_DESCRIPTION.toUpperCase(), - HEADER_COMMAND.toUpperCase(), - HEADER_SESSION.toUpperCase(), - HEADER_TYPE.toUpperCase(), - HEADER_MESSAGE.toUpperCase(), - - HEADER_UNLESS_MODIFIED_SINCE.toUpperCase() - }); - } - - /** - * Returns all known HTTP header names presented as List - * @return The list of all known HTTP header names - */ - public static List getAllKnownHeaderNames() { - return Arrays.asList(new Object[] { - HEADER_ACCEPT.toUpperCase(), - HEADER_ACCEPT_CHARSET.toUpperCase(), - HEADER_ACCEPT_ENCODING.toUpperCase(), - HEADER_ACCEPT_LANGUAGE.toUpperCase(), - HEADER_ACCEPT_RANGES.toUpperCase(), - HEADER_AGE.toUpperCase(), - HEADER_ALLOW.toUpperCase(), - HEADER_AUTHORIZATION.toUpperCase(), - HEADER_CACHE_CONTROL.toUpperCase(), - HEADER_CONNECT.toUpperCase(), - HEADER_CONTENT_ENCODING.toUpperCase(), - HEADER_CONTENT_LANGUAGE.toUpperCase(), - HEADER_CONTENT_LENGTH.toUpperCase(), - HEADER_CONTENT_LOCATION.toUpperCase(), - HEADER_CONTENT_MD5.toUpperCase(), - HEADER_CONTENT_RANGE.toUpperCase(), - HEADER_CONTENT_TYPE.toUpperCase(), - HEADER_DATE.toUpperCase(), - HEADER_ETAG.toUpperCase(), - HEADER_EXPECT.toUpperCase(), - HEADER_EXPIRES.toUpperCase(), - HEADER_FROM.toUpperCase(), - HEADER_HOST.toUpperCase(), - HEADER_IF_MATCH.toUpperCase(), - HEADER_IF_MODIFIED_SINCE.toUpperCase(), - HEADER_IF_NONE_MATCH.toUpperCase(), - HEADER_IF_RANGE.toUpperCase(), - HEADER_IF_UNMODIFIED_SINCE.toUpperCase(), - HEADER_LAST_MODIFIED.toUpperCase(), - HEADER_LOCATION.toUpperCase(), - HEADER_MAX_FORWARDS.toUpperCase(), - HEADER_PRAGMA.toUpperCase(), - HEADER_PROXY_AUTHENTICATE.toUpperCase(), - HEADER_PROXY_AUTHORIZATION.toUpperCase(), - HEADER_RANGE.toUpperCase(), - HEADER_REFERER.toUpperCase(), - HEADER_RETRY_AFTER.toUpperCase(), - HEADER_SERVER.toUpperCase(), - HEADER_TE.toUpperCase(), - HEADER_TRAILER.toUpperCase(), - HEADER_TRANSFER_ENCODING.toUpperCase(), - HEADER_UPGRADE.toUpperCase(), - HEADER_USER_AGENT.toUpperCase(), - HEADER_VARY.toUpperCase(), - HEADER_VIA.toUpperCase(), - HEADER_WARNING.toUpperCase(), - HEADER_WWW_AUTHENTICATE.toUpperCase(), - HEADER_MIME_VERSION.toUpperCase(), - HEADER_CONTENT_DISPOSITION.toUpperCase(), - - HEADER_AUTHENTICATION_INFO.toUpperCase(), - - HEADER_SET_COOKIE.toUpperCase(), - - HEADER_COOKIE.toUpperCase(), - HEADER_COOKIE2.toUpperCase(), - HEADER_SET_COOKIE2.toUpperCase(), - - HEADER_DAV.toUpperCase(), - HEADER_DEPTH.toUpperCase(), - HEADER_DESTINATION.toUpperCase(), - HEADER_IF.toUpperCase(), - HEADER_LOCK_TOKEN.toUpperCase(), - HEADER_OVERWRITE.toUpperCase(), - HEADER_STATUS_URI.toUpperCase(), - HEADER_TIMEOUT.toUpperCase(), - - HEADER_CONTENT_BASE.toUpperCase(), - HEADER_PUBLIC.toUpperCase(), - HEADER_CONTENT_VERSION.toUpperCase(), - HEADER_DERIVED_FROM.toUpperCase(), - HEADER_LINK.toUpperCase(), - HEADER_URI.toUpperCase(), - HEADER_KEEP_ALIVE.toUpperCase(), - - HEADER_A_IM.toUpperCase(), - HEADER_DELTA_BASE.toUpperCase(), - HEADER_IM.toUpperCase(), - - HEADER_DIGEST.toUpperCase(), - HEADER_WANT_DIGEST.toUpperCase(), - - HEADER_METER.toUpperCase(), - - HEADER_ACCEPT_FEATURES.toUpperCase(), - HEADER_ALTERNATES.toUpperCase(), - HEADER_NEGOTIATE.toUpperCase(), - HEADER_TCN.toUpperCase(), - HEADER_VARIANT_VARY.toUpperCase(), - - HEADER_SAFE.toUpperCase(), - - HEADER_ACCEPT_ADDITIONS.toUpperCase(), - - HEADER_CONTENT_PRIVACY_DOMAIN.toUpperCase(), - HEADER_MAC_INFO.toUpperCase(), - HEADER_PREARRANGED_KEY_INFO.toUpperCase(), - - HEADER_C_EXT.toUpperCase(), - HEADER_C_MAN.toUpperCase(), - HEADER_C_OPT.toUpperCase(), - HEADER_EXT.toUpperCase(), - HEADER_MAN.toUpperCase(), - HEADER_OPT.toUpperCase(), - - HEADER_PICS_LABEL.toUpperCase(), - HEADER_PROTOCOL.toUpperCase(), - HEADER_PROTOCOL_REQUEST.toUpperCase(), - - HEADER_P3P.toUpperCase(), - - HEADER_C_PEP.toUpperCase(), - HEADER_C_PEP_INFO.toUpperCase(), - HEADER_PEP.toUpperCase(), - HEADER_PEP_INFO.toUpperCase(), - - HEADER_CONTENT_ID.toUpperCase(), - HEADER_DIFFERENTIAL_ID.toUpperCase(), - - HEADER_SURROGATE_CAPABILITY.toUpperCase(), - HEADER_SURROGATE_CONTROL.toUpperCase(), - - HEADER_PROTOCOL.toUpperCase(), - HEADER_PROTOCOL_INFO.toUpperCase(), - HEADER_PROTOCOL_QUERY.toUpperCase(), - HEADER_PROTOCOL_REQUEST.toUpperCase(), - - HEADER_GETPROFILE.toUpperCase(), - HEADER_PROFILEOBJECT.toUpperCase(), - HEADER_SETPROFILE.toUpperCase(), - - HEADER_PROXY_FEATURES.toUpperCase(), - HEADER_PROXY_INSTRUCTION.toUpperCase(), - - HEADER_CONTENT_TRANSFER_ENCODING.toUpperCase(), - HEADER_COST.toUpperCase(), - HEADER_MESSAGE_ID.toUpperCase(), - HEADER_TITLE.toUpperCase(), - HEADER_VERSION.toUpperCase(), - - HEADER_EXTENSION.toUpperCase(), - - HEADER_OPTIONAL.toUpperCase(), - HEADER_RESOLUTION_HINT.toUpperCase(), - - HEADER_SUBOK.toUpperCase(), - HEADER_SUBST.toUpperCase(), - - HEADER_COMPLIANCE.toUpperCase(), - HEADER_NON_COMPLIANCE.toUpperCase(), - - HEADER_REQUEST_RANGE.toUpperCase(), - HEADER_UA_COLOR.toUpperCase(), - HEADER_UA_CPU.toUpperCase(), - HEADER_UA_OS.toUpperCase(), - HEADER_UA_PIXELS.toUpperCase(), - - HEADER_REFERRER.toUpperCase(), - - HEADER_COPYRIGHT.toUpperCase(), - HEADER_CONTENT.toUpperCase(), - HEADER_AUTHOR.toUpperCase(), - HEADER_CONTACT.toUpperCase(), - HEADER_KEYWORDS.toUpperCase(), - HEADER_GENERATOR.toUpperCase(), - HEADER_DESCRIPTION.toUpperCase(), - HEADER_COMMAND.toUpperCase(), - HEADER_SESSION.toUpperCase(), - HEADER_TYPE.toUpperCase(), - HEADER_MESSAGE.toUpperCase(), - - HEADER_UNLESS_MODIFIED_SINCE.toUpperCase() - }); - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/HTTPUtils.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/HTTPUtils.java deleted file mode 100644 index 735e435e5..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/HTTPUtils.java +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.util.HashMap; -import java.util.Map; -import java.util.StringTokenizer; - -import org.eclipse.wst.wsi.internal.core.WSIException; - -/** - * Set of HTTPL related utilities. - * - * @version 1.0.1 - * @author Peter Brittenham - */ - -public final class HTTPUtils -{ - - /** - * Find the URL string in a HTTP POST header. - * @param httpPostHeader a HTTP POST header. - * @return the URL string in a HTTP POST header. - */ - public static String getURLString(String httpPostHeader) - { - String urlString = null; - int start, end; - - // If POST, then continue - if (httpPostHeader.startsWith("POST") || httpPostHeader.startsWith("GET")) - { - // Start after first space - start = httpPostHeader.indexOf(' ') + 1; - - // Look for next non-space character - while (httpPostHeader.charAt(start) == ' ') - start++; - - // Find next space character - end = httpPostHeader.indexOf(' ', start); - - // Get URL string which is located in between start and end - urlString = httpPostHeader.substring(start, end); - } - - // Else throw exception - else - { - throw new IllegalArgumentException( - "HTTP header does not contain POST data (was: " + httpPostHeader + ")"); - } - - // Return URL string - return urlString; - } - /** - * Utility to present HTTP header information as attribute-value pairs, - * based on ':' as attribute-value separator. - * @param httpHeaderString an HTTP header string. - * @param separators attribute-value separator list. - * @return HTTP header information as attribute-value pairs. - * @throws WSIException if unable to create HTTP header information - * as attribute-value pairs. - */ - public static Map getHttpHeaderTokens(String httpHeaderString, String separators) - throws WSIException - { - StringTokenizer tokenizer = new StringTokenizer(httpHeaderString, "\n\r\f"); - Map map = new HashMap(); - String name = null; - while (tokenizer.hasMoreTokens()) - { - String line = tokenizer.nextToken(); - int index = line.indexOf(separators); - if (index > 0 && index < line.length() - 1) - { - name = line.substring(0, index).toUpperCase(); - map.put(name, line.substring(index + 1).trim()); - } - else - { - if ((name != null) && (line.length()>0) && Character.isWhitespace(line.charAt(0))) - map.put(name, map.get(name) + " " + line.trim()); - } - } - return map; - } - - /** - * Utility to take sub attribute value from HTTP header - * @param httpHeaderString an HTTP header string. - * @param attributeName attribute name. - * @param subAttributeName sub attribute name. - * @return sub attribute value from HTTP header. - * @throws WSIException if unable to get sub attribute value from HTTP header. - */ - public static String getHttpHeaderSubAttribute(String httpHeaderString, - String attributeName, String subAttributeName) - throws WSIException - { - // get attribute value - String value = - (String) getHttpHeaderTokens(httpHeaderString,":").get(attributeName.toUpperCase()); - if(value != null) - { - // search sub attribute token - int idxQ = value.toUpperCase().indexOf(subAttributeName.toUpperCase()+"=\""); - int idx = value.toUpperCase().indexOf(subAttributeName.toUpperCase()+"="); - // if attribute is quoted - if (idxQ != -1) - { - idxQ += (subAttributeName+"=\"").length(); - int eIdxQ = value.indexOf("\"", idxQ); - if (eIdxQ != -1) - { - return value.substring(idxQ, eIdxQ); - } - else - { - return null; - } - } - // if attribute do not quoted - else if (idx != -1) - { - idx += (subAttributeName+"=").length(); - int eIdx = -1; - // find end space separator - if ((eIdx = value.indexOf(" ", idx)) != -1) - { - return value.substring(idx, eIdx); - } - // find coma separator - else if ((eIdx = value.indexOf(";", idx)) != -1) - { - return value.substring(idx, eIdx); - } - // this is last attribute - else - { - return value.substring(idx); - } - } - // if attribute do not found - else - { - return null; - } - } - return value; - } - - /** - * Utility to take attribute value from HTTP header - * @param httpHeaderString an HTTP header string. - * @param attributeName attribute name. - * @return attribute value from HTTP header. - * @throws WSIException if unable to get attribute value from HTTP header. - */ - public static String getHttpHeaderAttribute(String httpHeaderString, - String attributeName) - throws WSIException - { - String attributeValue = - (String) getHttpHeaderTokens(httpHeaderString,":").get(attributeName.toUpperCase()); - // get first token - if((attributeValue != null) && (attributeValue.indexOf(";") != -1)) { - attributeValue = attributeValue.substring(0, attributeValue.indexOf(";")); - } - return attributeValue; - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/HttpHeadersValidator.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/HttpHeadersValidator.java deleted file mode 100644 index f74694fd5..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/HttpHeadersValidator.java +++ /dev/null @@ -1,1721 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.ParseException; -import java.util.Locale; -import java.util.StringTokenizer; - -import sun.net.www.MessageHeader; - -import com.ibm.icu.text.SimpleDateFormat; - -/** - * This class checks HTTP request headers about RFC 2616. - * - * @author Volodin - */ -public class HttpHeadersValidator -{ - - private static final String HEADER_ALLOW = "Allow"; - private static final String HEADER_CONTENT_TYPE = "Content-Type"; - private static final String HEADER_CONTENT_ENCODING = "Content-Encoding"; - private static final String HEADER_CONTENT_LANGUAGE = "Content-Language"; - private static final String HEADER_CONTENT_LENGHT = "Content-Length"; - private static final String HEADER_CONTENT_LOCATION = "Content-Location"; - private static final String HEADER_CONTENT_RANGE = "Content-Range"; - private static final String HEADER_EXPIRES = "Expires"; - private static final String HEADER_LAST_MODIFIED = "Last-Modified"; - private static final String HEADER_CACHE_CONTROL = "Cache-Control"; - private static final String HEADER_CONNECTION = "Connection"; - private static final String HEADER_DATE = "Date"; - private static final String HEADER_PRAGMA = "Pragma"; - private static final String HEADER_TRAILER = "Trailer"; - private static final String HEADER_TRANSFER_ENCODING = "Transfer-Encoding"; - - private static final String HEADER_UPGRADE = "Upgrade"; - private static final String HEADER_VIA = "Via"; - private static final String HEADER_WARNING = "Warning"; - - private static final String HEADER_ACCEPT = "Accept"; - private static final String HEADER_ACCEPT_CHARSET = "Accept-Charset"; - private static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding"; - private static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language"; - private static final String HEADER_AUTHORIZATION = "Authorization"; - private static final String HEADER_EXPECT = "Expect"; - private static final String HEADER_FROM = "From"; - private static final String HEADER_HOST = "Host"; - private static final String HEADER_IF_MATCH = "If-Match"; - private static final String HEADER_IF_MODIFIED_SINCE = "If-Modified-Since"; - private static final String HEADER_IF_NONE_MATCH = "If-None-Match"; - private static final String HEADER_IF_RANGE = "If-Range"; - private static final String HEADER_IF_UNMODIFIED_SINCE = - "If-Unmodified-Since"; - private static final String HEADER_MAX_FORWARDS = "Max-Forwards"; - private static final String HEADER_PROXY_AUTHORIZATION = - "Proxy-Authorization"; - private static final String HEADER_RANGE = "Range"; - private static final String HEADER_REFERER = "Referer"; - private static final String HEADER_TE = "TE"; - private static final String HEADER_USER_AGENT = "User-Agent"; - - /** - * This class checks e-mail string about RFC 822. - */ - public static class MailboxValidator - { - private static final char[] SPECIAL = - { '(', ')', '<', '>', '@', ',', ';', ':', '\\', '\"', '.', '[', ']' }; - - /** - * Validates e-mail string. - * @param mailbox e-mail string - * @return boolean true if e-mail string is conform to RFC 822, false otherwise. - */ - - public static boolean validateMailbox(String mailbox) - { - - if (!isFullAddr(mailbox) && !isShortAddr(mailbox)) - return false; - - return true; - } - - /** - * Method isSimpleAddr. - * @param mailbox - * @return boolean - */ - private static boolean isShortAddr(String mailbox) - { - int indexAt = mailbox.indexOf('@'); - if (indexAt == -1) - return false; - - if (!isLocalPart(mailbox.substring(0, indexAt)) - || !isDomain(mailbox.substring(indexAt + 1))) - return false; - - return true; - } - - /** - * Method isDomaim. - * @param string - * return boolean - */ - private static boolean isDomain(String string) - { - if (string.trim().length() == 0) - return false; - StringTokenizer st = new StringTokenizer(string, "."); - while (st.hasMoreTokens()) - { - String subDomain = st.nextToken(); - if (!isAtom(subDomain) && !isDomainLiteral(subDomain)) - return false; - - } - return true; - } - - /** - * Method isDomainLiteral. - * @param subDomain - * @return boolean - */ - private static boolean isDomainLiteral(String subDomain) - { - if (getLastDomainLiteral(subDomain, 0) == subDomain.length()) - { - return true; - } - else - { - return false; - } - } - - private static int getLastDomainLiteral(String str, int startIndex) - { - - int index = startIndex; - //int newIndex = 0; - - // if end if the string - if (startIndex == str.length()) - return startIndex; - // if the begin is not '[' - if (str.charAt(index) != '[') - return startIndex; - - index++; - while (true) - { - index = getLastDtext(str, index); - if (index == str.length()) - return startIndex; - if (BasicRules.isQuotedPair(str, index - 1)) - { - index++; - if (index == str.length()) - return startIndex; - } - else - break; - } - // if the end is not ']' - if (str.charAt(index) != ']') - return startIndex; - - index++; - return index; - } - - private static int getLastDtext(String str, int startIndex) - { - if (str.length() == startIndex) - return startIndex; - int i = 0; - for (; i < str.length(); i++) - { - char ch = str.charAt(i); - i = BasicRules.getLastIndexLWS(str, i); - if (!BasicRules.isCHAR(ch) - || str.charAt(i) == '[' - || str.charAt(i) == ']' - || str.charAt(i) == '\\' - || str.charAt(i) == BasicRules.CR) - { - return i + 1; - } - } - return i + 1; - } - - /** - * Method isLocalPart. - * @param string - * @return boolean - */ - private static boolean isLocalPart(String string) - { - if (string.trim().length() == 0) - return false; - StringTokenizer st = new StringTokenizer(string, "."); - while (st.hasMoreTokens()) - { - if (!isWord(st.nextToken())) - return false; - } - return true; - } - - /** - * Method isWord. - * @param string - * @return boolean - */ - private static boolean isWord(String string) - { - if (!isAtom(string) && !isQuotedString(string)) - return false; - return true; - } - - /** - * Method isAtom. - * @param string - * @return boolean - */ - private static boolean isAtom(String string) - { - if (string.length() == 0) - return false; - for (int i = 0; i < string.length(); i++) - { - if (!BasicRules.isCHAR(string.charAt(i)) - || isSpecial(string.charAt(i)) - || string.charAt(i) == ' ' - || BasicRules.isCTL(string.charAt(i))) - { - return false; - } - } - return true; - } - - /** - * Method isSpecial. - * @param c - * @return boolean - */ - private static boolean isSpecial(char ch) - { - for (int index = 0; index < SPECIAL.length; index++) - { - if (ch == SPECIAL[index]) - return true; - } - return false; - } - - /** - * Method isFullAddr. - * @param mailbox - * @return boolean - */ - private static boolean isFullAddr(String mailbox) - { - if (mailbox.length() == 0) - return false; - int idxLT = mailbox.indexOf('<'); - if (idxLT == -1) - return false; - - //is phrase - String phrase = mailbox.substring(0, idxLT); - StringTokenizer st = new StringTokenizer(phrase, " "); - if (st.countTokens() == 0) - return false; - while (st.hasMoreTokens()) - { - if (!isWord(st.nextToken())) - return false; - } - if (phrase.charAt(phrase.length() - 1) != BasicRules.SP) - { - return false; - } - - //is route-addr - String routeAddr = mailbox.substring(idxLT + 1); - // is route - int idxTwoSpot = routeAddr.indexOf(':'); - if (idxTwoSpot != -1) - { - StringTokenizer stRouteAddr = - new StringTokenizer(routeAddr.substring(0, idxTwoSpot), ","); - if (!stRouteAddr.hasMoreTokens()) - return false; - while (stRouteAddr.hasMoreTokens()) - { - if (!isDomain(stRouteAddr.nextToken())) - return false; - } - } - - //is addr spec - int idxGT = routeAddr.indexOf('>'); - if (idxGT == -1 || idxGT != (routeAddr.length() - 1)) - return false; - - if (!isShortAddr(routeAddr.substring(idxTwoSpot + 1, idxGT))) - return false; - - return true; - } - - } - - /** - * Validates HTTP request headers. - * @param headers HTTP request headers - * @return boolean true if all HTTP headers string is conform to RFC 2616, false otherwise. - */ - - public static boolean validateHttpRequestHeaders(String headers) - { - - MessageHeader mh = new MessageHeader(); - try - { - mh.parseHeader(new ByteArrayInputStream(headers.getBytes())); - } - catch (IOException e) - { - return false; - } - - String header = null; - String value = null; - - header = mh.getKey(0); - if (header != null) - return false; - - value = mh.getValue(0); - if (value == null) - return false; - - //method - StringTokenizer st = new StringTokenizer(value, " "); - if (!st.hasMoreElements()) - return false; - String str = st.nextToken(); - if (!isToken(str)) - return false; - - if (!st.hasMoreElements()) - return false; - str = st.nextToken(); - if (!isURI(str) && !str.equals("*")) - return false; - - if (!st.hasMoreElements()) - return false; - str = st.nextToken(); - if (!isHTTPVersion(str)) - return false; - - int i = 1; - try - { - while ((header = mh.getKey(i)) != null) - { - value = mh.getValue(i); - i++; - - // is message-header token - if (!isToken(header)) - return false; - - //---- entity-headers - - if (header.equals(HEADER_ALLOW)) - { - if (!isValidAllow(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_CONTENT_TYPE)) - { - if (!isMediaType(value)) - return false; - else - continue; - } - if (header.equals(HEADER_CONTENT_ENCODING)) - { - if (!isToken(value)) - return false; - else - continue; - } - if (header.equals(HEADER_CONTENT_LANGUAGE)) - { - if (!isLanguageTag(value)) - return false; - else - continue; - } - if (header.equals(HEADER_CONTENT_LENGHT)) - { - if (!isDidgit(value)) - return false; - else - continue; - } - if (header.equals(HEADER_CONTENT_LOCATION)) - { - if (!isURI(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_CONTENT_RANGE)) - { - if (!isValidContentRange(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_EXPIRES) - || header.equals(HEADER_LAST_MODIFIED)) - { - if (!isHTTPDate(value)) - return false; - else - continue; - } - - //---- general-headers - if (header.equals(HEADER_CACHE_CONTROL)) - { - if (!isValidCacheControl(value)) - return false; - - continue; - //return true; - } - - if (header.equals(HEADER_CONNECTION)) - { - if (!isToken(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_DATE)) - { - if (!isHTTPDate(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_PRAGMA)) - { - if (!isPragmaDerective(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_TRAILER)) - { - if (!isToken(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_TRANSFER_ENCODING)) - { - if (!isTransferCoding(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_UPGRADE)) - { - if (!isValidUpgrade(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_VIA)) - { - if (!isValidVia(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_WARNING)) - { - if (!isValidWarning(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_ACCEPT)) - { - if (!isValidAccept(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_ACCEPT_CHARSET)) - { - if (!isValidAcceptCharSet(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_ACCEPT_ENCODING)) - { - if (!isValidAcceptEncoding(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_ACCEPT_LANGUAGE)) - { - if (!isValidAcceptLanguage(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_AUTHORIZATION) - || header.equals(HEADER_PROXY_AUTHORIZATION)) - { - if (!isCredentials(value)) - return false; - else - continue; - } - if (header.equals(HEADER_EXPECT)) - { - if (!isExpectation(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_FROM)) - { - if (!MailboxValidator.validateMailbox(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_IF_MATCH) - || header.equals(HEADER_IF_NONE_MATCH)) - { - if (!isValidIfMatch(value)) - return false; - else - continue; - } - if (header.equals(HEADER_IF_RANGE)) - { - if (!isEntityTag(value) && !isHTTPDate(value)) - return false; - else - continue; - } - - //--- - if (header.equals(HEADER_IF_MODIFIED_SINCE)) - { - if (!isHTTPDate(value)) - return false; - else - continue; - } - if (header.equals(HEADER_IF_UNMODIFIED_SINCE)) - { - if (!isHTTPDate(value)) - return false; - else - continue; - } - if (header.equals(HEADER_MAX_FORWARDS)) - { - if (!isDidgit(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_USER_AGENT)) - { - if (!isValidUserAgent(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_TE)) - { - if (!isValidTE(value)) - return false; - else - continue; - } - - if (header.equals(HEADER_RANGE)) - { - if (!isRange(value)) - return false; - else - continue; - } - if (header.equals(HEADER_HOST)) - { - if (!isHost(value)) - return false; - else - continue; - } - if (header.equals(HEADER_REFERER)) - { - if (!isURI(value)) - return false; - else - continue; - } - - } - } - catch (Exception e) - { - return false; - } - return true; - } - - /** - * Method isValidIfMatch. - * @param value - * @return boolean - */ - private static boolean isValidIfMatch(String value) - { - if (value.trim().length() == 0) - return true; - if ("*".equals(value.trim())) - return true; - - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreElements()) - { - String str = st.nextToken().trim(); - if (!isEntityTag(str)) - return false; - - } - - return true; - } - - /** - * Method isValidUpgrade. - * @param value - * @return boolean - */ - private static boolean isValidUpgrade(String value) - { - if (value.trim().length() == 0) - return false; - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreElements()) - { - String str = st.nextToken().trim(); - if (!isProduct(str)) - return false; - - } - return true; - } - - /** - * Method isValidCacheControl. - * @param value - * @return boolean - */ - private static boolean isValidCacheControl(String value) - { - - if (value.trim().length() == 0) - return false; - - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreElements()) - { - String str = st.nextToken().trim(); - int index = str.indexOf('='); - if (index == -1) - { - - } - else - { - if (!isToken(str.substring(0, index))) - return false; - String strAfterEq = str.substring(index + 1); - if (!isToken(strAfterEq) && !isQuotedString(strAfterEq)) - { - return false; - } - } - } - - return true; - } - - /** - * Method isHTTPVersion. - * @param str - * @return boolean - */ - private static boolean isHTTPVersion(String str) - { - if (!str.startsWith("HTTP/")) - return false; - int idx = "HTTP/".length(); - - int idx2 = str.indexOf("."); - - // 1*DIGIT - String s = str.substring(idx, idx2); - if (!isDidgit(s)) - return false; - - s = str.substring(idx2 + 1); - if (!isDidgit(s)) - return false; - - return true; - } - - /** - * Method isValidWarning. - * @param value - * @return boolean - */ - private static boolean isValidWarning(String value) - { - if (value.length() == 0) - return false; - value = value.trim(); - StringTokenizer st = new StringTokenizer(value, " "); - String str = st.nextToken(); - - if (str.length() > 3 || !isDidgit(str)) - return false; - - if (!st.hasMoreTokens()) - return false; - str = st.nextToken(); - if (!isHost(str) && !isToken(str)) - return false; - - //if(!st.hasMoreTokens()) return false; - str = st.nextToken("").trim(); - //??? - - int lastQuotedString = BasicRules.getLastQuotedString(str, 0); - if (lastQuotedString == str.length()) - { - return true; - } - else - { - String data = str.substring(lastQuotedString); - if (data.charAt(data.length()) != '\"') - return false; - if (str.charAt(0) != '\"') - return false; - if (!isHTTPDate(str.substring(1, data.length() - 1))) - return false; - } - - return true; - } - - /** - * Method isValidVia. - * @param value - * @return boolean - */ - private static boolean isValidVia(String value) - { - if (value.trim().length() == 0) - return false; - - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreElements()) - { - - String str = st.nextToken().trim(); - - StringTokenizer st2 = new StringTokenizer(str, " "); - - // protocol/version - str = st2.nextToken(); - int idx = str.indexOf("/"); - if (idx == -1) - { - if (!isToken(str)) - return false; - } - else - { - if (!isToken(str.substring(0, idx)) - || !isToken(str.substring(idx + 1))) - return false; - } - - //host - str = st2.nextToken(); - if (!isHost(str) && !isToken(str)) - return false; - - //comment - if (st2.hasMoreTokens()) - { - str = st2.nextToken(""); - if (!isComment(str.trim())) - return false; - } - } - return true; - } - - /** - * Method isHost. - * @param value - * @return boolean - */ - private static boolean isHost(String value) - { - - try - { - new URL("http://" + value); - } - catch (MalformedURLException e) - { - return false; - } - return true; - } - - /** - * Method isValidAllow. - * @param value - * @return boolean - */ - private static boolean isValidAllow(String value) - { - if (value.trim().length() == 0) - return true; - - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreElements()) - { - String str = st.nextToken().trim(); - if (!isToken(str)) - return false; - } - return true; - } - - /** - * Method isValidContentRange. - * @param value - * @return boolean - */ - private static boolean isValidContentRange(String value) - { - if (value.length() == 0) - return false; - if (!value.startsWith("bytes")) - return false; - String str = value.substring("bytes".length()).trim(); - - int idx = str.indexOf("/"); - if (idx == -1) - return false; - - String byteRange = str.substring(0, idx); - int idx2 = byteRange.indexOf("-"); - if (idx2 == -1) - { - if (!byteRange.equals("*")) - return false; - } - else - { - if (!isDidgit(byteRange.substring(0, idx2)) - || !isDidgit(byteRange.substring(idx2 + 1))) - return false; - } - - if (!isDidgit(str.substring(idx + 1)) - && !str.substring(idx + 1).equals("*")) - return false; - - return true; - } - - /** - * Method isRange. - * @param value - * @return boolean - */ - private static boolean isRange(String value) - { - if (value.length() == 0) - return false; - if (!value.startsWith("bytes=")) - return false; - String strByteRange = value.substring("bytes=".length()); - - StringTokenizer st = new StringTokenizer(strByteRange, ","); - while (st.hasMoreElements()) - { - String str = st.nextToken(); - int idx = str.indexOf("-"); - if (idx == -1) - return false; - if (idx == 0) - { - if (!isDidgit(str.substring(1))) - return false; - } - else - { - if (idx == (str.length() - 1)) - { - if (!isDidgit(str.substring(0, str.length() - 1))) - return false; - } - else - { - if (!isDidgit(str.substring(0, idx)) - || !isDidgit(str.substring(idx + 1))) - return false; - } - - } - - } - return true; - } - - /** - * Method isValidTE. - * @param value - * @return boolean - */ - private static boolean isValidTE(String value) - { - if (value.trim().length() == 0) - return true; - - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreElements()) - { - String str = st.nextToken().trim(); - if (st.equals("trailers")) - return true; - - int idx = str.indexOf(";"); - if (idx == -1) - { - if (!isLanguageRange(str)) - return false; - } - else - { - String _1 = str.substring(0, idx).trim(); - String _2 = str.substring(idx + 1).trim(); - if (!isLanguageRange(_1)) - return false; - if (!isQAndQValue(_2)) - return false; - } - - } - - return true; - } - - /** - * Method isValidUserAgent. - * @param value - * @return boolean - */ - private static boolean isValidUserAgent(String value) - { - if (value.length() == 0) - return false; - StringTokenizer st = new StringTokenizer(value, " "); - while (st.hasMoreElements()) - { - String str = st.nextToken(); - if (!isProduct(str) && !isComment(str)) - return false; - - } - - return true; - } - - /** - * Method isComment. - * @param str - * @return boolean - */ - private static boolean isComment(String str) - { - if (BasicRules.getLastComment(str, 0) != str.length()) - return false; - return true; - } - - /** - * Method isValidAcceptLanguage. - * @param value - * @return boolean - */ - private static boolean isValidAcceptLanguage(String value) - { - if (value.trim().length() == 0) - return false; - - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreElements()) - { - String str = st.nextToken().trim(); - int idx = str.indexOf(";"); - if (idx == -1) - { - if (!isToken(str)) - return false; - } - else - { - String _1 = str.substring(0, idx).trim(); - String _2 = str.substring(idx + 1).trim(); - if (!isToken(_1)) - return false; - if (!isAcceptParams(_2)) - return false; - } - - } - - return true; - } - - /** - * Method isLanguageRange. - * @param str - * @return boolean - */ - private static boolean isLanguageRange(String str) - { - if (str.trim().equals("*")) - return true; - StringTokenizer st = new StringTokenizer(str, "-"); - while (st.hasMoreElements()) - { - if (!is8ALPHA(st.nextToken())) - return false; - } - return true; - } - - /** - * Method isValidAcceptEncoding. - * @param value - * @return boolean - */ - private static boolean isValidAcceptEncoding(String value) - { - if (value.trim().length() == 0) - return false; - - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreElements()) - { - String str = st.nextToken().trim(); - int idx = str.indexOf(";"); - if (idx == -1) - { - if (!isToken(str) && !str.equals("*")) - return false; - } - else - { - String _1 = str.substring(0, idx).trim(); - String _2 = str.substring(idx + 1).trim(); - - if ((!isToken(_1) && !_1.equals("*"))) - return false; - if (!isQAndQValue(_2)) - return false; - } - - } - - return true; - } - - /** - * Method isValidAcceptCharSet. - * @param value - * @return boolean - */ - private static boolean isValidAcceptCharSet(String value) - { - if (value.trim().length() == 0) - return false; - - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreElements()) - { - String str = st.nextToken().trim(); - int idx = str.indexOf(";"); - if (idx == -1) - { - if (!isToken(str) && !str.equals("*")) - return false; - } - else - { - String _1 = str.substring(0, idx).trim(); - String _2 = str.substring(idx + 1).trim(); - - if ((!isToken(_1) && !_1.equals("*"))) - return false; - if (!isQAndQValue(_2)) - return false; - } - - } - - return true; - } - - /** - * Method isValidAccept. - * @param value - * @return boolean - */ - private static boolean isValidAccept(String value) - { - if (value.trim().length() == 0) - return true; - - StringTokenizer st = new StringTokenizer(value, ","); - while (st.hasMoreElements()) - { - String str = st.nextToken().trim(); - int idx = str.indexOf(";"); - if (idx == -1) - { - if (!isMediaRange(str)) - return false; - } - else - { - if (!isMediaRange(str.substring(0, idx).trim()) - || !isAcceptParams(str.substring(idx + 1).trim())) - return false; - - } - - } - return true; - } - - /** - * Method isAcceptParams. - * @param string - * @return boolean - */ - private static boolean isAcceptParams(String string) - { - if (string.trim().length() == 0) - return false; - - StringTokenizer st = new StringTokenizer(string, ";"); - String str = st.nextToken(); - - int idx = str.indexOf("="); - if (idx == -1) - { - if (str.equals("q") || !isToken(str)) - return false; - } - else - { - if (str.substring(0, idx).equals("q")) - { - if (!isQValue(str.substring(idx + 1))) - return false; - } - else - { - if (!isParameterWithoutValue(str)) - return false; - } - } - - while (st.hasMoreElements()) - { - str = st.nextToken(); - if (!isParameterWithoutValue(str)) - return false; - } - return true; - } - - /** - * Method isQAndQValue. - * @param str - * @return boolean - */ - private static boolean isQAndQValue(String str) - { - str = str.trim(); - if (!str.trim().startsWith("q=")) - return false; - if (!isQValue(str.substring("q=".length()))) - return false; - return true; - } - - /** - * Method isQValue. - * @param string - * @return boolean - */ - private static boolean isQValue(String string) - { - if (string.trim().length() == 0) - return false; - - int idx = string.indexOf("."); - if (idx == -1) - { - if (!"0".equals(string) && !"1".equals(string)) - return false; - } - else - { - String strDig = string.substring(idx + 1); - if (strDig.length() > 3) - return false; - - if (string.substring(0, idx).equals("0")) - { - if (!isDidgit(strDig)) - return false; - - } - else - { - if (!string.substring(0, idx).equals("1")) - return false; - - for (int i = 0; i < strDig.length(); i++) - { - if (strDig.charAt(i) != '0') - return false; - } - } - - } - return true; - } - - /** - * Method isMediaRange. - * @param str - * @return boolean - */ - private static boolean isMediaRange(String str) - { - if (str.trim().length() == 0) - return false; - - int idx = str.indexOf("/"); - if (idx == -1) - return false; - - if (!isToken(str.substring(0, idx)) && !str.substring(0, idx).equals("*")) - return false; - if (!isToken(str.substring(idx + 1)) - && !str.substring(idx + 1).equals("*")) - return false; - - return true; - } - - /** - * Method isEntityTag. - * @param value - * @return boolean - */ - private static boolean isEntityTag(String value) - { - - int idx = 0; - if (value.startsWith("W/")) - idx = 2; - if (!isQuotedString(value.substring(idx))) - return false; - return true; - } - - /** - * Method isExpectation. - * @param value - * @return boolean - */ - private static boolean isExpectation(String value) - { - if (value.equals("100-continue")) - return true; - - StringTokenizer st = new StringTokenizer(value, ";"); - while (st.hasMoreElements()) - { - if (!isParameterWithoutValue(st.nextToken())) - return false; - } - - return true; - } - - /** - * Method isCredentials. - * @param value - * @return boolean - */ - private static boolean isCredentials(String value) - { - StringTokenizer st = new StringTokenizer(value, " "); - if (!isToken(st.nextToken())) - return false; - - while (st.hasMoreElements()) - { - String param = st.nextToken(","); - if (!isParameter(param)) - return false; - } - return true; - } - - /** - * Method isProduct. - * @param value - * @return boolean - */ - private static boolean isProduct(String value) - { - int idx = value.indexOf("/"); - if (idx == -1) - { - if (!isToken(value)) - return false; - } - else - { - if (!isToken(value.substring(0, idx)) - || !isToken(value.substring(idx + 1))) - return false; - } - return true; - } - - /** - * Method isTransferCoding. - * @param value - * @return boolean - */ - private static boolean isTransferCoding(String value) - { - if (value.equals("chunked")) - { - return true; - } - else - { - StringTokenizer st = new StringTokenizer(value, ";"); - if (!isToken(st.nextToken())) - return false; - - while (st.hasMoreElements()) - { - if (!isParameter(st.nextToken())) - return false; - } - - } - - return true; - } - - /** - * Method isParameter. - * @param string - * @return boolean - */ - private static boolean isParameter(String string) - { - - // check parameter - int idx = string.indexOf("="); - if (!isToken(string.substring(0, idx))) - return false; - - String parValue = string.substring(idx + 1); - if (!isToken(parValue) && !isQuotedString(parValue)) - return false; - - return true; - } - - /** - * Method isParameterWithoutValue. - * @param string - * @return boolean - */ - private static boolean isParameterWithoutValue(String string) - { - - // check parameter - int idx = string.indexOf("="); - if (idx != -1) - { - if (!isToken(string.substring(0, idx))) - return false; - String parValue = string.substring(idx + 1); - if (!isToken(parValue) && !isQuotedString(parValue)) - return false; - - } - else - { - if (!isToken(string)) - return false; - } - - return true; - } - - /** - * Method isPragmaDerective. - * @param value - * @return boolean - */ - private static boolean isPragmaDerective(String value) - { - if (value.equals("no-cache")) - return true; - else - { - int idx = value.indexOf("="); - if (idx == -1) - { - if (isToken(value)) - return true; - } - else - { - String str = value.substring(idx + 1); - if (isToken(value.substring(0, idx)) - && (isToken(str) || isQuotedString(str))) - return true; - } - } - return true; - } - - /** - * Method isHTTPDate. - * @param value - * @return boolean - */ - private static boolean isHTTPDate(String value) - { - - String rfc1123_date = "EEE, dd MMM yyyy hh:mm:ss 'GMT'"; - String rfc850_date = "EEEE, dd-MMM-yy hh:mm:ss 'GMT'"; - String asctime_date = "EEE MMM d hh:mm:ss yyyy"; - - try - { - SimpleDateFormat sdf = new SimpleDateFormat(rfc1123_date, Locale.US); - if (sdf.parse(value) != null) - return true; - } - catch (ParseException e) - { - } - - try - { - SimpleDateFormat sdf = new SimpleDateFormat(rfc850_date, Locale.US); - if (sdf.parse(value) != null) - return true; - } - catch (ParseException e) - { - } - - try - { - SimpleDateFormat sdf = new SimpleDateFormat(asctime_date, Locale.US); - if (sdf.parse(value) != null) - return true; - } - catch (ParseException e) - { - } - - return false; - - } - - /** - * Method isURI. - * @param value - * @return boolean - */ - private static boolean isURI(String value) - { - try - { - new URL(value); - } - catch (MalformedURLException e) - { - try - { - new URL("http://localhost" + value); - } - catch (MalformedURLException e2) - { - return false; - } - } - - return true; - } - - /** - * Method isLanguageTag. - * @param value - * @return boolean - */ - private static boolean isLanguageTag(String value) - { - int idx = value.indexOf("-"); - if (idx == -1) - { - return is8ALPHA(value); - } - else - { - if (!is8ALPHA(value.substring(0, idx)) - || !is8ALPHA(value.substring(idx + 1))) - return false; - else - return true; - - } - } - - /** - * Method is8ALPHA. - * @param string - * @return boolean - */ - private static boolean is8ALPHA(String string) - { - if (string.length() > 8 || !isALPHA(string)) - return false; - else - return true; - } - - /** - * Method isALPHA. - * @param string - * @return boolean - */ - private static boolean isALPHA(String string) - { - for (int i = 0; i < string.length(); i++) - { - if (!BasicRules.isCHAR(string.charAt(i))) - return false; - } - - return true; - } - - /** - * Method isDidgit. - * @param value - * @return boolean - */ - private static boolean isDidgit(String value) - { - if (value.length() == 0) - return false; - char[] chs = value.toCharArray(); - for (int i = 0; i < chs.length; i++) - { - if (chs[i] < '0' || chs[i] > '9') - return false; - } - - return true; - } - - /** - * Method isMediaType. - * @param value - * @return boolean - */ - private static boolean isMediaType(String value) - { - StringTokenizer st = new StringTokenizer(value, ";"); - String mediaType = st.nextToken(); - - int idx = mediaType.indexOf("/"); - if (!isToken(mediaType.substring(0, idx)) - || !isToken(mediaType.substring(idx + 1))) - { - return false; - } - - while (st.hasMoreElements()) - { - if (!isParameter(st.nextToken(";").trim())) - return false; - } - return true; - } - - /** - * Method isQuotedString. - * @param parValue - * @return boolean - */ - private static boolean isQuotedString(String parValue) - { - if (BasicRules.getLastQuotedString(parValue, 0) != parValue.length()) - { - return false; - } - return true; - } - - /** - * Method isToken. - * @param value - * @return boolean - */ - private static boolean isToken(String value) - { - return BasicRules.isToken(value); - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/JavaEncoding.properties b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/JavaEncoding.properties deleted file mode 100644 index 42935366a..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/JavaEncoding.properties +++ /dev/null @@ -1,31 +0,0 @@ -# /** -# * <copyright> -# * -# * Copyright (c) 2002-2003 IBM Corporation, Beacon Information Technology Inc. and others. -# * All rights reserved. This program and the accompanying materials -# * are made available under the terms of the Eclipse Public License v1.0 -# * which accompanies this distribution, and is available at -# * http://www.eclipse.org/legal/epl-v10.html -# * -# * Contributors: -# * IBM - Initial API and implementation -# * BeaconIT - Initial API and implementation -# * </copyright> -# */ -## I18N: 2003.02.26 modified by K.Nakagome@BeaconIT -## Property file used to get JavaVM supported character encoding. - -ISO8859_1=ISO8859_1 -ISO8859-1=ISO8859_1 -utf8=UTF8 -utf-8=UTF8 -UTF-8=UTF8 -utf16=UTF-16 -utf-16=UTF-16 -UTF16=UTF-16 - -## -Shift_JIS=Windows-31J - -MS932=Windows-31J -#SJIS=Shift_JIS
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/MIMEConstants.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/MIMEConstants.java deleted file mode 100644 index e94b4b4ac..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/MIMEConstants.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -/** - * A set of HTTP values that are defined by Network Working Group. - * http://www.ietf.org/ - * - * @version 1.0 - * @author Ilya Kanonirov (kio@isg.axmor.com) - */ -public class MIMEConstants { - public static final String HEADER_CONTENT_ID = "Content-ID"; - public static final String HEADER_CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding"; - public static final String HEADER_CONTENT_TYPE = "Content-Type"; -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/MIMEUtils.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/MIMEUtils.java deleted file mode 100644 index 76fd947f7..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/MIMEUtils.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.util.HashMap; -import java.util.Map; -import java.util.StringTokenizer; - -import org.eclipse.wst.wsi.internal.core.WSIException; - -/** - * Set of HTTPL related utilities. - * - * @version 1.0.1 - * @author Peter Brittenham - */ - -public final class MIMEUtils -{ - - /** - * Utility to present MIME header information as attribute-value pairs, - * based on ':' as attribute-value separator. - * @param mimeHeaderString an MIME header string. - * @param separators attribute-value separator list. - * @return MIME header information as attribute-value pairs. - * @throws WSIException if unable to create MIME header information - * as attribute-value pairs. - */ - public static Map getMimeHeaderTokens(String mimeHeaderString, String separators) - throws WSIException - { - StringTokenizer tokenizer = new StringTokenizer(mimeHeaderString, "\n\r\f"); - Map map = new HashMap(); - while (tokenizer.hasMoreTokens()) - { - String line = tokenizer.nextToken(); - int index = line.indexOf(separators); - if (index > 0 && index < line.length() - 1) - { - map.put(line.substring(0, index).toUpperCase(), line.substring(index + 1).trim()); - } - } - return map; - } - - /** - * Utility to take sub attribute value from MIME header - * @param mimeHeaderString an MIME header string. - * @param attributeName attribute name. - * @param subAttributeName sub attribute name. - * @return sub attribute value from MIME header. - * @throws WSIException if unable to get sub attribute value from MIME header. - */ - public static String getMimeHeaderSubAttribute(String mimeHeaderString, - String attributeName, String subAttributeName) - throws WSIException - { - // get attribute value - String value = - (String) getMimeHeaderTokens(mimeHeaderString,":").get(attributeName.toUpperCase()); - if(value != null) - { - // search sub attribute token - int idxQ = value.toUpperCase().indexOf(subAttributeName.toUpperCase()+"=\""); - int idx = value.toUpperCase().indexOf(subAttributeName.toUpperCase()+"="); - // if attribute is quoted - if (idxQ != -1) - { - idxQ += (subAttributeName+"=\"").length(); - int eIdxQ = value.indexOf("\"", idxQ); - if (eIdxQ != -1) - { - return value.substring(idxQ, eIdxQ); - } - else - { - return null; - } - } - // if attribute is not quoted - else if (idx != -1) - { - idx += (subAttributeName+"=").length(); - int eIdx = -1; - // find end space separator - if ((eIdx = value.indexOf(" ", idx)) != -1) - { - return value.substring(idx, eIdx); - } - // find coma separator - else if ((eIdx = value.indexOf(";", idx)) != -1) - { - return value.substring(idx, eIdx); - } - // this is last attribute - else - { - return value.substring(idx); - } - } - // if attribute do not found - else - { - return null; - } - } - return value; - } - - /** - * Utility to take attribute value from MIME header - * @param mimeHeaderString an MIME header string. - * @param attributeName attribute name. - * @return attribute value from MIME header. - * @throws WSIException if unable to get attribute value from MIME header. - */ - public static String getMimeHeaderAttribute(String mimeHeaderString, - String attributeName) - throws WSIException - { - String attributeValue = - (String) getMimeHeaderTokens(mimeHeaderString,":").get(attributeName.toUpperCase()); - // get first token - if((attributeValue != null) && (attributeValue.indexOf(";") != -1)) { - attributeValue = attributeValue.substring(0, attributeValue.indexOf(";")); - } - return attributeValue; - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/MessageList.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/MessageList.java deleted file mode 100644 index c04f091e4..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/MessageList.java +++ /dev/null @@ -1,171 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.util.ResourceBundle; - -/** - * This class creates and maintains a message list. - * - * @author Peter Brittenham (peterbr@us.ibm.com) - * @version 1.0.1 - */ -public class MessageList -{ - /** - * Message resource bundle. - */ - private ResourceBundle messageResourceBundle = null; - - /** - * Do not allow this object to be created with null constructor. - */ - private MessageList() - { - } - - /** - * Constructor for MessageList. - * @param resourceBundleName a resource bundle name. - */ - public MessageList(String resourceBundleName) - { - this.messageResourceBundle = ResourceBundle.getBundle(resourceBundleName); - } - - /** - * Get a message from the resource bundle. - * @param key a key. - * @param defaultMessage a default message. - * @return message from the resource bundle. - */ - public String getMessage(String key, String defaultMessage) - { - return getMessage(key, null, defaultMessage); - } - - /** - * Get a message from the resource bundle. - * @param key a key. - * @param messageData message data. - * @param defaultMessage a default message. - * @return message from the resource bundle. - */ - public String getMessage( - String key, - String messageData, - String defaultMessage) - { - String message = defaultMessage; - - try - { - // Get message - message = messageResourceBundle.getString(key); - } - - catch (Exception e) - { - // Ignore and just use default message - } - - if (messageData != null) - message += " " + messageData; - - // Return message - return message; - } - - /** - * Print a message from the resource bundle. - * @param key a key. - * @param defaultMessage a default message. - */ - public void printMessage(String key, String defaultMessage) - { - printMessage(key, null, defaultMessage); - } - - /** - * Print a message from the resource bundle. - * @param key a key. - * @param messageData message data. - * @param defaultMessage a default message. - */ - public void printMessage( - String key, - String messageData, - String defaultMessage) - { - // Print message - System.out.println(getMessage(key, messageData, defaultMessage)); - } - - /** - * Static get message. - * @param resourceBundleName resource bundle name. - * @param key a key. - * @param messageData message data. - * @param defaultMessage a default message. - * @return message. - */ - public static String getMessage( - String resourceBundleName, - String key, - String messageData, - String defaultMessage) - { - String message = defaultMessage; - ResourceBundle messageResourceBundle = null; - - try - { - // Get resource bundle - messageResourceBundle = ResourceBundle.getBundle(resourceBundleName); - - // Get message - message = messageResourceBundle.getString(key); - } - - catch (Exception e) - { - // Ignore and just use default message - } - - if (messageData != null) - message += " " + messageData; - - if (!message.endsWith(".")) - message += "."; - - // Return message - return message; - } - - /** - * Print message. - * @param resourceBundleName resource bundle name. - * @param key a key. - * @param messageData message data. - * @param defaultMessage a default message. - */ - public static void printMessage( - String resourceBundleName, - String key, - String messageData, - String defaultMessage) - { - // Print message - System.out.println( - getMessage(resourceBundleName, key, messageData, defaultMessage)); - } - -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/NullUtil.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/NullUtil.java deleted file mode 100644 index 487cca321..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/NullUtil.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -/** - * The utility class to automate null checking. - * - * @author Kulik - */ -public final class NullUtil -{ - /** - * The method checks objects on existence and compare with <code>equals</code> method. - * @param o1 first object. - * @param o2 second object. - * @return true if first object is equal to the second object. - */ - public static boolean equals(Object o1, Object o2) - { - return ((o1 == null && o2 == null) || (o1 != null && o1.equals(o2))); - } - - /** - * The method checks object on existence and returns its string representation with <code>toString()</code> method. - * @param o source object. - * @return string representation of object. - */ - public static String toString(Object o) - { - return (o == null) ? null : o.toString(); - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/OperationSignature.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/OperationSignature.java deleted file mode 100644 index 639a3f209..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/OperationSignature.java +++ /dev/null @@ -1,788 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import javax.wsdl.Binding; -import javax.wsdl.BindingFault; -import javax.wsdl.BindingInput; -import javax.wsdl.BindingOperation; -import javax.wsdl.BindingOutput; -import javax.wsdl.Definition; -import javax.wsdl.Fault; -import javax.wsdl.Import; -import javax.wsdl.Input; -import javax.wsdl.Message; -import javax.wsdl.Operation; -import javax.wsdl.Output; -import javax.wsdl.Part; -import javax.wsdl.Port; -import javax.wsdl.PortType; -import javax.wsdl.Service; -import javax.wsdl.Types; -import javax.wsdl.extensions.ExtensibilityElement; -import javax.wsdl.extensions.soap.SOAPBinding; -import javax.wsdl.extensions.soap.SOAPBody; -import javax.wsdl.extensions.soap.SOAPFault; -import javax.wsdl.extensions.soap.SOAPHeader; -import javax.wsdl.extensions.soap.SOAPHeaderFault; -import javax.wsdl.extensions.soap.SOAPOperation; -import javax.xml.namespace.QName; - -import org.eclipse.wst.wsi.internal.core.WSIConstants; -import org.eclipse.wst.wsi.internal.core.WSITag; -import org.eclipse.wst.wsi.internal.core.wsdl.traversal.WSDLTraversal; -import org.eclipse.wst.wsi.internal.core.wsdl.traversal.WSDLTraversalContext; -import org.eclipse.wst.wsi.internal.core.wsdl.traversal.WSDLVisitor; -import org.eclipse.wst.wsi.internal.core.xml.XMLUtils; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * The class implements mechanism for creating unique signature of operation. - * - * @author Kulik - */ -public final class OperationSignature -{ - // the flag indicates whether the messages is represented as document style - // vice versa is not generally true - private boolean isDocumentStyle = false; - private boolean isCreated = false; - private boolean isFault = false; - - protected List signature = new LinkedList(); - private Element firstBody = null; - - /** - * Class operates as container for matched operation. - * @author Kulik - */ - public final static class OperationMatch - { - final private String style; - final private BindingOperation operation; - final private List signature; - - /** - * Constructor. - * @param style operation style. - * @param signature a signature. - * @param operation a binding operation. - */ - protected OperationMatch( - String style, - List signature, - BindingOperation operation) - { - this.style = style; - this.signature = signature; - this.operation = operation; - } - /** - * Gets operation style. - * @return operation style. - */ - public String getOperationStyle() - { - return style; - } - /** - * Gets WSDL binding operation object. - * @return WSDL binding operation object. - */ - public BindingOperation getOperation() - { - return operation; - } - - /** - * Gets operation signature as list. - * @return operation signature as list. - */ - public List getSignature() - { - return signature; - } - } - - /** - * The class searches BindingOperation by the given OperationSigbnature. - * @author Kulik - */ - public final class Visitor implements WSDLVisitor - { - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Part, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Part obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Service, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Service obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Types, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Types obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Operation, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Operation obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Input, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Input obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Output, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Output obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Fault, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Fault obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Binding, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Binding obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.BindingOperation, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit( - BindingOperation obj, - Object parent, - WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.BindingInput, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit( - BindingInput obj, - Object parent, - WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.BindingOutput, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit( - BindingOutput obj, - Object parent, - WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(BindingFault, Object, WSDLTraversalContext) - */ - public void visit( - BindingFault obj, - Object parent, - WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Import, Object, WSDLTraversalContext) - */ - public void visit(Import obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Element, Object, WSDLTraversalContext) - */ - public void visit(Element obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Message, Object, WSDLTraversalContext) - */ - public void visit(Message obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Port, Object, WSDLTraversalContext) - */ - public void visit(Port obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(PortType, Object, WSDLTraversalContext) - */ - public void visit(PortType obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Definition, Object, WSDLTraversalContext) - */ - public void visit(Definition obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(ExtensibilityElement, Object, WSDLTraversalContext) - */ - public void visit( - ExtensibilityElement obj, - Object parent, - WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(SOAPHeader, Object, WSDLTraversalContext) - */ - public void visit(SOAPHeader obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(SOAPHeaderFault, Object, WSDLTraversalContext) - */ - public void visit( - SOAPHeaderFault obj, - Object parent, - WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(SOAPFault, Object, WSDLTraversalContext) - */ - public void visit(SOAPFault obj, Object parent, WSDLTraversalContext ctx) - { - } - - private String requiredStyle = null; - private String soapAction = null; - private BindingOperation operation = null; - private TypesRegistry registry = null; - private boolean isSOAPActionRequired = false; - - /** - * Constructor. - */ - public Visitor() - { - super(); - // TODO Auto-generated constructor stub - } - - /** - * Constructor. - * @param requiredStyle required style. - * @param registry types registry. - */ - public Visitor(String requiredStyle, TypesRegistry registry) - { - this.requiredStyle = requiredStyle; - this.registry = registry; - } - - /** - * The method returns matched binding operation. - * @return BindingOperation - */ - public BindingOperation getMatchedOperation() - { - return operation; - } - - /** - * The method sets up required operation to be found. - * The possible values is rpc and document. - * @param requiredStyle operation style. - */ - public void setRequiredStyle(String requiredStyle) - { - this.requiredStyle = requiredStyle; - } - - /** - * The method indicates whether SOAP Action be included into operation. - * signature. - * @return true if SOAP Action isd required. - */ - public boolean isSOAPActionRequired() - { - return isSOAPActionRequired; - } - - /** - * Sets SOAP action to be included into signature. - */ - public void setSOAPActionRequired() - { - isSOAPActionRequired = true; - } - - /** - * internal method. - */ - public void visit( - SOAPBinding binding, - Object parent, - WSDLTraversalContext ctx) - { - String style = - (binding.getStyle() == null) - ? WSIConstants.ATTRVAL_SOAP_BIND_STYLE_DOC - : binding.getStyle(); - ctx.addParameter("style", style); - } - - /** - * internal method. - */ - public void visit( - SOAPOperation operation, - Object parent, - WSDLTraversalContext ctx) - { - soapAction = null; - String style = operation.getStyle(); - if (style == null) - style = (String) ctx.getParameter("style"); - if (!requiredStyle.equals(style)) - ctx.cancelBindingOperationProcessing(); - else - //if (isSOAPActionRequired) - soapAction = operation.getSoapActionURI(); - } - - /** - * internal method. - */ - public void visit(SOAPBody body, Object parent, WSDLTraversalContext ctx) - { - // assert parent instanceof BindingInput - BindingOperation bop = ctx.getBindingOperation(); - if (bop.getOperation() == null - || bop.getOperation().getInput() == null - || bop.getOperation().getInput().getMessage() == null) - return; - - Message msg = bop.getOperation().getInput().getMessage(); - List parts = - WSDLUtil.getParts(bop.getOperation(), msg, body, requiredStyle); - - QName additionalName = null; - // if operation is rpc, add to parts qname qith function name - if (WSIConstants.ATTRVAL_SOAP_BIND_STYLE_RPC.equals(requiredStyle)) - { - // found out target namespace - String namespace = body.getNamespaceURI(); - if (namespace == null || namespace.length() == 0) - // !! ATTENTION - // namespace should be retrieved from service target nameapce - namespace = ctx.getBinding().getQName().getNamespaceURI(); - - // insert operation name as first signature part - additionalName = - new QName(namespace, ctx.getBindingOperation().getName()); - } - - OperationSignature op = - new OperationSignature(parts, null, registry, false); - - if (additionalName != null) - op.getSignature().add(0, additionalName); - //if (isSOAPActionRequired) - //if (soapAction != null) - if (isSOAPActionRequired && soapAction != null) - op.getSignature().add(0, soapAction); - if (op.getSignature().equals(signature)) - { - // required operation is found - operation = ctx.getBindingOperation(); - ctx.cancelBindingOperationProcessing(); - ctx.cancelBindingProcessing(); - } - - else - { - op = new OperationSignature(parts, null, registry, true); - if (additionalName != null) - op.getSignature().add(0, additionalName); - - //if (isSOAPActionRequired) - //if (soapAction != null) - if (isSOAPActionRequired && soapAction != null) - op.getSignature().add(0, soapAction); - - if (op.getSignature().equals(signature)) - { - // required operation is found - operation = ctx.getBindingOperation(); - ctx.cancelBindingOperationProcessing(); - ctx.cancelBindingProcessing(); - } - } - } - } - - /** - * The constructor creates OperationSignature for SOAP message. - * @param doc a Document object. - */ - public OperationSignature(Document doc) - { - Element body = - XMLUtils.findChildElement( - doc.getDocumentElement(), - WSITag.ELEM_SOAP_BODY); - processParts(body, false); - isDocumentStyle |= (signature.size() > 1); - } - - /** - * The constructor creates OperationSIgnature for - * list of <code>Part</code> objects and given WSDL document within these - * parts are defined. - * - * @param parts a list of Part objects. - * @param wsdlDocument a WSDL document. - * @param registry a types registry. - * @param partial a partial status. - */ - public OperationSignature( - List parts, - Document wsdlDocument, - TypesRegistry registry, - boolean partial) - { - if (parts != null) - { - Iterator it = parts.iterator(); - - while (it.hasNext()) - { - Part part = (Part) it.next(); - String localName = (partial) ? part.getName() : null; - QName typeName = part.getTypeName(); - QName elementName = part.getElementName(); - - String namespace = ""; - - // If type name is not null, then a type element was used so it should be an RPC style signature - if (typeName != null) - { - // Part wrappers do not have namespaces - namespace = ""; - - if (localName == null) - localName = typeName.getLocalPart(); - } - - // If element name is not null, then it should be a document style signature - else if (elementName != null) - { - namespace = elementName.getNamespaceURI(); - - if (localName == null) - localName = elementName.getLocalPart(); - } - - signature.add(new QName(namespace, localName)); - } - } - - isCreated = true; - } - - /** - * The method recreates OperationSignature with assumption that operation is - * RPC. - */ - public void createRPCSignature() - { - isCreated = false; - if (firstBody == null) - return; - processParts(firstBody, true); - isDocumentStyle = false; - } - - /** - * Internal method processes WSDL parts and creates operation signature. - * @param parent - */ - private void processParts(Node parent, boolean processWrapper) - { - if (parent != null) - { - Node n = parent.getFirstChild(); - - // variable indicates that first tag is processed - boolean isFirst = true; - // iterate all bodies - while (n != null) - { - if (Node.ELEMENT_NODE == n.getNodeType()) - { - if (isFirst && firstBody == null) - { - isFirst = false; - firstBody = (Element) n; - // check soapenv:fault - if (XMLUtils.equals(n, WSITag.ELEM_SOAP_FAULT)) - { - isFault = true; - isCreated = false; - return; - } - } - - String namespace = n.getNamespaceURI(); - String localName = n.getLocalName(); - - /*I have no idea why this code is in here since it makes no sense at all, so I am commenting it out - // try to get xsi:tag - if (XMLUtils.getAttribute((Element) n, WSITag.ATTR_XSI_TYPE) != null) { - // we suppose that RPC style does not use xsi:type attribute - isDocumentStyle = true; - Attr xsiType = XMLUtils.getAttribute((Element) n, WSITag.ATTR_XSI_TYPE); - - String xsiValue = xsiType.getNodeValue(); - int i = xsiValue.indexOf(':'); - if (i != -1) - { - namespace = XMLUtils.findNamespaceURI(n, xsiValue.substring(0, i)); - localName = xsiValue.substring(i+1); - } - } - */ - - // If this is rpc-literal and processing a part (not the wrapper), then the part should not have a namespace - // And if it does, then one of the test assertions will detect it - if (!isDocumentStyle && processWrapper) - { - namespace = ""; - } - - if (namespace == null || namespace.length() == 0) - { - if (isDocumentStyle) - { - //Element firstChild = null; - Node it = n.getFirstChild(); - while (it != null && !(it instanceof Element)) - it = it.getNextSibling(); - if (it != null) - namespace = it.getNamespaceURI(); - } - } - - // normalize namespaces. All empty namespaces -> null - if (namespace != null && namespace.length() == 0) - namespace = null; - - // put part into signature - signature.add(new QName(namespace, localName)); - } - - n = n.getNextSibling(); - } - } - else - { - isCreated = false; // not found ? - return; - } - - isCreated = true; - } - - /** - * Indicates whether operation has document style or RPC. - * @return true if operation has document style. - */ - public boolean isDocumentStyle() - { - return isDocumentStyle; - } - - /** - * Indicates whether WSDL fault parts should be included into signature or - * not. - * @return true if WSDL fault parts should be included into signature. - */ - public boolean isFault() - { - return isFault; - } - - /** - * Indicates that operation signature was created. - * @return true if operation signature was created. - */ - public boolean isCreated() - { - return isCreated; - } - - /** - * Gets operation signature created for SOAP message. - * @return operation signature created for SOAP message. - */ - public List getSignature() - { - return signature; - } - - /** - * @see java.lang.Object#hashCode() - */ - public int hashCode() - { - return signature.hashCode(); - } - - /** - * @see java.lang.Object#equals(Object) - */ - public boolean equals(Object o) - { - if (o instanceof OperationSignature) - return signature.equals(((OperationSignature) o).getSignature()); - return false; - } - - /** - * The method matches operation based on the given SOAP message request, - * WSDL binding, and soapAction. - * - * @param inputMessage an SOAP message request. - * @param soapAction a soap action. - * @param binding a WSDL binding. - * @param registry a types registry. - * @return OperationMatch object. - */ - public static OperationMatch matchOperation( - Document inputMessage, - String soapAction, - Binding binding, - TypesRegistry registry) - { - return matchOperation(inputMessage, soapAction, binding, registry, true); - } - - /** - * The method matches operation based on the given SOAP message request, - * WSDL binding, and soapAction. - * - * @param inputMessage SOAP message request. - * @param soapAction a soap action. - * @param binding a WSDL binding. - * @param registry a types registry. - * @param soapActionRequired must process the soapAction value even if it is null - * @return OperationMatch object. - */ - public static OperationMatch matchOperation( - Document inputMessage, - String soapAction, - Binding binding, - TypesRegistry registry, - boolean soapActionRequired) - { - // Parse request message - OperationSignature signature = new OperationSignature(inputMessage); - if (!signature.isCreated()) - return null; - - // first of all looking for document style - // because rpc style is subset of document style - OperationSignature.Visitor resolver = - signature.new Visitor(WSIConstants.ATTRVAL_SOAP_BIND_STYLE_DOC, registry); - - // normalize SOAPAction - if (soapAction != null - && soapAction.length() > 1 - && soapAction.charAt(0) == '"' - && soapAction.charAt(soapAction.length() - 1) == '"') - soapAction = soapAction.substring(1, soapAction.length() - 1); - - // if soap action URI processing required - // if soap action URI processing required - // analyze SOAPAction after parts being processed - // put SOAPAction into signature - //if (soapAction != null && soapAction.length() > 0) { - if (soapAction != null) - { - signature.getSignature().add(0, soapAction); - } - - if (soapActionRequired) - resolver.setSOAPActionRequired(); - - WSDLTraversal traversal = new WSDLTraversal(); - //VisitorAdaptor.adapt(resolver); - traversal.setVisitor(resolver); - traversal.visitSOAPBinding(true); - traversal.visitSOAPBody(true); - traversal.visitSOAPOperation(true); - - traversal.ignoreReferences(); - traversal.ignoreBindingOutput(); - traversal.traverse(binding); - - BindingOperation operation = resolver.getMatchedOperation(); - if (operation == null && !signature.isDocumentStyle()) - { - resolver.setRequiredStyle(WSIConstants.ATTRVAL_SOAP_BIND_STYLE_RPC); - signature.createRPCSignature(); - traversal.traverse(binding); - operation = resolver.getMatchedOperation(); - if (operation == null) - return null; - } - - return new OperationMatch( - resolver.requiredStyle, - signature.getSignature(), - resolver.getMatchedOperation()); - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/Pair.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/Pair.java deleted file mode 100644 index 471a192d0..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/Pair.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -/** - * The class represents pair of values. - * - * @author Kulik - */ -public final class Pair -{ - final private Object first; - final private Object second; - - /** - * Constructor. - * @param first object - * @param second object. - */ - public Pair(Object first, Object second) - { - this.first = first; - this.second = second; - } - - /** - * Gets first object. - * @return Object - */ - public Object getFirst() - { - return first; - } - - /** - * Gets second object. - * @return Object - */ - public Object getSecond() - { - return second; - } - - /** - * @see java.lang.Object#equals(Object) - */ - public boolean equals(Object o) - { - if (o == null || !(o instanceof Pair)) - return false; - Pair p = (Pair) o; - return ( - NullUtil.equals(p.getFirst(), first) - && NullUtil.equals(p.getSecond(), second)); - } - - /** - * @see java.lang.Object#hashCode() - */ - public int hashCode() - { - int code = 0; - if (first != null) - code += first.hashCode(); - if (second != null) - code += second.hashCode(); - return code; - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/SetCookie2Validator.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/SetCookie2Validator.java deleted file mode 100644 index 5982e3a85..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/SetCookie2Validator.java +++ /dev/null @@ -1,629 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Vector; - -/** - * This class checks the cookies conform to RFC2965. - * - * @author Baltak - */ -public class SetCookie2Validator -{ - - private Vector commentVect = new Vector(); - private Vector commentURLVect = new Vector(); - private Vector domainVect = new Vector(); - private Vector max_AgeVect = new Vector(); - private Vector pathVect = new Vector(); - private Vector portVect = new Vector(); - private Vector versionVect = new Vector(); - - private boolean path = false; - - /** - * Method resetFlags. - */ - private void resetPath() - { - path = false; - } - - /** - * Check if the string satisfy the "Set-Cookie2" header value. - * @param str String - * @return boolean - */ - public boolean isSetCookie2(String str) - { - - try - { - int index = 0; - int newIndex = 0; - while (true) - { - newIndex = getLastCookie(str, index); - if (index == newIndex) - return false; - // skip spaces - index = newIndex; - index = skipSpaces(str, index); - if (index == str.length()) - { - return true; - } - else - { - if (str.charAt(index) != ',') - return false; - index++; - // skip spaces - index = skipSpaces(str, index); - } - - } - } - catch (Throwable th) - { - return false; - } - - } - - /** - * Method getLastCookie. - * @param str - * @param startIndex - * @return int - */ - private int getLastCookie(String str, int startIndex) - { - - resetPath(); - - int index = startIndex; - // find token - int newIndex = BasicRules.getLastToken(str, index); - if (index == newIndex) - return startIndex; - - index = newIndex; - if (index == str.length()) - return startIndex; - - // if not '=' - error - if (str.charAt(index) != '=') - return startIndex; - - index++; - if (index == str.length()) - return startIndex; - - // get value - newIndex = getLastValue(str, index); - if (index == newIndex) - return startIndex; - - while (true) - { - index = newIndex; - if (index == str.length()) - return index; - - if (str.charAt(index) != ';') - return index; - index++; - // skip spaces - index = skipSpaces(str, index); - - if (index == str.length()) - return startIndex; - newIndex = getLastSetCookieAv(str, index); - if (index == newIndex) - return startIndex; - } - } - - /** - * Method getLastValue. - * @param str - * @param startIndex - * @return int - */ - private int getLastValue(String str, int startIndex) - { - - int index = BasicRules.getLastToken(str, startIndex); - if (index != startIndex) - return index; - index = BasicRules.getLastQuotedString(str, startIndex); - if (index != startIndex) - return index; - - return startIndex; - } - - /** - * Method getLastSetCookieAv. - * @param str - * @param startIndex - * @return int - */ - private int getLastSetCookieAv(String str, int startIndex) - { - - int index = startIndex; - int newIndex = 0; - - if (str.startsWith("Comment=", index)) - { - index += "Comment=".length(); - newIndex = getLastValue(str, index); - if (index == newIndex) - return startIndex; - // debug -> - String qqq = getValue(str, index, newIndex); - commentVect.add(qqq); - // debug <- - return newIndex; - } - else if (str.startsWith("CommentURL=", index)) - { - index += "CommentURL=".length(); - - if (str.charAt(index) != '\"') - return startIndex; - - newIndex = str.indexOf('\"', index + 1); - if (newIndex == -1) - return startIndex; - try - { - new URL(str.substring(index + 1, newIndex)); - } - catch (MalformedURLException mue) - { - return startIndex; - } - // debug -> - String qqq = getValue(str, index + 1, newIndex); - commentURLVect.add(qqq); - // debug <- - newIndex++; - return newIndex; - } - else if (str.startsWith("Discard", index)) - { - return startIndex + "Discard".length(); - } - else if (str.startsWith("Domain=", index)) - { - index += "Domain=".length(); - - newIndex = getLastValue(str, index); - if (index == newIndex) - return startIndex; - - // debug -> - String qqq = getValue(str, index, newIndex); - domainVect.add(qqq); - // debug <- - return newIndex; - } - else if (str.startsWith("Max-Age=", index)) - { - index += "Max-Age=".length(); - - newIndex = getLastValue(str, index); - if (index == newIndex) - return startIndex; - - String qqq = getValue(str, index, newIndex); - try - { - Integer.parseInt(qqq); - } - catch (NumberFormatException nfe) - { - return startIndex; - } - // debug -> - max_AgeVect.add(qqq); - // debug <- - return newIndex; - } - else if (str.startsWith("Path=", index)) - { - index += "Path=".length(); - - newIndex = getLastValue(str, index); - if (index == newIndex) - return startIndex; - - String qqq = getValue(str, index, newIndex); - if (path == false) - pathVect.add(qqq); - path = true; - return newIndex; - } - else if (str.startsWith("Port", index)) - { - index += "Port".length(); - if (str.charAt(index) != '=') - return index; - - index++; - if (str.charAt(index) != '\"') - return startIndex; - - index++; - newIndex = getLastPortList(str, index); - if (index == newIndex) - return startIndex; - - // debug -> - String qqq = getValue(str, index, newIndex); - portVect.add(qqq); - // debug <- - - index = newIndex; - if (str.charAt(index) != '\"') - return startIndex; - index++; - return index; - - } - else if (str.startsWith("Secure", index)) - { - return startIndex + "Secure".length(); - } - else if (str.startsWith("Version=", index)) - { - index += "Version=".length(); - - newIndex = getLastDIGIT(str, index); - if (index == newIndex) - return startIndex; - - // debug -> - String qqq = getValue(str, index, newIndex); - versionVect.add(qqq); - // debug <- - return newIndex; - } - else - { - return startIndex; - } - } - - /** - * Method getLastPortList. - * @param str - * @param startIndex - * @return int - */ - private int getLastPortList(String str, int startIndex) - { - int index = startIndex; - int newIndex = 0; - - while (true) - { - newIndex = getLastDIGIT(str, index); - if (index == newIndex) - return startIndex; - - index = newIndex; - if (str.charAt(index) != ',') - return index; - index++; - } - } - - /** - * Method getLastDIGIT. - * @param str - * @param startIndex - * @return int - */ - private int getLastDIGIT(String str, int startIndex) - { - int index = startIndex; - for (; index < str.length(); index++) - { - if (!BasicRules.isDIGIT(str.charAt(index))) - return index; - } - return index; - } - - /** - * Check if the string satisfy the "Cookie" header value. - * @param str String - * @return boolean - */ - public boolean isCookie(String str) - { - int index = 0; - int newIndex = 0; - - try - { - newIndex = getLastVersion(str, index); - if (index == newIndex) - return false; - - index = newIndex; - index = skipSpaces(str, index); - if (str.charAt(index) != ';' && str.charAt(index) != ',') - return false; - - index++; - index = skipSpaces(str, index); - - while (true) - { - newIndex = getLastCookiesValue(str, index); - if (index == newIndex) - return false; - - index = newIndex; - if (index == str.length()) - return true; - - if (str.charAt(index) != ';' && str.charAt(index) != ',') - return false; - index++; - index = skipSpaces(str, index); - } - } - catch (Throwable th) - { - return false; - } - } - - /** - * Method getLastVersion. - * @param str - * @param startIndex - * @return int - */ - private int getLastVersion(String str, int startIndex) - { - int index = startIndex; - int newIndex = 0; - if (!str.startsWith("$Version=")) - return startIndex; - index += "$Version=".length(); - newIndex = getLastValue(str, index); - if (index == newIndex) - return startIndex; - - return newIndex; - } - - /** - * Method getLastCookiesValue. - * @param str - * @param startIndex - * @return int - */ - private int getLastCookiesValue(String str, int startIndex) - { - int index = startIndex; - int newIndex = 0; - int oldIndex = 0; - - // find token - newIndex = BasicRules.getLastToken(str, index); - if (index == newIndex) - return startIndex; - - index = newIndex; - if (index == str.length()) - return startIndex; - - // if not '=' - error - if (str.charAt(index) != '=') - return startIndex; - - index++; - if (index == str.length()) - return startIndex; - - // get value - newIndex = getLastValue(str, index); - if (index == newIndex) - return startIndex; - - index = newIndex; - if (index == str.length()) - return index; - - if (str.charAt(index) != ';') - return index; - - // process [";" path] [";" domain] [";" port] - oldIndex = index; - index++; - if (index == str.length()) - return startIndex; - - index = skipSpaces(str, index); - if (index == str.length()) - return startIndex; - - // process path - newIndex = getLastPath(str, index); - if (index != newIndex) - { - index = newIndex; - if (index == str.length()) - return index; - - if (str.charAt(index) != ';') - return index; - - oldIndex = index; - index++; - if (index == str.length()) - return startIndex; - - index = skipSpaces(str, index); - if (index == str.length()) - return startIndex; - - } - - // process domain - newIndex = getLastDomain(str, index); - if (index != newIndex) - { - index = newIndex; - if (index == str.length()) - return index; - - if (str.charAt(index) != ';') - return index; - - oldIndex = index; - index++; - if (index == str.length()) - return startIndex; - - index = skipSpaces(str, index); - if (index == str.length()) - return startIndex; - - } - - // process port - newIndex = getLastPort(str, index); - if (index != newIndex) - return newIndex; - else - return oldIndex; - } - - /** - * Method getLastPath. - * @param str - * @param startIndex - * @return int - */ - private int getLastPath(String str, int startIndex) - { - int index = startIndex; - int newIndex = 0; - - if (!str.startsWith("$Path=", index)) - return startIndex; - index += "$Path=".length(); - newIndex = getLastValue(str, index); - if (index == newIndex) - return startIndex; - - return newIndex; - } - - /** - * Method getLastDomain. - * @param str - * @param startIndex - * @return int - */ - private int getLastDomain(String str, int startIndex) - { - int index = startIndex; - int newIndex = 0; - - if (!str.startsWith("$Domain=", index)) - return startIndex; - index += "$Domain=".length(); - newIndex = getLastValue(str, index); - if (index == newIndex) - return startIndex; - - return newIndex; - } - - /** - * Method getLastPort. - * @param str - * @param startIndex - * @return int - */ - private int getLastPort(String str, int startIndex) - { - int index = startIndex; - int newIndex = 0; - - if (!str.startsWith("$Port", index)) - return startIndex; - - index += "$Port".length(); - if (str.charAt(index) != '=') - return index; - - index++; - if (str.charAt(index) != '\"') - return startIndex; - - index++; - newIndex = getLastPortList(str, index); - if (index == newIndex) - return startIndex; - - index = newIndex; - if (str.charAt(index) != '\"') - return startIndex; - index++; - return index; - } - - /** - * Method skipSpaces. - * @param str - * @param index - * @return int - */ - private int skipSpaces(String str, int index) - { - for (; index < str.length(); index++) - if (!BasicRules.isSP(str.charAt(index))) - break; - return index; - } - - /** - * Method getValue. - * @param str - * @param beg - * @param end - * @return String - */ - private String getValue(String str, int beg, int end) - { - String qqq = null; - if (str.charAt(beg) == '\"') - qqq = str.substring(beg + 1, end - 1); - else - qqq = str.substring(beg, end); - return qqq; - } - -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/StringTokenizer.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/StringTokenizer.java deleted file mode 100644 index 5c9539814..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/StringTokenizer.java +++ /dev/null @@ -1,212 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - ********************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -/** - * String tokenizer. - * - * @author: Kulik - */ -final public class StringTokenizer -{ - private char[] spaceDel; - private char[] del; - private char[] allDel; - - /** - * Enumeration of strings. - * @author Kulik - */ - private class StringTokenizerEnumeration implements java.util.Enumeration - { - private final char[] str; - private final int size; - private int index; - - /** - * Constructor. - * @param s - */ - StringTokenizerEnumeration(char[] s) - { - str = s; - size = str.length; - index = 0; - - // skip space delimiters - while (index < size && contain(str[index], spaceDel)) - index++; - } - - /** - * @see java.util.Enumeration#hasMoreElements() - */ - public boolean hasMoreElements() - { - return (index < size); - } - - /** - * @see java.util.Enumeration#nextElement() - */ - public Object nextElement() - { - if (index >= size) - throw new java.util.NoSuchElementException( - "StringTokenizer enumeration"); - - // skip delimiters - int begStr = index; - if (index < size && contain(str[index], del)) - index++; - - // skip word - if (begStr == index) - while (index < size && !contain(str[index], allDel)) - index++; - - int endStr = index; - - // skip space delimiters - while (index < size && contain(str[index], spaceDel)) - index++; - - return String.copyValueOf(str, begStr, endStr - begStr); - } - - /** - * @see java.lang.Object#toString() - */ - public String toString() - { - int i = index; - String s = (String) nextElement(); - index = i; - return s; - } - } - - /** - * StringTokenizer constructor. - * @param spaceDelimiters the set of delimiters to be ignored - * @param delimiters the set of delimiters to be remained. - */ - public StringTokenizer(char[] spaceDelimiters, char[] delimiters) - { - super(); - - if (spaceDelimiters != null) - { - spaceDel = new char[spaceDelimiters.length]; - System.arraycopy(spaceDelimiters, 0, spaceDel, 0, spaceDelimiters.length); - sort(spaceDel); - } - else - spaceDel = null; - - if (delimiters != null) - { - del = new char[delimiters.length]; - System.arraycopy(delimiters, 0, del, 0, delimiters.length); - sort(del); - } - else - del = null; - - if (del != null && spaceDel != null) - { - allDel = new char[del.length + spaceDel.length]; - System.arraycopy(del, 0, allDel, 0, del.length); - System.arraycopy(spaceDel, 0, allDel, del.length, spaceDel.length); - } - else if (del != null) - allDel = del; - else - allDel = spaceDel; - - sort(allDel); - } - /** - * Parses string. - * @return java.util.Enumeration - * @param s java.lang.String - */ - public java.util.Enumeration parse(String s) - { - if (s == null) - throw new IllegalArgumentException("StringTokenizer : String cannot be NULL"); - - return new StringTokenizerEnumeration(s.toCharArray()); - } - - /** - * Binary search. - * @return boolean - * @param c char - */ - private static boolean contain(char c, char[] a) - { - if (a == null) - return false; - - int l = 0, r = a.length - 1, center; - while (l < r) - { - center = (l + r) / 2; - if (c > a[center]) - l = center + 1; - else - r = center; - } - - return a[l] == c; - } - /** - * Heap sort - * @param c char[] - */ - static private void sort(char[] c) - { - if (c != null) - { - int j, k; - char ci; - - // push heap - for (int i = 1; i < c.length; i++) - { - j = ((k = i) - 1) / 2; - ci = c[i]; - while (k > 0 && c[j] < ci) - { - c[k] = c[j]; - j = ((k = j) - 1) / 2; - } - c[k] = ci; - } - - // pop heap - for (int i = c.length - 1; i > 0; i--) - { - j = 2; - k = 0; - ci = c[0]; - while (j <= i) - { - c[k] = (c[j - 1] > c[j]) ? c[--j] : c[j]; - j = ((k = j) + 1) * 2; - } - c[k] = c[i]; - c[i] = ci; - } - } - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/TestUtils.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/TestUtils.java deleted file mode 100644 index c0ae9459e..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/TestUtils.java +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.io.BufferedReader; -import java.io.InputStreamReader; - -import org.eclipse.wst.wsi.internal.core.ToolInfo; -import org.eclipse.wst.wsi.internal.core.WSIConstants; -import org.eclipse.wst.wsi.internal.core.common.AddStyleSheet; -import org.eclipse.wst.wsi.internal.core.xml.XMLUtils; -import org.w3c.dom.Element; - -/** - * Test Utility class. - * - * @version 1.0.1 - * @author Peter Brittenham (peterbr@us.ibm.com) - */ -public final class TestUtils -{ - /** - * Format a style sheet declaration from the addStyleSheet element. - * @param element an Element object. - * @param addStyleSheet an addStyleSheet element. - * @param defaultHref default href. - */ - public static final void parseAddStyleSheet( - Element element, - AddStyleSheet addStyleSheet, - String defaultHref) - { - addStyleSheet.setHref( - XMLUtils.getAttributeValue(element, WSIConstants.ATTR_HREF, defaultHref)); - addStyleSheet.setType( - XMLUtils.getAttributeValue( - element, - WSIConstants.ATTR_TYPE, - WSIConstants.DEFAULT_XSL_TYPE)); - addStyleSheet.setTitle( - XMLUtils.getAttributeValue(element, WSIConstants.ATTR_TITLE)); - addStyleSheet.setMedia( - XMLUtils.getAttributeValue(element, WSIConstants.ATTR_MEDIA)); - addStyleSheet.setCharset( - XMLUtils.getAttributeValue(element, WSIConstants.ATTR_CHARSET)); - addStyleSheet.setAlternate( - XMLUtils.getAttributeValue(element, WSIConstants.ATTR_ALTERNATE)); - } - - /** - * Display tool name and copyright notice. - * @param toolInfo a ToolInfo object. - */ - public static void printToolInfo(ToolInfo toolInfo) - { - System.out.println( - "Conformance " - + toolInfo.getName() - + " Tool" - + ", Version: " - + toolInfo.getVersion() - + ", Release Date: " - + toolInfo.getReleaseDate()); - System.out.println(WSIConstants.COPYRIGHT); - System.out.println(" "); - } - - /** - * Get XML comment used in log and report file. - * @return XML comment used in log and report file. - */ - public static String getXMLComment() - { - String comment = null; - String readLine = null; - - try - { - // Add required comments (copyright, etc.) - BufferedReader bufferedReader = - new BufferedReader( - new InputStreamReader( - Utils.getInputStream(WSIConstants.COMMENTS_FILE))); - - // Initialize string to empty string - comment = ""; - - while (bufferedReader.ready()) - { - if ((readLine = bufferedReader.readLine()) != null) - comment += readLine + WSIConstants.LINE_SEPARATOR; - } - } - - catch (Exception e) - { - // Ignore exception and just return null - } - - return comment; - } - - /** - * Get schema location for XML schema. - * @return schema location for XML schema. - */ - public static String getXMLSchemaLocation() - { - return getSchemaLocation( - WSIProperties.PROP_XML_SCHEMA, - WSIProperties.DEF_XML_SCHEMA); - } - - /** - * Get SOAP schema location. - * @return SOAP schema location. - */ - public static String getSOAPSchemaLocation() - { - return getSchemaLocation( - WSIProperties.PROP_SOAP_SCHEMA, - WSIProperties.DEF_SOAP_SCHEMA); - } - - /** - * Get WSDL schema location. - * @return WSDL schema location. - */ - public static String getWSDLSchemaLocation() - { - return getSchemaLocation( - WSIProperties.PROP_WSDL_SCHEMA, - WSIProperties.DEF_WSDL_SCHEMA); - } - - /** - * Get WSDL SOAP schema location. - * @return WSDL SOAP schema location. - */ - public static String getWSDLSOAPSchemaLocation() - { - return getSchemaLocation( - WSIProperties.PROP_WSDL_SOAP_SCHEMA, - WSIProperties.DEF_WSDL_SOAP_SCHEMA); - } - /** - * Get WSDL schema location. - * @return WSDL schema location. - */ - private static String getSchemaLocation( - String propertyName, - String defaultValue) - { - //String schemaLocation = null; - - // Get the wsi.home system property - //String wsiHome = System.getProperty(WSIProperties.PROP_WSI_HOME); - //String fileLocation = WSIProperties.getProperty(propertyName, defaultValue); - // - // If the file location is specified in the wsi.properties file then build location - //if (fileLocation != null) - //{ - // If wsi.home is set, then use it - // if (wsiHome != null) - // { - // schemaLocation = wsiHome; - // } - // if (schemaLocation == null) - // { - // schemaLocation = fileLocation; - // } - // else - // { - // if (!schemaLocation.endsWith("/")) - // { - // schemaLocation += "/"; - // } - // - // schemaLocation += fileLocation; - // } - // } - return defaultValue; - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/TypesRegistry.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/TypesRegistry.java deleted file mode 100644 index 6c12b28f9..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/TypesRegistry.java +++ /dev/null @@ -1,577 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.wsdl.Binding; -import javax.wsdl.BindingFault; -import javax.wsdl.BindingInput; -import javax.wsdl.BindingOperation; -import javax.wsdl.BindingOutput; -import javax.wsdl.Definition; -import javax.wsdl.Fault; -import javax.wsdl.Import; -import javax.wsdl.Input; -import javax.wsdl.Message; -import javax.wsdl.Operation; -import javax.wsdl.Output; -import javax.wsdl.Part; -import javax.wsdl.Port; -import javax.wsdl.PortType; -import javax.wsdl.Service; -import javax.wsdl.Types; -import javax.wsdl.extensions.ExtensibilityElement; -import javax.wsdl.extensions.UnknownExtensibilityElement; -import javax.wsdl.extensions.soap.SOAPBinding; -import javax.wsdl.extensions.soap.SOAPBody; -import javax.wsdl.extensions.soap.SOAPFault; -import javax.wsdl.extensions.soap.SOAPHeader; -import javax.wsdl.extensions.soap.SOAPHeaderFault; -import javax.wsdl.extensions.soap.SOAPOperation; -import javax.xml.namespace.QName; - -import org.eclipse.wst.wsi.internal.core.WSITag; -import org.eclipse.wst.wsi.internal.core.profile.validator.BaseValidator; -import org.eclipse.wst.wsi.internal.core.wsdl.traversal.WSDLTraversal; -import org.eclipse.wst.wsi.internal.core.wsdl.traversal.WSDLTraversalContext; -import org.eclipse.wst.wsi.internal.core.wsdl.traversal.WSDLVisitor; -import org.eclipse.wst.wsi.internal.core.xml.XMLUtils; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - - -/** - * The class extracts XSD schema information from the given WSDL. - * - * @author Kulik - */ -public final class TypesRegistry implements WSITag, WSDLVisitor -{ - List schemaProcessedList = new ArrayList(); - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Part, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Part obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Service, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Service obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Types, Object, - * WSDLTraversalContext) - */ - public void visit(Types obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Operation, Object, - * WSDLTraversalContext) - */ - public void visit(Operation obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Input, Object, - * WSDLTraversalContext) - */ - public void visit(Input obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Output, Object, - * WSDLTraversalContext) - */ - public void visit(Output obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Fault, Object, - * WSDLTraversalContext) - */ - public void visit(Fault obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Binding, Object, - * WSDLTraversalContext) - */ - public void visit(Binding obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(BindingOperation, Object, - * WSDLTraversalContext) - */ - public void visit( - BindingOperation obj, - Object parent, - WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(BindingInput, Object, - * WSDLTraversalContext) - */ - public void visit(BindingInput obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(BindingOutput, Object, - * WSDLTraversalContext) - */ - public void visit(BindingOutput obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(BindingFault, Object, - * WSDLTraversalContext) - */ - public void visit(BindingFault obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Element, Object, - * WSDLTraversalContext) - */ - public void visit(Element obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Message, Object, - * WSDLTraversalContext) - */ - public void visit(Message obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Port, Object, - * WSDLTraversalContext) - */ - public void visit(Port obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(PortType, Object, - * WSDLTraversalContext) - */ - public void visit(PortType obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(Definition, Object, - * WSDLTraversalContext) - */ - public void visit(Definition obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(ExtensibilityElement, - * Object, WSDLTraversalContext) - */ - public void visit( - ExtensibilityElement obj, - Object parent, - WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(SOAPBinding, Object, - * WSDLTraversalContext) - */ - public void visit(SOAPBinding obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(SOAPBody, Object, - * WSDLTraversalContext) - */ - public void visit(SOAPBody obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(SOAPHeader, Object, - * WSDLTraversalContext) - */ - public void visit(SOAPHeader obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(SOAPHeaderFault, Object, - * WSDLTraversalContext) - */ - public void visit( - SOAPHeaderFault obj, - Object parent, - WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(SOAPFault, Object, - * WSDLTraversalContext) - */ - public void visit(SOAPFault obj, Object parent, WSDLTraversalContext ctx) - { - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(SOAPOperation, Object, - * WSDLTraversalContext) - */ - public void visit(SOAPOperation obj, Object parent, WSDLTraversalContext ctx) - { - } - - private Map element2Type = new HashMap(); - private Set extendsArray = new HashSet(); - private Set usesWsdlArrayType = new HashSet(); - - protected BaseValidator baseValidator = null; - - /** - * Constructor creates the types registry. by the given WSDL definition - * object. - * - * @param def a WSDL definition. - * @param baseValidator a base validator. - */ - public TypesRegistry(Definition def, BaseValidator baseValidator) - { - this.baseValidator = baseValidator; - if (def == null) - throw new IllegalArgumentException("Definition can not be null"); - - WSDLTraversal traversal = new WSDLTraversal(); - //VisitorAdaptor.adapt(this); - traversal.setVisitor(this); - traversal.visitImport(true); - - processTypes(def.getTypes(), def.getDocumentBaseURI()); - traversal.traverse(def); - } - - /** - * Constructor creates the types registry by given WSDL types object and - * location context URI. - * @param types WSDL types object. - * @param context location context URI. - * @param baseValidator a base validator. - */ - public TypesRegistry( - Types types, - String context, - BaseValidator baseValidator) - { - this.baseValidator = baseValidator; - processTypes(types, context); - } - - /** - * The method returns type's qname by given element's qname. - * @param elementName a qualified element name. - * @return type's qname by given element's qname. - */ - public QName getType(QName elementName) - { - return (QName) element2Type.get(elementName); - } - - /** - * The method returns set of types which is array attribute. - * @return set of types which is array attribute. - */ - public Set getArrayTypes() - { - Set s = new HashSet(); - s.addAll((Collection) usesWsdlArrayType); - s.addAll((Collection) extendsArray); - return s; - } - - /** - * The method returns set of elements defined in types element. - * @return set of elements defined in types element. - */ - public Set getElementList() - { - return this.element2Type.keySet(); - } - - /** - * The method returns true if the given type declares wsdl:arrayType - * attribute within declaration. - * @param type a type. - * @return true if the given type declares wsdl:arrayType - * attribute within declaration. - */ - public boolean isUsesWSDLArrayType(QName type) - { - return usesWsdlArrayType.contains(type); - } - - /** - * The method returns true if given type extends soapenc:Array type. - * @param type a type. - * @return true if given type extends soapenc:Array type. - */ - public boolean isExtendsArray(QName type) - { - return extendsArray.contains(type); - } - - /* (non-Javadoc) - * @see org.wsi.wsdl.traversal.WSDLVisitor#visit(javax.wsdl.Import, java.lang.Object, org.wsi.wsdl.traversal.WSDLTraversalContext) - */ - public void visit(Import im, Object parent, WSDLTraversalContext ctx) - { - if (im.getDefinition() != null) - processWSDL(im.getDefinition()); - } - - /** - * Internal method processes WSDL definition. - * @param def a WSDL definition. - */ - private void processWSDL(Definition def) - { - if (def.getTypes() != null) - processTypes(def.getTypes(), def.getDocumentBaseURI()); - } - - /** - * Internal method processes WSDL types. - * @param types WSDL types. - * @param context a context. - */ - private void processTypes(Types types, String context) - { - if (types == null) - return; - List exts = types.getExtensibilityElements(); - if (exts != null) - { - Iterator it = exts.iterator(); - while (it.hasNext()) - { - ExtensibilityElement el = (ExtensibilityElement) it.next(); - if (el instanceof UnknownExtensibilityElement) - searchForSchema( - ((UnknownExtensibilityElement) el).getElement(), - context); - } - } - } - - /** - * Internal method searches XSD schema declaration and XSD import - * statements. - * @param n - * @param context - */ - private void searchForSchema(Node n, String context) - { - while (n != null) - { - // searches for xsd:import element - if (Node.ELEMENT_NODE == n.getNodeType()) - { - // if xsd:schema element is found -> process schema - if (XMLUtils.equals(n, ELEM_XSD_SCHEMA)) - processSchema(n, context); - } - n = n.getNextSibling(); - } - } - - /** - * Internal method loads XSD schema by using schema location and - * location context. - * @param importNode - * @param context - */ - private void loadSchema(Node importNode, String context) - { - Element im = (Element) importNode; - Attr schemaLocation = XMLUtils.getAttribute(im, ATTR_XSD_SCHEMALOCATION); - - // try to parse imported XSD - if (schemaLocation != null && schemaLocation.getValue() != null) - try - { - String urlString = XMLUtils.createURLString(schemaLocation.getValue(), context); - if (!schemaProcessedList.contains(urlString)) - { - // if any error or root element is not XSD schema -> error - Document schema = - baseValidator.parseXMLDocumentURL( - schemaLocation.getValue(), - context, - null); - schemaProcessedList.add(urlString); - if (XMLUtils.equals(schema.getDocumentElement(), ELEM_XSD_SCHEMA)) - processSchema( - schema.getDocumentElement(), - urlString); - } - } - catch (Throwable t) - { - //t.printStackTrace(); - // nothing. it's not a schema - } - } - - /** - * Internal method processes XSD schema and retrieves types declaration from - * it. - * @param schema - * @param context - */ - private void processSchema(Node schema, String context) - { - Attr a = XMLUtils.getAttribute((Element) schema, ATTR_XSD_TARGETNAMESPACE); - String targetNamespace = (a != null) ? a.getValue() : ""; - // iterate schema - Node n = schema.getFirstChild(); - // !! we suppose that xsd:import element is occured only within xsd:schema element - while (n != null) - { - if (Node.ELEMENT_NODE == n.getNodeType()) - { - if (XMLUtils.equals(n, ELEM_XSD_ELEMENT)) - { - Element el = (Element) n; - a = XMLUtils.getAttribute(el, ATTR_XSD_NAME); - QName element = - new QName(targetNamespace, (a != null) ? a.getValue() : ""); - - a = XMLUtils.getAttribute(el, ATTR_XSD_TYPE); - QName type = null; - if (a != null) - { - String t = a.getValue(); - // if type contains ':', it means that it contains qname - int i = t.indexOf(':'); - if (i != -1) - { - String prefix = t.substring(0, i); - String nsURI = XMLUtils.findNamespaceURI(n, prefix); - type = new QName(nsURI, t.substring(i + 1)); - } - else - type = new QName(targetNamespace, t); - } - else - { - // suppose that element directly contains type declaration - type = element; - checkType(n, type); - } - - element2Type.put(element, type); - } - else if (XMLUtils.equals(n, ELEM_XSD_IMPORT)) - loadSchema(n, context); - else if (XMLUtils.equals(n, ELEM_XSD_INCLUDE)) - loadSchema(n, context); - else if (XMLUtils.equals(n, ELEM_XSD_COMPLEXTYPE)) - { - Element el = (Element) n; - a = XMLUtils.getAttribute(el, ATTR_XSD_NAME); - QName type = - new QName(targetNamespace, (a != null) ? a.getValue() : ""); - checkType(n, type); - } - - } - - n = n.getNextSibling(); - } - } - - /** - * Internal method checks whether specified type has WSDL array type - * attribute in the XSD declaration. - * @param n - * @param name - */ - private void checkType(Node n, QName name) - { - while (n != null) - { - if (Node.ELEMENT_NODE == n.getNodeType()) - { - // check such sentence - // xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="tns:MyArray2Type[]"/> - if (XMLUtils.equals(n, ELEM_XSD_ATTRIBUTE)) - { - Attr a = XMLUtils.getAttribute((Element) n, ATTR_WSDL_ARRAYTYPE); - if (a != null) - usesWsdlArrayType.add(name); - } - - // retrieve base attribute may be from restriction or extension - Attr a = XMLUtils.getAttribute((Element) n, ATTR_XSD_BASE); - if (a != null) - { - String base = a.getValue(); - int i = base.indexOf(":"); - if (i != -1) - { - String prefix = base.substring(0, i); - String local = base.substring(i + 1); - String namespace = XMLUtils.findNamespaceURI(n, prefix); - if (SOAPENC_ARRAY.equals(new QName(namespace, local))) - extendsArray.add(name); - } - } - checkType(n.getFirstChild(), name); - } - n = n.getNextSibling(); - } - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/UDDIUtils.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/UDDIUtils.java deleted file mode 100644 index c572363a8..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/UDDIUtils.java +++ /dev/null @@ -1,336 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Vector; - -import org.uddi4j.UDDIException; -import org.uddi4j.client.UDDIProxy; -import org.uddi4j.datatype.binding.BindingTemplate; -import org.uddi4j.datatype.binding.TModelInstanceInfo; -import org.uddi4j.datatype.business.BusinessEntity; -import org.uddi4j.datatype.service.BusinessService; -import org.uddi4j.datatype.tmodel.TModel; -import org.uddi4j.response.BusinessDetail; -import org.uddi4j.response.ServiceDetail; -import org.uddi4j.response.TModelDetail; -import org.uddi4j.response.TModelInfo; -import org.uddi4j.response.TModelList; -import org.uddi4j.transport.TransportException; -import org.uddi4j.util.CategoryBag; -import org.uddi4j.util.FindQualifier; -import org.uddi4j.util.FindQualifiers; -import org.uddi4j.util.KeyedReference; - -/** - * This class provide some service functions used by UDDIValidator. - * - * @version 1.0.1 - * @author Peter Brittenham - */ -public final class UDDIUtils -{ - static public final FindQualifiers EXACT_NAME_MATCH_QUALIFIER; - static { - Vector vector = new Vector(); - EXACT_NAME_MATCH_QUALIFIER = new FindQualifiers(); - vector.add(new FindQualifier(FindQualifier.exactNameMatch)); - vector.add(new FindQualifier(FindQualifier.sortByNameAsc)); - EXACT_NAME_MATCH_QUALIFIER.setFindQualifierVector(vector); - } - - static final String WS_I_CONFORMANCE_TMODEL_NAME = - "ws-i-org:conformsTo:2002_12"; - - static private Hashtable wsiConformanceTable = new Hashtable(); - - /** - * Gets a business service by key. - * @param proxy a UDDI proxy. - * @param key a key to a business service. - * @return a business service specified by the given key. - * @throws TransportException if error originating within the SOAP transport. - * @throws UDDIException if the return value of a UDDI API cannot indicate an error condition. - */ - public static BusinessService getBusinessServiceByKey( - UDDIProxy proxy, - String key) - throws TransportException, UDDIException - { - BusinessService result = null; - - ServiceDetail sd = proxy.get_serviceDetail(key); - - if (sd != null) - { - Vector v = sd.getBusinessServiceVector(); - - if (v != null && v.size() > 0) - { - result = (BusinessService) v.firstElement(); - } - } - - return result; - } - - /** - * Gets business entity by key. - * @param proxy a UDDI proxy. - * @param key a key to a business entiy. - * @return a business entity specified by the given key. - * @throws TransportException if error originating within the SOAP transport. - * @throws UDDIException if the return value of a UDDI API cannot indicate - * an error condition. - */ - public static BusinessEntity getBusinessByKey(UDDIProxy proxy, String key) - throws TransportException, UDDIException - { - BusinessEntity result = null; - - BusinessDetail bd = proxy.get_businessDetail(key); - - if (bd != null) - { - Vector v = bd.getBusinessEntityVector(); - - if (v != null && v.size() > 0) - { - result = (BusinessEntity) v.firstElement(); - } - } - - return result; - } - - /** - * Gets a tModel by key. - * @param proxy a UDDI proxy. - * @param key a key to a tModel. - * @return a tModel specified by the given key. - * @throws TransportException if error originating within the SOAP transport. - * @throws UDDIException if the return value of a UDDI API cannot indicate - * an error condition. - */ - public static TModel getTModelByKey(UDDIProxy proxy, String key) - { - TModel result = null; - - try - { - TModelDetail bd = proxy.get_tModelDetail(key); - - if (bd != null) - { - Vector v = bd.getTModelVector(); - - if (v != null && v.size() > 0) - { - result = (TModel) v.firstElement(); - } - } - } - catch (Throwable e) - { - } - - return result; - } - - /** - * Gets key of the WSI Conformance tModel. - * @param proxy a UDDI proxy. - * @return the key of the WSI Conformance tModel. - */ - public static String getWSIConformanceTModelKey(UDDIProxy proxy) - { - if (proxy == null) - throw new IllegalArgumentException("UDDI proxy cannot be null."); - - String result = null; - - if (wsiConformanceTable.containsKey(proxy)) - { - result = wsiConformanceTable.get(proxy).toString(); - } - else - { - result = getTModelKeyByName(proxy, WS_I_CONFORMANCE_TMODEL_NAME); - - if (result == null) - { - throw new IllegalStateException("WS-I conformance taxonomy tModel was not found"); - } - - wsiConformanceTable.put(proxy, result); - } - - return result; - } - - /** - * Gets a tModel key by tModel name. - * @param proxy a UDDI proxy. - * @param name a tModel name. - * @return a tModel key specified by the given tModel name. - */ - public static String getTModelKeyByName(UDDIProxy proxy, String name) - { - String result = null; - try - { - TModelList list = - proxy.find_tModel(name, null, null, EXACT_NAME_MATCH_QUALIFIER, 1); - TModelInfo info = - (TModelInfo) list.getTModelInfos().getTModelInfoVector().firstElement(); - result = info.getTModelKey(); - } - catch (Throwable e) - { - } - - return result; - } - - /** - * Get string representation of bindingTemplate. - * @param bindingTemplate a BindingTemplate object. - * @return a string representation of bindingTemplate. - */ - public static String bindingTemplateToString(BindingTemplate bindingTemplate) - { - String returnString = ""; - - if (bindingTemplate == null) - returnString = "null"; - - else - { - returnString = - "accessPoint: " - + (bindingTemplate.getAccessPoint() == null - ? "null" - : bindingTemplate.getAccessPoint().getText()); - - if (bindingTemplate.getTModelInstanceDetails() == null - || bindingTemplate - .getTModelInstanceDetails() - .getTModelInstanceInfoVector() - == null) - { - returnString += ", [no tModel reference]"; - } - - else - { - Iterator iterator = - bindingTemplate - .getTModelInstanceDetails() - .getTModelInstanceInfoVector() - .iterator(); - - int infoCount = 1; - TModelInstanceInfo info; - while (iterator.hasNext()) - { - info = (TModelInstanceInfo) iterator.next(); - returnString += ", [" - + infoCount++ - + "] tModelKey: " - + info.getTModelKey(); - } - } - } - - return returnString; - } - - /** - * Get string representation of tModel. - * @param tModel a TModel object. - * @return a string representation of tModel. - */ - public static String tModelToString(TModel tModel) - { - String returnString = ""; - - if (tModel == null) - returnString = "null"; - - else - { - returnString = - "name: " - + tModel.getNameString() - + ", categoryBag: " - + (tModel.getCategoryBag() == null - ? "null" - : categoryBagToString(tModel.getCategoryBag())) - + ", overviewURL: " - + (tModel.getOverviewDoc() == null - ? "null" - : tModel.getOverviewDoc().getOverviewURLString()); - } - - return returnString; - } - - /** - * Get string representation of categoryBag. - * @param categoryBag a CategoryBag object. - * @return a tring representation of categoryBag. - */ - public static String categoryBagToString(CategoryBag categoryBag) - { - String returnString = ""; - - if (categoryBag == null) - { - returnString += "null"; - } - - else - { - returnString += "KeyedReferenceList: "; - - Vector krList = null; - if ((krList = categoryBag.getKeyedReferenceVector()) == null) - { - returnString += "null"; - } - - else if (krList.size() == 0) - { - returnString += "empty"; - } - - else - { - KeyedReference kr = null; - Iterator iterator = krList.iterator(); - while (iterator.hasNext()) - { - kr = (KeyedReference) iterator.next(); - returnString += "tModelKey: " - + kr.getTModelKey() - + ", keyName: " - + kr.getKeyName() - + ", keyValue: " - + kr.getKeyValue(); - } - } - } - - return returnString; - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/Utils.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/Utils.java deleted file mode 100644 index 85882d297..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/Utils.java +++ /dev/null @@ -1,1416 +0,0 @@ -/******************************************************************************* - * - * Copyright (c) 2002-2003 IBM Corporation, Beacon Information Technology Inc. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - * BeaconIT - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.UnsupportedEncodingException; -import java.net.ConnectException; -import java.net.InetAddress; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.ResourceBundle; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.eclipse.wst.wsi.internal.core.WSIConstants; -import org.eclipse.wst.wsi.internal.core.WSIException; -import org.eclipse.wst.wsi.internal.core.log.MimePart; -import org.eclipse.wst.wsi.internal.core.log.MimeParts; -import org.eclipse.wst.wsi.internal.core.log.impl.MimePartImpl; -import org.eclipse.wst.wsi.internal.core.log.impl.MimePartsImpl; -import org.eclipse.wst.wsi.internal.core.profile.ProfileAssertions; -import org.eclipse.wst.wsi.internal.core.xml.XMLUtils; - -import com.ibm.icu.text.SimpleDateFormat; -import com.ibm.icu.util.TimeZone; - -/** - * General set of utilities. - */ -public final class Utils -{ - public static final byte CR = (byte) '\r'; - public static final byte LF = (byte) '\n'; - - /** - * Common timestamp format. - */ - // public static final SimpleDateFormat timestampFormat = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - public static final SimpleDateFormat timestampFormat = - new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); - - /** - * Basic date format. - */ - public static final SimpleDateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd"); - - /** - * Wrapper method for error logging; - * for now it just goes to stderr. - * @param inError an error message. - */ - public final static void logError(String inError) - { - System.err.println("Error: " + inError); - } - - /** - * Get exception information as a string. - * @param throwable a Throwable object. - * @return exception information as a string. - */ - public final static String getExceptionDetails(Throwable throwable) - { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - - pw.println("Exception: "); - throwable.printStackTrace(pw); - - return sw.toString(); - } - - /** - * Get current date and time as a timestamp. - * @return urrent date and time as a timestamp. - */ - public static String getTimestamp() - { - // Use GMT timezone - //timestampFormat.setTimeZone(TimeZone.getTimeZone("GMT")); - timestampFormat.setTimeZone(TimeZone.getDefault()); - - // Return timestamp - return timestampFormat.format(new Date()); - } - - /** - * Get current date for default time zone. - * @return current date for default time zone. - */ - public static String getDate() - { - // Use GMT timezone - dateFormat.setTimeZone(TimeZone.getDefault()); - - // Return date - return dateFormat.format(new Date()); - } - - /** - * Get HTTP status code. - * @param httpHeaders HTTP headers. - * @return HTTP status code. - * @throws WSIException if the status code in http headers was not found. - */ - public static String getHTTPStatusCode(String httpHeaders) - throws WSIException - { - String statusCode = null; - - if (httpHeaders.startsWith("HTTP")) - { - // Get location of status code - int index = httpHeaders.indexOf(" "); - int index2 = httpHeaders.indexOf(" ", index + 1); - - if ((index == -1) || (index2 == -1)) - { - throw new WSIException( - "Could not find status code in http headers: [" + httpHeaders + "]."); - } - - else - { - statusCode = httpHeaders.substring(index + 1, index2); - } - } - - else - { - throw new WSIException( - "Could not find status code in http headers: [" + httpHeaders + "]."); - } - - // Return status code - return statusCode; - } - - /** - * Get HTTP headers from a full message. - * @param fullMessage a message. - * @return HTTP headers from a full message. - */ - public static String getHTTPHeaders(String fullMessage) - { - //String httpHeaders = null; - - // Try looking for the double newline - int index = fullMessage.indexOf("\r\n\r\n"); - if (index != -1) - { - index += 4; - } - else - { - // check for case "\r\r...\r\n\r\r...\n" - // Note the index that is returned points to the first character - // immediatedly following the first occurence of the CRLFCRLF. - index = getFirstCRLFCRLF(fullMessage); - if (index == -1) - { - logError( - "Unable to parse HTTP message to find headers. Full message: " - + fullMessage); - return "x-WSI-Test-Tool-Error: Couldn't find headers. Full message: [" - + fullMessage - + "]."; - } - } - - // Return HTTP headers - return fullMessage.substring(0, index); - } - - /** - * Get SOAP message from a full message. - * @param fullMessage a message. - * @return SOAP message from a full message. - */ - public static String getContent(String fullMessage) - { - String message = ""; - - // Find start of message - int index = fullMessage.indexOf("\r\n\r\n"); - if (index != -1) - { - index += 4; - } - else - { - // check for case "\r\r...\r\n\r\r...\n" - // Note the index that is returned points to the first character - // immediatedly following the first occurence of the CRLFCRLF. - index = getFirstCRLFCRLF(fullMessage); - } - - if (index < 0) - { - // If we couldn't find the end of the HTTP headers or the start of the message, then show error - logError( - "Unable to parse message to get content. Full message: " - + fullMessage); - message = - "x-WSI-Test-Tool-Error: Couldn't find message content. Full message: [" - + fullMessage - + "]."; - } - // If the index is greater than the length, then there is no message content - else if (index >= fullMessage.length()) - { - message = ""; - } - - // Else get the message content - else - { - message = fullMessage.substring(index); - } - - // Return SOAP message - return message; - } - - /** - * Get HTTP headers from a full message. - * @param fullMessage a message. - * @return HTTP headers from a full message. - */ - public static byte[] getHTTPHeaders(byte[] fullMessage) - { - //String httpHeaders = null; - int index = getFirstCRLFCRLF(fullMessage, 0); - if (index == -1) - { - logError( - "Unable to parse HTTP message to find headers. Full message: " - + fullMessage); - return ("x-WSI-Test-Tool-Error: Couldn't find headers. Full message: [" - + fullMessage + "].").getBytes(); - } - - // Return HTTP headers - byte[] b = new byte[index]; - System.arraycopy(fullMessage, 0, b, 0, index); - - return b; - } - - /** - * Get HTTP headers from a full message. - * @param fullMessage a message. - * @return HTTP headers from a full message. - */ - public static String getHTTPHeadersAsString(byte[] fullMessage, String encoding) - { - //String httpHeaders = null; - int index = getFirstCRLFCRLF(fullMessage, 0); - if (index == -1) - { - logError( - "Unable to parse HTTP message to find headers. Full message: " - + fullMessage); - return "x-WSI-Test-Tool-Error: Couldn't find headers. Full message: [" - + fullMessage + "]."; - } - - // Return HTTP headers - try - { - return new String(fullMessage, 0, index, encoding); - } - catch (UnsupportedEncodingException e) - { - logError( - "Unsupported Encoding: " + encoding + ". Full message: " - + fullMessage); - return "x-WSI-Test-Tool-Error: Unsupported Encoding \"" + encoding + "\". Full message: [" - + fullMessage + "]."; - } - } - - /** - * Get SOAP message from a full message. - * @param fullMessage a message. - * @return SOAP message from a full message. - */ - public static String getContentAsString(byte[] message) - { - String content = ""; - //String httpHeaders = null; - int index = getFirstCRLFCRLF(message, 0); - - // If we couldn't find the end of the HTTP headers or the start of the message, then show error - if (index < 0) - { - logError( - "Unable to parse message to get content. Full message: " - + message); - content = - "x-WSI-Test-Tool-Error: Couldn't find message content. Full message: [" - + message.toString() - + "]."; - } - - // Else get the message content - else if (index < message.length) - { - try - { - content = new String(message, index, message.length - index); - } - catch (Exception e) - { - logError( - "Unable to parse message to get content. Full message: " - + message); - content = - "x-WSI-Test-Tool-Error: Couldn't find message content. Full message: [" - + message.toString() - + "]."; - } - } - - // Return SOAP message - return content; - } - - /** - * Get SOAP message from a full message. - * @param fullMessage a message. - * @return SOAP message from a full message. - */ - public static byte[] getContent(byte[] message) - { - byte[] content = new byte [0]; - - //String httpHeaders = null; - int index = getFirstCRLFCRLF(message, 0); - - // If we couldn't find the end of the HTTP headers or the start of the message, then show error - if (index < 0) - { - logError( - "Unable to parse message to get content. Full message: " - + message); - message = - ("x-WSI-Test-Tool-Error: Couldn't find message content. Full message: [" - + message.toString() - + "].").getBytes(); - } - - // If the index is greater than the length, then there is no message content - //else if (index >= fullMessage.length()) - //{ - // message = ""; - //} - - // Else get the message content - else if (index < message.length) - { - byte[] b = new byte[message.length - index]; - System.arraycopy(message, index, b, 0, message.length - index); - - content = b; - } - - // Return SOAP message - return content; - } - - - /** - * Returns the first location of a CRLF. - * - * @return int - */ - public static int getFirstCRLF(byte[] buffer, int index) - { - int size = buffer.length; - int i = index; - while (i < size - 1) { - if (buffer[i] == CR && buffer[i+1] == LF) - return i; - i++; - } - return -1; - } - - /** - * Returns the first location of a CRLF followed imediately by another CRLF. - * - * @return int - */ - public static int getFirstCRLFCRLF(byte[] buffer, int index) - { - int size = buffer.length; - int i = index; - while (i < size - 3) - { - if (buffer[i] == CR && buffer[i+1] == LF && buffer[i+2] == CR) - { - if (buffer[i+3] == LF) - { - return i+4; - } - else - { - int j = i + 3; - while (j < buffer.length && buffer[j] == CR) - { - j++; - } - if (j < buffer.length && buffer[j] == LF) - { - return j + 1; - } - } - } - i++; - } - return -1; - } - - /** - * Returns the first location of a CRLF followed imediately by another CRLF. - * - * @return int - */ - public static int getFirstCRLFCRLF(String buffer) - { - int index = buffer.indexOf("\r\n\r"); - if (index != -1) - { - int i = index +3; - while (i < buffer.length() && buffer.startsWith("\r", i)) - i++; - - if (i < buffer.length() && buffer.startsWith("\n", i)) - return i+1; - else - return getFirstCRLFCRLF(buffer.substring(index + 3)); - } - else - { - return -1; - } - } - - /** - * Returns the list of indices which marks the separation of parts. - */ - public static int[] getBoundaryIndices(byte[] message, String boundaryStr) - { - int[] indices = new int[256]; - int indicesIndex = 0; - try - { - byte[] boundary = ("\r\n--" + boundaryStr).getBytes("US-ASCII"); - - int index = 0; - int start = 0; - while (index != -1) - { - index = indexOf(message, boundary, start); - - if (index != -1) - { - start = index + boundary.length; - indices[indicesIndex] = index; - indicesIndex++; - } - } - int[] b = new int[indicesIndex]; - System.arraycopy(indices, 0, b, 0, indicesIndex); - indices = b; - } - catch (Exception e) - {} - return indices; - } - - /** - * Returns the index of the first occurrence of key in the buffer. - */ - public static int indexOf(byte[] buffer, byte[] key, int start) - { - int bufferLen = buffer.length; - int keyLen = key.length; - int i,j,k = 0; - - if (keyLen > bufferLen - start) - { - return -1; - } - - for (k = start + keyLen - 1; k < bufferLen; k++) - { - for (j = keyLen - 1, i = k; (j >= 0) && (buffer[i] == key[j]); j--) - { - i--; - } - - if (j == (-1)) { - return i + 1; - } - } - - return -1; - } - /** - * Get contents of a resource and return as a input stream. - * - * @param resourceName the name of the resource to get and return as - * an input stream. - * @return contents of a resource as an input stream. - * @throws IOException if the resource could not be located. - */ - public static InputStream getInputStream(String resourceName) - throws IOException - { - InputStream is = null; - - // If resource reference is a URL, then input stream from URL - try - { - // Try to create URL - URL urlResource = new URL(resourceName); - - // If successful, then get URL input stream - is = getInputStream(urlResource); - } - - // Else try to read resource directly - catch (MalformedURLException mue) - { - boolean bTryClassLoader = false; - - try - { - // Open file input stream - is = new BufferedInputStream(new FileInputStream(resourceName)); - } - catch (FileNotFoundException fnfe) - { - // Set try class loader flag - bTryClassLoader = true; - } - catch (SecurityException se) - { - // Set try class loader flag - bTryClassLoader = true; - } - catch (Exception e) - { - // DEBUG: - System.out.println("Exception in getInputStream :" + e.toString()); - } - - // If try class loader, then use it to get input stream - if (bTryClassLoader) - { - // Use class loader to load resource - is = ClassLoader.getSystemResourceAsStream(resourceName); - } - } - - // If the input stream is null, then throw FileNotFoundException - if (is == null) - { - //try this - is = - Thread.currentThread().getContextClassLoader().getResourceAsStream( - resourceName); - } - - // If the input stream is null, then throw FileNotFoundException - if (is == null) - { - //try this - URL aURL = - Thread.currentThread().getContextClassLoader().getResource( - resourceName); - if (aURL != null) - is = getInputStream(aURL); - } - - if (is == null) - // Throw execption - throw new FileNotFoundException( - "Could not locate resource file: " + resourceName); - - // Return input stream - return is; - } - - /** - * Get the input stream from a URL. - * @param urlFile the URL to get the input stream from. - * @return the input stream corresponding to the given URL. - * @throws IOException if attempt to open the file denoted by URL has failed. - * @throws ConnectException if trouble connecting to URL. - */ - public static InputStream getInputStream(URL urlFile) - throws IOException, ConnectException - { - InputStream is = null; - - // ADD: how are URLs that are password protected handled???? - - try - { - // Open file input stream - is = new BufferedInputStream(urlFile.openStream()); - } - - catch (ConnectException e) - { - // Re-throw this excpetion with additional information - throw new java.net.ConnectException( - "Could not connect to URL: " + urlFile.toExternalForm() + "."); - } - - // Return input stream - return is; - } - - /** - * Get contents of a resource and return as a input stream. - * @param fileLocation the location of the file. - * @return contents of a resource as a input stream. - */ - public static boolean fileExists(String fileLocation) - { - boolean fileExists = false; - - // If resource reference is a URL, then input stream from URL - try - { - // Try to create URL - URL url = new URL(fileLocation); - - // If successful, then try to open connection - url.openStream(); - fileExists = true; - } - - // Else try to read resource directly - catch (MalformedURLException mue) - { - try - { - File file = new File(fileLocation); - - fileExists = file.exists(); - } - - catch (Exception e2) - { - fileExists = false; - } - } - - catch (FileNotFoundException fnfe) - { - fileExists = false; - } - - catch (Exception e) - { - fileExists = false; - } - - // Return file exists indicator - return fileExists; - } - - /** - * Get local host name. - * @return the local host name. - */ - public static String getLocalHostName() - { - String sLocalHostName; - - try - { - // Get local host name - sLocalHostName = InetAddress.getLocalHost().getHostName(); - } - catch (Exception e) - { - // Set default local host name - sLocalHostName = "127.0.0.1"; - } - - // Return local host name - return sLocalHostName; - } - - /** - * Build a URL string from hostname, port and URN. - * - * @param hostname the hostname. - * @param port the port. - * @param urn the URN. - * @return formatted URL string. - */ - public static String formatURL(String hostname, String port, String urn) - { - // Build URN - String formatURN = urn; - - // If URN doesn't start with "/", then add it - if (!(formatURN.startsWith("/"))) - { - // Add "/" to beginning of the string - formatURN = "/" + urn; - } - - // Return URL string - return "http://" + hostname + ":" + port + formatURN; - } - - /** - * This method will replace all of the occurances of a string - * with a substitution string. - * - * @param sText String to udpate. - * @param sFind String to find. - * @param sReplace String to use for substitution. - * @return updated string. - */ - public static String replaceString( - String sText, - String sFind, - String sReplace) - { - int iPrevIndex = 0; - - int iFindLen = sFind.length(); - int iReplaceLen = sReplace.length(); - - String sUpdatedText = sText; - - // Replace all occurances of the find string - for (int iIndex = sUpdatedText.indexOf(sFind); - iIndex < (sUpdatedText.length() - 1) && iIndex != -1; - iIndex = sUpdatedText.indexOf(sFind, iPrevIndex + iReplaceLen)) - { - // Set updated text from the front portion + replacement text + back portion - sUpdatedText = - sUpdatedText.substring(0, iIndex) - + sReplace - + sUpdatedText.substring(iIndex + iFindLen); - - // Set the previous index field - iPrevIndex = iIndex; - } - - // Return updated text string - return sUpdatedText; - } - - /** - * Convert string to hex string. - * @param data a String object. - * @return hex string. - */ - public static String toHexString(String data) - { - char[] HEX_CHARS = - { - '0', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F' }; - - // Get string as byte array - byte[] byteData = data.getBytes(); - - // Get length - int length = byteData.length; - - // Create Char buffer - char[] charBuffer = new char[length * 2]; - - int next; - for (int byteCnt = 0, charCnt = 0; byteCnt < length;) - { - next = byteData[byteCnt++]; - charBuffer[charCnt++] = HEX_CHARS[(next >>> 4) & 0x0F]; - charBuffer[charCnt++] = HEX_CHARS[next & 0x0F]; - } - - return new String(charBuffer); - } - - /** - * Convert byte buffer to hex string. - * @param data a byte array. - * @return hex string. - */ - public static String toHexString(byte[] byteData) - { - char[] HEX_CHARS = - { - '0', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F' }; - - - // Get length - int length = byteData.length; - - // Create Char buffer - char[] charBuffer = new char[length * 2]; - - int next; - for (int byteCnt = 0, charCnt = 0; byteCnt < length;) - { - next = byteData[byteCnt++]; - charBuffer[charCnt++] = HEX_CHARS[(next >>> 4) & 0x0F]; - charBuffer[charCnt++] = HEX_CHARS[next & 0x0F]; - } - - return new String(charBuffer); - } - - // I18N: 2003.02.26 modified by K.Nakagome@BeaconIT - /** - * Get MIME charset from a HTTP headers. - * @param httpHeaders String of HTTP header. - * @return the MIME charset string. - * @author K.Nakagome@BeaconIT Japan SIG - */ - public static String getHTTPCharset(String httpHeaders) - { - String mimeCharset = null; - - mimeCharset = httpHeaders.toUpperCase(); - int[] index = { -1, -1, -1 }; - int indexS = mimeCharset.indexOf("CHARSET"); - int indexE = Integer.MAX_VALUE; - if (indexS < 17) - { - return ""; - } - indexS = mimeCharset.indexOf("=", indexS + 7); - if (indexS == -1) - { - return ""; - } - indexS++; - index[0] = mimeCharset.indexOf("'", indexS); - index[1] = mimeCharset.indexOf("\r\n", indexS); - index[2] = mimeCharset.indexOf("\"", indexS); - for (int i = 0; i < 3; i++) - { - if (index[i] != -1 & indexE > index[i]) - { - indexE = index[i]; - } - } - - if (indexE != Integer.MAX_VALUE) - { - mimeCharset = httpHeaders.substring(indexS, indexE); - mimeCharset.trim(); - } - else - { - mimeCharset = ""; - } - return mimeCharset; - } - - /** - * Checks to see if the message is a simple SOAP message or whether it is a SOAP messagwe with attachments. - */ - public static boolean isMultipartRelatedMessage(String httpHeaders) - { - boolean result = false; - try - { - // check header for mime version and boundary - String contentType = HTTPUtils.getHttpHeaderAttribute(httpHeaders, HTTPConstants.HEADER_CONTENT_TYPE); - if (contentType == null) - { - // there is no contentType, check if there is a boundary attribute - String boundary = Utils.getHttpHeaderSubAttribute(httpHeaders, HTTPConstants.HEADER_CONTENT_TYPE, "boundary"); - if ((boundary != null) && (!boundary.equals(""))) - result = true; - } - else - { - result = contentType.equalsIgnoreCase("multipart/related"); - } - } - catch (WSIException e) - { - result = false; - } - return result; - } - - public static String getHttpHeaderAttribute(String httpHeaders, String attributeName) - { String result = null; - try - { - result = HTTPUtils.getHttpHeaderAttribute(httpHeaders, attributeName); - } - catch (WSIException e) - { - result = null; - } - return result; - } - - public static String getHttpHeaderSubAttribute(String httpHeaders, String attributeName, String subAttributeName) - { String result = null; - try - { - result = HTTPUtils.getHttpHeaderSubAttribute(httpHeaders, attributeName, subAttributeName); - } - catch (WSIException e) - { - result = null; - } - return result; - } - - public static String getMimeHeaderAttribute(String mimeHeaders, String attributeName) - { String result = null; - try - { - result = MIMEUtils.getMimeHeaderAttribute(mimeHeaders, attributeName); - } - catch (WSIException e) - { - result = null; - } - return result; - } - - public static String getMimeHeaderSubAttribute(String mimeHeaders, String attributeName, String subAttributeName) - { String result = null; - try - { - result = MIMEUtils.getMimeHeaderSubAttribute(mimeHeaders, attributeName, subAttributeName); - } - catch (WSIException e) - { - result = null; - } - return result; - } - // I18N: 2003.02.26 modified by K.Nakagome@BeaconIT - /** - * Get XML encoding from a SOAP Messages. - * @param message SOAP Message String. - * @return character encoding of XML. - * @author K.Nakagome@BeaconIT Japan SIG - */ - public static String getXMLEncoding(String message) - { - String xmlDef = null; - - int indexS = message.indexOf("<?xml"); - int indexE = -1; - if (indexS != -1) - { - indexE = message.indexOf("?>", indexS); - if (indexE > indexS) - { - xmlDef = message.substring(indexS, indexE); - } - } - - if (xmlDef != null) - { - indexS = xmlDef.indexOf("encoding"); - if (indexS == -1) - { - xmlDef = ""; - } - else - { - xmlDef = xmlDef.substring(indexS + 8); - xmlDef = xmlDef.trim(); - } - } - else - { - return ""; - } - - if (xmlDef.length() > 3) - { - indexS = xmlDef.indexOf("="); - if (indexS == 0) - { - xmlDef = xmlDef.substring(1); - } - else - { - return ""; - } - } - - if (xmlDef.length() > 3) - { - String end = "\""; - indexS = xmlDef.indexOf(end); - if (indexS != 0) - { - indexS = xmlDef.indexOf((end = "'")); - } - if (indexS == 0) - { - indexE = xmlDef.indexOf(end, 3); - if (indexE != -1) - { - xmlDef = xmlDef.substring(1, indexE); - } - else - { - xmlDef = ""; - } - } - else - { - xmlDef = ""; - } - } - return xmlDef; - } - - // I18N: 2003.02.26 modified by K.Nakagome@BeaconIT - private static ResourceBundle javaEncodingResource = null; - private static final String JAVA_ENCODING_RESOURCE = - "org.wsi.test.util.JavaEncoding"; - private static final String JAVA_ENCODING_DEFAULT = "UTF-8"; - - // I18N: 2003.02.26 modified by K.Nakagome@BeaconIT - /** - * Get Java VM supported character encoding. - * - * @param mimeEncoding string of MIME(IANA) character encoding. - * @return string of character encoding supported by Java VM. - * @author K.Nakagome@BeaconIT Japan SIG - */ - public static String getJavaEncoding(String mimeEncoding) - { - if (mimeEncoding == null || mimeEncoding.length() == 0) - { - return JAVA_ENCODING_DEFAULT; - } - try - { - if (javaEncodingResource == null) - { - javaEncodingResource = ResourceBundle.getBundle(JAVA_ENCODING_RESOURCE); - } - return javaEncodingResource.getString(mimeEncoding); - } - catch (Throwable t) - { - return mimeEncoding; - } - } - - /** - * Convert an array to a Vector. - * - * @param array the array to be converted . - * @return converted Vector (null if array is null, empty if empty). - * @author Graham Turrell IBM - */ - public static Vector arrayToVector(Object[] array) - { - if (array == null) - return null; - Vector v = new Vector(array.length); - for (int i = 0; i < array.length; i++) - v.add(array[i]); - return v; - } - /** - * Checks to ensure that version of the profile test assertion - * document is supported in this version of the test tools. - * @param profileAssertions - a profile TAD. - * @return true if the version of the profile test assertion - * docuement is supported in this version of the test tools. - */ - public static boolean isValidProfileTADVersion(ProfileAssertions profileAssertions) - { - boolean result = false; - - String name = profileAssertions.getTADName(); - String version = profileAssertions.getTADVersion(); - - if (WSIConstants.BASIC_PROFILE_TAD_NAME.equals(name)) - { - result = - checkVersionNumber(WSIConstants.BASIC_PROFILE_TAD_VERSION, version); - } else if (WSIConstants.BASIC_PROFILE_1_1_TAD_NAME.equals(name)) - { - result = - checkVersionNumber(WSIConstants.BASIC_PROFILE_1_1_TAD_VERSION, version); - } else if (WSIConstants.SIMPLE_SOAP_BINDINGS_PROFILE_TAD_NAME.equals(name)) - { - result = - checkVersionNumber(WSIConstants.SIMPLE_SOAP_BINDINGS_PROFILE_TAD_VERSION, version); - } else if (WSIConstants.ATTACHMENTS_PROFILE_TAD_NAME.equals(name)) - { - result = - checkVersionNumber(WSIConstants.ATTACHMENTS_PROFILE_TAD_VERSION, version); - } - return result; - } - - /** - * Checks to ensure that version number of the actual profile test assertion - * document is supported in this version of the test tools. - * @param supportedVersion - supported version number of profile TAD. - * @param actualVersion - actual version number of profile TAD. - * @return true if the version number of the actual profile test assertion - * document is supported in this version of the test tools. - */ - private static boolean checkVersionNumber( - String supportedVersion, - String actualVersion) - { - boolean validVersion = true; - - try - { - StringTokenizer supportedVersionTokenizer = - new StringTokenizer(supportedVersion, "."); - StringTokenizer actualVersionTokenizer = - new StringTokenizer(actualVersion, "."); - - while (supportedVersionTokenizer.hasMoreTokens() && validVersion) - { - int supportedVersionToken = - Integer.parseInt(supportedVersionTokenizer.nextToken()); - if (actualVersionTokenizer.hasMoreTokens()) - { - int actualVersionToken = - Integer.parseInt(actualVersionTokenizer.nextToken()); - if (supportedVersionToken > actualVersionToken) break; - else validVersion = (supportedVersionToken >= actualVersionToken); - } - } - } - catch (Exception e) - { - validVersion = false; - } - return validVersion; - } - - /** - * Identifies the root part in the list using the "start" attribute. - * If the "start" attribute does not exist then the first part is designated the root. - */ - public static MimePart findRootPart(String httpHeaders, Collection parts) - { - MimePart root = null; - String start = Utils.getHttpHeaderSubAttribute(httpHeaders, HTTPConstants.HEADER_CONTENT_TYPE, "start"); - if (!parts.isEmpty()) - { - // default to the first part in the collection - root = (MimePart)parts.iterator().next(); - - if ((start != null) && (!start.equals(""))) - { - Iterator i = parts.iterator(); - boolean rootNotFound = true; - while (i.hasNext() && rootNotFound) - { - MimePart part = (MimePart)i.next(); - String headers = part.getHeaders(); - if (headers != null) - { - String contentId = Utils.getMimeHeaderAttribute(headers, MIMEConstants.HEADER_CONTENT_ID); - if (start.equals(contentId)) - { - root = part; - rootNotFound = false; - } - } - } - } - } - return root; - } - - /** - * Decodes the given encoded string. - */ - public static byte[] decodeBase64(String str) - { - try - { - sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder(); - return decoder.decodeBuffer(str); - } - catch (Exception e) - { - return new byte[0]; - } - } - - /** - * Encodes the given byte array. - */ - public static String encodeBase64(byte[] buffer) - { - sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder(); - return encoder.encodeBuffer(buffer); - } - - public static MimeParts parseMultipartRelatedMessage(String message, String httpHeaders, String encoding) - { - byte[] buffer = null; - try - { - buffer = message.getBytes(encoding); - } - catch (Exception e) - { - return null; - } - return parseMultipartRelatedMessage(buffer, httpHeaders, encoding); - } - public static MimeParts parseMultipartRelatedMessage(byte[] message, String httpHeaders, String encoding) - { - MimeParts mimeParts = new MimePartsImpl(); - String boundary = Utils.getHttpHeaderSubAttribute(httpHeaders, HTTPConstants.HEADER_CONTENT_TYPE, "boundary"); - ArrayList parts = new ArrayList(); - - if (boundary == null) - { - // assume it is a simple SOAP message - return null; - } - else - { - String start = Utils.getHttpHeaderSubAttribute(httpHeaders, HTTPConstants.HEADER_CONTENT_TYPE, "start"); - int[] indices = Utils.getBoundaryIndices(message, boundary); - boolean rootNotFound = true; - - for (int i= indices.length - 2; i>=0; i--) - { - try - { - MimePart part = new MimePartImpl(); - int index = Utils.getFirstCRLFCRLF(message, indices[i]); - if ((index > indices[i]) && (index < indices[i+1])) - { - // the boundary string & mime headers (include the trailing CRLF CRLF) - String str = new String(message, indices[i], (index - indices[i]), "US-ASCII"); - String delimiter = str.substring(0, str.indexOf("\r\n", 2) + 2); - - if (i == indices.length -2) - { - String endDelimiter = new String(message, indices[i + 1], message.length - indices[i + 1], "US-ASCII"); - int j = str.indexOf("\r\n", 2); - if (j != -1) - endDelimiter = str.substring(0, str.indexOf("\r\n", 2) + 2); - part.setBoundaryStrings(new String[]{delimiter, endDelimiter}); - } - else - part.setBoundaryStrings(new String[]{delimiter}); - - // the headers - String headers = str.substring(delimiter.length()); - if (headers.startsWith("\r\n")) - { - // no headers present - part.setHeaders(""); - } - else - { - part.setHeaders(headers); - } - - // the content - String contentId = Utils.getMimeHeaderAttribute(headers, MIMEConstants.HEADER_CONTENT_ID); - int size = indices[i+1] - (index); - byte[] content = new byte[size]; - System.arraycopy(message, index, content, 0, size); - - if ((rootNotFound && (i == 0)) || - ((start != null) && (!start.equals("")) && (start.equals(contentId)))) - { - // root part -- do not encode - part.setContent(new String(content, encoding)); - mimeParts.setRootPart(part); - } - else - { - String transferEncoding = Utils.getMimeHeaderAttribute(headers, MIMEConstants.HEADER_CONTENT_TRANSFER_ENCODING); - - if ((transferEncoding != null) && transferEncoding.equalsIgnoreCase("base64")) - part.setContent(new String(content, encoding)); - else - part.setContent(Utils.encodeBase64(content)); - } - parts.add(part); - } - } - catch (Exception e) - { - return null; - } - } - int size = parts.size(); - for (int i = size-1; i>=0; i--) - mimeParts.addPart((MimePart)parts.get(i)); - } - return mimeParts; - } - - public static String toXMLString(MimeParts mimeParts) - { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - - // Add message content with attachments element - pw.print("<" + WSIConstants.ELEM_MESSAGE_CONTENT_WITH_ATTACHMENTS); - pw.print(">"); - - Collection partList = mimeParts.getParts(); - if (!partList.isEmpty()) - { - Iterator iMimeParts = partList.iterator(); - while (iMimeParts.hasNext()) - { - MimePart mimePart = (MimePart)iMimeParts.next(); - pw.print(mimePart.toXMLString("")); - } - } - - // Add end message element - pw.println("</" + WSIConstants.ELEM_MESSAGE_CONTENT_WITH_ATTACHMENTS + ">"); - // Return string - return sw.toString(); - } - - public static void main (String[] args) - { - try - { - FileInputStream inputStream = new FileInputStream("d:\\b.xml"); - int i = inputStream.available(); - byte[] buffer = new byte[i]; - inputStream.read(buffer); - String message = new String(buffer); - message = XMLUtils.xmlRemoveEscapedString(message); - String headers = Utils.getHTTPHeaders(message); - MimeParts parts = Utils.parseMultipartRelatedMessage(message, headers, Utils.JAVA_ENCODING_DEFAULT); - System.out.println(Utils.toXMLString(parts)); - } - catch (Exception e){} - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/WSDLUtil.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/WSDLUtil.java deleted file mode 100644 index 1adcf00b7..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/WSDLUtil.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.util.Iterator; -import java.util.List; - -import javax.wsdl.Binding; -import javax.wsdl.Definition; -import javax.wsdl.Import; -import javax.wsdl.Message; -import javax.wsdl.Operation; -import javax.wsdl.Part; -import javax.wsdl.PortType; -import javax.wsdl.Service; -import javax.wsdl.extensions.soap.SOAPBody; - -import org.eclipse.wst.wsi.internal.core.WSIConstants; - -/** - * The utility class to automate WSDL processing. - * - * @author Kulik - */ -public final class WSDLUtil -{ - - /** - * The method extracts list of parts for the given soapbind:body, - * binding operation, message, and style. - * - * @param op an operation. - * @param m a message. - * @param body a SOAP body. - * @param style an operation style. - * @return list of parts for the given soapbind:body, - * binding operation, message, and style. - */ - static public List getParts( - Operation op, - Message m, - SOAPBody body, - String style) - { - // if null, get parts from message - if (body.getParts() == null) - // if rpc style is used, try to use partOrder attribute from operation - if (WSIConstants.ATTRVAL_SOAP_BIND_STYLE_RPC.equals(style)) - return m.getOrderedParts(op.getParameterOrdering()); - else - return m.getOrderedParts(null); - else - // converse parts name to parts objects - return m.getOrderedParts(body.getParts()); - } - - /** - * The method iterates all imports from the given definition and expands all - * imported messages, service, portTypes, and bindings to the definition. - * - * @param def a WSDL definition. - */ - static public void expandDefinition(Definition def) - { - if (def != null && def.getImports() != null) - { - Iterator it = def.getImports().values().iterator(); - while (it.hasNext()) - { - List v = (List) it.next(); - if (v != null) - { - Iterator it2 = v.iterator(); - while (it2.hasNext()) - expandDefinition(def, (Import) it2.next()); - } - } - } - } - - /** - * The internal method to expand definition. - * @param target WSDL definition. - * @param im internal method. - */ - static private void expandDefinition(Definition target, Import im) - { - if (im != null && im.getDefinition() != null) - { - Definition d = im.getDefinition(); - if (d.getMessages() != null) - { - Iterator it = d.getMessages().values().iterator(); - while (it.hasNext()) - target.addMessage((Message) it.next()); - } - if (d.getPortTypes() != null) - { - Iterator it = d.getPortTypes().values().iterator(); - while (it.hasNext()) - target.addPortType((PortType) it.next()); - } - if (d.getBindings() != null) - { - Iterator it = d.getBindings().values().iterator(); - while (it.hasNext()) - target.addBinding((Binding) it.next()); - } - if (d.getServices() != null) - { - Iterator it = d.getServices().values().iterator(); - while (it.hasNext()) - target.addService((Service) it.next()); - } - - Iterator it = d.getImports().values().iterator(); - while (it.hasNext()) - { - List v = (List) it.next(); - if (v != null) - { - Iterator it2 = v.iterator(); - while (it2.hasNext()) - expandDefinition(target, (Import) it2.next()); - } - } - } - } - - /** - * The method extracts part from the message. - * - * @param message a SOAP message. - * @param part a part name. - * @return part from the specified message. - */ - static public Part getPart(Message message, String part) - { - Part mesPart = null; - if (part == null) - mesPart = (Part) message.getOrderedParts(null).get(0); - else - mesPart = message.getPart(part); - return mesPart; - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/WSIProperties.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/WSIProperties.java deleted file mode 100644 index ba1403362..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/WSIProperties.java +++ /dev/null @@ -1,347 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -import java.util.Enumeration; -import java.util.MissingResourceException; -import java.util.Properties; -import java.util.ResourceBundle; - -import org.uddi4j.transport.TransportFactory; - -/** - * The WSI properties can be defined in one of three locations. - * - * 1. The wsi.properties file which can be located anywhere in the classpath. - * 2. The system property settings. - * 3. The thread local property settings. - * - * The properties are set based on this ordering. For example, the properties - * from the wsi.properties file will be replaced by properties from the system - * property settings, which will be replaced by the thread local property settings. - * - * The properties that are used to define the implementation classes can be - * specified as system properties or as properties that are set in a thread - * local variable. System properties should be used if only one implementation - * is needed per JVM. If two or more implementations are needed per JVM, then - * the properties should be set using the thread local variable. - * - * @version 1.0.1 - * @author: Peter Brittenham - */ -public final class WSIProperties -{ - /** - * Properties object. - */ - protected static Properties wsiProperties = new Properties(); - - /** - * Default ProfileValidatorFactory class name. - */ - public static final String DEF_VALIDATOR_FACTORY = - "org.eclipse.wst.wsi.internal.core.profile.validator.impl.ProfileValidatorFactoryImpl"; - - /** - * Property that contains ProfileValidatorFactory class name. - */ - public static final String PROP_VALIDATOR_FACTORY = - "wsi.profile.validator.factory"; - - /** - * Default document factory class name. - */ - public static final String DEF_DOCUMENT_FACTORY = - "org.eclipse.wst.wsi.internal.core.document.impl.DocumentFactoryImpl"; - - /** - * Property that contains document factory class name. - */ - public static final String PROP_DOCUMENT_FACTORY = "wsi.document.factory"; - - /** - * Default JAXP XML parser document factory builder. - */ - public static final String DEF_JAXP_DOCUMENT_FACTORY = - "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"; - - /** - * Property that contains JAXP XML parser document factory builder. - */ - public static final String PROP_JAXP_DOCUMENT_FACTORY = - "javax.xml.parsers.DocumentBuilderFactory"; - - /** - * Default WSDL schema location. - */ - public static final String DEF_WSDL_SCHEMA = "http://schemas.xmlsoap.org/wsdl/"; - - /** - * Property that contains WSDL schema location. - */ - public static final String PROP_WSDL_SCHEMA = "wsi.analyzer.wsdl.schema"; - - /** - * Default WSDL SOAP schema location. - */ - public static final String DEF_WSDL_SOAP_SCHEMA = - "http://schemas.xmlsoap.org/wsdl/soap/"; - - /** - * Property that contains WSDL SOAP schema location. - */ - public static final String PROP_WSDL_SOAP_SCHEMA = - "wsi.analyzer.wsdlsoap.schema"; - - /** - * Default WSDL MIME schema location. - */ - public static final String DEF_WSDL_MIME_SCHEMA = - "http://schemas.xmlsoap.org/wsdl/mime/"; - - /** - * Property that contains WSDL SOAP schema location. - */ - public static final String PROP_WSDL_MIME_SCHEMA = - "wsi.analyzer.wsdlmime.schema"; - - /** - * Default SOAP schema location. - */ - public static final String DEF_SOAP_SCHEMA = - "http://schemas.xmlsoap.org/soap/envelope/"; - - /** - * Property that contains SOAP schema location. - */ - public static final String PROP_SOAP_SCHEMA = "wsi.analyzer.soap.schema"; - - /** - * Default SOAP schema location. - */ - public static final String DEF_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema.xsd"; - - /** - * Property that contains SOAP schema location. - */ - public static final String PROP_XML_SCHEMA = "wsi.analyzer.xmlschema.schema"; - - /** - * Property which contains WSI_HOME value. - */ - public static final String PROP_WSI_HOME = "wsi.home"; - - /** - * Property file name. - */ - protected static final String PROP_FILENAME = "org.eclipse.wst.wsi.internal.core.util.wsi"; - - /** - * Thread local variable. - */ - private static ThreadLocal threadLocal = new ThreadLocal(); - - // Load profiles file - static { - loadPropertiesFile(); - } - - /** - * Load properties from wsi.properties file. - */ - private static void loadPropertiesFile() - { - try - { - // Try to load properties from wsi.properties - //InputStream is = Utils.getInputStream(PROP_FILENAME); - - // Load properties from file - //wsiPropertiesFile.load(is); - - ResourceBundle resourceBundle = ResourceBundle.getBundle(PROP_FILENAME); - - String nextKey; - Enumeration enumeration = resourceBundle.getKeys(); - while (enumeration.hasMoreElements()) - { - nextKey = (String) enumeration.nextElement(); - wsiProperties.put(nextKey, resourceBundle.getString(nextKey)); - } - } - - catch (MissingResourceException mre) - { - // DEBUG: - System.err.println( - "WARNING: Could not read " - + PROP_FILENAME - + ". " - + "Verify that it is in the CLASSPATH."); - - // Set up default values - wsiProperties.put(PROP_VALIDATOR_FACTORY, DEF_VALIDATOR_FACTORY); - wsiProperties.put(PROP_DOCUMENT_FACTORY, DEF_DOCUMENT_FACTORY); - wsiProperties.put(PROP_JAXP_DOCUMENT_FACTORY, DEF_JAXP_DOCUMENT_FACTORY); - wsiProperties.put( - TransportFactory.PROPERTY_NAME, - "org.uddi4j.transport.ApacheAxisTransport"); - } - } - - /** - * Do not allow this object to be instantiated. - */ - private WSIProperties() - { - } - - /** - * Get properties that were set for this thread only. - * @return the properties that were set for this thread only. - * - * @see #setThreadLocalProperties - */ - public static Properties getThreadLocalProperties() - { - // Return properties - return (Properties) threadLocal.get(); - } - - /** - * Set properties for this thread only. - * @param props a Properties object. - * - * @see #getThreadLocalProperties - */ - public static void setThreadLocalProperties(Properties props) - { - // Save the properties as thread local variables - threadLocal.set(props); - } - - /** - * Get the property value given the property name. - * @param propertyName a property name. - * @return the corresponding property value. If not found return null. - */ - public static String getProperty(String propertyName) - { - String propertyValue = null; - Properties threadLocalProps = null; - - // 1. Look in thread local properties first - if ((threadLocalProps = getThreadLocalProperties()) != null) - { - propertyValue = threadLocalProps.getProperty(propertyName); - } - - // 2. Next look in system properties - if (propertyValue == null) - { - propertyValue = System.getProperty(propertyName); - } - - // 3. Last look in the properties file - if (propertyValue == null) - { - propertyValue = wsiProperties.getProperty(propertyName); - } - - // Return property value - return propertyValue; - } - - /** - * Get the property value given the property name. - * @param propertyName a property name. - * @param defaultValue a default value for the property. - * @return the corresponding property value. If not found return the default value. - */ - public static String getProperty(String propertyName, String defaultValue) - { - String propertyValue = null; - - // If the propertyValue was not found, then return default value - if ((propertyValue = getProperty(propertyName)) == null) - { - propertyValue = defaultValue; - } - - // Return property value - return propertyValue; - } - - /** - * This method is used to unit test this class. - * @param args the arguments for main. - */ - public static void main(String[] args) - { - try - { - // Set property for this thread - Properties props = new Properties(); - props.setProperty(PROP_VALIDATOR_FACTORY, "main"); - WSIProperties.setThreadLocalProperties(props); - - // Start four threads to verify that the multithreaded use of tread local vars works - for (int i = 0; i < 5; i++) - { - // Create new thread - (new Thread(new ThreadTest("test" + i))).start(); - - try - { - // Sleep - Thread.sleep(200); - - // Display properties, which should be main - System.out.println( - "PROP_VALIDATOR_FACTORY: " - + WSIProperties.getProperty(PROP_VALIDATOR_FACTORY)); - } - - catch (Exception e) - { - } - } - } - - catch (Exception e) - { - // e.printStackTrace(); - } - } - - /** - * Inner class used for unit test. - */ - static private class ThreadTest extends Thread - { - String name; - - ThreadTest(String name) - { - this.name = name; - } - - public void run() - { - Properties props = new Properties(); - props.setProperty(PROP_VALIDATOR_FACTORY, name); - WSIProperties.setThreadLocalProperties(props); - System.out.println( - "PROP_VALIDATOR_FACTORY: " - + WSIProperties.getProperty(PROP_VALIDATOR_FACTORY)); - } - } -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/XMLInfo.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/XMLInfo.java deleted file mode 100644 index b92119912..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/XMLInfo.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2002-2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.wsi.internal.core.util; - -/** - * This class ... - * - * @version 1.0.1 - * @author Peter Brittenham (peterbr@us.ibm.com) - */ -public interface XMLInfo -{ - /** - * Get addtional tool environment information as an XML string. - * @param namespaceName a namespace prefix. - * @return addtional tool environment information as an XML string. - */ - public String toXMLString(String namespaceName); -} diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/wsi.properties b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/wsi.properties deleted file mode 100644 index bfe48da10..000000000 --- a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/wsi.properties +++ /dev/null @@ -1,46 +0,0 @@ -# /** -# * <copyright> -# * -# * Copyright (c) 2002-2003 IBM Corporation and others. -# * All rights reserved. This program and the accompanying materials -# * are made available under the terms of the Eclipse Public License v1.0 -# * which accompanies this distribution, and is available at -# * http://www.eclipse.org/legal/epl-v10.html -# * -# * Contributors: -# * IBM - Initial API and implementation -# * </copyright> -# */ -# -# Property file used to set parameters for Conformance Tools - -# ----------------------------------------------------------------------- -# Document factory. -# ----------------------------------------------------------------------- -wsi.document.factory=org.eclipse.wst.wsi.internal.core.document.impl.DocumentFactoryImpl - -# ----------------------------------------------------------------------- -# Profile validation factory. -# ----------------------------------------------------------------------- -wsi.profile.validator.factory=org.eclipse.wst.wsi.internal.core.profile.validator.impl.ProfileValidatorFactoryImpl - -# ----------------------------------------------------------------------- -# Reference to JAXP document builder -# ----------------------------------------------------------------------- -javax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl -#javax.xml.parsers.DocumentBuilderFactory=org.eclipe.wst.wsi.internal.core.xml.jaxp.DocumentBuilderFactoryImpl - -# ----------------------------------------------------------------------- -# Transport class used by UDDI4J -# ----------------------------------------------------------------------- -org.uddi4j.TransportClassName=org.uddi4j.transport.ApacheAxisTransport - - -# ----------------------------------------------------------------------- -# Location of XML schema documents relative to the plugin directory -# ----------------------------------------------------------------------- -wsi.analyzer.xmlschema.schema=http://www.w3.org/2001/XMLSchema.xsd -wsi.analyzer.soap.schema=http://schemas.xmlsoap.org/soap/envelope/ -wsi.analyzer.wsdl.schema=http://schemas.xmlsoap.org/wsdl/ -wsi.analyzer.wsdlsoap.schema=wsi.analyzer.wsdlsoap.schema -wsi.analyzer.wsdlmime.schema=http://schemas.xmlsoap.org/wsdl/mime/ |