List of usage examples for java.net URI toASCIIString
public String toASCIIString()
From source file:org.gatherdata.archiver.dao.vfs.internal.VfsArchiverDao.java
public boolean exists(URI uid) { boolean fileExists = false; try {// w w w . j av a2s . c o m FileObject envelopeFile = fsManager.resolveFile(fsBase, uid.toASCIIString()); fileExists = envelopeFile.exists(); } catch (FileSystemException e) { e.printStackTrace(); } return fileExists; }
From source file:org.osiam.resources.controller.GroupController.java
private void setLocationUriWithNewId(HttpServletRequest request, HttpServletResponse response, String id) { String requestUrl = request.getRequestURL().toString(); URI uri = new UriTemplate("{requestUrl}{internalId}").expand(requestUrl + "/", id); response.setHeader("Location", uri.toASCIIString()); }
From source file:br.com.ingenieux.jenkins.plugins.awsebdeployment.AWSClientFactory.java
public <T extends AmazonWebServiceClient> String getEndpointFor(T client) { try {// w ww . ja va 2 s . c o m URI endpointUri = (URI) FieldUtils.readField(client, "endpoint", true); return endpointUri.toASCIIString(); } catch (Exception e) { return null; } }
From source file:org.deegree.portal.owswatch.validator.CSWGetRecordsValidator.java
@Override protected ValidatorResponse validateXmlServiceException(HttpMethodBase method) { Document doc = null;/*from w ww. j av a 2s.c o m*/ String lastMessage = null; Status status = null; try { InputStream stream = method.getResponseBodyAsStream(); stream.reset(); doc = instantiateParser().parse(stream); } catch (Exception e) { status = Status.RESULT_STATE_INVALID_XML; lastMessage = "Error: MalFormed XML Response"; return new ValidatorResponse(lastMessage, status); } try { NamespaceContext cnxt = CommonNamespaces.getNamespaceContext(); URI owsns = CommonNamespaces.OWSNS; String prefix = doc.lookupPrefix(owsns.toASCIIString()); StringBuilder builder = new StringBuilder(100); builder.append("./"); if (prefix != null && prefix.length() > 0) { builder.append(prefix).append(":"); cnxt.addNamespace(prefix, owsns); } builder.append("Exception"); status = Status.RESULT_STATE_SERVICE_UNAVAILABLE; lastMessage = XMLTools.getNodeAsString(doc.getDocumentElement(), builder.toString(), cnxt, "Service Unavailable. Unknown error"); return new ValidatorResponse(lastMessage, status); } catch (XMLParsingException e) { lastMessage = "Service Unavailable"; status = Status.RESULT_STATE_SERVICE_UNAVAILABLE; return new ValidatorResponse(lastMessage, status); } }
From source file:fr.acxio.tools.agia.ftp.FTPDownloadTasklet.java
@Override public RepeatStatus execute(StepContribution sContribution, ChunkContext sChunkContext) throws Exception { FTPClient aClient = ftpClientFactory.getFtpClient(); RegexFilenameFilter aFilter = new RegexFilenameFilter(); aFilter.setRegex(regexFilename);/*w w w. j a va 2s .c om*/ try { URI aRemoteBaseURI = new URI(remoteBaseDir); URI aRemoteBasePath = new URI(aRemoteBaseURI.toASCIIString() + SEPARATOR); if (LOGGER.isInfoEnabled()) { LOGGER.info("Listing : [{}] {} ({})", aClient.getRemoteAddress().toString(), aRemoteBaseURI.toASCIIString(), regexFilename); } FTPFile[] aRemoteFiles = aClient.listFiles(aRemoteBaseURI.toASCIIString(), aFilter); if (LOGGER.isInfoEnabled()) { LOGGER.info(" {} file(s) found", aRemoteFiles.length); } for (FTPFile aRemoteFile : aRemoteFiles) { if (sContribution != null) { sContribution.incrementReadCount(); } File aLocalFile = new File(localBaseDir, aRemoteFile.getName()); URI aRemoteTFile = aRemoteBasePath.resolve(aRemoteFile.getName()); FileOutputStream aOutputStream = new FileOutputStream(aLocalFile); try { if (LOGGER.isInfoEnabled()) { LOGGER.info(" Downloading : {} => {}", aRemoteTFile.toASCIIString(), aLocalFile.getAbsolutePath()); } aClient.retrieveFile(aRemoteTFile.toASCIIString(), aOutputStream); if (removeRemote) { if (LOGGER.isInfoEnabled()) { LOGGER.info(" Deleting : {}", aRemoteTFile.toASCIIString()); } aClient.deleteFile(aRemoteTFile.toASCIIString()); } if (sContribution != null) { sContribution.incrementWriteCount(1); } } finally { aOutputStream.close(); } } } finally { aClient.logout(); aClient.disconnect(); } return RepeatStatus.FINISHED; }
From source file:org.gatherdata.archiver.dao.vfs.internal.VfsArchiverDao.java
public GatherArchive retrieveEnvelope(URI uid) { GatherArchive foundEnvelope = null;//w w w .j ava 2s .co m try { FileObject envelopeFile = fsManager.resolveFile(fsBase, uid.toASCIIString()); if (envelopeFile.exists()) { foundEnvelope = (GatherArchive) SerializationUtils .deserialize(envelopeFile.getContent().getInputStream()); } } catch (FileSystemException e) { e.printStackTrace(); } return foundEnvelope; }
From source file:org.gatherdata.data.dao.jpa.model.JpaFlatForm.java
public void setNamespace(URI namespace) { this.lazyNamespace = namespace; this.namespaceAsString = (namespace != null) ? namespace.toASCIIString() : null; }
From source file:org.openlegacy.terminal.mvc.web.LoginController.java
@RequestMapping(value = { "Login", "login" }, method = RequestMethod.POST) public String login(Model uiModel, HttpServletRequest request, @RequestParam(value = "partial", required = false) String partial, @RequestParam(value = "target", required = false) String target) throws URISyntaxException { ScreenEntityDefinition loginEntityDefinition = loginMetadata.getLoginScreenDefinition(); terminalSession.getModule(Login.class).logoff(); Object loginEntity = ReflectionUtil.newInstance(loginEntityDefinition.getEntityClass()); ServletRequestDataBinder binder = new ServletRequestDataBinder(loginEntity); binder.bind(request);/*from w w w . j a v a 2 s . co m*/ try { terminalSession.getModule(Login.class).login(loginEntity); } catch (LoginException e) { logger.error(e.getMessage()); terminalSession.getModule(Login.class).logoff(); ScreenPojoFieldAccessor fieldAccessor = new SimpleScreenPojoFieldAccessor(loginEntity); fieldAccessor.setFieldValue(Login.ERROR_FIELD_NAME, e.getMessage()); uiModel.addAttribute(MvcConstants.LOGIN_MODEL, loginEntity); return MvcConstants.LOGIN_VIEW; } System.out.println(request.getParameterNames()); if (StringUtils.isNotEmpty(target)) { URI uri = new URI(target.replaceAll(" ", "%20")); return MvcConstants.REDIRECT + uri.toASCIIString(); } ScreenEntity screenEntity = terminalSession.getEntity(); if (screenEntity != null) { String resultEntityName = ProxyUtil.getOriginalClass(screenEntity.getClass()).getSimpleName(); if (partial != null) { return MvcConstants.ROOTMENU_VIEW; } else { if (afterLoginURL != null) { return MvcConstants.REDIRECT + afterLoginURL; } return MvcConstants.REDIRECT + resultEntityName; } } return MvcConstants.REDIRECT + openlegacyWebProperties.getFallbackUrl(); }
From source file:org.lockss.util.UrlUtil.java
/** Resolve possiblyRelativeUrl relative to baseUrl. * @param baseUrl The base URL relative to which to resolve * @param possiblyRelativeUrl resolved relative to baseUrl * @return The URL formed by combining the two URLs *//* ww w.ja v a2s . co m*/ public static String resolveUri0(String baseUrl, String possiblyRelativeUrl) throws MalformedURLException { baseUrl = trimNewlinesAndLeadingWhitespace(baseUrl); possiblyRelativeUrl = trimNewlinesAndLeadingWhitespace(possiblyRelativeUrl); String encodedBase = minimallyEncodeUrl(baseUrl); String encodedChild = minimallyEncodeUrl(possiblyRelativeUrl); try { java.net.URI base = new java.net.URI(encodedBase); java.net.URI child = new java.net.URI(encodedChild); java.net.URI res = resolveUri0(base, child); return res.toASCIIString(); } catch (URISyntaxException e) { throw newMalformedURLException(e); } }
From source file:com.galeoconsulting.leonardinius.servlet.ScriptRunnerSessionServlet.java
private boolean loginIfNot(HttpServletRequest request, HttpServletResponse response) throws ServletException { if (userManager.getRemoteUsername(request) == null) { try {/*ww w . jav a 2s.c o m*/ URI currentUri = new URI(request.getRequestURI()); URI loginUri = loginUriProvider.getLoginUri(currentUri); response.sendRedirect(loginUri.toASCIIString()); } catch (URISyntaxException e) { throw new ServletException(e); } catch (IOException e) { throw new ServletException(e); } return true; } return false; }