Package org.rhq.core.clientapi.agent.upgrade

Examples of org.rhq.core.clientapi.agent.upgrade.ResourceUpgradeResponse


        for (ResourceUpgradeRequest request : upgradeRequests) {
            Resource existingResource = this.entityManager.find(Resource.class, request.getResourceId());
            if (existingResource != null) {
                try {
                    ResourceUpgradeResponse upgradedData = upgradeResource(existingResource, request,
                        allowGenericPropertiesUpgrade);
                    if (upgradedData != null) {
                        result.add(upgradedData);
                    }
                } catch (Exception e) {
View Full Code Here


                upgradeRequest.getTimestamp());
            resourceManager.addResourceError(error);
            return null;
        }

        ResourceUpgradeResponse ret = new ResourceUpgradeResponse();
        ret.setResourceId(resource.getId());

        if (upgradeRequest.hasSomethingToUpgrade()) {

            String resourceKey = upgradeRequest.getNewResourceKey();
            String name = upgradeRequest.getNewName();
            String description = upgradeRequest.getNewDescription();
            String version = upgradeRequest.getNewVersion();
            boolean isUpgradeAll = allowGenericPropertiesUpgrade || upgradeRequest.isForceGenericPropertyUpgrade();

            StringBuilder logMessage = new StringBuilder("Resource [").append(resource.toString()).append(
                "] upgraded [");

            if (needsUpgrade(resource.getResourceKey(), resourceKey)) {
                resource.setResourceKey(resourceKey);
                logMessage.append("resourceKey, ");
                ret.setUpgradedResourceKey(resource.getResourceKey());
            }

            if (isUpgradeAll && needsUpgrade(resource.getName(), name)) {
                resource.setName(name);
                logMessage.append("name, ");
                ret.setUpgradedResourceName(resource.getName());
            }

            if (isUpgradeAll && needsUpgrade(resource.getDescription(), description)) {
                resource.setDescription(description);
                logMessage.append("description, ");
                ret.setUpgradedResourceDescription(resource.getDescription());
            }

            if (needsUpgrade(resource.getVersion(), version)) {
                resource.setVersion(version);
                logMessage.append("version, ");
                ret.setUpgradedResourceVersion(resource.getVersion());
            }

            // If provided, assume the new plugin config should replace the old plugin config in its entirety.
            // Use a deep copy without ids as the updgardeRequest config may contain entity config props.
            // Note: we explicitly do not call configurationManager.updatePluginConfiguration() because the
            // agent is already updated to the new configuration. Instead we call the dedicated local method
            // supporting this use case.
            Configuration pluginConfig = upgradeRequest.getNewPluginConfiguration();
            if (null != pluginConfig) {
                pluginConfig = pluginConfig.deepCopy(false);
                PluginConfigurationUpdate update = configurationManager.upgradePluginConfiguration(
                    subjectManager.getOverlord(), resource.getId(), pluginConfig);
                ret.setUpgradedResourcePluginConfiguration(update.getResource().getPluginConfiguration());
            }

            // finally let's remove the potential previous upgrade error. we've now successfully
            // upgraded the resource.
            List<ResourceError> upgradeErrors = resourceManager.findResourceErrors(subjectManager.getOverlord(),
View Full Code Here

                                return request.getResourceId();
                            }
                        }, ID_COMPARATOR);
                        if (resource != null) {

                            ResourceUpgradeResponse resp = new ResourceUpgradeResponse();
                            resp.setResourceId(resource.getId());

                            if (request.getNewDescription() != null) {
                                resource.setDescription(request.getNewDescription());
                                resp.setUpgradedResourceDescription(resource.getDescription());
                            }

                            if (request.getNewVersion() != null) {
                                resource.setVersion(request.getNewVersion());
                                resp.setUpgradedResourceVersion(resource.getVersion());
                            }

                            if (request.getNewName() != null) {
                                resource.setName(request.getNewName());
                                resp.setUpgradedResourceName(resource.getName());
                            }

                            if (request.getNewResourceKey() != null) {
                                resource.setResourceKey(request.getNewResourceKey());
                                resp.setUpgradedResourceKey(resource.getResourceKey());
                            }

                            if (request.getNewPluginConfiguration() != null) {
                                resource.setPluginConfiguration(request.getNewPluginConfiguration());
                                resp.setUpgradedResourcePluginConfiguration(resource.getPluginConfiguration());
                            }

                            if (request.getUpgradeErrorMessage() != null) {
                                ResourceError error = new ResourceError(resource, ResourceErrorType.UPGRADE,
                                    request.getUpgradeErrorMessage(), request.getUpgradeErrorStackTrace(),
View Full Code Here

                                return request.getResourceId();
                            }
                        }, ID_COMPARATOR);
                        if (resource != null) {

                            ResourceUpgradeResponse resp = new ResourceUpgradeResponse();
                            resp.setResourceId(resource.getId());

                            if (request.getNewDescription() != null) {
                                resource.setDescription(request.getNewDescription());
                                resp.setUpgradedResourceDescription(resource.getDescription());
                            }

                            if (request.getNewVersion() != null) {
                                resource.setVersion(request.getNewVersion());
                                resp.setUpgradedResourceVersion(resource.getVersion());
                            }

                            if (request.getNewName() != null) {
                                resource.setName(request.getNewName());
                                resp.setUpgradedResourceName(resource.getName());
                            }

                            if (request.getNewResourceKey() != null) {
                                resource.setResourceKey(request.getNewResourceKey());
                                resp.setUpgradedResourceKey(resource.getResourceKey());
                            }

                            if (request.getNewPluginConfiguration() != null) {
                                resource.setPluginConfiguration(request.getNewPluginConfiguration());
                                resp.setUpgradedResourcePluginConfiguration(resource.getPluginConfiguration());
                            }

                            if (request.getUpgradeErrorMessage() != null) {
                                ResourceError error = new ResourceError(resource, ResourceErrorType.UPGRADE,
                                    request.getUpgradeErrorMessage(), request.getUpgradeErrorStackTrace(),
View Full Code Here

TOP

Related Classes of org.rhq.core.clientapi.agent.upgrade.ResourceUpgradeResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.