List of usage examples for java.lang UnsupportedOperationException toString
public String toString()
From source file:com.piusvelte.sonet.core.SonetHttpClient.java
protected static byte[] httpBlobResponse(HttpClient httpClient, HttpUriRequest httpRequest) { if (httpClient != null) { HttpResponse httpResponse;/*from w w w. j a va 2 s .c o m*/ HttpEntity entity = null; try { httpResponse = httpClient.execute(httpRequest); StatusLine statusLine = httpResponse.getStatusLine(); entity = httpResponse.getEntity(); switch (statusLine.getStatusCode()) { case 200: case 201: case 204: if (entity != null) { return getBlob(new FlushedInputStream(entity.getContent())); } break; } } catch (ClientProtocolException e) { Log.e(TAG, e.toString()); try { httpRequest.abort(); } catch (UnsupportedOperationException ignore) { Log.e(TAG, ignore.toString()); } } catch (IOException e) { Log.e(TAG, e.toString()); try { httpRequest.abort(); } catch (UnsupportedOperationException ignore) { Log.e(TAG, ignore.toString()); } } finally { if (entity != null) { try { entity.consumeContent(); } catch (IOException e) { Log.e(TAG, e.toString()); } } } } return null; }
From source file:com.piusvelte.sonet.core.SonetHttpClient.java
protected static String httpResponse(HttpClient httpClient, HttpUriRequest httpRequest) { String response = null;//from w ww . ja v a2s.com if (httpClient != null) { HttpResponse httpResponse; HttpEntity entity = null; try { httpResponse = httpClient.execute(httpRequest); StatusLine statusLine = httpResponse.getStatusLine(); entity = httpResponse.getEntity(); switch (statusLine.getStatusCode()) { case 200: case 201: case 204: if (entity != null) { InputStream is = entity.getContent(); ByteArrayOutputStream content = new ByteArrayOutputStream(); byte[] sBuffer = new byte[512]; int readBytes = 0; while ((readBytes = is.read(sBuffer)) != -1) { content.write(sBuffer, 0, readBytes); } response = new String(content.toByteArray()); } else { response = "OK"; } break; default: Log.e(TAG, httpRequest.getURI().toString()); Log.e(TAG, "" + statusLine.getStatusCode() + " " + statusLine.getReasonPhrase()); if (entity != null) { InputStream is = entity.getContent(); ByteArrayOutputStream content = new ByteArrayOutputStream(); byte[] sBuffer = new byte[512]; int readBytes = 0; while ((readBytes = is.read(sBuffer)) != -1) { content.write(sBuffer, 0, readBytes); } Log.e(TAG, "response:" + new String(content.toByteArray())); } break; } } catch (ClientProtocolException e) { Log.e(TAG, e.toString()); try { httpRequest.abort(); } catch (UnsupportedOperationException ignore) { Log.e(TAG, ignore.toString()); } } catch (IllegalStateException e) { Log.e(TAG, e.toString()); try { httpRequest.abort(); } catch (UnsupportedOperationException ignore) { Log.e(TAG, ignore.toString()); } } catch (IOException e) { Log.e(TAG, e.toString()); try { httpRequest.abort(); } catch (UnsupportedOperationException ignore) { Log.e(TAG, ignore.toString()); } } finally { if (entity != null) { try { entity.consumeContent(); } catch (IOException e) { Log.e(TAG, e.toString()); } } } } return response; }
From source file:com.garethahealy.elasticpostman.scraper.entities.EmailContent.java
private DateTime tryParseDate(String pattern, String value, Boolean isLogException) { DateTime parsed = null;//from w ww . j ava 2 s. c o m try { //http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html parsed = DateTimeFormat.forPattern(pattern).parseDateTime(value); } catch (UnsupportedOperationException ex) { if (isLogException) { LOG.error(ex.toString()); } } catch (IllegalArgumentException ex) { if (isLogException) { LOG.error(ex.toString()); } } return parsed; }
From source file:com.orange.ngsi.server.NgsiBaseController.java
@ExceptionHandler({ UnsupportedOperationException.class }) public ResponseEntity<Object> unsupportedOperation(HttpServletRequest req, UnsupportedOperationException exception) { logger.error("Unsupported operation: {}", exception.toString()); return errorResponse(req.getRequestURI(), new StatusCode(CodeEnum.CODE_403)); }
From source file:co.anarquianegra.rockolappServidor.mundo.ListaReproductor.java
/** * Agrega canciones de un usuario a la lista de reproduccion grande * notifica a la interfaz para mostrar un mensaje de que han * sido aadidas las canciones// w w w . j a va 2 s.c o m * @param canciones * @param infoUsuario informacion del usuario */ synchronized public void agregarLista(Stack<Cancion> canciones, String infoUsuario) { for (int i = 0; i < canciones.size(); i++) { Cancion c = (Cancion) canciones.get(i); } while (!canciones.empty()) { try { listaReproduccion.add(canciones.pop()); } catch (UnsupportedOperationException e) { System.out.println("Erro agregar cancion: " + e.toString()); } } if (mediaPlayer == null && playing) reproducir(); else if (mediaPlayer != null && mediaPlayer.getStatus().equals(Status.DISPOSED) && playing) reproducir(); cantidadConexionesPositivas++; }
From source file:ffx.xray.Rescore.java
private File rescoreSingle(File modelFile, RescoreStrategy rscType, DoubleIndexPair[] energies, int i) { Path filepath = generatePath(modelFile); if (filepath == null) { logger.warning(String.format(" Could not generate path to file %s", modelFile.toPath())); return null; }/*from www . j a va 2 s. c o m*/ String filename = pwdPath.relativize(filepath).toString(); File retFile = modelFile; try { MolecularAssembly[] openedAssemblies = utils.open(filename); MolecularAssembly assembly = openedAssemblies[0]; switch (rscType) { case NO_RESCORE: logger.warning(" Rescore is being called with rscType = NO_RESCORE"); break; case ENERGY_EVAL: break; case MINIMIZE: logger.info(String.format("\n Running minimize on %s", filename)); logger.info(String.format(" RMS gradient convergence criteria: %f", eps)); utils.energy(assembly); utils.minimize(assembly, eps); String ext = FilenameUtils.getExtension(filename); ext = ".".concat(ext); if (resultDir != null) { filename = FilenameUtils.getBaseName(filename); filename = FilenameUtils.concat(resultPath.toString(), filename); } else { filename = FilenameUtils.removeExtension(filename); } filename = filename.concat(fileSuffix).concat(ext); retFile = new File(filename); if (ext.toUpperCase().contains("XYZ")) { utils.saveAsXYZ(assembly, retFile); } else { utils.saveAsPDB(assembly, retFile); } break; case XRAY_MIN: logger.info(String.format("\n Running x-ray minimize on %s", filename)); DiffractionFile diffractionFile = null; if (diffractionFiles.isEmpty()) { diffractionFile = new DiffractionFile(assembly, 1.0, false); diffractionFiles.add(diffractionFile); } CompositeConfiguration properties = Keyword.loadProperties(modelFile); DiffractionData diffractionData = new DiffractionData(assembly, properties, SolventModel.POLYNOMIAL, diffractionFiles.toArray(new DiffractionFile[diffractionFiles.size()])); diffractionData.scaleBulkFit(); diffractionData.printStats(); utils.energy(assembly); RefinementMinimize refinementMinimize = new RefinementMinimize(diffractionData, refinementMode); if (eps < 0.0) { eps = refinementMinimize.getEps(); } logger.info(String.format("\n RMS gradient convergence criteria: %8.5f max number of iterations %d", eps, maxiter)); refinementMinimize.minimize(eps, maxiter); diffractionData.scaleBulkFit(); diffractionData.printStats(); ext = FilenameUtils.getExtension(filename); ext = ".".concat(ext); if (resultDir != null) { filename = FilenameUtils.getBaseName(filename); filename = FilenameUtils.concat(resultPath.toString(), filename); } else { filename = FilenameUtils.removeExtension(filename); } filename = filename.concat(fileSuffix); diffractionData.writeData(filename + ".mtz"); filename = filename.concat(ext); diffractionData.writeModel(filename); retFile = new File(filename); if (diffractionFile != null) { try { diffractionFiles.remove(diffractionFile); } catch (UnsupportedOperationException ex) { // This should never occur, because diffractionFiles should be of a List type supporting remove(object). diffractionFiles = new ArrayList<>(); } } break; case RS_MIN: logger.info(String.format("\n Running real-space minimize on %s", filename)); RealSpaceFile realspaceFile = null; if (mapFiles.isEmpty()) { realspaceFile = new RealSpaceFile(assembly); mapFiles.add(realspaceFile); } properties = Keyword.loadProperties(modelFile); RealSpaceData realspaceData = new RealSpaceData(assembly, properties, new ParallelTeam(), mapFiles.toArray(new RealSpaceFile[mapFiles.size()])); utils.energy(assembly); refinementMinimize = new RefinementMinimize(realspaceData, refinementMode); if (eps < 0.0) { eps = 1.0; } logger.info(String.format("\n RMS gradient convergence criteria: %8.5f max number of iterations %d", eps, maxiter)); refinementMinimize.minimize(eps, maxiter); ext = FilenameUtils.getExtension(filename); ext = ".".concat(ext); if (resultDir != null) { filename = FilenameUtils.getBaseName(filename); filename = FilenameUtils.concat(resultPath.toString(), filename); } else { filename = FilenameUtils.removeExtension(filename); } filename = filename.concat(fileSuffix).concat(ext); retFile = new File(filename); if (ext.toUpperCase().contains("XYZ")) { utils.saveAsXYZ(assembly, retFile); } else { utils.saveAsPDB(assembly, retFile); } if (realspaceFile != null) { try { mapFiles.remove(realspaceFile); } catch (UnsupportedOperationException ex) { // This should never occur, because diffractionFiles should be of a List type supporting remove(object). mapFiles = new ArrayList<>(); } } break; default: logger.severe(" No valid rescore type: FFX will not continue."); } double e = utils.returnEnergy(assembly); energies[i] = new DoubleIndexPair(i, e); utils.closeAll(openedAssemblies); } catch (Exception ex) { logger.warning(String.format(" Exception rescoring on file %s", filename)); logger.info(ex.toString()); } return retFile; }
From source file:ffx.xray.RescoreAndCluster.java
private File rescoreSingle(File modelFile, RescoreStrategy rscType, DoubleIndexPair[] energies, int i) { Path filepath = generatePath(modelFile); if (filepath == null) { logger.warning(String.format(" Could not generate path to file %s", modelFile.toPath())); return null; }/*from ww w.jav a 2s .c o m*/ String filename = pwdPath.relativize(filepath).toString(); File retFile = modelFile; try { MolecularAssembly[] openedAssemblies = utils.open(filename); MolecularAssembly assembly = openedAssemblies[0]; switch (rscType) { case NO_RESCORE: logger.warning(" Rescore is being called with rscType = NO_RESCORE"); break; case ENERGY_EVAL: break; case MINIMIZE: logger.info(String.format("\n Running minimize on %s", filename)); logger.info(String.format(" RMS gradient convergence criteria: %f", eps)); utils.energy(assembly); utils.minimize(assembly, eps); String ext = FilenameUtils.getExtension(filename); ext = ".".concat(ext); if (resultDir != null) { filename = FilenameUtils.getBaseName(filename); filename = FilenameUtils.concat(resultPath.toString(), filename); } else { filename = FilenameUtils.removeExtension(filename); } filename = filename.concat(fileSuffix).concat(ext); retFile = new File(filename); if (ext.toUpperCase().contains("XYZ")) { utils.saveAsXYZ(assembly, retFile); } else { utils.saveAsPDB(assembly, retFile); } break; case XRAY_MIN: logger.info(String.format("\n Running x-ray minimize on %s", filename)); DiffractionFile diffractionFile = null; if (diffractionFiles.isEmpty()) { diffractionFile = new DiffractionFile(assembly, 1.0, false); diffractionFiles.add(diffractionFile); } CompositeConfiguration properties = Keyword.loadProperties(modelFile); DiffractionData diffractionData = new DiffractionData(assembly, properties, SolventModel.POLYNOMIAL, diffractionFiles.toArray(new DiffractionFile[diffractionFiles.size()])); diffractionData.scaleBulkFit(); diffractionData.printStats(); utils.energy(assembly); RefinementMinimize refinementMinimize = new RefinementMinimize(diffractionData, refinementMode); if (eps < 0.0) { eps = refinementMinimize.getEps(); } logger.info(String.format("\n RMS gradient convergence criteria: %8.5f max number of iterations %d", eps, maxiter)); refinementMinimize.minimize(eps, maxiter); diffractionData.scaleBulkFit(); diffractionData.printStats(); ext = FilenameUtils.getExtension(filename); ext = ".".concat(ext); if (resultDir != null) { filename = FilenameUtils.getBaseName(filename); filename = FilenameUtils.concat(resultPath.toString(), filename); } else { filename = FilenameUtils.removeExtension(filename); } filename = filename.concat(fileSuffix); diffractionData.writeData(filename + ".mtz"); filename = filename.concat(ext); diffractionData.writeModel(filename); retFile = new File(filename); if (diffractionFile != null) { try { diffractionFiles.remove(diffractionFile); } catch (UnsupportedOperationException ex) { // This should never occur, because diffractionFiles should be of a List type supporting remove(object). diffractionFiles = new ArrayList<>(); } } break; case RS_MIN: logger.info(String.format("\n Running real-space minimize on %s", filename)); RealSpaceFile realspaceFile = null; if (mapFiles.isEmpty()) { realspaceFile = new RealSpaceFile(assembly); mapFiles.add(realspaceFile); } properties = Keyword.loadProperties(modelFile); RealSpaceData realspaceData = new RealSpaceData(assembly, properties, mapFiles.toArray(new RealSpaceFile[mapFiles.size()])); utils.energy(assembly); refinementMinimize = new RefinementMinimize(realspaceData, refinementMode); if (eps < 0.0) { eps = 1.0; } logger.info(String.format("\n RMS gradient convergence criteria: %8.5f max number of iterations %d", eps, maxiter)); refinementMinimize.minimize(eps, maxiter); ext = FilenameUtils.getExtension(filename); ext = ".".concat(ext); if (resultDir != null) { filename = FilenameUtils.getBaseName(filename); filename = FilenameUtils.concat(resultPath.toString(), filename); } else { filename = FilenameUtils.removeExtension(filename); } filename = filename.concat(fileSuffix).concat(ext); retFile = new File(filename); if (ext.toUpperCase().contains("XYZ")) { utils.saveAsXYZ(assembly, retFile); } else { utils.saveAsPDB(assembly, retFile); } if (realspaceFile != null) { try { mapFiles.remove(realspaceFile); } catch (UnsupportedOperationException ex) { // This should never occur, because diffractionFiles should be of a List type supporting remove(object). mapFiles = new ArrayList<>(); } } break; default: logger.severe(" No valid rescore type: FFX will not continue."); } double e = utils.returnEnergy(assembly); energies[i] = new DoubleIndexPair(i, e); utils.closeAll(openedAssemblies); } catch (Exception ex) { logger.warning(String.format(" Exception rescoring on file %s", filename)); logger.info(ex.toString()); } return retFile; }
From source file:org.apache.axis2.jaxws.BindingProvider.java
public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) { EndpointReference jaxwsEPR = null; String addressingNamespace = EndpointReferenceUtils.getAddressingNamespace(clazz); try {//from w ww . j a v a 2 s . c o m org.apache.axis2.addressing.EndpointReference epr = binding.getAxis2EndpointReference(); if (epr == null) { String address = (String) requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); if (address == null) address = endpointDesc.getEndpointAddress(); QName service = endpointDesc.getServiceQName(); QName port = endpointDesc.getPortQName(); String wsdlLocation = ((ServiceDescriptionWSDL) endpointDesc.getServiceDescription()) .getWSDLLocation(); epr = EndpointReferenceUtils.createAxis2EndpointReference(address, service, port, wsdlLocation, addressingNamespace); } else if (!addressingNamespace.equals(binding.getAddressingNamespace())) { throw ExceptionFactory.makeWebServiceException(Messages.getMessage("bindingProviderErr1", binding.getAddressingNamespace(), addressingNamespace)); } jaxwsEPR = EndpointReferenceUtils.convertFromAxis2(epr, addressingNamespace); } catch (UnsupportedOperationException e) { throw e; } catch (WebServiceException e) { throw e; } catch (Exception e) { throw ExceptionFactory .makeWebServiceException(Messages.getMessage("endpointRefConstructionFailure3", e.toString())); } return clazz.cast(jaxwsEPR); }
From source file:org.apache.hadoop.fs.FileContextMainOperationsBaseTest.java
@Test public void testListCorruptFileBlocks() throws IOException { final Path rootPath = getTestRootPath(fc, "test"); final Path path = new Path(rootPath, "zoo"); createFile(path);//from ww w . j av a2 s .c o m try { final RemoteIterator<Path> remoteIterator = fc.listCorruptFileBlocks(path); if (listCorruptedBlocksSupported()) { assertTrue(remoteIterator != null); Path p; while (remoteIterator.hasNext()) { p = remoteIterator.next(); System.out.println("corrupted block: " + p); } try { remoteIterator.next(); fail(); } catch (NoSuchElementException nsee) { // okay } } else { fail(); } } catch (UnsupportedOperationException uoe) { if (listCorruptedBlocksSupported()) { fail(uoe.toString()); } else { // okay } } }
From source file:password.pwm.util.PwmPasswordRuleValidator.java
public boolean testPassword(final PasswordData password, final PasswordData oldPassword, final UserInfo userInfo, final ChaiUser user) throws PwmDataValidationException, ChaiUnavailableException, PwmUnrecoverableException { final List<ErrorInformation> errorResults = validate(password, oldPassword, userInfo); if (!errorResults.isEmpty()) { throw new PwmDataValidationException(errorResults.iterator().next()); }//ww w . j a v a 2 s . c o m if (user != null) { try { LOGGER.trace("calling chai directory password validation checker"); user.testPasswordPolicy(password.getStringValue()); } catch (UnsupportedOperationException e) { LOGGER.trace("Unsupported operation was thrown while validating password: " + e.toString()); } catch (ChaiUnavailableException e) { pwmApplication.getStatisticsManager().incrementValue(Statistic.LDAP_UNAVAILABLE_COUNT); LOGGER.warn("ChaiUnavailableException was thrown while validating password: " + e.toString()); throw e; } catch (ChaiPasswordPolicyException e) { final ChaiError passwordError = e.getErrorCode(); final PwmError pwmError = PwmError.forChaiError(passwordError); final ErrorInformation info = new ErrorInformation( pwmError == null ? PwmError.PASSWORD_UNKNOWN_VALIDATION : pwmError); LOGGER.trace("ChaiPasswordPolicyException was thrown while validating password: " + e.toString()); errorResults.add(info); } } if (!errorResults.isEmpty()) { throw new PwmDataValidationException(errorResults.iterator().next()); } return true; }