List of usage examples for java.io IOException getLocalizedMessage
public String getLocalizedMessage()
From source file:ca.phon.plugins.praat.TextGridManager.java
/** * List available TextGrids for a given session. * //from w w w .j av a2 s . co m * @param corpus * @param session * * @return list of TextGrid files available */ public List<File> textGridFilesForSession(String corpus, String session) { List<File> retVal = new ArrayList<>(); final Path textGridFolderPath = Paths.get(textGridFolder(corpus, session)); if (Files.exists(textGridFolderPath)) { try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(textGridFolderPath)) { for (Path subFile : directoryStream) { if (subFile.getFileName().toString().endsWith(TEXTGRID_EXT)) { retVal.add(subFile.toFile()); } } } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } } return retVal; }
From source file:org.zenoss.zep.impl.Application.java
private void startQueueListeners() throws ZepException { QueueConfig queueConfig;/* ww w . j a va2 s.c o m*/ try { queueConfig = ZenossQueueConfig.getConfig(); } catch (IOException e) { throw new ZepException(e.getLocalizedMessage(), e); } Collection<AbstractQueueListener> queueListeners = applicationContext .getBeansOfType(AbstractQueueListener.class).values(); for (AbstractQueueListener queueListener : queueListeners) { QueueConfiguration queue = queueConfig.getQueue(queueListener.getQueueIdentifier()); this.queueListeners.add(this.amqpConnectionManager.addListener(queue, queueListener)); } }
From source file:com.kylinolap.rest.service.QueryService.java
public void saveQuery(final String creator, final Query query) { List<Query> queries = getQueries(creator); queries.add(query);//from w ww.j a v a 2 s . co m Query[] queryArray = new Query[queries.size()]; byte[] bytes = querySerializer.serialize(queries.toArray(queryArray)); HTableInterface htable = null; try { htable = HBaseConnection.get(hbaseUrl).getTable(userTableName); Put put = new Put(Bytes.toBytes(creator)); put.add(Bytes.toBytes(USER_QUERY_FAMILY), Bytes.toBytes(USER_QUERY_COLUMN), bytes); htable.put(put); htable.flushCommits(); } catch (IOException e) { logger.error(e.getLocalizedMessage(), e); } finally { IOUtils.closeQuietly(htable); } }
From source file:com.qut.middleware.delegator.openid.authn.impl.AuthnProcessorImpl.java
public result execute(AuthnProcessorData processorData) { Element response;/* www .j ava2 s .c o m*/ RegisterPrincipalResponse responseObj; List<AttributeType> esoeAttributes = new ArrayList<AttributeType>(); /* Determine operation to invoke */ if (processorData.getHttpRequest().getParameter(ConfigurationConstants.OPENID_USER_IDENTIFIER) != null) { try { this.invokeOpenIDAuthnRequest(processorData); return result.NoOp; } catch (IOException e) { this.logger.error(e.getLocalizedMessage()); this.logger.debug(e.toString()); return result.Failure; } catch (OpenIDException e) { this.logger.error(e.getLocalizedMessage()); this.logger.debug(e.toString()); return result.Failure; } catch (ServletException e) { this.logger.error(e.getLocalizedMessage()); this.logger.debug(e.toString()); return result.Failure; } } else { try { this.verifyOpenIDAuthnResponse(processorData, esoeAttributes); } catch (OpenIDException e) { this.logger.error(e.getLocalizedMessage()); this.logger.debug(e.toString()); return result.Failure; } catch (NoSuchAlgorithmException e) { this.logger.error(e.getLocalizedMessage()); this.logger.debug(e.toString()); return result.Failure; } } /* Ensure we set default attributes */ for (OpenIDAttribute attribute : this.defaultSiteAttributes) { AttributeType esoeDefaultAttribute = new AttributeType(); esoeDefaultAttribute.setNameFormat(AttributeFormatConstants.basic); esoeDefaultAttribute.setName(attribute.getEsoeAttributeName()); esoeDefaultAttribute.getAttributeValues().add(attribute.getValuePrepend() + attribute.getValue()); esoeAttributes.add(esoeDefaultAttribute); } Element request = generateRegisterPrincipalRequest(esoeAttributes); if (request == null) { this.logger.warn("Failed attempting to marshall register principal request"); return result.Failure; } this.logger.debug("Sending register principal request of: \n" + request); try { response = wsClient.registerPrincipal(request, this.principalRegistrationEndpoint); } catch (WSClientException e) { this.logger.error("Failed to successfully send WS call to registerPrincipal endpoint of " + this.principalRegistrationEndpoint); this.logger.debug(e.getMessage(), e); return result.Failure; } this.logger.debug("Got a SAML response from RegisterPrincipal WS call of: \n" + response); responseObj = this.validateResponse(response); if (responseObj == null) { this.logger.debug( "Unable to correctly unmarshall response document from ESOE, failing principal authn attempt"); return result.Failure; } /* Set the session identifier to whatever the ESOE says it should be */ this.logger.debug( "Setting session identifier as: " + responseObj.getSessionIdentifier() + " as advised by ESOE"); processorData.setSessionID(responseObj.getSessionIdentifier()); /* Insert attributes into the session for web teir to display to user for acceptance */ processorData.getHttpRequest().getSession() .setAttribute(ConfigurationConstants.RELEASED_ATTRIBUTES_SESSION_IDENTIFIER, esoeAttributes); return result.Completed; }
From source file:com.kylinolap.rest.service.AclService.java
@Override public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> oids, List<Sid> sids) throws NotFoundException { Map<ObjectIdentity, Acl> aclMaps = new HashMap<ObjectIdentity, Acl>(); HTableInterface htable = null;/*from w w w . ja v a 2s . c o m*/ Result result = null; try { htable = HBaseConnection.get(hbaseUrl).getTable(aclTableName); for (ObjectIdentity oid : oids) { result = htable.get(new Get(Bytes.toBytes(String.valueOf(oid.getIdentifier())))); if (null != result && !result.isEmpty()) { SidInfo owner = sidSerializer.deserialize(result.getValue(Bytes.toBytes(ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_OWNER_COLUMN))); Sid ownerSid = (null == owner) ? null : (owner.isPrincipal() ? new PrincipalSid(owner.getSid()) : new GrantedAuthoritySid(owner.getSid())); boolean entriesInheriting = Bytes.toBoolean(result.getValue(Bytes.toBytes(ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_ENTRY_INHERIT_COLUMN))); Acl parentAcl = null; DomainObjectInfo parentInfo = domainObjSerializer.deserialize(result.getValue( Bytes.toBytes(ACL_INFO_FAMILY), Bytes.toBytes(ACL_INFO_FAMILY_PARENT_COLUMN))); if (null != parentInfo) { ObjectIdentity parentObj = new ObjectIdentityImpl(parentInfo.getType(), parentInfo.getId()); parentAcl = readAclById(parentObj, null); } AclImpl acl = new AclImpl(oid, oid.getIdentifier(), aclAuthorizationStrategy, permissionGrantingStrategy, parentAcl, null, entriesInheriting, ownerSid); genAces(sids, result, acl); aclMaps.put(oid, acl); } else { throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'"); } } } catch (IOException e) { logger.error(e.getLocalizedMessage(), e); } finally { IOUtils.closeQuietly(htable); } return aclMaps; }
From source file:com.kylinolap.rest.service.QueryService.java
public List<Query> getQueries(final String creator) { if (null == creator) { return null; }/*from ww w . ja v a 2 s. c om*/ List<Query> queries = new ArrayList<Query>(); HTableInterface htable = null; try { htable = HBaseConnection.get(hbaseUrl).getTable(userTableName); Get get = new Get(Bytes.toBytes(creator)); get.addFamily(Bytes.toBytes(USER_QUERY_FAMILY)); Result result = htable.get(get); Query[] query = querySerializer.deserialize( result.getValue(Bytes.toBytes(USER_QUERY_FAMILY), Bytes.toBytes(USER_QUERY_COLUMN))); if (null != query) { queries.addAll(Arrays.asList(query)); } } catch (IOException e) { logger.error(e.getLocalizedMessage(), e); } finally { IOUtils.closeQuietly(htable); } return queries; }
From source file:com.app.model.m3.M3UpgradModelOLD.java
private void buildThread() { taskActionNumber = new Thread(new Runnable() { @Override//from w w w .ja v a 2 s. c o m public void run() { try { actionNumber.loadData(); } catch (IOException ex) { Ressource.logger.error(ex.getLocalizedMessage(), ex); } } }); taskM3Config = new Thread(new Runnable() { @Override public void run() { try { configm3.loadData(); } catch (IOException ex) { Ressource.logger.error(ex.getLocalizedMessage(), ex); } } }); taskM3User = new Thread(new Runnable() { @Override public void run() { try { m3user.loadData(); } catch (IOException ex) { Ressource.logger.error(ex.getLocalizedMessage(), ex); } } }); }
From source file:grisu.frontend.view.swing.jobmonitoring.single.appSpecific.Gold.java
@Override public void jobStarted() { final File temp = getJob().downloadAndCacheOutputFile("ligands_total"); List<String> l = null; try {/*from w w w . ja va 2 s . c o m*/ l = FileUtils.readLines(temp); } catch (final IOException e) { myLogger.error(e.getLocalizedMessage(), e); return; } final String ligandsTotalUrl = getJob().getJobDirectoryUrl() + "/ligands_total"; try { startTimestamp = fm.getLastModified(ligandsTotalUrl); endTimestamp = startTimestamp + (walltime * 1000); getWalltimeProgressbar().setEnabled(true); getWalltimeProgressbar().setMinimum(0); getWalltimeProgressbar().setMaximum(walltime); } catch (final RemoteFileSystemException e1) { myLogger.debug(e1.getLocalizedMessage(), e1); } if (l.size() != 1) { myLogger.error("Can't get total number of ligands..."); return; } try { noLigands = Integer.parseInt(l.get(0)); } catch (final Exception e) { myLogger.error(e.getLocalizedMessage(), e); return; } getProgressBar().setEnabled(true); getProgressBar().setMaximum(noLigands); getLicensesAllProgressbar().setMinimum(0); getLicensesAllProgressbar().setMaximum(GOLD_LICENSES); getLicensesAllProgressbar().setEnabled(true); getLicensesJobProgressBar().setMinimum(0); getLicensesJobProgressBar().setMaximum(noCpus); getLicensesJobProgressBar().setEnabled(true); getCpusProgressBar().setMinimum(0); getCpusProgressBar().setMaximum(noCpus); getCpusProgressBar().setEnabled(true); updateProgress(); }
From source file:com.app.model.m3.M3UpgradModelOLD.java
public void save(String path) { XMLManage xml = new XMLManage("m3upgrade", "envs"); ArrayList<String> env = new ArrayList<>(); env.add("" + this.listEntity.get(0).getEntity().getModelEntity().getIdLink()); env.add("" + this.listEntity.get(0).getEntity().getModelEntity().getId()); env.add("" + this.listEntity.get(1).getEntity().getModelEntity().getId()); xml.add(new ArrayList(Arrays.asList(new String[] { "customer", "envsrc", "envtarg" })), env); for (int i = 0; i < configm3.getListConfig().size(); i++) { ArrayList<String> a = new ArrayList<>(); a.add(configm3.getListConfig().get(i)); a.add(configm3.getListConfig().get(i).equals(configm3.getConfigSelect()) ? "1" : "0"); a.add(configm3.getListUnderConfig().contains(configm3.getListConfig().get(i)) ? "1" : "0"); a.add(configm3.getListUnderConfigSelect().contains(configm3.getListConfig().get(i)) ? "1" : "0"); xml.add("Config", new ArrayList(Arrays.asList(new String[] { "configId", "selected", "under", "underselected" })), a);/*from w ww .j a v a 2 s.com*/ } ArrayList<String> a = new ArrayList<>(); a.add(actionNumber.getActionNumberSelect()); xml.add("ActionNumber", new ArrayList(Arrays.asList(new String[] { "actionumberId" })), a); for (int j = 0; j < m3user.getListUser().size(); j++) { a = new ArrayList<>(); a.add(m3user.getListUser().get(j)); a.add(m3user.getListUserSelect().contains(m3user.getListUser().get(j)) ? "1" : "0"); xml.add("User", new ArrayList(Arrays.asList(new String[] { "userId", "userselected" })), a); } String[] headerLng = new String[header.length]; for (int k = 0; k < header.length; k++) { headerLng[k] = i18n.Language.getLabel(header[k], "EN"); } if (data != null) { for (Object[] data1 : data) { xml.add("Data", "Id", new ArrayList(Arrays.asList(headerLng)), new ArrayList(Arrays.asList(data1))); } } try { xml.save(path); } catch (IOException ex) { Ressource.logger.error(ex.getLocalizedMessage(), ex); } }
From source file:com.whizzosoftware.hobson.rest.v1.resource.device.MediaProxyResource.java
@Override public Representation get() { try {//from w w w.java 2 s .c o m 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) { final HttpProps httpProps = createHttpGet(hvar.getValue().toString()); try { final CloseableHttpResponse response = httpProps.client.execute(httpProps.httpGet); // make sure we got a valid 2xx response int statusCode = response.getStatusLine().getStatusCode(); if (statusCode >= 200 && statusCode < 300) { String contentType = null; HttpEntity entity = response.getEntity(); Header header = entity.getContentType(); if (header != null) { contentType = header.getValue(); } // The Content-Type response header is required or we won't know the type of content being proxied if (contentType != null) { final InputStream inputStream = entity.getContent(); return new StreamRepresentation(new MediaType(contentType)) { @Override public InputStream getStream() throws IOException { return inputStream; } @Override public void write(OutputStream output) throws IOException { try { // stream the camera image to the response stream byte[] buf = new byte[PROXY_BUF_SIZE]; int read; while ((read = inputStream.read(buf)) > -1) { output.write(buf, 0, read); } output.close(); } catch (IOException ioe) { logger.debug("IOException occurred while streaming media", ioe); } finally { response.close(); httpProps.client.close(); } } }; } else { response.close(); httpProps.client.close(); throw new HobsonRuntimeException("Unable to determine proxy content type"); } // explicitly handle the 401 code } else if (statusCode == HttpStatus.SC_UNAUTHORIZED) { getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN); response.close(); httpProps.client.close(); return new EmptyRepresentation(); // otherwise, its a general failure } else { response.close(); httpProps.client.close(); throw new HobsonRuntimeException( "Received " + statusCode + " response while retrieving image from camera"); } } catch (IOException e) { try { httpProps.client.close(); } catch (IOException ioe) { logger.warn("Error closing HttpClient", ioe); } throw new HobsonRuntimeException(e.getLocalizedMessage(), e); } } else { getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new EmptyRepresentation(); } } catch (ParseException | URISyntaxException e) { logger.error("Error obtaining media stream from device", e); throw new HobsonRuntimeException(e.getLocalizedMessage(), e); } }