List of usage examples for java.net URI toASCIIString
public String toASCIIString()
From source file:org.apache.ode.bpel.compiler.BpelCompiler.java
public void addWsdlImport(URI from, URI wsdlImport, SourceLocation sloc) { Definition4BPEL def;// w w w . j a v a2 s .c o m try { WSDLReader r = _wsdlFactory.newWSDLReader(); WSDLLocatorImpl locator = new WSDLLocatorImpl(_resourceFinder, _resourceFinder.resolve(from, wsdlImport)); def = (Definition4BPEL) r.readWSDL(locator); } catch (WSDLException e) { recoveredFromError(sloc, new CompilationException( __cmsgs.errWsdlParseError(e.getFaultCode(), e.getLocation(), e.getMessage()))); throw new CompilationException( __cmsgs.errWsdlImportFailed(wsdlImport.toASCIIString(), e.getFaultCode()).setSource(sloc), e); } try { _wsdlRegistry.addDefinition(def, _resourceFinder, _resourceFinder.resolve(from, wsdlImport)); if (__log.isDebugEnabled()) __log.debug("Added WSDL Definition: " + wsdlImport); } catch (CompilationException ce) { recoveredFromError(sloc, ce); } }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.source.CswSource.java
@Override public ResourceResponse retrieveResource(URI resourceUri, Map<String, Serializable> properties) throws IOException, ResourceNotFoundException, ResourceNotSupportedException { LOGGER.debug("retrieving resource at : {}", resourceUri); ResourceResponse resource = null;// ww w . ja v a2 s.com if (resourceUri == null) { throw new ResourceNotFoundException("Unable to find resource due to null URI"); } String scheme = resourceUri.getScheme(); LOGGER.debug("Searching for ResourceReader that supports scheme = " + scheme); LOGGER.debug("resourceReaders.size() = {}", resourceReaders.size()); Iterator<ResourceReader> iterator = resourceReaders.iterator(); while (iterator.hasNext() && resource == null) { ResourceReader reader = iterator.next(); if (reader.getSupportedSchemes() != null && reader.getSupportedSchemes().contains(scheme)) { try { LOGGER.debug("Found an acceptable resource reader ({}) for URI {}", reader.getId(), resourceUri.toASCIIString()); resource = reader.retrieveResource(resourceUri, properties); if (resource == null) { LOGGER.info( "Resource returned from ResourceReader {} was null. Checking other readers for URI: {}", reader.getId(), resourceUri); } } catch (ResourceNotFoundException e) { LOGGER.debug("Enterprise Search: Product not found using resource reader with name {}", reader.getId(), e); } catch (ResourceNotSupportedException e) { LOGGER.debug("Enterprise Search: Product not found using resource reader with name {}", reader.getId(), e); } catch (IOException ioe) { LOGGER.debug("Enterprise Search: Product not found using resource reader with name {}", reader.getId(), ioe); } } } if (resource == null) { throw new ResourceNotFoundException( "Resource Readers could not find resource (or returned null resource) for URI: " + resourceUri); } LOGGER.debug("Received resource, sending back: {}", resource.getResource().getName()); return resource; }
From source file:org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl.java
/** * Get service URLs associated with all username/password pairs currently in * the Keystore.// w w w .j av a 2 s . co m * * @deprecated * @see #getServiceURIsForAllUsernameAndPasswordPairs() */ @Deprecated public ArrayList<String> getServiceURLsforAllUsernameAndPasswordPairs() throws CMException { // Need to make sure we are initialized before we do anything else // as Credential Manager can be created but not initialized initialize(); List<URI> uris = getServiceURIsForAllUsernameAndPasswordPairs(); ArrayList<String> serviceURLs = new ArrayList<>(); for (URI uri : uris) serviceURLs.add(uri.toASCIIString()); return serviceURLs; }
From source file:net.sf.taverna.t2.security.credentialmanager.impl.CredentialManagerImpl.java
/** * Get service URLs associated with all username/password pairs currently in * the Keystore./*from w w w . ja va 2 s.c om*/ * * @deprecated * @see #getServiceURIsForAllUsernameAndPasswordPairs() */ @Deprecated public ArrayList<String> getServiceURLsforAllUsernameAndPasswordPairs() throws CMException { /* * Need to make sure we are initialized before we do anything else, as * the Credential Manager can be created but not initialized. */ initialize(); List<URI> uris = getServiceURIsForAllUsernameAndPasswordPairs(); ArrayList<String> serviceURLs = new ArrayList<>(); for (URI uri : uris) serviceURLs.add(uri.toASCIIString()); return serviceURLs; }
From source file:org.apache.olingo.fit.v4.EntityCreateTestITCase.java
private void onContained(final ODataFormat format) { final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts") .appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build(); // 1. read contained collection before any operation ODataEntitySet instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute() .getBody();//from w w w . j a v a2 s . c o m assertNotNull(instruments); final int sizeBefore = instruments.getCount(); // 2. instantiate an ODataEntity of the same type as the collection above final ODataEntity instrument = getClient().getObjectFactory().newEntity( new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument")); int id = RandomUtils.nextInt(101999, 105000); instrument.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("PaymentInstrumentID", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id))); instrument.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("FriendlyName", getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("New one"))); instrument.getProperties() .add(getClient().getObjectFactory().newPrimitiveProperty("CreatedDate", getClient().getObjectFactory().newPrimitiveValueBuilder() .setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()) .build())); // 3. create it as contained entity final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory() .getEntityCreateRequest(uri, instrument); req.setFormat(format); final ODataEntityCreateResponse<ODataEntity> res = req.execute(); assertEquals(201, res.getStatusCode()); // 4. verify that the contained collection effectively grew instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody(); assertNotNull(instruments); final int sizeAfter = instruments.getCount(); assertEquals(sizeBefore + 1, sizeAfter); // 5. remove the contained entity created above final ODataDeleteResponse deleteRes = getClient().getCUDRequestFactory() .getDeleteRequest(getClient().newURIBuilder(uri.toASCIIString()).appendKeySegment(id).build()) .execute(); assertEquals(204, deleteRes.getStatusCode()); // 6. verify that the contained collection effectively reduced instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody(); assertNotNull(instruments); final int sizeEnd = instruments.getCount(); assertEquals(sizeBefore, sizeEnd); }
From source file:org.apache.olingo.fit.base.EntityCreateTestITCase.java
private void onContained(final ContentType contentType) { final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts") .appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build(); // 1. read contained collection before any operation ClientEntitySet instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute() .getBody();/*from ww w . j a v a2 s . c o m*/ assertNotNull(instruments); final int sizeBefore = instruments.getCount(); // 2. instantiate an ODataEntity of the same type as the collection above final ClientEntity instrument = getClient().getObjectFactory().newEntity( new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument")); int id = RandomUtils.nextInt(101999, 105000); instrument.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("PaymentInstrumentID", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(id))); instrument.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("FriendlyName", getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("New one"))); instrument.getProperties() .add(getClient().getObjectFactory().newPrimitiveProperty("CreatedDate", getClient().getObjectFactory().newPrimitiveValueBuilder() .setType(EdmPrimitiveTypeKind.DateTimeOffset).setValue(Calendar.getInstance()) .build())); // 3. create it as contained entity final ODataEntityCreateRequest<ClientEntity> req = getClient().getCUDRequestFactory() .getEntityCreateRequest(uri, instrument); req.setFormat(contentType); final ODataEntityCreateResponse<ClientEntity> res = req.execute(); assertEquals(201, res.getStatusCode()); // 4. verify that the contained collection effectively grew instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody(); assertNotNull(instruments); final int sizeAfter = instruments.getCount(); assertEquals(sizeBefore + 1, sizeAfter); // 5. remove the contained entity created above final ODataDeleteResponse deleteRes = getClient().getCUDRequestFactory() .getDeleteRequest(getClient().newURIBuilder(uri.toASCIIString()).appendKeySegment(id).build()) .execute(); assertEquals(204, deleteRes.getStatusCode()); // 6. verify that the contained collection effectively reduced instruments = getClient().getRetrieveRequestFactory().getEntitySetRequest(uri).execute().getBody(); assertNotNull(instruments); final int sizeEnd = instruments.getCount(); assertEquals(sizeBefore, sizeEnd); }
From source file:eu.abc4trust.smartcard.HardwareSmartcard.java
private byte[] uriToByteArr(URI uri) { String s = uri.toASCIIString(); byte[] res = new byte[s.length()]; for (int i = 0; i < s.length(); i++) { res[i] = (byte) s.charAt(i); }/*from www .j av a 2s.c o m*/ return res; }
From source file:org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl.java
/** * Delete a username and password pair for the given service URI from the * Keystore.//from ww w. java 2 s . c om */ @Override public void deleteUsernameAndPasswordForService(URI serviceURI) throws CMException { // Need to make sure we are initialized before we do anything else // as Credential Manager can be created but not initialized initialize(); String uriString = serviceURI.toASCIIString(); deleteUsernameAndPasswordForService(uriString); }
From source file:org.apache.taverna.security.credentialmanager.impl.CredentialManagerImpl.java
/** * Insert a username and password pair for the given service URI in the * Keystore.//from w w w .ja va2 s. c om * <p> * Effectively, this method inserts a new secret key entry in the Keystore, * where key contains <USERNAME>"\000"<PASSWORD> string, i.e. password is * prepended with the username and separated by a \000 character (which * hopefully will not appear in the username). * <p> * Username and password string is saved in the Keystore as byte array using * SecretKeySpec (which constructs a secret key from the given byte array * but does not check if the given bytes indeed specify a secret key of the * specified algorithm). * <p> * An alias used to identify the username and password entry is constructed * as "password#"<SERVICE_URL> using the service URL this username/password * pair is to be used for. * * @param usernamePassword * The {@link UsernamePassword} to store * @param serviceURI * The (possibly normalized) URI to store the credentials under * @throws CMException * If the credentials could not be stored * @return the alias under which this username and password entry was saved * in the Keystore */ @Override public String addUsernameAndPasswordForService(UsernamePassword usernamePassword, URI serviceURI) throws CMException { // Need to make sure we are initialized before we do anything else // as Credential Manager can be created but not initialized initialize(); String uriString = serviceURI.toASCIIString(); String alias = saveUsernameAndPasswordForService(usernamePassword.getUsername(), String.valueOf(usernamePassword.getPassword()), uriString); return alias; }
From source file:org.wrml.runtime.schema.generator.SchemaGenerator.java
/** * Generates the method associated with a Link slot value ({@link LinkValue}). * * @param javaBytecodeClass The {@link JavaBytecodeClass} representing the Schema interface being generated. * @param isAggregate <code>true</code> if the {@link Schema} that owns the link {@link Slot} is an {@link org.wrml.model.rest.AggregateDocument}. * @param slot The slot holding the LinkValue to use as a template for a set of generated Java methods. *//* ww w .jav a 2s. c o m*/ private void generateLinkMethod(final JavaBytecodeClass javaBytecodeClass, final boolean isAggregate, final Slot slot) { JavaBytecodeAnnotation aliasAnnotation = null; final List<String> aliases = slot.getAliases(); if (aliases != null && aliases.size() > 0) { aliasAnnotation = new JavaBytecodeAnnotation(SchemaGenerator.ANNOTATION_INTERNAL_NAME_ALIASES); final String[] aliasesArray = new String[aliases.size()]; aliasAnnotation.setAttributeValue(AnnotationParameterName.value.name(), aliases.toArray(aliasesArray)); } final JavaBytecodeAnnotation linkSlotAnnotation = new JavaBytecodeAnnotation( SchemaGenerator.ANNOTATION_INTERNAL_NAME_LINK_SLOT); final LinkValue linkValue = (LinkValue) slot.getValue(); final URI linkRelationUri = linkValue.getLinkRelationUri(); if (linkRelationUri == null) { throw new SchemaGeneratorException("The link must specify a URI value in its \"linkRelationUri\" slot.", null, this); } final String linkRelationUriString = linkRelationUri.toASCIIString(); if (linkRelationUriString == null || linkRelationUriString.isEmpty()) { throw new SchemaGeneratorException("The link must specify a URI value in its \"linkRelationUri\" slot.", null, this); } linkSlotAnnotation.setAttributeValue(AnnotationParameterName.linkRelationUri.name(), linkRelationUriString); final ApiLoader apiLoader = getContext().getApiLoader(); final LinkRelation linkRelation = apiLoader.loadLinkRelation(linkRelationUri); if (linkRelation == null) { throw new SchemaGeneratorException("Could not get the LinkRelation with URI: " + linkRelationUri, null, this); } final String slotName = slot.getName(); final String linkSlotName = StringUtils.deleteWhitespace(slotName); String linkMethodName = linkSlotName; final Method method = linkRelation.getMethod(); linkSlotAnnotation.setAttributeValue(AnnotationParameterName.method.name(), method); final URI linkValueResponseSchemaUri = linkValue.getResponseSchemaUri(); final URI linkRelationResponseSchemaUri = linkRelation.getResponseSchemaUri(); final URI methodReturnSchemaUri = (linkValueResponseSchemaUri != null) ? linkValueResponseSchemaUri : linkRelationResponseSchemaUri; final JavaBytecodeType methodReturnType = javaBytecodeTypeForSchemaUri(methodReturnSchemaUri); final URI linkValueRequestSchemaUri = linkValue.getRequestSchemaUri(); final URI linkRelationRequestSchemaUri = linkRelation.getRequestSchemaUri(); final URI methodParameterSchemaUri = (linkValueRequestSchemaUri != null) ? linkValueRequestSchemaUri : linkRelationRequestSchemaUri; final JavaBytecodeMethod linkMethod; if (methodParameterSchemaUri != null) { // Link method accepts a parameter final JavaBytecodeType methodParameterType = javaBytecodeTypeForSchemaUri(methodParameterSchemaUri); linkMethod = generateMethod(linkMethodName, methodReturnType, methodParameterType, aliasAnnotation, linkSlotAnnotation); } else { // A zero argument link method if (method == Method.Get) { // Links with GET semantics are named with a pattern: get{LinkSlotName}() linkMethodName = JavaBean.GET + StringUtils.capitalize(linkMethodName); } linkMethod = generateMethod(linkMethodName, methodReturnType, aliasAnnotation, linkSlotAnnotation); } boolean embedded = (linkValue.isEmbedded() || isAggregate) && (method == Method.Get); linkSlotAnnotation.setAttributeValue(AnnotationParameterName.embedded.name(), embedded); List<LinkValueBinding> linkValueBindings = linkValue.getBindings(); if (!linkValueBindings.isEmpty()) { final JavaBytecodeAnnotation[] bindingsArray = new JavaBytecodeAnnotation[linkValueBindings.size()]; for (int i = 0; i < bindingsArray.length; i++) { final LinkValueBinding linkValueBinding = linkValueBindings.get(i); final String referenceSlot = linkValueBinding.getReferenceSlot(); final String linkValueSource = linkValueBinding.getValueSource(); final ValueSourceType linkValueSourceType = linkValueBinding.getValueSourceType(); final JavaBytecodeAnnotation linkSlotBindingAnnotation = new JavaBytecodeAnnotation( SchemaGenerator.ANNOTATION_INTERNAL_NAME_LINK_SLOT_BINDING); linkSlotBindingAnnotation.setAttributeValue(AnnotationParameterName.referenceSlot.name(), referenceSlot); linkSlotBindingAnnotation.setAttributeValue(AnnotationParameterName.valueSource.name(), linkValueSource); linkSlotBindingAnnotation.setAttributeValue(AnnotationParameterName.valueSourceType.name(), linkValueSourceType); bindingsArray[i] = linkSlotBindingAnnotation; } linkSlotAnnotation.setAttributeValue(AnnotationParameterName.bindings.name(), bindingsArray); } javaBytecodeClass.getMethods().add(linkMethod); }