List of usage examples for java.lang IllegalArgumentException toString
public String toString()
From source file:org.kawanfw.sql.servlet.ServerSqlDispatch.java
/** * Execute the client sent sql request//from w w w. j av a 2 s. c o m * * @param request * the http request * @param response * the http response * @param servletContextTempDir * The temp dir used by Servlets * @param commonsConfigurator * the client commons http configurator specific class * @param fileConfigurator * the client file http configurator specific class * @param sqlConfigurator * the client sql http configurator specific class * @param connection * the Sql Jdbc Connection * @throws IOException * if any IOException occurs */ public void executeRequest(HttpServletRequest request, HttpServletResponse response, File servletContextTempDir, CommonsConfigurator commonsConfigurator, FileConfigurator fileConfigurator, SqlConfigurator sqlConfigurator) throws IOException { // Immediate catch if we are asking a file upload, because parameters // are // in unknown sequence. We know it's a upload action if it's mime // multipart if (ServletFileUpload.isMultipartContent(request)) { ServerFileUploadAction serverFileUploadAction = new ServerFileUploadAction(); serverFileUploadAction.executeAction(request, response, servletContextTempDir, commonsConfigurator, fileConfigurator); return; } OutputStream out = null; try { debug("executeRequest Start"); // Prepare the response response.setContentType("text/html"); // Get the send string debug("ACTION retrieval"); String action = null; // We must trap the IllegalArgumentException to rethrow properly to // client // This happens if there is an encryption problem try { action = request.getParameter(Parameter.ACTION); } catch (IllegalArgumentException e) { debug("IllegalArgumentException : " + e.toString()); out = response.getOutputStream(); throw e; } String username = request.getParameter(Parameter.USERNAME); debug("Before if (action.equals(Action.LOGIN_ACTION"); if (action.equals(Action.LOGIN_ACTION) || action.equals(Action.BEFORE_LOGIN_ACTION)) { ServerLoginActionSql serverLoginActionSql = new ServerLoginActionSql(); serverLoginActionSql.executeAction(request, response, commonsConfigurator, sqlConfigurator, action); return; } debug("ACTION : " + action); // Redirect to Awake FILE if it's a File request (Blobs/Clobs) if (isActionForAwakeFile(action)) { ServerFileDispatch serverFileDispatch = new ServerFileDispatch(); serverFileDispatch.executeRequest(request, response, servletContextTempDir, commonsConfigurator, fileConfigurator); return; } debug("After isActionForAwakeFile"); out = response.getOutputStream(); if (action == null || action.equals("")) { // out.println(HttpTransferOne.SEND_FAILED + SPACE + // ERR_ACTION_NOT_SET); // out.println(TransferStatus.SEND_FAILED); // out.println(ERR_ACTION_NOT_SET); ServerSqlManager.writeLine(out, TransferStatus.SEND_FAILED); ServerSqlManager.writeLine(out, ERR_ACTION_NOT_SET); return; } debug("Before if (! ServerFileDispatch.isTokenValid(username, token, commonsConfigurator"); String token = request.getParameter(Parameter.TOKEN); if (!ServerFileDispatch.isTokenValid(username, token, commonsConfigurator)) { //out.println(TransferStatus.SEND_OK); //out.println(ReturnCode.INVALID_LOGIN_OR_PASSWORD); ServerSqlManager.writeLine(out, TransferStatus.SEND_OK); ServerSqlManager.writeLine(out, ReturnCode.INVALID_LOGIN_OR_PASSWORD); return; } String connectionId = request.getParameter(ConnectionParms.CONNECTION_ID); // If we are in normal mode (not server stateless mode), transaction // id is > 0 // So Extract a Connection from the pool and store it memory if (action.equals(SqlActionTransaction.ACTION_SQL_INIT_REMOTE_CONNECTION) && !connectionId.equals("0")) { // Create the Connection & store it ConnectionStore connectionStore = new ConnectionStore(username, connectionId); Connection connection = commonsConfigurator.getConnection(); connectionStore.put(connection); debug("ACTION_SQL_INIT_REMOTE_CONNECTION"); debug("username :" + username + ":"); debug("connectionId :" + connectionId + ":"); debug("connection :" + connection + ":"); //out.println(TransferStatus.SEND_OK); ServerSqlManager.writeLine(out, TransferStatus.SEND_OK); return; } // If we are not in stateless mode, clean old connections with a // Thread if (!connectionId.equals("0") && !ConnectionStoreCleaner.IS_RUNNING) { ConnectionStoreCleaner cleaner = new ConnectionStoreCleaner(sqlConfigurator); cleaner.start(); } // Notify to Kawan in async mode using a secured Thread that // the user has successfully logged (done once in JVM session per // username). // No notification is done if user.home/.kawansoft/no_notify.txt exists // or web server name is localhost or 127.0.0.1 if (!KawanNotifier.existsNoNotifyTxt() && !KawanNotifier.usernameAlreadyLogged(username) && !KawanNotifier.serverNameIsLocalhost()) { KawanNotifier kawanNotifier = new KawanNotifier(username, "AceQL_" + VersionValues.VERSION); kawanNotifier.start(); } if (action.equals(SqlAction.ACTION_SQL_STATEMENT)) { executeStatement(request, commonsConfigurator, fileConfigurator, sqlConfigurator, out); } else if (action.equals(SqlAction.ACTION_SQL_STATEMENT_BATCH)) { executeStatementBatch(request, commonsConfigurator, fileConfigurator, sqlConfigurator, out); } else if (action.equals(SqlAction.ACTION_SQL_PREP_STATEMENT_BATCH)) { executePrepStatementBatch(request, commonsConfigurator, fileConfigurator, sqlConfigurator, out); } else if (action.equals(SqlAction.ACTION_SQL_GET_METADATA)) { executeGetMetadata(request, commonsConfigurator, sqlConfigurator, out); } else if (action.equals(SqlAction.ACTION_SQL_EXECUTE_RAW)) { executeRaw(request, commonsConfigurator, fileConfigurator, sqlConfigurator, out); } else if (action.equals(SqlActionTransaction.ACTION_SQL_GET_TRANSACTION_ISOLATION)) { getTransactionIsolation(request, commonsConfigurator, sqlConfigurator, out); } else if (action.equals(SqlActionCallable.ACTION_SQL_CALLABLE_EXECUTE_RAW)) { callableExecute(request, commonsConfigurator, fileConfigurator, sqlConfigurator, out); } else if (action.equals(SqlActionCallable.ACTION_SQL_CALLABLE_EXECUTE_QUERY)) { callableExecuteQuery(request, commonsConfigurator, fileConfigurator, sqlConfigurator, out); } else if (action.equals(SqlActionTransaction.ACTION_SQL_COMMIT) || action.equals(SqlActionTransaction.ACTION_SQL_ROLLBACK) || action.equals(SqlActionTransaction.ACTION_SQL_CON_CLOSE) ) { setCommitRollbackCloseExecute(request, commonsConfigurator, sqlConfigurator, out, action); } else if (action.equals(SqlActionTransaction.ACTION_SQL_SET_AUTOCOMMIT) || action.equals(SqlActionTransaction.ACTION_SQL_SET_READ_ONLY) || action.equals(SqlActionTransaction.ACTION_SQL_SET_HOLDABILITY) || action.equals(SqlActionTransaction.ACTION_SQL_SET_TRANSACTION_ISOLATION) ) { setAutocommitReadOnlyHoldabilityTransactionInsolationExecute(request, commonsConfigurator, out, action); } else if (action.equals(SqlActionTransaction.ACTION_SQL_IS_READ_ONLY) || action.equals(SqlActionTransaction.ACTION_SQL_GET_HOLDABILITY) || action.equals(SqlActionTransaction.ACTION_SQL_GET_AUTOCOMMIT)) { getAutocommitReadOnlyHoldabilityExecute(request, commonsConfigurator, out, action); } else if (action.equals(SqlActionTransaction.ACTION_SQL_SET_SAVEPOINT) || action.equals(SqlActionTransaction.ACTION_SQL_SET_SAVEPOINT_NAME) || action.equals(SqlActionTransaction.ACTION_SQL_SET_ROLLBACK_SAVEPOINT) || action.equals(SqlActionTransaction.ACTION_SQL_SET_RELEASE_SAVEPOINT)) { setSavepointExecute(request, commonsConfigurator, out, action); } else if (action.equals(SqlAction.ACTION_SQL_IS_VALID) || action.equals(SqlAction.ACTION_SQL_SET_CLIENT_INFO_NAME) || action.equals(SqlAction.ACTION_SQL_SET_CLIENT_INFO_PROP) || action.equals(SqlAction.ACTION_SQL_GET_CLIENT_INFO_NAME) || action.equals(SqlAction.ACTION_SQL_GET_CLIENT_INFO) || action.equals(SqlAction.ACTION_SQL_CREATE_ARRAY_OF)) { connectionInfoExecute(request, commonsConfigurator, out, action); } else { throw new IllegalArgumentException("Invalid Sql Action: " + action); } } catch (Exception e) { // out.println(TransferStatus.SEND_FAILED); // out.println(e.getClass().getName()); // out.println(ServerUserThrowable.getMessage(e)); // out.println(ExceptionUtils.getStackTrace(e)); ServerSqlManager.writeLine(out, TransferStatus.SEND_FAILED); ServerSqlManager.writeLine(out, e.getClass().getName()); ServerSqlManager.writeLine(out, ServerUserThrowable.getMessage(e)); ServerSqlManager.writeLine(out, ExceptionUtils.getStackTrace(e)); try { ServerLogger.getLogger().log(Level.WARNING, Tag.PRODUCT_EXCEPTION_RAISED + " " + ServerUserThrowable.getMessage(e)); ServerLogger.getLogger().log(Level.WARNING, Tag.PRODUCT_EXCEPTION_RAISED + " " + ExceptionUtils.getStackTrace(e)); } catch (Exception e1) { e1.printStackTrace(); e1.printStackTrace(System.out); } } }
From source file:org.powertac.common.config.Configurator.java
private void gatherConfiguration(Object thing, String name, ConfigurationRecorder recorder, Predicate<ConfigurableProperty> p) { String prefix = extractClassnamePrefix(extractClassnamePath(thing)); Map<String, ConfigurableProperty> analysis = getAnalysis(thing.getClass()); for (Iterator<Entry<String, ConfigurableProperty>> props = analysis.entrySet().iterator(); props .hasNext();) {// w w w . j av a2 s . c o m Map.Entry<String, ConfigurableProperty> prop = props.next(); ConfigurableProperty cp = prop.getValue(); if (p.apply(cp)) { String key = prefix; if (null != name) { // handle named instances // TODO - this is probably a bad way to detect these... key = key + "." + name; } key = key + "." + prop.getKey(); log.debug("Recording property " + key); Object value = null; try { if (cp.field != null) { // extract value from field cp.field.setAccessible(true); value = cp.field.get(thing); } else if (cp.getter != null) { value = cp.getter.invoke(thing); } else { // cannot do much throw new Exception("field and getter both null"); } recorder.recordItem(key, value); recorder.recordMetadata(key, cp.cv.description(), cp.cv.valueType(), cp.cv.publish(), cp.cv.bootstrapState()); } catch (IllegalArgumentException e) { log.error("cannot read published value: " + e.toString()); } catch (IllegalAccessException e) { log.error("cannot read published value: " + e.toString()); } catch (InvocationTargetException e) { log.error("cannot read published value: " + e.toString()); } catch (Exception e) { log.error("cannot read published value: " + e.toString()); } } } }
From source file:com.example.android.snake.SnakeView.java
public void displayNewPortion() { if (mWidth == (MAX_WIDTH - START_WIDTH) && mHeight == (MAX_HEIGHT - START_HEIGHT)) setMode(WIN);/*from www. ja v a2 s.c om*/ if (!mFirstBlockHit) { mFirstBlockHit = true; mBackground.setVisibility(View.VISIBLE); } if (mWidth + WIDTH_INCR <= MAX_WIDTH) mWidth += WIDTH_INCR; else mWidth = MAX_WIDTH - START_WIDTH; if (mHeight + HEIGHT_INCR <= MAX_HEIGHT) mHeight += HEIGHT_INCR; else mHeight = MAX_HEIGHT - START_HEIGHT; String except; try { //mBackground.setImageBitmap((mSourceBitmap)); Bitmap cropped = Bitmap.createBitmap(mSourceBitmap, START_WIDTH, START_HEIGHT, mWidth, mHeight, null, false); mBackground.setImageBitmap(cropped); } catch (java.lang.IllegalArgumentException e) { e.printStackTrace(); except = e.toString(); return; } }
From source file:org.gvnix.occ.roo.addon.addon.OCCChecksumMetadata.java
/** * Add checksum field (plus getter/setter) to builder * //from w w w. j ava 2 s . c o m * @param field * @param getter * @param setter * @param typeManagementService */ private void addChecksumFieldToEntity(FieldMetadata field, MethodMetadata getter, MethodMetadata setter, TypeManagementService typeManagementService) { PhysicalTypeDetails ptd = governorPhysicalTypeMetadata.getMemberHoldingTypeDetails(); Validate.isInstanceOf(ClassOrInterfaceTypeDetails.class, ptd, "Java source code is immutable for type " + PhysicalTypeIdentifier.getFriendlyName(governorPhysicalTypeMetadata.getId())); ClassOrInterfaceTypeDetailsBuilder mutableTypeDetails = new ClassOrInterfaceTypeDetailsBuilder( (ClassOrInterfaceTypeDetails) ptd); // Try to locate an existing field with @javax.persistence.Version try { if (!fieldExist(mutableTypeDetails, field)) { mutableTypeDetails .addField(new FieldMetadataBuilder(governorTypeDetails.getDeclaredByMetadataId(), field)); } if (!methodExists(mutableTypeDetails, getter)) { mutableTypeDetails.addMethod(getter); } if (!methodExists(mutableTypeDetails, setter)) { mutableTypeDetails.addMethod(setter); } typeManagementService.createOrUpdateTypeOnDisk(mutableTypeDetails.build()); } catch (IllegalArgumentException e) { // TODO In some cases, one element is added more than one time LOGGER.finest("Problem adding version field: ".concat(e.toString())); } }
From source file:cn.dacas.providers.downloads.DownloadThread.java
/** * Send the request to the server, handling any I/O exceptions. */// www. j a v a 2s .c om private HttpResponse sendRequest(State state, AndroidHttpClient client, HttpGet request) throws StopRequest { try { return client.execute(request); } catch (IllegalArgumentException ex) { throw new StopRequest(Downloads.STATUS_HTTP_DATA_ERROR, "while trying to execute request: " + ex.toString(), ex); } catch (IOException ex) { logNetworkState(); throw new StopRequest(getFinalStatusForHttpError(state), "while trying to execute request: " + ex.toString(), ex); } }
From source file:com.example.download.DownloadThread.java
/** * Send the request to the server, handling any I/O exceptions. *///from w ww. j a v a 2 s.com private HttpResponse sendRequest(State state, AndroidHttpClient client, HttpGet request) throws StopRequest { try { return client.execute(request); } catch (IllegalArgumentException ex) { throw new StopRequest(DownloadManager.Impl.STATUS_HTTP_DATA_ERROR, "while trying to execute request: " + ex.toString(), ex); } catch (IOException ex) { logNetworkState(); throw new StopRequest(getFinalStatusForHttpError(state), "while trying to execute request: " + ex.toString(), ex); } }
From source file:com.android.providers.downloads.DownloadThread.java
/** * Send the request to the server, handling any I/O exceptions. *///from w ww .j a v a 2 s .c om private HttpResponse sendRequest(State state, AndroidHttpClient client, HttpGet request) throws StopRequest { try { return client.execute(request); } catch (IllegalArgumentException ex) { throw new StopRequest(Downloads.Impl.STATUS_HTTP_DATA_ERROR, "while trying to execute request: " + ex.toString(), ex); } catch (IOException ex) { logNetworkState(); throw new StopRequest(getFinalStatusForHttpError(state), "while trying to execute request: " + ex.toString(), ex); } }
From source file:ru.medved.json.wssoap.WebServiceSampler.java
/** * Sample the URL using Apache SOAP driver. Implementation note for myself * and those that are curious. Current logic marks the end after the * response has been read. If read response is set to false, the buffered * reader will read, but do nothing with it. Essentially, the stream from * the server goes into the ether.//from w ww . j ava2s.co m */ @Override public SampleResult sample() { SampleResult result = new SampleResult(); result.setSuccessful(false); // Assume it will fail result.setResponseCode("000"); // ditto $NON-NLS-1$ result.setSampleLabel(getName()); try { result.setURL(this.getUrl()); org.w3c.dom.Element rdoc = createDocument(); if (rdoc == null) { throw new SOAPException("Could not create document", null); } // set the response defaults result.setDataEncoding(ENCODING); result.setContentType("text/xml"); // $NON-NLS-1$ result.setDataType(SampleResult.TEXT); result.setSamplerData(fileContents);// WARNING - could be large Envelope msgEnv = Envelope.unmarshall(rdoc); // create a new message Message msg = new Message(); result.sampleStart(); SOAPHTTPConnection spconn = null; // if a blank HeaderManager exists, try to // get the SOAPHTTPConnection. After the first // request, there should be a connection object // stored with the cookie header info. if (this.getHeaderManager() != null && this.getHeaderManager().getSOAPHeader() != null) { spconn = (SOAPHTTPConnection) this.getHeaderManager().getSOAPHeader(); } else { spconn = new SOAPHTTPConnection(); } spconn.setTimeout(getTimeoutAsInt()); // set the auth. thanks to KiYun Roe for contributing the patch // I cleaned up the patch slightly. 5-26-05 if (getAuthManager() != null) { if (getAuthManager().getAuthForURL(getUrl()) != null) { AuthManager authmanager = getAuthManager(); Authorization auth = authmanager.getAuthForURL(getUrl()); spconn.setUserName(auth.getUser()); spconn.setPassword(auth.getPass()); } else { log.warn("the URL for the auth was null." + " Username and password not set"); } } // check the proxy String phost = ""; int pport = 0; // if use proxy is set, we try to pick up the // proxy host and port from either the text // fields or from JMeterUtil if they were passed // from command line if (this.getUseProxy()) { if (this.getProxyHost().length() > 0 && this.getProxyPort() > 0) { phost = this.getProxyHost(); pport = this.getProxyPort(); } else { if (System.getProperty("http.proxyHost") != null || System.getProperty("http.proxyPort") != null) { phost = System.getProperty("http.proxyHost"); pport = Integer.parseInt(System.getProperty("http.proxyPort")); } } // if for some reason the host is blank and the port is // zero, the sampler will fail silently if (phost.length() > 0 && pport > 0) { spconn.setProxyHost(phost); spconn.setProxyPort(pport); if (PROXY_USER.length() > 0 && PROXY_PASS.length() > 0) { spconn.setProxyUserName(PROXY_USER); spconn.setProxyPassword(PROXY_PASS); } } } // by default we maintain the session. spconn.setMaintainSession(true); msg.setSOAPTransport(spconn); msg.send(this.getUrl(), this.getSoapAction(), msgEnv); @SuppressWarnings("unchecked") // API uses raw types final Map<String, String> headers = spconn.getHeaders(); result.setResponseHeaders(convertSoapHeaders(headers)); if (this.getHeaderManager() != null) { this.getHeaderManager().setSOAPHeader(spconn); } BufferedReader br = null; if (spconn.receive() != null) { br = spconn.receive(); SOAPContext sc = spconn.getResponseSOAPContext(); // Set details from the actual response // Needs to be done before response can be stored final String contentType = sc.getContentType(); result.setContentType(contentType); result.setEncodingAndType(contentType); int length = 0; if (getReadResponse()) { StringWriter sw = new StringWriter(); length = IOUtils.copy(br, sw); result.sampleEnd(); result.setResponseData(sw.toString().getBytes(result.getDataEncodingWithDefault())); } else { // by not reading the response // for real, it improves the // performance on slow clients length = br.read(); result.sampleEnd(); result.setResponseData(JMeterUtils.getResString("read_response_message"), null); //$NON-NLS-1$ } // It is not possible to access the actual HTTP response code, so we assume no data means failure if (length > 0) { result.setSuccessful(true); result.setResponseCodeOK(); result.setResponseMessageOK(); } else { result.setSuccessful(false); result.setResponseCode("999"); result.setResponseMessage("Empty response"); } } else { result.sampleEnd(); result.setSuccessful(false); final String contentType = spconn.getResponseSOAPContext().getContentType(); result.setContentType(contentType); result.setEncodingAndType(contentType); result.setResponseData( spconn.getResponseSOAPContext().toString().getBytes(result.getDataEncodingWithDefault())); } if (br != null) { br.close(); } // reponse code doesn't really apply, since // the soap driver doesn't provide a // response code } catch (IllegalArgumentException exception) { String message = exception.getMessage(); log.warn(message); result.setResponseMessage(message); } catch (SAXException exception) { log.warn(exception.toString()); result.setResponseMessage(exception.getMessage()); } catch (SOAPException exception) { log.warn(exception.toString()); result.setResponseMessage(exception.getMessage()); } catch (MalformedURLException exception) { String message = exception.getMessage(); log.warn(message); result.setResponseMessage(message); } catch (IOException exception) { String message = exception.getMessage(); log.warn(message); result.setResponseMessage(message); } catch (NoClassDefFoundError error) { log.error("Missing class: ", error); result.setResponseMessage(error.toString()); } catch (Exception exception) { if ("javax.mail.MessagingException".equals(exception.getClass().getName())) { log.warn(exception.toString()); result.setResponseMessage(exception.getMessage()); } else { log.error("Problem processing the SOAP request", exception); result.setResponseMessage(exception.toString()); } } finally { // Make sure the sample start time and sample end time are recorded // in order not to confuse the statistics calculation methods: if // an error occurs and an exception is thrown it is possible that // the result.sampleStart() or result.sampleEnd() won't be called if (result.getStartTime() == 0) { result.sampleStart(); } if (result.getEndTime() == 0) { result.sampleEnd(); } } return result; }
From source file:com.github.diogochbittencourt.googleplaydownloader.downloader.impl.DownloadThread.java
/** * Send the request to the server, handling any I/O exceptions. *//*from ww w .j a v a 2 s . co m*/ private HttpResponse sendRequest(State state, AndroidHttpClient client, HttpGet request) throws StopRequest { try { return client.execute(request); } catch (IllegalArgumentException ex) { throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR, "while trying to execute request: " + ex.toString(), ex); } catch (IOException ex) { logNetworkState(); throw new StopRequest(getFinalStatusForHttpError(state), "while trying to execute request: " + ex.toString(), ex); } }