Package org.rhq.core.domain.resource

Examples of org.rhq.core.domain.resource.DeleteResourceHistory


        if (LOG.isDebugEnabled()) {
            LOG.debug("Received call to complete delete resource: " + response);
        }

        // Load the persisted history entry
        DeleteResourceHistory history = entityManager.find(DeleteResourceHistory.class, response.getRequestId());

        // There is some inconsistency if we're completing a request that was not in the database
        if (history == null) {
            LOG.error("Attempting to complete a request that was not found in the database: " + response.getRequestId());
            return;
        }

        // Update the history entry
        history.setErrorMessage(response.getErrorMessage());
        history.setStatus(response.getStatus());

        // If successful mark resource as deleted and uninventory children
        if (response.getStatus() == DeleteResourceStatus.SUCCESS) {
            Resource resource = history.getResource();

            // get doomed children
            Set<Resource> children = resource.getChildResources();

            // set the resource deleted and update the db in case it matters to the child operations
View Full Code Here


    public DeleteResourceHistory persistDeleteHistory(Subject user, int resourceId) {
        // Load relationships
        Resource resource = entityManager.find(Resource.class, resourceId);

        // Persist and establish relationships
        DeleteResourceHistory history = new DeleteResourceHistory(resource, user.getName());
        history.setStatus(DeleteResourceStatus.IN_PROGRESS);

        entityManager.persist(history);
        resource.addDeleteResourceHistory(history);

        // Caller will need this
View Full Code Here

            throw new PermissionException("User [" + subject.getName()
                + "] does not have permission to delete resource [" + resource + "]");
        }

        // Persist in separate transaction so it is committed immediately, before the request is sent to the agent
        DeleteResourceHistory persistedHistory = resourceFactoryManager.persistDeleteHistory(subject, resourceId);

        // Package into transfer object
        DeleteResourceRequest request = new DeleteResourceRequest(persistedHistory.getId(), resourceId);

        try {
            AgentClient agentClient = agentManager.getAgentClient(agent);
            ResourceFactoryAgentService resourceFactoryAgentService = agentClient.getResourceFactoryAgentService();
            resourceFactoryAgentService.deleteResource(request);

            return persistedHistory;
        } catch (CannotConnectException e) {
            LOG.error("Error while sending delete resource request to agent service", e);

            // Submit the error as a failure response
            String errorMessage = ThrowableUtil.getAllMessages(e);
            DeleteResourceResponse response = new DeleteResourceResponse(persistedHistory.getId(),
                DeleteResourceStatus.FAILURE, errorMessage);
            resourceFactoryManager.completeDeleteResourceRequest(response);

            throw new CannotConnectToAgentException("Error while sending delete resource request to agent service", e);
        } catch (Exception e) {
            LOG.error("Error while sending delete resource request to agent service", e);

            // Submit the error as a failure response
            String errorMessage = ThrowableUtil.getAllMessages(e);
            DeleteResourceResponse response = new DeleteResourceResponse(persistedHistory.getId(),
                DeleteResourceStatus.FAILURE, errorMessage);
            resourceFactoryManager.completeDeleteResourceRequest(response);

            throw new RuntimeException("Error while sending delete resource request to agent service", e);
        }
View Full Code Here

                    if (DataSource.TYPE_CREATE.equals(typeString)) {
                        CreateResourceHistory history = (CreateResourceHistory) selectedRows[0]
                            .getAttributeAsObject(DataSource.Field.OBJECT);
                        detailsView = new ChildHistoryDetails(history);
                    } else if (DataSource.TYPE_DELETE.equals(typeString)) {
                        DeleteResourceHistory history = (DeleteResourceHistory) selectedRows[0]
                            .getAttributeAsObject(DataSource.Field.OBJECT);
                        detailsView = new ChildHistoryDetails(history);
                    }
                    new DetailsWindow(detailsView).show();
                }
View Full Code Here

                record.setAttribute(Field.SUBJECT_NAME, history.getSubjectName());
                record.setAttribute(Field.CREATED_DATE, history.getCreatedDate());
                record.setAttribute(Field.LAST_MODIFIED_TIME, history.getLastModifiedDate());
                record.setAttribute(Field.STATUS, history.getStatus().name());
            } else if (from instanceof DeleteResourceHistory) {
                DeleteResourceHistory history = (DeleteResourceHistory) from;
                record.setAttribute(Field.TYPE, TYPE_DELETE);
                record.setAttribute(Field.ID, history.getId());
                record.setAttribute(Field.SUBJECT_NAME, history.getSubjectName());
                record.setAttribute(Field.CREATED_DATE, history.getCreatedDate());
                record.setAttribute(Field.LAST_MODIFIED_TIME, history.getLastModifiedDate());
                record.setAttribute(Field.STATUS, history.getStatus().name());
            } else {
                CoreGUI.getErrorHandler().handleError("invalid child history type: " + from.getClass()); // should never occur
            }

            return record;
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.DeleteResourceHistory

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.