List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:com.tune.reporting.base.endpoints.ReportExportWorker.java
/** * Poll export status and upon completion gather download URL * referencing requested report./* w w w . j a v a2 s . com*/ * * @return Boolean If True upon successful completion. * @throws TuneSdkException If error within SDK. * @throws TuneServiceException If service fails to handle post request. */ public final Boolean run() throws TuneSdkException, TuneServiceException { String status = null; TuneServiceResponse response = null; int attempt = 0; int timeout = 0; Map<String, String> mapQueryString = new HashMap<String, String>(); mapQueryString.put("job_id", jobId); TuneServiceClient client = null; try { client = new TuneServiceClient(this.exportController, this.exportAction, this.authKey, this.authType, mapQueryString); } catch (IllegalArgumentException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } while (true) { if (this.timeout > 0) { if (timeout >= this.timeout) { throw new TuneSdkException(String.format( "Fetch request for Job ID '%s' has expired after '%d' seconds. Service request URL: %s", jobId, timeout, client.getServiceUrl())); } timeout += sleep; } try { client.call(this.authKey, this.authType); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } response = client.getResponse(); // Failed to return response. if (null == response) { throw new TuneSdkException("No response returned from export request."); } String requestUrl = response.getRequestUrl(); int responseHttpCode = response.getHttpCode(); // Failed to get successful service response. if ((response.getHttpCode() != HTTP_STATUS_OK) || (null != response.getErrors())) { throw new TuneServiceException(String.format("Service failed request: %d: %s", response.getHttpCode(), response.toString())); } // Failed to get data. JSONObject jdata = (JSONObject) response.getData(); if (null == jdata) { throw new TuneServiceException("Report request failed to get export data."); } try { status = jdata.getString("status"); } catch (JSONException ex) { throw new TuneSdkException(ex.getMessage(), ex); } catch (Exception ex) { throw new TuneSdkException(ex.getMessage(), ex); } if (this.verbose) { System.out.println(String.format("= status: %s", status)); } if (status.equals("fail") || status.equals("complete")) { break; } attempt += 1; if (this.verbose) { System.out.println(String.format("= attempt: %d\n= timeout: %d\n= response: %s", attempt, timeout, response.toString())); } try { Thread.sleep(this.sleep * 1000); } catch (InterruptedException e) { e.printStackTrace(); } } if (!status.equals("complete")) { throw new TuneServiceException( String.format("= status: %s, response: %s", status, response.toString())); } if (this.verbose) { System.out.println(String.format("= attempt: %d\n= timeout: %d\n= response: %s", attempt, timeout, response.toString())); } this.response = response; return true; }
From source file:org.openregistry.core.service.DefaultDisclosureIntegrationTests.java
private Long createSorPerson(String sorName, String lastName, String[] affiliations, long orgUnitId) { Long validPersonId = null;//from w w w . j a va 2 s . c o m int personCount = countRowsInTable("prs_sor_persons"); int roleCount = countRowsInTable("prs_role_records"); int identifierCount = countRowsInTable("prc_identifiers"); int newRoleCount = 0; SystemOfRecord sor = referenceRepository.findSystemOfRecord(sorName); ReconciliationCriteria reconciliationCriteria = new JpaReconciliationCriteriaImpl(); reconciliationCriteria.setEmailAddress(lastName + "@test.tst"); reconciliationCriteria.setPhoneNumber("1234567890"); try { SorPerson sorPerson = reconciliationCriteria.getSorPerson(); sorPerson.setDateOfBirth(new Date(new Date(0).getTime() + (long) (Math.random() * 10000000000L))); sorPerson.setGender("M"); sorPerson.setSorId(lastName + sorName); sorPerson.setSourceSor(sor.getSorId()); SorName name = sorPerson .addName(this.referenceRepository.findType(Type.DataTypes.NAME, Type.NameTypes.FORMAL)); name.setFamily(lastName); name.setGiven("First"); ServiceExecutionResult<Person> result = personService.addPerson(reconciliationCriteria); entityManager.flush(); Person person = result.getTargetObject(); person.addIdentifier(this.referenceRepository.findIdentifierType("NETID"), lastName); validPersonId = person.getId(); sorPerson = personService.findByPersonIdAndSorIdentifier(validPersonId, sorName); for (String affiliation : affiliations) { newRoleCount++; SorRole sorRole = sorPerson .createRole(referenceRepository.findType(Type.DataTypes.AFFILIATION, affiliation)); sorRole.setSystemOfRecord(sor); sorRole.setSorId(newRoleCount + "-" + sorPerson.getSorId()); sorRole.setStart(new Date()); sorRole.setPersonStatus(this.referenceRepository.getTypeById(1L)); sorRole.setSponsorId(1L); sorRole.setSponsorType(this.referenceRepository.getTypeById(1L)); sorRole.setOrganizationalUnit( this.referenceRepository.getOrganizationalUnitById(new Long(orgUnitId))); sorRole.setTitle("Professor"); sorPerson.addRole(sorRole); personService.validateAndSaveRoleForSorPerson(sorPerson, sorRole); entityManager.flush(); } } catch (IllegalArgumentException e) { e.printStackTrace(); fail(e.getMessage()); } catch (ReconciliationException e) { e.printStackTrace(); fail(e.getMessage()); } catch (SorPersonAlreadyExistsException e) { e.printStackTrace(); fail(e.getMessage()); } assertNotNull("The id of created person must not be null before test", validPersonId); assertTrue("The id of created person must be positive before test", validPersonId.longValue() > 0); assertEquals("A valid SOR person must be created", personCount + 1, countRowsInTable("prs_sor_persons")); assertEquals("A valid SOR role must be created", roleCount + newRoleCount, countRowsInTable("prs_role_records")); assertEquals("An identifier must have been created", identifierCount + 1, countRowsInTable("prc_identifiers")); return validPersonId; }
From source file:com.pddstudio.share.Share.java
/** * Add a file to the content you want to share. * <b>Note:</b> This requires a {@linkplain FileProvider}. * @param mimeType - The MIME-Type of the file * @param file - The File itself// w w w .j av a2 s . c o m * @param fileProviderAuthority - The name of your {@linkplain FileProvider} * @return - */ public Share withFile(String mimeType, File file, String fileProviderAuthority) { try { Uri fileUri = FileProvider.getUriForFile(activity, fileProviderAuthority, file); intentBuilder.setType(mimeType); intentBuilder.setStream(fileUri); fileAttached = true; this.fileUri = fileUri; } catch (IllegalArgumentException ex) { Log.e("Share", "Unable to retrieve Uri for the given file. The given File might be outside the paths supported by the provider."); ex.printStackTrace(); } return this; }
From source file:org.alfresco.reporting.execution.PentahoReporting.java
public void processReport() throws IllegalStateException, SecurityException { logger.debug("processReport start"); try {//from w w w .ja v a 2s .c om ContentWriter contentWriter = serviceRegistry.getContentService().getWriter(output, ContentModel.PROP_CONTENT, true); String filename = serviceRegistry.getNodeService().getProperty(output, ContentModel.PROP_NAME) .toString(); String mimetype = serviceRegistry.getMimetypeService().guessMimetype(filename); contentWriter.setMimetype(mimetype); logger.debug("Found: " + filename + " mimetype: " + mimetype); //OutputStream outputStream = contentWriter.getContentOutputStream(); //logger.debug("Got the outputstream: " + outputStream); if ("pdf".equalsIgnoreCase(format)) { generateReport(OutputType.PDF, contentWriter); } if ("excel".equalsIgnoreCase(format)) { generateReport(OutputType.EXCEL, contentWriter); } if ("csv".equalsIgnoreCase(format)) { generateReport(OutputType.CSV, contentWriter); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (ReportProcessingException e) { e.printStackTrace(); } catch (ContentIOException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (NamingException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } logger.debug("processReport end"); }
From source file:org.mdissjava.mdisscore.view.upload.UploadDetailsBean.java
public void saveDetails() { //TODO: Check again public +18... the user could disable javascript in the browser... try {// www .j a v a 2s . c o m this.photoManager.insertPhoto(this.imageID, this.userNick, this.title, this.album, this.publicPhotoScope, this.plus18, this.license, this.tags); //throw photo upload event NotificationManager notifier = NotificationManager.getInstance(); PhotoUploadedObservable puo = notifier.getPhotoUploadedObservable(); puo.photoUploaded(this.userNick, this.imageID); //Set status to detailed this.photoStatusManager.markAsDetailed(this.imageID); //redirect to the final photo ParamsBean params = getPrettyfacesParams(); params.setPhotoId(this.imageID); params.setUserId(this.userNick); String outcome = "pretty:photo-detail"; FacesContext facesContext = FacesContext.getCurrentInstance(); facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, outcome); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.iiitd.networking.UDPMessenger.java
public void startMessageReceiver() { Runnable receiver = new Runnable() { @Override/* w w w . ja v a2 s. c o m*/ public void run() { WifiManager wim = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wim != null) { MulticastLock mcLock = wim.createMulticastLock(TAG); mcLock.acquire(); } byte[] buffer = new byte[BUFFER_SIZE]; DatagramPacket rPacket = new DatagramPacket(buffer, buffer.length); MulticastSocket rSocket; try { rSocket = new MulticastSocket(MULTICAST_PORT); } catch (IOException e) { Log.d(DEBUG_TAG, "Impossible to create a new MulticastSocket on port " + MULTICAST_PORT); e.printStackTrace(); return; } while (receiveMessages) { try { rSocket.receive(rPacket); } catch (IOException e1) { Log.d(DEBUG_TAG, "There was a problem receiving the incoming message."); e1.printStackTrace(); continue; } if (!receiveMessages) break; byte data[] = rPacket.getData(); int i; for (i = 0; i < data.length; i++) { if (data[i] == '\0') break; } String messageText; try { messageText = new String(data, 0, i, "UTF-8"); } catch (UnsupportedEncodingException e) { Log.d(DEBUG_TAG, "UTF-8 encoding is not supported. Can't receive the incoming message."); e.printStackTrace(); continue; } try { incomingMessage = new Message(messageText, rPacket.getAddress()); } catch (IllegalArgumentException ex) { Log.d(DEBUG_TAG, "There was a problem processing the message: " + messageText); ex.printStackTrace(); continue; } incomingMessageHandler.post(getIncomingMessageAnalyseRunnable()); } } }; receiveMessages = true; if (receiverThread == null) receiverThread = new Thread(receiver); if (!receiverThread.isAlive()) receiverThread.start(); }
From source file:org.cloudifysource.dsl.ApplicationValidationTest.java
/******* * Tests the validation of an application with an invalid name using DSL parsing of a groovy file. * <p>/* w w w .j a v a 2s . com*/ * Should throw <code>DSLValidationException</code>. */ @Test public void testInvalidNameGroovyFileValidation() { final File applicationFile = new File(APPLICATION_WITH_INVALID_NAME_GROOVY); try { ServiceReader.getApplicationFromFile(applicationFile).getApplication(); Assert.fail( "Application name is invalid: " + INVALID_APP_NAME + ". IllegalArgumentException expected."); } catch (final IllegalArgumentException e) { // OK - the invalid application name caused the exception } catch (final Exception e) { Assert.fail("Application name is invalid: " + INVALID_APP_NAME + ". IllegalArgumentException expected, " + "but " + e.getClass() + " was thrown instead."); e.printStackTrace(); } }
From source file:de.fuberlin.wiwiss.marbles.loading.CacheController.java
/** * Retrieves a cached response header field from the metadata cache * //from www . j av a 2s. c o m * @param metaDataConn A connection to the metadata repository * @param url The resource of interest * @param headerField The header field of interest * @return Header data * @throws RepositoryException */ public Header getCachedHeaderData(RepositoryConnection metaDataConn, String url, String headerField) throws RepositoryException { try { URI metaUrlContext = metaDataRepository.getValueFactory().createURI(url); return getCachedHeaderData(metaDataConn, metaUrlContext, headerField); } catch (IllegalArgumentException e) { e.printStackTrace(); return null; } }
From source file:com.racoon.ampdroid.Mp3PlayerService.java
private void play(int id) { mediaPlayer.reset();// w ww. j a va 2s . c o m try { Log.d("bugs", "song url " + playList.get(id).getUrl()); String pattern = "ssid=([a-z]|[0-9])*&"; String dataUrl = playList.get(id).getUrl().replaceAll(pattern, "ssid=" + session + "&"); Log.d("bugs", "session " + session); Log.d("bugs", "data url " + dataUrl); //mediaPlayer.setDataSource(dataUrl); File extStore = Environment.getExternalStorageDirectory(); String tmpfilename = extStore.getPath() + "/tmp/Ampdroid.mp3"; File tmpfile = new File(tmpfilename); tmpfile.delete(); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_notify) .setContentTitle(getResources().getString(R.string.app_name)) .setContentText(getResources().getString(R.string.downloadinfo)); int mNotificationId = 1; NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mNotifyMgr.notify(mNotificationId, mBuilder.build()); DownloadFromUrl(dataUrl, tmpfilename, oCuser, oCpassword); mediaPlayer.setDataSource(tmpfilename); mNotifyMgr.cancel(mNotificationId); mediaPlayer.prepare(); currentSong = playList.get(id); mediaPlayer.start(); setNotifiction(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.opendatakit.persistence.engine.pgres.TaskLockImpl.java
@Override public boolean renewLock(String lockId, String formId, ITaskLockType taskType) { boolean result = false; try {//from w w w . ja v a2 s . co m TaskLockTable relation = TaskLockTable.assertRelation(datastore, user); TaskLockTable entity = datastore.getEntity(relation, lockId, user); if (!(entity.getFormId().equals(formId) && entity.getTaskType().equals(taskType.getName()))) { throw new IllegalArgumentException("formId or taskType don't match datastore values"); } entity = doTransaction(entity, taskType.getLockExpirationTimeout()); result = true; } catch (IllegalArgumentException e) { // unexpected failure... e.printStackTrace(); } catch (ODKEntityNotFoundException e) { // unexpected failure... e.printStackTrace(); } catch (ODKDatastoreException e) { // unexpected failure... e.printStackTrace(); } catch (ODKTaskLockException e) { // unexpected failure... e.printStackTrace(); } return result; }