- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 05 Oct 2009 14:25:43 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/input In directory hutz:/tmp/cvs-serv14938/src/org/w3c/unicorn/input Modified Files: URIInputParameter.java DirectInputParameter.java UploadInputParameter.java Log Message: simpler way to make the Message level enum Index: UploadInputParameter.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/input/UploadInputParameter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- UploadInputParameter.java 1 Oct 2009 14:01:37 -0000 1.3 +++ UploadInputParameter.java 5 Oct 2009 14:25:41 -0000 1.4 @@ -18,20 +18,20 @@ @Override public void check() throws UnicornException { if (file.getName() == null || file.getName().equals("")) { - throw new UnicornException(Message.Level.ERROR, "$message_no_uploaded_file", null); + throw new UnicornException(Message.ERROR, "$message_no_uploaded_file", null); } if (file.getSize() == 0) { - throw new UnicornException(Message.Level.ERROR, "$message_empty_uploaded_file", null); + throw new UnicornException(Message.ERROR, "$message_empty_uploaded_file", null); } String sMimeType = file.getContentType(); if (null == sMimeType || "".equals(sMimeType)) { // TODO Is there another solution here to find the mime-type ? - throw new UnicornException(Message.Level.ERROR, "$message_not_found_mime_type", null); + throw new UnicornException(Message.ERROR, "$message_not_found_mime_type", null); } try { mimeType = new MimeType(sMimeType); } catch (MimeTypeParseException e) { - throw new UnicornException(Message.Level.ERROR, "$message_invalid_mime_type", null); + throw new UnicornException(Message.ERROR, "$message_invalid_mime_type", null); } inputModule = new FileItemInputModule(mimeType, file); } Index: DirectInputParameter.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/input/DirectInputParameter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- DirectInputParameter.java 30 Sep 2009 13:55:03 -0000 1.4 +++ DirectInputParameter.java 5 Oct 2009 14:25:41 -0000 1.5 @@ -21,13 +21,13 @@ @Override public void check() throws UnicornException { if (document == null || document.equals("")) - throw new UnicornException(Message.Level.ERROR, "$message_empty_direct_input", null); + throw new UnicornException(Message.ERROR, "$message_empty_direct_input", null); if (sMimeType == null || sMimeType.equals("")) - throw new UnicornException(Message.Level.ERROR, "$message_missing_mime_type", null); + throw new UnicornException(Message.ERROR, "$message_missing_mime_type", null); try { mimeType = new MimeType(sMimeType); } catch (MimeTypeParseException e) { - throw new UnicornException(Message.Level.ERROR, "$message_invalid_mime_type", null); + throw new UnicornException(Message.ERROR, "$message_invalid_mime_type", null); } inputModule = new DirectInputModule(mimeType, document); } Index: URIInputParameter.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/input/URIInputParameter.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- URIInputParameter.java 2 Oct 2009 12:19:27 -0000 1.10 +++ URIInputParameter.java 5 Oct 2009 14:25:41 -0000 1.11 @@ -37,18 +37,18 @@ URL docUrl = null; try { if (uri.equals("")) - throw new UnicornException(Message.Level.ERROR, "$message_empty_uri", null); + throw new UnicornException(Message.ERROR, "$message_empty_uri", null); Pattern urlPattern = Pattern.compile("^(https?)://([A-Z0-9][A-Z0-9_-]*)(\\.[A-Z0-9][A-Z0-9_-]*)*(:(\\d+))?([/#]\\p{ASCII}*)?", Pattern.CASE_INSENSITIVE); if (!urlPattern.matcher(uri).matches()) { if (!uri.contains("://")) uri = "http://" + uri; if (!urlPattern.matcher(uri).matches()) - throw new UnicornException(Message.Level.ERROR, "$message_invalid_url_syntax " + uri, null); + throw new UnicornException(Message.ERROR, "$message_invalid_url_syntax " + uri, null); } docUrl = new URL(uri); if (!docUrl.getProtocol().equals("http") && !docUrl.getProtocol().equals("https")) - throw new UnicornException(Message.Level.ERROR, "$message_unsupported_protocol " + docUrl.getProtocol(), null); + throw new UnicornException(Message.ERROR, "$message_unsupported_protocol " + docUrl.getProtocol(), null); HttpURLConnection con = (HttpURLConnection) docUrl.openConnection(); System.out.println(con.getClass()); con.setConnectTimeout(connectTimeOut); @@ -56,27 +56,27 @@ int responseCode = con.getResponseCode(); switch (responseCode) { case HttpURLConnection.HTTP_UNAUTHORIZED: - throw new UnicornException(Message.Level.ERROR, "$message_unauthorized_access", null); + throw new UnicornException(Message.ERROR, "$message_unauthorized_access", null); case HttpURLConnection.HTTP_NOT_FOUND: - throw new UnicornException(Message.Level.ERROR, "$message_document_not_found", null); + throw new UnicornException(Message.ERROR, "$message_document_not_found", null); } String sMimeType = con.getContentType(); sMimeType = sMimeType.split(";")[0]; mimeType = new MimeType(sMimeType); inputModule = new URIInputModule(mimeType, uri); } catch (MalformedURLException e) { - throw new UnicornException(Message.Level.ERROR, "$message_invalid_url_syntax " + uri, null); + throw new UnicornException(Message.ERROR, "$message_invalid_url_syntax " + uri, null); } catch (MimeTypeParseException e) { - throw new UnicornException(Message.Level.ERROR, "$message_invalid_mime_type", null); + throw new UnicornException(Message.ERROR, "$message_invalid_mime_type", null); } catch (UnknownHostException e) { - throw new UnicornException(Message.Level.ERROR, "$message_unknown_host " + docUrl.getHost(), null); + throw new UnicornException(Message.ERROR, "$message_unknown_host " + docUrl.getHost(), null); } catch (SSLException e) { - throw new UnicornException(Message.Level.ERROR, "$message_ssl_exception", null); + throw new UnicornException(Message.ERROR, "$message_ssl_exception", null); } catch (ConnectException e) { - throw new UnicornException(Message.Level.ERROR, "$message_connect_exception", null); + throw new UnicornException(Message.ERROR, "$message_connect_exception", null); } catch (SocketTimeoutException e) { if (e.getMessage().contains("connect timed out")) { - throw new UnicornException(Message.Level.ERROR, "$message_connect_exception", null); + throw new UnicornException(Message.ERROR, "$message_connect_exception", null); } else { throw new UnicornException(new Message(e)); }
Received on Monday, 5 October 2009 14:25:49 UTC