当前位置: 首页>>代码示例>>Java>>正文


Java GovernanceException类代码示例

本文整理汇总了Java中org.wso2.carbon.governance.api.exception.GovernanceException的典型用法代码示例。如果您正苦于以下问题:Java GovernanceException类的具体用法?Java GovernanceException怎么用?Java GovernanceException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GovernanceException类属于org.wso2.carbon.governance.api.exception包,在下文中一共展示了GovernanceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populateLicense

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
private License populateLicense(GenericArtifact artifact) throws GovernanceException, ParseException {
    License license = new License();
    license.setName(artifact.getAttribute(DeviceManagementConstants.LicenseProperties.NAME));
    license.setProvider(artifact.getAttribute(DeviceManagementConstants.LicenseProperties.PROVIDER));
    license.setVersion(artifact.getAttribute(DeviceManagementConstants.LicenseProperties.VERSION));
    license.setLanguage(artifact.getAttribute(DeviceManagementConstants.LicenseProperties.LANGUAGE));
    license.setText(artifact.getAttribute(DeviceManagementConstants.LicenseProperties.TEXT));

    DateFormat format = new SimpleDateFormat("dd-mm-yyyy", Locale.ENGLISH);
    String validFrom = artifact.getAttribute(DeviceManagementConstants.LicenseProperties.VALID_FROM);
    if (validFrom != null && !validFrom.isEmpty()) {
        license.setValidFrom(format.parse(validFrom));
    }
    String validTo = artifact.getAttribute(DeviceManagementConstants.LicenseProperties.VALID_TO);
    if (validTo != null && !validTo.isEmpty()) {
        license.setValidFrom(format.parse(validTo));
    }
    return license;
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:20,代码来源:RegistryBasedLicenseManager.java

示例2: addLicense

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
@Override
public boolean addLicense(String deviceType, License license) throws LicenseManagementException {
    GenericArtifactManager artifactManager =
            GenericArtifactManagerFactory.getTenantAwareGovernanceArtifactManager();
    try {
        GenericArtifact artifact =
                artifactManager.newGovernanceArtifact(new QName("http://www.wso2.com",
                        DeviceManagementConstants.LicenseProperties.LICENSE_REGISTRY_KEY));
        artifact.setAttribute(DeviceManagementConstants.LicenseProperties.NAME, license.getName());
        artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VERSION, license.getVersion());
        artifact.setAttribute(DeviceManagementConstants.LicenseProperties.PROVIDER, license.getProvider());
        artifact.setAttribute(DeviceManagementConstants.LicenseProperties.LANGUAGE, license.getLanguage());
        artifact.setAttribute(DeviceManagementConstants.LicenseProperties.TEXT, license.getText());
        artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_TO,
                license.getValidTo().toString());
        artifact.setAttribute(DeviceManagementConstants.LicenseProperties.VALID_FROM,
                license.getValidFrom().toString());
        artifactManager.addGenericArtifact(artifact);
        return true;
    } catch (GovernanceException e) {
        throw new LicenseManagementException("Error occurred while adding license for device type " +
                deviceType + "'", e);
    }
}
 
开发者ID:wso2-incubator,项目名称:iot-server-appliances,代码行数:25,代码来源:LicenseManagerImpl.java

示例3: getAttachedPolicies

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
/**
 * Method to retrieve all policies attached to this service artifact.
 *
 * @return all policies attached to this service artifact.
 * @throws GovernanceException if the operation failed.
 */
