本文整理汇总了Java中org.wso2.carbon.registry.core.utils.RegistryUtils.decodeBytes方法的典型用法代码示例。如果您正苦于以下问题:Java RegistryUtils.decodeBytes方法的具体用法?Java RegistryUtils.decodeBytes怎么用?Java RegistryUtils.decodeBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.core.utils.RegistryUtils
的用法示例。
在下文中一共展示了RegistryUtils.decodeBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreProcessedDocument
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
private IndexDocument getPreProcessedDocument(AsyncIndexer.File2Index fileData) throws RegistryException {
String jsonAsString = RegistryUtils.decodeBytes(fileData.data);
IndexDocument indexDocument = new IndexDocument(fileData.path, jsonAsString,
null);
Map<String, List<String>> attributes = new HashMap<>();
if (fileData.mediaType != null) {
attributes.put(IndexingConstants.FIELD_MEDIA_TYPE, Arrays.asList(fileData.mediaType.toLowerCase()));
}
if (fileData.lcState != null) {
attributes.put(IndexingConstants.FIELD_LC_STATE, Arrays.asList(fileData.lcState.toLowerCase()));
}
if (fileData.lcName != null) {
attributes.put(IndexingConstants.FIELD_LC_NAME, Arrays.asList(fileData.lcName.toLowerCase()));
}
if (fileData.path != null) {
attributes.put(IndexingConstants.FIELD_OVERVIEW_NAME, Arrays.asList(RegistryUtils.getResourceName(fileData.path).toLowerCase()));
}
indexDocument.setFields(attributes);
return indexDocument;
}
示例2: registerArtifactConfigurationByPath
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
* This method is used to add artifact configurations into the artifact configuration map given the registry path
*
* @param registry registry instance
* @param tenantId tenant id
* @param path path of the resource
* @throws RegistryException
*/
public static void registerArtifactConfigurationByPath(Registry registry, int tenantId, String path) throws RegistryException {
GovernanceArtifactConfiguration governanceArtifactConfiguration;
Resource resource = registry.get(path);
Object content = resource.getContent();
String elementString;
if (content instanceof String) {
elementString = (String) content;
} else {
elementString = RegistryUtils.decodeBytes((byte[]) content);
}
governanceArtifactConfiguration = getGovernanceArtifactConfiguration(elementString);
List<GovernanceArtifactConfiguration> configurations = artifactConfigurations.get(tenantId);
if (configurations != null) {
configurations.add(governanceArtifactConfiguration);
} else {
configurations = new LinkedList<GovernanceArtifactConfiguration>();
configurations.add(governanceArtifactConfiguration);
}
artifactConfigurations.put(tenantId, configurations);
}
示例3: buildOMContent
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
private static String buildOMContent(Resource resource, StatCollection currentCollection) throws Exception {
String content = null;
String property = resource.getProperty(REGISTRY_LIFECYCLE_HISTORY_ORDER);
int newOrder = 0;
if (property != null) {
newOrder = Integer.parseInt(property) + 1;
}
resource.setProperty(REGISTRY_LIFECYCLE_HISTORY_ORDER, "" + newOrder);
if (resource.getContent() != null) {
if (resource.getContent() instanceof String) {
content = (String) resource.getContent();
} else if (resource.getContent() instanceof byte[]) {
content = RegistryUtils.decodeBytes((byte[]) resource.getContent());
}
}
if (content == null) {
content = buildInitialOMElement().toString();
}
return addNewContentElement(content, currentCollection, newOrder);
}
示例4: findGovernanceArtifactConfigurations
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
/**
* Method to locate Governance Artifact configurations.
*
* @param registry the registry instance to run query on.
* @return an array of resource paths.
* @throws GovernanceException if the operation failed.
*/
public static List<GovernanceArtifactConfiguration> findGovernanceArtifactConfigurations(
Registry registry) throws RegistryException {
String[] artifactConfigurations = findGovernanceArtifacts(
GovernanceConstants.GOVERNANCE_ARTIFACT_CONFIGURATION_MEDIA_TYPE, registry);
List<GovernanceArtifactConfiguration> configurations =
new LinkedList<GovernanceArtifactConfiguration>();
for (String artifactConfiguration : artifactConfigurations) {
Resource resource = registry.get(artifactConfiguration);
Object content = resource.getContent();
String elementString;
if (content instanceof String) {
elementString = (String) content;
} else {
elementString = RegistryUtils.decodeBytes((byte[]) content);
}
configurations.add(getGovernanceArtifactConfiguration(elementString));
}
return configurations;
}
示例5: getIndexedDocument
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public IndexDocument getIndexedDocument(File2Index fileData) throws SolrException, RegistryException {
// we register both the content as it is and only text content
String xmlAsStr = RegistryUtils.decodeBytes(fileData.data);
final StringBuffer contentOnly = new StringBuffer();
ByteArrayInputStream inData = new ByteArrayInputStream(fileData.data);
// this will handle text content
DefaultHandler handler = new DefaultHandler() {
public void characters(char ch[], int start, int length)
throws SAXException {
contentOnly.append(new String(ch, start, length)).append(" ");
}
};
// SAXParserFactory factory = SAXParserFactory.newInstance();
// SAXParser saxParser = factory.newSAXParser();
// saxParser.parse(inData, handler);
IndexDocument indexDocument = new IndexDocument(fileData.path, xmlAsStr,
contentOnly.toString());
Map<String, List<String>> attributes = new HashMap<String, List<String>>();
if (fileData.mediaType != null) {
attributes.put(IndexingConstants.FIELD_MEDIA_TYPE, Arrays.asList(fileData.mediaType));
}
if (fileData.lcState != null) {
attributes.put(IndexingConstants.FIELD_LC_STATE, Arrays.asList(fileData.lcState));
}
if (fileData.lcName != null) {
attributes.put(IndexingConstants.FIELD_LC_NAME, Arrays.asList(fileData.lcName));
}
indexDocument.setFields(attributes);
return indexDocument;
}
示例6: getDefaultLifecycle
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public static String getDefaultLifecycle(Registry registry, String shortName) throws RegistryException {
String[] rxtList = null;
String lifecycle = "";
rxtList = MediaTypesUtils.getResultPaths(registry, CommonConstants.RXT_MEDIA_TYPE);
for (String rxtContent : rxtList) {
Resource resource = registry.get(rxtContent);
Object content = resource.getContent();
String elementString;
if (content instanceof String) {
elementString = (String) content;
} else {
elementString = RegistryUtils.decodeBytes((byte[]) content);
}
OMElement configElement = null;
try {
configElement = AXIOMUtil.stringToOM(elementString);
} catch (XMLStreamException e) {
throw new RegistryException("Error while serializing to OM content from String", e);
}
if (shortName.equals(configElement.getAttributeValue(new QName("shortName")))) {
OMElement lifecycleElement = configElement.getFirstChildWithName(
new QName("lifecycle"));
if (lifecycleElement != null) {
lifecycle = lifecycleElement.getText();
}
}
}
return lifecycle;
}
示例7: getTextContent
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public static String getTextContent(String path, Registry registry) throws Exception {
try {
if (path != null && path.contains("..")) {
path = FilenameUtils.normalize(path);
}
Resource resource = registry.get(path);
byte[] content = (byte[]) resource.getContent();
String contentString = "";
if (content != null) {
contentString = RegistryUtils.decodeBytes(content);
}
resource.discard();
return contentString;
} catch (RegistryException e) {
String msg = "Could not get the content of the resource " +
path + ". Caused by: " + ((e.getCause() instanceof SQLException) ?
"" : e.getMessage());
log.error(msg, e);
throw new RegistryException(msg, e);
}
}
示例8: getHandlerConfiguration
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public static String getHandlerConfiguration(Registry configSystemRegistry, String name) throws RegistryException,
XMLStreamException {
String path = getContextRoot() + name;
Resource resource;
if (handlerExists(configSystemRegistry, name)) {
resource = configSystemRegistry.get(path);
return RegistryUtils.decodeBytes((byte[])resource.getContent());
}
return null;
}
示例9: getArtifactUIConfiguration
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public String getArtifactUIConfiguration(String key) throws RegistryException {
try {
key = key.replaceAll("\\s+","");
Registry registry = getConfigSystemRegistry();
return RegistryUtils.decodeBytes((byte[]) registry.get(GOVERNANCE_ARTIFACT_CONFIGURATION_PATH + key)
.getContent());
} catch (Exception e) {
log.error("An error occurred while obtaining configuration", e);
return null;
}
}
示例10: getIndexedDocument
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public IndexDocument getIndexedDocument(AsyncIndexer.File2Index fileData) throws SolrException, RegistryException {
IndexDocument indexedDocument = super.getIndexedDocument(fileData);
try {
Registry registry =
GovernanceUtils.getGovernanceSystemRegistry(IndexingManager.getInstance().getRegistry(fileData.tenantId));
GovernanceArtifactConfiguration configuration =
GovernanceUtils.findGovernanceArtifactConfigurationByMediaType(fileData.mediaType, registry);
if (configuration == null) {
return indexedDocument;
}
GenericArtifactManager manager = new GenericArtifactManager(registry, configuration.getKey());
String xmlAsStr = RegistryUtils.decodeBytes(fileData.data);
IndexableGovernanceArtifact artifact = new IndexableGovernanceArtifact((GovernanceArtifactImpl)
manager.newGovernanceArtifact(AXIOMUtil.stringToOM(xmlAsStr)));
Map<String, List<String>> fields = indexedDocument.getFields();
setAttributesToLowerCase(fields);
Map<String, List<String>> attributes = artifact.getAttributes();
//Content artifact (policy, wsdl, schema ...etc) doesn't contains the attributes.
if (fileData.mediaType.matches("application/vnd.(.)+\\+xml") && attributes.size() > 0) {
setAttributesToLowerCase(attributes);
fields.putAll(attributes);
CommonUtil.updateTenantsUnboundedFieldMap(configuration.getContentDefinition().getParent().toString());
if (configuration.getArtifactNameAttribute() != null) {
fields.put("overview_name", attributes.get(configuration.getArtifactNameAttribute()));
}
} else {
fields.put("overview_name", Arrays.asList(RegistryUtils.getResourceName(fileData.path).toLowerCase()));
}
indexedDocument.setFields(fields);
if (log.isDebugEnabled()) {
log.debug("Registry RXT Indexer is running");
}
} catch (XMLStreamException e) {
log.error("Unable to parse XML", e);
}
return indexedDocument;
}
示例11: getContentString
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
private String getContentString(Object content) throws RegistryException {
String contentString;
if (content instanceof String) {
contentString = (String) content;
} else {
contentString = RegistryUtils.decodeBytes((byte[])content);
}
return contentString;
}
示例12: getResourceContent
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public static String getResourceContent(Resource tempResource) throws RegistryException {
if (tempResource.getContent() instanceof String) {
return (String) tempResource.getContent();
} else if (tempResource.getContent() instanceof byte[]) {
return RegistryUtils.decodeBytes((byte[]) tempResource.getContent());
}
return null;
}
示例13: generateAspect
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public static boolean generateAspect(String resourceFullPath, Registry registry) throws RegistryException,
XMLStreamException {
RegistryContext registryContext = registry.getRegistryContext();
if (registryContext == null) {
return false;
}
Resource resource = registry.get(resourceFullPath);
if (resource != null) {
String content = null;
if (resource.getContent() != null) {
content = RegistryUtils.decodeBytes((byte[])resource.getContent());
}
if (content != null) {
OMElement aspect = AXIOMUtil.stringToOM(content);
if (aspect != null) {
OMElement dummy = OMAbstractFactory.getOMFactory().createOMElement("dummy", null);
dummy.addChild(aspect);
Aspect aspectinstance = RegistryConfigurationProcessor.updateAspects(dummy);
Iterator aspectElement = dummy.getChildrenWithName(new QName("aspect"));
String name = "";
if (aspectElement != null) {
OMElement aspectelement = (OMElement) aspectElement.next();
name = aspectelement.getAttributeValue(new QName("name"));
}
registry.addAspect(name,aspectinstance);
return true;
}
}
}
return false;
}
示例14: convertContentToString
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
private static String convertContentToString(Resource resource) throws RegistryException {
if (resource.getContent() instanceof String) {
return RegistryUtils.decodeBytes(((String) resource.getContent()).getBytes());
} else if (resource.getContent() instanceof byte[]) {
return RegistryUtils.decodeBytes((byte[]) resource.getContent());
}
return RegistryUtils.decodeBytes("".getBytes());
}
示例15: getArtifactContent
import org.wso2.carbon.registry.core.utils.RegistryUtils; //导入方法依赖的package包/类
public String getArtifactContent(String path) throws RegistryException {
Registry registry = getGovernanceUserRegistry();
// resource path is created to make sure the version page doesn't give null values
if (!registry.resourceExists(new ResourcePath(path).getPath())) {
return null;
}
return RegistryUtils.decodeBytes((byte[]) registry.get(path).getContent());
}