List of usage examples for java.io IOException getLocalizedMessage
public String getLocalizedMessage()
From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticator.java
/** * Validates user's password on the server *//*from w w w . j a va2s .com*/ private Bundle onlineConfirmPassword(Account account, String password) { Bundle response = null; try { response = NetworkClient.authenticate(mContext, account, password); } catch (final IOException e) { Log.e(TAG, e.getLocalizedMessage(), e); } catch (final JSONException e) { Log.e(TAG, e.getLocalizedMessage(), e); } catch (final NetworkProtocolException e) { Log.e(TAG, e.getLocalizedMessage(), e); } return response; }
From source file:fr.sanofi.fcl4transmart.controllers.listeners.clinicalData.SelectWMFListener.java
@Override public void handleEvent(Event event) { // TODO Auto-generated method stub String path = this.selectWMFUI.getPath(); if (path == null) return;//from w w w. j a v a2 s . c o m if (path.contains("%")) { this.selectWMFUI.displayMessage("File name can not contain percent ('%') symbol."); return; } File file = new File(path); if (file.exists()) { if (file.isFile()) { if (!this.checkFormat(file)) return; String newPath; if (file.getName().endsWith(".words")) { newPath = this.dataType.getPath().getAbsolutePath() + File.separator + file.getName(); } else { newPath = this.dataType.getPath().getAbsolutePath() + File.separator + file.getName() + ".words"; } File copiedFile = new File(newPath); try { FileUtils.copyFile(file, copiedFile); ((ClinicalData) this.dataType).setWMF(copiedFile); this.selectWMFUI.displayMessage("File has been added"); WorkPart.updateSteps(); //to do: update files list UsedFilesPart.sendFilesChanged(dataType); } catch (IOException e) { // TODO Auto-generated catch block this.selectWMFUI.displayMessage("Error: " + e.getLocalizedMessage()); e.printStackTrace(); } } else { this.selectWMFUI.displayMessage("This is a directory"); } } else { this.selectWMFUI.displayMessage("This path does no exist"); } }
From source file:it.geosolutions.geobatch.actions.commons.MoveAction.java
/** * Removes TemplateModelEvents from the queue and put *///from ww w. j a v a 2 s . co m public Queue<EventObject> execute(Queue<EventObject> events) throws ActionException { listenerForwarder.started(); listenerForwarder.setTask("build the output absolute file name"); // return final Queue<EventObject> ret = new LinkedList<EventObject>(); listenerForwarder.setTask("Building/getting the root data structure"); boolean moveMultipleFile; final int size = events.size(); if (size == 0) { throw new ActionException(this, "Empty file list"); } else if (size > 1) { moveMultipleFile = true; } else { moveMultipleFile = false; } if (conf.getDestination() == null) { throw new IllegalArgumentException("Unable to work with a null dest dir"); } if (!conf.getDestination().isAbsolute()) { conf.setDestination(new File(this.getConfigDir(), conf.getDestination().getPath())); if (LOGGER.isWarnEnabled()) { LOGGER.warn("Destination is not an absolute path. Absolutizing destination using temp dir: " + conf.getDestination()); } } boolean moveToDir; if (!conf.getDestination().isDirectory()) { // TODO LOG moveToDir = false; if (moveMultipleFile) { throw new ActionException(this, "Unable to run on multiple file with an output file, use directory instead"); } } else { moveToDir = true; } while (!events.isEmpty()) { listenerForwarder.setTask("Generating the output"); final EventObject event = events.remove(); if (event == null) { // TODO LOG continue; } if (event instanceof FileSystemEvent) { File source = ((FileSystemEvent) event).getSource(); File dest; listenerForwarder.setTask("moving to destination"); if (moveToDir) { dest = conf.getDestination(); try { FileUtils.moveFileToDirectory(source, dest, true); } catch (IOException e) { throw new ActionException(this, e.getLocalizedMessage()); } } else if (moveMultipleFile) { dest = new File(conf.getDestination(), source.getPath()); try { FileUtils.moveFile(source, dest); } catch (IOException e) { throw new ActionException(this, e.getLocalizedMessage()); } } else { // LOG continue continue; } // add the file to the return ret.add(new FileSystemEvent(dest, FileSystemEventType.FILE_ADDED)); } } listenerForwarder.completed(); return ret; }
From source file:com.whizzosoftware.hobson.rest.v1.resource.device.MediaProxyResource.java
@Override public Representation head() { HobsonRestContext ctx = HobsonRestContext.createContext(this, getRequest()); HobsonVariable hvar = variableManager.getDeviceVariable(ctx.getUserId(), ctx.getHubId(), getAttribute("pluginId"), getAttribute("deviceId"), getAttribute("mediaId")); if (hvar != null && hvar.getValue() != null) { try {// w w w . ja va 2 s . c o m final HttpProps httpProps = createHttpGet(hvar.getValue().toString()); try { final CloseableHttpResponse response = httpProps.client.execute(httpProps.httpGet); getResponse().setStatus(new Status(response.getStatusLine().getStatusCode())); response.close(); return new EmptyRepresentation(); } catch (IOException e) { throw new HobsonRuntimeException(e.getLocalizedMessage(), e); } finally { try { httpProps.client.close(); } catch (IOException e) { logger.warn("Error closing HttpClient", e); } } } catch (ParseException | URISyntaxException e) { logger.error("Error obtaining media stream from device", e); throw new HobsonRuntimeException(e.getLocalizedMessage(), e); } } getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new EmptyRepresentation(); }
From source file:fedroot.dacs.http.DacsClientContext.java
public DacsResponse execute(DacsGetRequest dacsGetRequest, HttpClient httpClient, HttpContext httpContext) throws DacsException { try {//from w w w .j a va 2 s. co m return new DacsResponse(httpClient.execute(dacsGetRequest.getHttpGet(), httpContext)); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); throw new DacsException(ex.getLocalizedMessage()); } }
From source file:fedroot.dacs.http.DacsClientContext.java
public DacsResponse execute(DacsPostRequest dacsPostRequest, HttpClient httpClient, HttpContext httpContext) throws DacsException { try {// www.j a v a 2s . co m return new DacsResponse(httpClient.execute(dacsPostRequest.getHttpPost(), httpContext)); } catch (IOException ex) { logger.log(Level.SEVERE, null, ex); throw new DacsException(ex.getLocalizedMessage()); } }
From source file:com.jaspersoft.jasperserver.remote.handlers.FileResourceHandler.java
@Override protected void updateResource(Resource resource, ResourceDescriptor descriptor, Map options) { try {/* ww w . jav a2 s.c om*/ FileResource fResource; if (!(resource instanceof FileResource)) { throw new IllegalStateException("resource:" + resource.getName() + " is not a File Resource"); } else { fResource = (FileResource) resource; } super.updateResource(fResource, descriptor, options); fResource.setLabel(descriptor.getLabel()); fResource.setDescription(descriptor.getDescription()); if (ResourceDescriptor.TYPE_REFERENCE.equals(descriptor.getWsType()) || descriptor.getIsReference()) { // check if the reference uri is valid... String referenceUri = descriptor.getReferenceUri(); try { getRepository().getResource(null, referenceUri); } catch (Exception ex) { throw new ServiceException(ServiceException.GENERAL_ERROR2, getMessageSource().getMessage("webservices.error.resourceNotFoundOrInvalid", new Object[] { referenceUri }, LocaleContextHolder.getLocale())); } fResource.setReferenceURI(referenceUri); } else { fResource.setFileType(descriptor.getWsType()); if (getRunReportService().getInputAttachments().containsKey(descriptor.getUriString())) { InputStream ds = getRunReportService().getInputAttachments().get(descriptor.getUriString()) .getInputStream(); fResource.setData(IOUtils.toByteArray(ds)); } else { throw new IllegalStateException( "could not find the binary content for resource: " + descriptor.getUriString()); } } } catch (IOException e) { throw new ServiceException(ServiceException.INTERNAL_SERVER_ERROR, e.getLocalizedMessage()); } }
From source file:com.nextgis.maplib.map.NGWVectorLayer.java
public String download() { if (!mNet.isNetworkAvailable()) { //return tile from cache return mContext.getString(R.string.error_network_unavailable); }// ww w . ja va 2 s .co m try { final HttpGet get = new HttpGet(mURL); //basic auth if (null != mLogin && mLogin.length() > 0 && null != mPassword && mPassword.length() > 0) { get.setHeader("Accept", "*/*"); final String basicAuth = "Basic " + Base64.encodeToString((mLogin + ":" + mPassword).getBytes(), Base64.NO_WRAP); get.setHeader("Authorization", basicAuth); } final DefaultHttpClient HTTPClient = mNet.getHttpClient(); final HttpResponse response = HTTPClient.execute(get); // Check to see if we got success final org.apache.http.StatusLine line = response.getStatusLine(); if (line.getStatusCode() != 200) { Log.d(TAG, "Problem downloading GeoJSON: " + mURL + " HTTP response: " + line); return mContext.getString(R.string.error_download_data); } final HttpEntity entity = response.getEntity(); if (entity == null) { Log.d(TAG, "No content downloading GeoJSON: " + mURL); return mContext.getString(R.string.error_download_data); } String data = EntityUtils.toString(entity); JSONObject geoJSONObject = new JSONObject(data); return createFromGeoJSON(geoJSONObject); } catch (IOException e) { Log.d(TAG, "Problem downloading GeoJSON: " + mURL + " Error: " + e.getLocalizedMessage()); return mContext.getString(R.string.error_download_data); } catch (JSONException e) { e.printStackTrace(); return mContext.getString(R.string.error_download_data); } }
From source file:ca.phon.app.modules.EntryPointArgs.java
/** * <p>Get the project based on either (in order): * <ul><li>project object</li><li>project location</li><li>project name</li></ul> * </p>//from w ww . j av a 2s .c o m * * @return project or <code>null</code> if not specified */ public Project getProject() { Project retVal = null; final Object projectObj = get(PROJECT_OBJECT); final Object projectLoc = get(PROJECT_LOCATION); final Object projectName = get(PROJECT_NAME); File projectFile = null; if (projectObj != null && projectObj instanceof Project) { retVal = Project.class.cast(projectObj); } else if (projectLoc != null) { final String projectLocation = projectLoc.toString(); projectFile = new File(projectLocation); } else if (projectName != null) { final Workspace workspace = Workspace.userWorkspace(); projectFile = new File(workspace.getWorkspaceFolder(), projectName.toString()); } if (projectFile != null) { final ProjectFactory factory = new DesktopProjectFactory(); try { retVal = factory.openProject(projectFile); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } catch (ProjectConfigurationException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } } return retVal; }
From source file:com.kylinolap.rest.service.UserService.java
public UserService() { String metadataUrl = KylinConfig.getInstanceFromEnv().getMetadataUrl(); // split TABLE@HBASE_URL int cut = metadataUrl.indexOf('@'); tableNameBase = cut < 0 ? DEFAULT_TABLE_PREFIX : metadataUrl.substring(0, cut); hbaseUrl = cut < 0 ? metadataUrl : metadataUrl.substring(cut + 1); userTableName = tableNameBase + USER_TABLE_NAME; try {//ww w . j a va 2 s .c o m HBaseConnection.createHTableIfNeeded(hbaseUrl, userTableName, USER_AUTHORITY_FAMILY, QueryService.USER_QUERY_FAMILY); } catch (IOException e) { logger.error(e.getLocalizedMessage(), e); } }