@Override
public Policy[] getAttachedPolicies() throws GovernanceException {
    checkRegistryResourceAssociation();
    Registry registry = getAssociatedRegistry();
    String path = getPath();
    List<Policy> policies = new ArrayList<Policy>();
    try {
        Association[] associations =
                registry.getAssociations(path, GovernanceConstants.DEPENDS);
        for (Association association : associations) {
            String destinationPath = association.getDestinationPath();
            GovernanceArtifact governanceArtifact =
                    GovernanceUtils.retrieveGovernanceArtifactByPath(registry, destinationPath);
            if (governanceArtifact instanceof PolicyImpl) {
                policies.add((Policy) governanceArtifact);
            }
        }
    } catch (RegistryException e) {
        String msg =
                "Error in getting attached policies from the artifact at path: " + path + ".";
        log.error(msg, e);
        throw new GovernanceException(msg, e);
    }
    return policies.toArray(new Policy[policies.size()]);
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:32,代码来源:ServiceImpl.java

示例4: persistNewArtifact

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
protected void persistNewArtifact(GenericArtifactManager artifactManager, DetachedGenericArtifact artifact,
                                  String shortName, GenericArtifact server, String seqNo,
                                  String originProperty, Map<String, List<String>> feedback)
        throws GovernanceException {
    if (isExists(artifactManager, artifact)) {
        switch (onExistArtifactStrategy) {
            case IGNORE:
                log.info("Ignored already existing artifact" + artifact);
                feedback.get(ARTIFACT_IGNORED).add(shortName + ":" + artifact.getQName().getLocalPart());
                break;
            case REMOVE:
                //If artifact is already exists, delete and then add new artifact.
                artifactManager.removeGenericArtifact(artifact);
                log.info("Removed already existing artifact" + artifact);
                addNewGenericArtifact(artifactManager, artifact, server, seqNo, originProperty);
                feedback.get(ARTIFACT_REPLACED).add(shortName + ":" + artifact.getQName().getLocalPart());
                break;
            case CUSTOM:
                customizeExistArtifactStrategy(artifactManager, artifact, seqNo, originProperty);
                break;
        }
    } else {
        addNewGenericArtifact(artifactManager, artifact, server, seqNo, originProperty);
        feedback.get(ARTIFACT_ADDED).add(shortName + ":" + artifact.getQName().getLocalPart());
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:27,代码来源:DiscoveryAgentExecutorSupport.java

示例5: getPathFromPathExpression

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
/**
 * Method to convert the expression specified for storing the path with corresponding values
 * where the artifact is stored.
 *
 * @param pathExpression the expression specified for storing the path
 * @param artifact       the governance artifact
 * @return the path with corresponding values where the artifact is stored
 * @throws GovernanceException if the operation failed.
 */
public static String getPathFromPathExpression(String pathExpression,
                                               GovernanceArtifact artifact)
        throws GovernanceException {
    String output = replaceNameAndNamespace(pathExpression, artifact);
    String[] elements = output.split("@");
    for (int i = 1; i < elements.length; i++) {
        if (elements[i].indexOf("}") > 0 && elements[i].indexOf("{") == 0) {
            String key = elements[i].split("}")[0].substring(1);
            String artifactAttribute = artifact.getAttribute(key);
            if (artifactAttribute != null) {
                output = output.replace("@{" + key + "}", artifactAttribute);
            } else {
                String msg = "Value for required attribute " + key + " found empty.";
                log.error(msg);
                throw new GovernanceException(msg);
            }
        }
    }
    return output;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:30,代码来源:GovernanceUtils.java

示例6: createAssociation

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
/**
 * Create an association between rest service and api.
 *
 */
private void createAssociation() throws GovernanceException, RegistryException{
	GenericArtifactManager artifactManager = new GenericArtifactManager(registry, "api");
	GenericArtifact[] artifacts = artifactManager.findGenericArtifacts(
			new GenericArtifactFilter() {
				public boolean matches(GenericArtifact apiArtifact) throws GovernanceException {
					String attributeVal = apiArtifact.getAttribute("overview_name");
					return (attributeVal != null && attributeVal.equals(artifact.getAttribute("overview_name")));
				}
			});
	if (artifacts != null && artifacts.length > 0) {
		GenericArtifact api = artifacts[0];
		api.addAssociation("createdBy", artifact);
		artifact.addAssociation("promotedTo", api);
	}
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:20,代码来源:ApiStore2Executor.java

示例7: testBuildSearchCriteria2

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
public void testBuildSearchCriteria2() throws Exception {

        String val = getStringFromInputStream(this.getClass().getClassLoader().getResourceAsStream("uri.rxt"));
        Resource resource = registry.newResource();
        resource.setMediaType(GovernanceConstants.GOVERNANCE_ARTIFACT_CONFIGURATION_MEDIA_TYPE);
        resource.setContentStream(this.getClass().getClassLoader().getResourceAsStream("uri.rxt"));
        registry.put("/uri", resource);
        GovernanceArtifactConfiguration governanceArtifactConfiguration =
                GovernanceUtils.getGovernanceArtifactConfiguration(val);

        GovernanceUtils.loadGovernanceArtifacts((UserRegistry) registry);

        try {
            GovernanceUtils.findGovernanceArtifacts("name:(SampleURI2 OR SampleURI1)", registry,
                                                    governanceArtifactConfiguration.getMediaType());
        } catch (GovernanceException e) {
            assertEquals("Attribute Search Service not Found", e.getMessage());
            assertNull(e.getCause());
        }

    }
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:22,代码来源:TestBuildSearchCriteria.java

示例8: getAllEndpoints

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
/**
 * Finds all Endpoint artifacts on the registry.
 *
 * @return all Endpoint artifacts on the registry.
 * @throws GovernanceException if the operation failed.
 */
public Endpoint[] getAllEndpoints() throws GovernanceException {
    List<String> endpointPaths =
            Arrays.asList(GovernanceUtils.getResultPaths(registry,
                    GovernanceConstants.ENDPOINT_MEDIA_TYPE));
    Collections.sort(endpointPaths, new Comparator<String>() {
        public int compare(String o1, String o2) {
            // First order by name
            int result = RegistryUtils.getResourceName(o1).compareToIgnoreCase(
                    RegistryUtils.getResourceName(o2));
            if (result != 0) {
                return result;
            }
            // Then order by namespace
            return o1.compareToIgnoreCase(o2);
        }
    });
    List<Endpoint> endpoints = new ArrayList<Endpoint>();
    for (String endpointPath : endpointPaths) {
        GovernanceArtifact artifact =
                GovernanceUtils.retrieveGovernanceArtifactByPath(registry, endpointPath);
        endpoints.add((Endpoint) artifact);
    }
    return endpoints.toArray(new Endpoint[endpoints.size()]);
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:31,代码来源:EndpointManager.java

示例9: testBuildSearchCriteriaTaxonomy

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
public void testBuildSearchCriteriaTaxonomy() throws Exception {

        String val = getStringFromInputStream(this.getClass().getClassLoader().getResourceAsStream("uri.rxt"));
        Resource resource = registry.newResource();
        resource.setMediaType(GovernanceConstants.GOVERNANCE_ARTIFACT_CONFIGURATION_MEDIA_TYPE);
        resource.setContentStream(this.getClass().getClassLoader().getResourceAsStream("uri.rxt"));
        registry.put("/uri", resource);
        GovernanceArtifactConfiguration governanceArtifactConfiguration =
                GovernanceUtils.getGovernanceArtifactConfiguration(val);

        GovernanceUtils.loadGovernanceArtifacts((UserRegistry) registry);

        try {
            GovernanceUtils.findGovernanceArtifacts("taxonomy=(SampleURI2 OR SampleURI1)", registry,
                                                    governanceArtifactConfiguration.getMediaType());
        } catch (GovernanceException e) {
            assertEquals("Attribute Search Service not Found", e.getMessage());
            assertNull(e.getCause());
        }

    }
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:22,代码来源:TestBuildSearchCriteria.java

示例10: modifyGovernanceAsset

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
private Response modifyGovernanceAsset(String assetType, String id, DetachedGenericArtifact genericArtifact,
                                       String baseURL) throws RegistryException {
    String shortName = Util.getShortName(assetType);
    try {
        GenericArtifactManager manager = getGenericArtifactManager(shortName);
        GenericArtifact artifact = genericArtifact.makeRegistryAware(manager);
        artifact.setId(id);
        manager.updateGenericArtifact(artifact);
        //Use 'generateLink' method with four parameters.
        //Fix for REGISTRY-3129
        URI link = new URL(Util.generateLink(assetType, id, baseURL, false)).toURI();
        return Response.created(link).build();
    } catch (MalformedURLException | URISyntaxException e) {
        throw new GovernanceException(e);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:17,代码来源:Asset.java

示例11: getPathsFromPathExpression

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
/**
 * Method to convert the expression specified for storing the path with corresponding values
 * where the artifact is stored. This method will return multiple paths.
 *
 * @param pathExpression the expression specified for storing the path
 * @param artifact       the governance artifact
 * @return the paths with corresponding values where the artifact is stored
 * @throws GovernanceException if the operation failed.
 */
public static String[] getPathsFromPathExpression(String pathExpression,
                                                  GovernanceArtifact artifact)
        throws GovernanceException {
    String expression = replaceNameAndNamespace(pathExpression, artifact);
    String[] elements = expression.split("@");
    for (int i = 1; i < elements.length; i++) {
        if (!(elements[i].indexOf(":") > 0) &&
                elements[i].indexOf("}") > 0 && elements[i].indexOf("{") == 0) {
            String key = elements[i].split("}")[0].substring(1);
            String artifactAttribute = artifact.getAttribute(key);
            if (artifactAttribute != null) {
                expression = expression.replace("@{" + key + "}", artifactAttribute);
            }
        }
    }
    List<String> output = fixExpressionForMultiplePaths(artifact, expression);
    return output.toArray(new String[output.size()]);
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:28,代码来源:GovernanceUtils.java

示例12: getAllArtifactPathsByLifecycleState

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
/**
 * Retrieve all the governance artifact paths which associated with the given lifecycle in the given lifecycle state
 *
 * @param registry  registry instance
 * @param lcName    lifecycle name
 * @param lcState   lifecycle state
 * @param mediaType mediatype of the artifacts
 * @return String array of all the artifact paths
 * @throws GovernanceException if the operation failed.
 */
public static String[] getAllArtifactPathsByLifecycleState(
        Registry registry, String lcName, String lcState, String mediaType) throws GovernanceException {
    String sql = "SELECT R.REG_PATH_ID, R.REG_NAME FROM REG_RESOURCE R, REG_PROPERTY PP, " +
            "REG_RESOURCE_PROPERTY RP WHERE R.REG_VERSION=RP.REG_VERSION AND RP.REG_PROPERTY_ID=PP.REG_ID " +
            "AND PP.REG_NAME = ?  AND  PP.REG_VALUE = ? AND R.REG_MEDIA_TYPE = ?";
    Map<String, String> parameter = new HashMap<String, String>();
    parameter.put("1", "registry.lifecycle." + lcName + ".state");
    parameter.put("2", lcState);
    parameter.put("3", mediaType);
    parameter.put("query", sql);

    try {
        return (String[]) registry.executeQuery(null, parameter).getContent();
    } catch (RegistryException e) {
        String msg = "Error occured while executing custom query";
        throw new GovernanceException(msg, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:29,代码来源:GovernanceUtils.java

示例13: removeArtifactFromPath

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
public static void removeArtifactFromPath(Registry registry, String path)
        throws GovernanceException {
    try {
        if (registry.resourceExists(path)) {
            deleteLifecycleHistoryFile(path, registry);
            registry.delete(path);
        }
        ArtifactCache artifactCache =
                ArtifactCacheManager.getCacheManager().getTenantArtifactCache(((UserRegistry) registry).getTenantId());
        if (artifactCache != null && path != null && artifactCache.getArtifact(path) != null) {
            artifactCache.invalidateArtifact(path);
        }
    } catch (RegistryException e) {
        String msg = "Error in deleting the the artifact path:" + path + ".";
        throw new GovernanceException(msg, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:18,代码来源:GovernanceUtils.java

示例14: testBuildSearchCriteriaSubPart

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
public void testBuildSearchCriteriaSubPart() throws Exception {

        String val = getStringFromInputStream(this.getClass().getClassLoader().getResourceAsStream("uri.rxt"));
        Resource resource = registry.newResource();
        resource.setMediaType(GovernanceConstants.GOVERNANCE_ARTIFACT_CONFIGURATION_MEDIA_TYPE);
        resource.setContentStream(this.getClass().getClassLoader().getResourceAsStream("uri.rxt"));
        registry.put("/uri", resource);
        GovernanceArtifactConfiguration governanceArtifactConfiguration =
                GovernanceUtils.getGovernanceArtifactConfiguration(val);

        GovernanceUtils.loadGovernanceArtifacts((UserRegistry) registry);

        try {
            GovernanceUtils.findGovernanceArtifacts("overview:name=(SampleURI2 OR SampleURI1)", registry,
                                                    governanceArtifactConfiguration.getMediaType());
        } catch (GovernanceException e) {
            assertEquals("Attribute Search Service not Found", e.getMessage());
            assertNull(e.getCause());
        }

    }
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:22,代码来源:TestBuildSearchCriteria.java

示例15: createLCStateChange

import org.wso2.carbon.governance.api.exception.GovernanceException; //导入依赖的package包/类
private AssetStateChange createLCStateChange(Map<String, Object> map) throws GovernanceException {
    String lc = (String) map.get(ATTR_LIFECYCLE);
    String action = (String) map.get(ATTR_ACTION);
    if (lc != null && action != null) {
        AssetStateChange stateChange = new AssetStateChange();
        stateChange.setLifecycle(lc);
        stateChange.setAction(action);
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            String key = entry.getKey();
            if (key.contains("item_")) {
                String itemNumber = key.substring(5);
                stateChange.addParameter(itemNumber.concat(".item"), (String) entry.getValue());
            }
        }
        return stateChange;
    }
    throw new GovernanceException("Can't create LCState");
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:19,代码来源:LCStateMessageBodyReader.java


注:本文中的org.wso2.carbon.governance.api.exception.GovernanceException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。