本文整理汇总了Java中org.wso2.carbon.registry.core.Resource.setProperties方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.setProperties方法的具体用法?Java Resource.setProperties怎么用?Java Resource.setProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.core.Resource
的用法示例。
在下文中一共展示了Resource.setProperties方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetServiceProviders
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Test
public void testGetServiceProviders() throws Exception {
when(mockRegistry.resourceExists(IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS)).thenReturn(true);
Resource collection = new CollectionImpl();
String[] paths = new String[]{
getPath("DummyIssuer"), getPath("DummyAdvIssuer")
};
Properties dummyResourceProperties = new Properties();
dummyResourceProperties.putAll(dummyBasicProperties);
Resource dummyResource = new ResourceImpl();
dummyResource.setProperties(dummyResourceProperties);
Properties dummyAdvProperties = new Properties();
dummyAdvProperties.putAll((Map<?, ?>) dummyAdvProperties);
Resource dummyAdvResource = new ResourceImpl();
dummyAdvResource.setProperties(dummyAdvProperties);
Resource[] spResources = new Resource[]{dummyResource, dummyAdvResource};
collection.setContent(paths);
when(mockRegistry.get(IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS)).thenReturn(collection);
when(mockRegistry.get(paths[0])).thenReturn(spResources[0]);
when(mockRegistry.get(paths[1])).thenReturn(spResources[1]);
SAMLSSOServiceProviderDO[] serviceProviders = objUnderTest.getServiceProviders();
assertEquals(serviceProviders.length, 2, "Should have returned 2 service providers.");
}
示例2: testGetServiceProvider
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Test
public void testGetServiceProvider() throws Exception {
mockStatic(IdentityTenantUtil.class);
RealmService mockRealmService = mock(RealmService.class);
TenantManager mockTenantManager = mock(TenantManager.class);
when(IdentityTenantUtil.getRealmService()).thenReturn(mockRealmService);
when(mockRealmService.getTenantManager()).thenReturn(mockTenantManager);
when(mockTenantManager.getDomain(anyInt())).thenReturn("test.com");
Properties dummyResourceProperties = new Properties();
dummyResourceProperties.putAll(dummyBasicProperties);
Resource dummyResource = new ResourceImpl();
dummyResource.setProperties(dummyResourceProperties);
String path = getPath(dummyResource.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
when(mockRegistry.resourceExists(path)).thenReturn(true);
when(mockRegistry.get(path)).thenReturn(dummyResource);
SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.getServiceProvider(dummyResource.getProperty
(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
assertEquals(serviceProviderDO.getTenantDomain(), "test.com", "Retrieved resource's tenant domain mismatch");
}
示例3: testAddServiceProvider
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Test(dataProvider = "ResourceToObjectData")
public void testAddServiceProvider(Object paramMapObj) throws Exception {
Properties properties = new Properties();
properties.putAll((Map<?, ?>) paramMapObj);
Resource dummyResource = new ResourceImpl();
dummyResource.setProperties(properties);
SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.resourceToObject(dummyResource);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
String expectedPath = getPath(dummyResource
.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
objUnderTest.addServiceProvider(serviceProviderDO);
verify(mockRegistry).put(captor.capture(), any(Resource.class));
assertEquals(captor.getValue(), expectedPath, "Resource is not added at correct path");
}
示例4: testUploadServiceProvider
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Test
public void testUploadServiceProvider() throws Exception {
setUpResources();
Properties properties = new Properties();
properties.putAll(dummyBasicProperties);
Resource dummyResource = new ResourceImpl();
dummyResource.setProperties(properties);
String expectedPath = getPath(dummyResource
.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
when(mockRegistry.resourceExists(expectedPath)).thenReturn(false);
SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.resourceToObject(dummyResource);
assertEquals(objUnderTest.uploadServiceProvider(serviceProviderDO), serviceProviderDO, "Same resource should" +
" have returned after successful upload.");
}
示例5: testUploadExistingServiceProvider
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Test(expectedExceptions = IdentityException.class)
public void testUploadExistingServiceProvider() throws Exception {
setUpResources();
Properties properties = new Properties();
properties.putAll(dummyAdvProperties);
Resource dummyResource = new ResourceImpl();
dummyResource.setProperties(properties);
String expectedPath = getPath(dummyResource
.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
when(mockRegistry.resourceExists(expectedPath)).thenReturn(true);
SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.resourceToObject(dummyResource);
objUnderTest.uploadServiceProvider(serviceProviderDO);
fail("Uploading an existing SP should have failed");
}
示例6: addEndpointToRegistry
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* Adds the service endpoint element to the registry.
*
* @param requestContext current request information.
* @param endpointElement endpoint metadata element.
* @param endpointPath endpoint location.
* @return The resource path of the endpoint.
* @throws RegistryException If fails to add the endpoint to the registry.
*/
public static String addEndpointToRegistry(RequestContext requestContext, OMElement endpointElement, String endpointPath)
throws RegistryException {
if(requestContext == null || endpointElement == null || endpointPath == null) {
throw new IllegalArgumentException("Some or all of the arguments may be null. Cannot add the endpoint to registry. ");
}
endpointPath = getEndpointPath(requestContext, endpointElement, endpointPath);
Registry registry = requestContext.getRegistry();
//Creating new resource.
Resource endpointResource = new ResourceImpl();
//setting endpoint media type.
endpointResource.setMediaType(CommonConstants.ENDPOINT_MEDIA_TYPE);
//set content.
endpointResource.setContent(RegistryUtils.encodeString(endpointElement.toString()));
//copy other property
endpointResource.setProperties(copyProperties(requestContext));
//set path
//endpointPath = getChrootedEndpointLocation(requestContext.getRegistryContext()) + endpointPath;
String resourceId = endpointResource.getUUID();
//set resource UUID
resourceId = (resourceId == null) ? UUID.randomUUID().toString() : resourceId;
endpointResource.setUUID(resourceId);
//saving the api resource to repository.
registry.put(endpointPath, endpointResource);
if (log.isDebugEnabled()){
log.debug("Endpoint created at " + endpointPath);
}
return endpointPath;
}
示例7: updateTextContent
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static void updateTextContent(String path, String contentText, Registry registry)
throws Exception {
try {
Resource resource = registry.get(path);
String mediaType = resource.getMediaType();
if (resource.getProperty(RegistryConstants.REGISTRY_LINK) != null &&
(CommonConstants.WSDL_MEDIA_TYPE.equals(mediaType) ||
CommonConstants.SCHEMA_MEDIA_TYPE.equals(mediaType))) {
String description = resource.getDescription();
Properties properties = (Properties) resource.getProperties().clone();
resource = registry.newResource();
resource.setMediaType(mediaType);
resource.setDescription(description);
resource.setProperties(properties);
}
resource.setContent(RegistryUtils.encodeString(contentText));
registry.put(path, resource);
resource.discard();
} catch (RegistryException e) {
String msg = "Could not update the content of the resource " +
path + ". Caused by: " + ((e.getCause() instanceof SQLException) ?
"" : e.getMessage());
log.error(msg, e);
throw new RegistryException(msg, e);
}
}
示例8: setContent
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* Sets content of the given endpoint artifact to the given resource on the
* registry.
*
* @param endpoint the endpoint artifact.
* @param endpointResource the content resource.
*
* @throws GovernanceException if the operation failed.
*/
public void setContent(Endpoint endpoint, Resource endpointResource) throws GovernanceException {
// set the endpoint url
String url = ((EndpointImpl)endpoint).getUrl();
try {
String content = EndpointUtils.getEndpointContentWithOverview(url, EndpointUtils.deriveEndpointFromUrl(url),
EndpointUtils.deriveEndpointNameFromUrl(url), CommonConstants.ENDPOINT_VERSION_DEFAULT_VALUE);
endpointResource.setContent(content);
} catch (RegistryException e) {
String msg =
"Error in setting the resource content for endpoint. path: " +
endpoint.getPath() + ", " + "id: " + endpoint.getId() + ".";
log.error(msg);
throw new GovernanceException(msg, e);
}
// and set all the attributes as properties.
String[] attributeKeys = endpoint.getAttributeKeys();
if (attributeKeys != null) {
Properties properties = new Properties();
for (String attributeKey : attributeKeys) {
String[] attributeValues = endpoint.getAttributes(attributeKey);
if (attributeValues != null) {
// The list obtained from the Arrays#asList method is
// immutable. Therefore,
// we create a mutable object out of it before adding it as
// a property.
properties.put(attributeKey,
new ArrayList<String>(Arrays.asList(attributeValues)));
}
}
endpointResource.setProperties(properties);
}
endpointResource.setUUID(endpoint.getId());
}
示例9: setContent
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* Sets content of the given policy artifact to the given resource on the
* registry.
*
* @param policy the policy artifact.
* @param policyResource the content resource.
*
* @throws GovernanceException if the operation failed.
*/
protected void setContent(Policy policy, Resource policyResource) throws GovernanceException {
if (policy.getPolicyContent() != null) {
String policyContent = policy.getPolicyContent();
try {
policyResource.setContent(policyContent);
} catch (RegistryException e) {
String msg =
"Error in setting the content from policy, policy id: " + policy.getId() +
", policy path: " + policy.getPath() + ".";
log.error(msg, e);
throw new GovernanceException(msg, e);
}
}
// and set all the attributes as properties.
String[] attributeKeys = policy.getAttributeKeys();
if (attributeKeys != null) {
Properties properties = new Properties();
for (String attributeKey : attributeKeys) {
String[] attributeValues = policy.getAttributes(attributeKey);
if (attributeValues != null) {
// The list obtained from the Arrays#asList method is
// immutable. Therefore,
// we create a mutable object out of it before adding it as
// a property.
properties.put(attributeKey,
new ArrayList<String>(Arrays.asList(attributeValues)));
}
}
policyResource.setProperties(properties);
}
policyResource.setUUID(policy.getId());
}
示例10: addWSDLFromZip
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* Method that runs the WSDL upload procedure.
*
* @param requestContext the request context for the import/put operation
* @param uri the URL from which the WSDL is imported
*
* @return the path at which the WSDL was uploaded to
*
* @throws RegistryException if the operation failed.
*/
protected String addWSDLFromZip(RequestContext requestContext, String uri)
throws RegistryException {
if (uri != null) {
Resource local = requestContext.getRegistry().newResource();
String version = requestContext.getResource().getProperty("version");
local.setMediaType(wsdlMediaType);
local.setProperty("version", version);
local.setProperties(requestContext.getResource().getProperties());
requestContext.setSourceURL(uri);
requestContext.setResource(local);
String path = requestContext.getResourcePath().getPath();
if (path.lastIndexOf("/") != -1) {
path = path.substring(0, path.lastIndexOf("/"));
} else {
path = "";
}
String wsdlName = uri;
if (wsdlName.lastIndexOf("/") != -1) {
wsdlName = wsdlName.substring(wsdlName.lastIndexOf("/"));
} else {
wsdlName = "/" + wsdlName;
}
path = path + wsdlName;
requestContext.setResourcePath(new ResourcePath(path));
WSDLProcessor wsdlProcessor = buildWSDLProcessor(requestContext, this.useOriginalSchema);
String addedPath = wsdlProcessor.addWSDLToRegistry(requestContext, uri, local, false,
true, disableWSDLValidation,disableSymlinkCreation);
if (CommonConstants.ENABLE.equals(System.getProperty(
CommonConstants.UDDI_SYSTEM_PROPERTY))) {
AuthToken authToken = UDDIUtil.getPublisherAuthToken();
if(authToken !=null){
BusinessServiceInfo businessServiceInfo = new BusinessServiceInfo();
WSDLInfo wsdlInfo = wsdlProcessor.getMasterWSDLInfo();
businessServiceInfo.setServiceWSDLInfo(wsdlInfo);
UDDIPublisher publisher = new UDDIPublisher();
publisher.publishBusinessService(authToken,businessServiceInfo);
}
}
log.debug("WSDL : " + addedPath);
return addedPath;
}
return null;
}
示例11: addSchemaFromZip
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* Method that runs the Schema upload procedure.
*
* @param requestContext the request context for the import/put operation
* @param uri the URL from which the Schema is imported
*
* @return the path at which the schema was uploaded to
*
* @throws RegistryException if the operation failed.
*/
protected String addSchemaFromZip(RequestContext requestContext, String uri)
throws RegistryException {
if (uri != null) {
Resource local = requestContext.getRegistry().newResource();
String version = requestContext.getResource().getProperty("version");
local.setMediaType(xsdMediaType);
local.setProperty("version",version);
local.setProperties(requestContext.getResource().getProperties());
requestContext.setSourceURL(uri);
requestContext.setResource(local);
String path = requestContext.getResourcePath().getPath();
if (path.lastIndexOf("/") != -1) {
path = path.substring(0, path.lastIndexOf("/"));
} else {
path = "";
}
String xsdName = uri;
if (xsdName.lastIndexOf("/") != -1) {
xsdName = xsdName.substring(xsdName.lastIndexOf("/"));
} else {
xsdName = "/" + xsdName;
}
path = path + xsdName;
requestContext.setResourcePath(new ResourcePath(path));
WSDLValidationInfo validationInfo = null;
try {
if (!disableSchemaValidation) {
validationInfo = SchemaValidator.validate(new XMLInputSource(null, uri, null));
}
} catch (Exception e) {
throw new RegistryException("Exception occured while validating the schema" , e);
}
SchemaProcessor schemaProcessor =
buildSchemaProcessor(requestContext, validationInfo, this.useOriginalSchema);
String addedPath = schemaProcessor
.importSchemaToRegistry(requestContext, path,
getChrootedSchemaLocation(requestContext.getRegistryContext()), true,disableSymlinkCreation);
requestContext.setActualPath(addedPath);
log.debug("XSD : " + addedPath);
return addedPath;
}
return null;
}
示例12: setContent
import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
* Sets content of the given schema artifact to the given resource on the
* registry.
*
* @param schema the schema artifact.
* @param schemaResource the content resource.
*
* @throws GovernanceException if the operation failed.
*/
protected void setContent(Schema schema, Resource schemaResource) throws GovernanceException {
if (schema.getSchemaElement() != null) {
OMElement contentElement = schema.getSchemaElement().cloneOMElement();
try {
for (String importType : new String[] {"import", "include", "redefine"}) {
List<OMElement> schemaImports =
GovernanceUtils.evaluateXPathToElements("//xsd:" + importType,
contentElement);
for (OMElement schemaImport : schemaImports) {
OMAttribute location = schemaImport.getAttribute(
new QName("schemaLocation"));
if (location != null) {
String path = location.getAttributeValue();
if (path.indexOf(";version:") > 0) {
location.setAttributeValue(path.substring(0,
path.lastIndexOf(";version:")));
}
}
}
}
} catch (JaxenException ignore) { }
String schemaContent = contentElement.toString();
try {
schemaResource.setContent(schemaContent);
} catch (RegistryException e) {
String msg =
"Error in setting the content from schema, schema id: " + schema.getId() +
", schema path: " + schema.getPath() + ".";
log.error(msg, e);
throw new GovernanceException(msg, e);
}
}
// and set all the attributes as properties.
String[] attributeKeys = schema.getAttributeKeys();
if (attributeKeys != null) {
Properties properties = new Properties();
for (String attributeKey : attributeKeys) {
String[] attributeValues = schema.getAttributes(attributeKey);
if (attributeValues != null) {
// The list obtained from the Arrays#asList method is
// immutable. Therefore,
// we create a mutable object out of it before adding it as
// a property.
properties.put(attributeKey,
new ArrayList<String>(Arrays.asList(attributeValues)));
}
}
schemaResource.setProperties(properties);
}
schemaResource.setUUID(schema.getId());
}