本文整理汇总了Java中org.wso2.carbon.registry.core.utils.RegistryUtils.getResourceName方法的典型用法代码示例。如果您正苦于以下问题:Java RegistryUtils.getResourceName方法的具体用法?Java RegistryUtils.getResourceName怎么用?Java RegistryUtils.getResourceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.core.utils.RegistryUtils
的用法示例。
在下文中一共展示了RegistryUtils.getResourceName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putChild
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void putChild(RequestContext requestContext) throws RegistryException {
String path = requestContext.getResourcePath().getPath();
Resource resource = requestContext.getResource();
if (resource instanceof Collection) {
String parentPath = resource.getParentPath();
String newVersionNumber = RegistryUtils.getResourceName(path);
if (!CommonConstants.VERSIONED_COLLECTION_MEDIA_TYPE.equals(resource.getMediaType())) {
throw new RegistryException("Only Collections of type " +
CommonConstants.VERSIONED_COLLECTION_MEDIA_TYPE + " can be put into the " +
"collection: " + parentPath);
}
if (!newVersionNumber.matches(CommonConstants.SERVICE_VERSION_REGEX)) {
throw new RegistryException("Version number should be in the format :" +
"<major no>.<minor no>.<patch no>");
}
Registry registry = requestContext.getRegistry();
Resource parent = registry.get(parentPath);
parent.setProperty(org.wso2.carbon.registry.common.CommonConstants.
LATEST_VERSION_PROP_NAME, newVersionNumber);
registry.put(parentPath, parent);
}
}
示例2: getGreatestChildVersion
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public static String getGreatestChildVersion(ServletConfig config, HttpSession session,
String path) throws Exception {
String[] nodes =
Utils.getSortedChildNodes(
new ResourceServiceClient(config, session).getCollectionContent(
path));
String last = "";
for (String node : nodes) {
String name = RegistryUtils.getResourceName(node);
try {
Integer.parseInt(name);
last = name;
} catch (NumberFormatException ignore) {
}
}
return last;
}
示例3: calculateAbsolutePath
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public static String calculateAbsolutePath(String wsdlPath, String targetPath) {
// then only it is considered as relative.
if (targetPath.startsWith("/") &&
targetPath.startsWith("http://") && targetPath.startsWith("https://")) {
return targetPath;
}
if (targetPath.startsWith("..") || targetPath.startsWith("./")) {
if(targetPath.startsWith("./")){
targetPath = targetPath.replaceFirst("./","/");
}
String wsdlCollection = RegistryUtils.getParentPath(wsdlPath);
String targetCollection = RegistryUtils.getParentPath(targetPath);
String[] targetPathParts = targetCollection.split("/");
String[] currentPathParts = wsdlCollection.split("/");
int countGoUpwardParts = 0;
for (int i = 0; i < targetPathParts.length; i ++) {
if (!targetPathParts[i].equals("..")) {
break;
}
countGoUpwardParts++;
}
if (currentPathParts.length < countGoUpwardParts) {
return null;
}
StringBuffer absolutePath = new StringBuffer();
for (int i = 0; i < currentPathParts.length - countGoUpwardParts; i ++) {
absolutePath.append(currentPathParts[i]).append("/");
}
for (int i = countGoUpwardParts; i < targetPathParts.length; i ++) {
absolutePath.append(targetPathParts[i]).append("/");
}
targetPath = absolutePath.toString() + RegistryUtils.getResourceName(targetPath);
return targetPath.replaceAll("//","/");
}
return targetPath;
}
示例4: addResourceName
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
* Method to set the resource name to IndexDocument attribute list.
*/
private void addResourceName() {
// Set the resource name
String resourceName = RegistryUtils.getResourceName(resourcePath);
if (StringUtils.isNotEmpty(resourceName)) {
attributes.put(IndexingConstants.FIELD_RESOURCE_NAME, Arrays.asList(resourceName));
}
}
示例5: getConfigurationBean
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
private ReportConfigurationBean getConfigurationBean(String path)
throws RegistryException, CryptoException, TaskException {
Registry registry = getConfigSystemRegistry();
Resource resource = registry.get(path);
ReportConfigurationBean bean = new ReportConfigurationBean();
String name = RegistryUtils.getResourceName(path);
bean.setName(name);
bean.setCronExpression(resource.getProperty("cronExpression"));
TaskManager taskManager = ReportingServiceComponent.getTaskManager(
((UserRegistry) getRootRegistry()).getTenantId());
bean.setScheduled(taskManager.isTaskScheduled(name));
bean.setReportClass(resource.getProperty("class"));
bean.setResourcePath(resource.getProperty("resourcePath"));
bean.setTemplate(resource.getProperty("template"));
bean.setType(resource.getProperty("type"));
bean.setUsername(resource.getProperty("registry.username"));
bean.setTenantId(Integer.parseInt(resource.getProperty("registry.tenantId")));
Map<String, String> attributes = new HashMap<String, String>();
Properties props = resource.getProperties();
for (Object key : props.keySet()) {
String propKey = (String) key;
if (propKey.startsWith("attribute.")) {
attributes.put(propKey.substring("attribute.".length()),
resource.getProperty(propKey));
}
}
bean.setAttributes(CommonUtil.mapToAttributeArray(attributes));
return bean;
}
示例6: putChild
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void putChild(RequestContext requestContext) throws RegistryException {
Registry registry = requestContext.getRegistry();
String thisCollectionPath = requestContext.getParentPath();
String thisCollectionName = RegistryUtils.getResourceName(thisCollectionPath);
String parentContainerPath = RegistryUtils.getParentPath(thisCollectionPath);
Resource parentContainer = registry.get(parentContainerPath);
if (thisCollectionName.equals(parentContainer.getProperty(
CommonConstants.LATEST_VERSION_PROP_NAME))) {
String resourcePath = requestContext.getResourcePath().getPath();
String resourceName = RegistryUtils.getResourceName(resourcePath);
registry.createLink(parentContainerPath + RegistryConstants.PATH_SEPARATOR +
resourceName, resourcePath);
}
}
示例7: put
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public void put(RequestContext requestContext) throws RegistryException {
//update symlinks if the property has changed
Registry registry = requestContext.getRegistry();
ResourcePath containerPath = requestContext.getResourcePath();
String latestVersionNumber = requestContext.getResource().getProperty(
org.wso2.carbon.registry.common.CommonConstants.LATEST_VERSION_PROP_NAME);
if (latestVersionNumber == null) {
return;
//throw new RegistryException("Property latest.version is missing in the Collection of " +
// "media-type application/vnd.wso2.version-container");
}
String latestVersionCollectionPath = containerPath + RegistryConstants.PATH_SEPARATOR +
latestVersionNumber;
if (registry.resourceExists(latestVersionCollectionPath)) {
Collection latestVersionCollection = (Collection) registry.get(
latestVersionCollectionPath);
for (String childPath : latestVersionCollection.getChildren()) {
String childName = RegistryUtils.getResourceName(childPath);
registry.createLink(containerPath + RegistryConstants.PATH_SEPARATOR + childName,
childPath);
}
} else {
//add a temp property to skip the case off calling put() method in the above putChild()
// throw new RegistryException("Latest versioned collection not found at" +
// latestVersionCollectionPath);
}
}
示例8: doCopy
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
protected void doCopy(RequestContext requestContext, String resourcePath, String newPath)
throws RegistryException {
if (requestContext.getResource() instanceof Collection) {
Registry registry = requestContext.getRegistry();
Object content = registry.get(
(String) parameterMap.get(MAPPINGS_RESOURCE)).getContent();
String contentString = getContentString(content);
int startingIndex = Integer.parseInt((String) parameterMap.get(STARTING_INDEX));
Map<String, String> conversions = new HashMap<String, String>();
for (String mapping : contentString.split("\n")) {
String[] mappings = mapping.split("\r")[0].split(",");
conversions.put(mappings[startingIndex - 1].trim(), mappings[startingIndex].trim());
}
registry.put(newPath, registry.get(resourcePath));
for (String path : ((Collection)requestContext.getResource()).getChildren()) {
String temp = RegistryConstants.PATH_SEPARATOR +
RegistryUtils.getResourceName(path);
Resource resource = registry.get(resourcePath + temp);
String string = getContentString(resource.getContent());
for (Map.Entry<String, String> e : conversions.entrySet()) {
string = string.replace(e.getKey(), e.getValue());
}
resource.setContent(string);
registry.put(newPath + temp, resource);
}
}
}
示例9: buildServiceVersionHierarchy
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
private Map<String, Map<String, ServiceBean>> buildServiceVersionHierarchy(
ServiceBean[] serviceBeans) {
Map<String, Map<String, ServiceBean>> hierarchy =
new LinkedHashMap<String, Map<String, ServiceBean>>();
if (serviceBeans == null) {
return hierarchy;
}
for (ServiceBean serviceBean : serviceBeans) {
if (serviceBean != null) {
String path = RegistryUtils.getParentPath(serviceBean.getPath());
String version = RegistryUtils.getResourceName(path);
if (!version.replace("-SNAPSHOT", "").matches("^\\d+[.]\\d+[.]\\d+$")) {
version = "SNAPSHOT";
serviceBean.setPath(serviceBean.getPath());
} else {
serviceBean.setPath(RegistryUtils.getParentPath(path));
}
Map<String, ServiceBean> versionMap;
if (hierarchy.containsKey(serviceBean.getQName())) {
versionMap = hierarchy.get(serviceBean.getQName());
} else {
versionMap = new LinkedHashMap<String, ServiceBean>();
hierarchy.put(serviceBean.getQName(), versionMap);
}
versionMap.put(version, serviceBean);
}
}
return hierarchy;
}
示例10: processGETWSDLArtifactRequest
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
private void processGETWSDLArtifactRequest(HttpServletRequest req, HttpServletResponse resp,
String pathComponent)
throws ServletException, IOException {
Entry entry = abdera.newEntry();
Element artifact = newSRAMPArtifact();
Element wsdlDocument = newExtensionElement(artifact, "WsdlDocument");
wsdlDocument.setAttributeValue(CONTENT_ENCODING_ATTRIBUTE, UTF_8);
WsdlManager manager = new WsdlManager(governanceSystemRegistry);
try {
Wsdl wsdl = manager.getWsdl(pathComponent);
String wsdlId = wsdl.getId();
entry.setId(URN_UUID + wsdlId);
wsdlDocument.setAttributeValue(UUID_ATTRIBUTE, wsdlId);
wsdlDocument.setAttributeValue(VERSION_ATTRIBUTE, DEFAULT_ARTIFACT_VERSION);
String path = wsdl.getPath();
String resourceName = RegistryUtils.getResourceName(path);
entry.setTitle(resourceName);
wsdlDocument.setAttributeValue(NAME_ATTRIBUTE, resourceName);
Resource resource = getResource(path);
if (resource != null) {
fillArtifactEntryDetailsFromResource(wsdlDocument, entry, resource);
fillArtifactEntryDescriptionFromResource(wsdlDocument, entry, resource);
fillPropertiesFromResource(wsdlDocument, resource);
fillArtifactEntryContentDetailsFromResource(wsdlDocument, resource);
}
String serviceURL = getServletURL(req) + WSDL_WSDL_DOCUMENT_PATH_COMPONENT + wsdlId;
entry.setContent(new IRI(serviceURL + CONTENT_PATH_COMPONENT), XML_MEDIA_TYPE);
addAtomLinksForGETRequest(entry, serviceURL);
entry.addExtension(artifact);
} catch (GovernanceException e) {
String message = "Unable to locate WSDL";
log.error(message, e);
throw new SRAMPServletException(message, e);
}
resp.setContentType(ATOM_ENTRY_MEDIA_TYPE);
resp.setStatus(200);
serializeOutput(resp, (FOMEntry) entry);
}
示例11: buildTree
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public TreeNode buildTree() throws Exception {
// prepare the root tree node.
String wadlName = RegistryUtils.getResourceName(wadlPath);
wadlNamespace = wadlElement.getNamespace().getNamespaceURI();
TreeNode root = new TreeNode(TreeNodeBuilderUtil.generateKeyName("WADL", wadlName));
OMElement grammarsElement = wadlElement.getFirstChildWithName(new QName(wadlNamespace, "grammars"));
if(grammarsElement != null){
TreeNode grammarsNode = new TreeNode("Grammars");
Iterator<OMElement> grammarElements = grammarsElement.
getChildrenWithName(new QName(wadlNamespace, "include"));
while (grammarElements.hasNext()){
grammarsNode.addChild(new TreeNode("Include",
grammarElements.next().getAttributeValue(new QName("href"))));
}
root.addChild(grammarsNode) ;
}
TreeNode resourcesNode = new TreeNode("Resources");
OMElement resourcesElement = wadlElement.
getFirstChildWithName(new QName(wadlNamespace, "resources"));
resourcesNode.addChild(new TreeNode("Base",
resourcesElement.getAttributeValue(new QName("base"))));
Iterator<OMElement> resourceElements = resourcesElement.
getChildrenWithName(new QName(wadlNamespace, "resource"));
while (resourceElements.hasNext()){
addResourceNodesRecursively(resourceElements.next(), resourcesNode);
}
root.addChild(resourcesNode);
return root;
}
示例12: buildTree
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public TreeNode buildTree() throws Exception{
String schemaName = RegistryUtils.getResourceName(schemaPath);
List<String> attributeList = new ArrayList<String>();
attributeList.add(SchemaConstants.NAME);
TreeNode root = new TreeNode(TreeNodeBuilderUtil.generateKeyName(SchemaConstants.SCHEMA, schemaName));
/* Adding namespace information in to the tree struction */
addSchemaDataToTreeWithHyperlink(SchemaConstants.XPATH_TARGETNAMESPACE,
SchemaConstants.TARGETNAMESPACE, root,
schemaElement, false);
/* Adding Elements*/
attributeList.add(SchemaConstants.REF);
addSchemaDataToTree(SchemaConstants.XPATH_ELEMENTS,SchemaConstants.ELEMENTS,root, schemaElement,attributeList);
/* Adding attributes */
attributeList.remove(SchemaConstants.REF);
addSchemaDataToTree(SchemaConstants.XPATH_ATTRIBUTES,SchemaConstants.ATTRIBUTES,root, schemaElement, attributeList);
/* Adding Groups */
addSchemaDataToTree(SchemaConstants.XPATH_GROUPS,SchemaConstants.GROUPS,root, schemaElement,attributeList);
/* Adding schema includes */
addSchemaDataToTreeWithHyperlink(SchemaConstants.SCHEMA_INCLUDES_EXPR,SchemaConstants.INCLUDES,root,
schemaElement, true);
/* Adding schema import namespaces*/
attributeList.clear();
attributeList.add(SchemaConstants.SCHEMALOCATION);
attributeList.add(SchemaConstants.NAMESPACE);
addSchemaDataToTreeWithHyperlink(SchemaConstants.SCHEMA_IMPORTS_EXPR,SchemaConstants.IMPORTS,
root,schemaElement,true);
return root;
}
示例13: getAdjacentVersions
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public static int[] getAdjacentVersions(ServletConfig config, HttpSession session,
String path, int current) throws Exception {
String[] nodes =
Utils.getSortedChildNodes(
new ResourceServiceClient(config, session).getCollectionContent(path));
int[] versions = new int[2];
versions[0] = -1;
versions[1] = -1;
int previous = -1;
for (String node : nodes) {
String name = RegistryUtils.getResourceName(node);
try {
int temp = Integer.parseInt(name);
if (previous == current) {
// The last match was the current version. Therefore, the match is the version
// after the current.
versions[1] = temp;
break;
}
if (temp == current) {
// The match is the current version. Therefore, the last match was the version
// before the current.
versions[0] = previous;
}
previous = temp;
} catch (NumberFormatException ignore) {
}
}
return versions;
}
示例14: loadDetails
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
* Method to load the details into this artifact.
*
* @throws GovernanceException if the operation failed.
*/
public void loadDetails() throws GovernanceException {
checkRegistryResourceAssociation();
Registry registry = getAssociatedRegistry();
String path = getPath();
String id = getId();
Resource resource;
try {
resource = registry.get(path);
this.content = (byte[]) resource.getContent();
this.mediaType = resource.getMediaType();
} catch (RegistryException e) {
throw new GovernanceException("Error in getting the qualified name for the artifact. " +
"artifact id: " + id + ", " + "path: " + path + ".", e);
}
// get the target namespace.
String fileName = RegistryUtils.getResourceName(path);
this.qName = new QName(null, fileName);
// and then iterate all the properties and add.
Properties properties = resource.getProperties();
if (properties != null) {
Set keySet = properties.keySet();
if (keySet != null) {
for (Object keyObj : keySet) {
String key = (String) keyObj;
List values = (List) properties.get(key);
if (values != null) {
for (Object valueObj : values) {
String value = (String) valueObj;
addAttribute(key, value);
}
}
}
}
}
}
示例15: buildTree
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public TreeNode buildTree() throws Exception {
// prepare the root tree node.
String wsdlName = RegistryUtils.getResourceName(wsdlPath);
TreeNode root = new TreeNode(TreeNodeBuilderUtil.generateKeyName(WSDLConstants.WSDL, wsdlName));
// adding the documentation
OMElement wsdlDocElement = TreeNodeBuilderUtil.evaluateXPathToElement(WSDLConstants.WSDL_DOCUMENTATION_EXPR,
wsdlElement);
if (wsdlDocElement != null) {
OMNode wsdlDocChild = wsdlDocElement.getFirstOMChild();
if (wsdlDocChild instanceof OMText) {
String documentationText = ((OMText)wsdlDocChild).getText();
if (documentationText != null) {
documentationText = documentationText.replace('\n', ' ').trim();
root.addChild(new TreeNode(WSDLConstants.WSDL_DOCUMENTATION, documentationText));
}
}
}
// adding the version
String wsdlVersion = getWSDLVersion(wsdlElement);
root.addChild(new TreeNode(WSDLConstants.WSDL_VERSION, wsdlVersion));
if (wsdlVersion.equals(WSDLConstants.WSDL_VERSION_VALUE_11)) {
buildWSDL11Services(root);
// adding the schema imports
List<String> wsdlImports = TreeNodeBuilderUtil.evaluateXPathToValues(WSDLConstants.WSDL_IMPORTS_EXPR, wsdlElement);
if (wsdlImports.size() != 0) {
TreeNode wsdlImportNode = new TreeNode(WSDLConstants.WSDL_IMPORTS);
root.addChild(wsdlImportNode);
for (String wsdlImport: wsdlImports) {
String wsdImportAbsolutePath;
if (actualWsdlPath != null) {
wsdImportAbsolutePath = TreeNodeBuilderUtil.calculateAbsolutePath(actualWsdlPath, wsdlImport);
} else {
wsdImportAbsolutePath = TreeNodeBuilderUtil.calculateAbsolutePath(wsdlPath, wsdlImport);
}
String wsdlImportEntry = "<a href='" + WSDLConstants.RESOURCE_JSP_PAGE + "?" +
WSDLConstants.PATH_REQ_PARAMETER + "=" +
wsdImportAbsolutePath + "'>" + wsdlImport + "</a>";
wsdlImportNode.addChild(wsdlImportEntry);
}
}
} else {
String msg = "Unknown WSDL Version.";
throw new Exception(msg);
}
List<String> schemaImports = TreeNodeBuilderUtil.evaluateXPathToValues(WSDLConstants.SCHEMA_IMPORTS_EXPR, wsdlElement);
if (schemaImports.size() != 0) {
TreeNode schemaImportsNode = new TreeNode(WSDLConstants.SCHEMA_IMPORTS);
root.addChild(schemaImportsNode);
for (String schemaImport: schemaImports) {
if (schemaImport.indexOf(";version:") > 0) {
schemaImport = schemaImport.substring(0, schemaImport.lastIndexOf(";version:"));
}
String schemaImportAbsolutePath;
if (actualWsdlPath != null) {
schemaImportAbsolutePath = TreeNodeBuilderUtil.calculateAbsolutePath(actualWsdlPath, schemaImport);
} else {
schemaImportAbsolutePath = TreeNodeBuilderUtil.calculateAbsolutePath(wsdlPath, schemaImport);
}
String schemaImportEntry = "<a href='" + WSDLConstants.RESOURCE_JSP_PAGE + "?" +
WSDLConstants.PATH_REQ_PARAMETER + "=" +
schemaImportAbsolutePath + "'>" + schemaImport + "</a>";
schemaImportsNode.addChild(schemaImportEntry);
}
}
return root;
}