List of usage examples for javax.ejb TransactionAttributeType NOT_SUPPORTED
TransactionAttributeType NOT_SUPPORTED
To view the source code for javax.ejb TransactionAttributeType NOT_SUPPORTED.
Click Source Link
NOT_SUPPORTED
with an unspecified transaction context. From source file:org.rhq.enterprise.server.alert.AlertNotificationManagerBean.java
/** * @throws AlertDefinitionUpdateException if the {@link AlertNotification} is not associated with a known sender */// www.j ava 2s.c om @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public AlertNotification addAlertNotification(Subject user, int alertDefinitionId, AlertNotification notification) throws AlertDefinitionUpdateException { List<String> validSenders = listAllAlertSenders(); if (validSenders.contains(notification.getSenderName()) == false) { throw new AlertDefinitionUpdateException( notification.getSenderName() + " is not a valid alert sender, options are: " + validSenders); } AlertDefinition definition = getDetachedAlertDefinition(alertDefinitionId); List<AlertNotification> notifications = definition.getAlertNotifications(); notifications.add(notification); postProcessAlertDefinition(definition); return notification; }
From source file:org.rhq.enterprise.server.alert.AlertNotificationManagerBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void updateAlertNotification(Subject subject, int alertDefinitionId, AlertNotification notification) { AlertDefinition alertDefinition = getDetachedAlertDefinition(alertDefinitionId); // permissions check first /* //from ww w. j a v a 2 s.c o m * NULL notifications used to perform cascade updates from template and group level for alert senders * that leverage custom UIs, which have a completely external methodology for loading/saving the data * into and out of configuration object(s) associated with an AlertNotification. */ if (notification != null) { // remove then add is a cheap way of performing an update List<AlertNotification> notifications = alertDefinition.getAlertNotifications(); notifications.remove(notification); notifications.add(notification); } postProcessAlertDefinition(alertDefinition); }
From source file:org.rhq.enterprise.server.alert.AlertNotificationManagerBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public int removeNotifications(Subject subject, Integer alertDefinitionId, Integer[] notificationIds) { AlertDefinition alertDefinition = getDetachedAlertDefinition(alertDefinitionId); // permissions check first if ((notificationIds == null) || (notificationIds.length == 0)) { return 0; }// ww w .j a va2s. c o m Set<Integer> notificationIdSet = new HashSet<Integer>(Arrays.asList(notificationIds)); List<AlertNotification> notifications = alertDefinition.getAlertNotifications(); List<AlertNotification> toBeRemoved = new ArrayList<AlertNotification>(); int removed = 0; for (AlertNotification notification : notifications) { if (notificationIdSet.contains(notification.getId())) { toBeRemoved.add(notification); removed--; } } alertDefinition.getAlertNotifications().removeAll(toBeRemoved); postProcessAlertDefinition(alertDefinition); return removed; }
From source file:org.rhq.enterprise.server.alert.AlertTemplateManagerBean.java
@RequiredPermission(Permission.MANAGE_SETTINGS) @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public int createAlertTemplate(Subject user, AlertDefinition alertTemplate, Integer resourceTypeId) throws InvalidAlertDefinitionException, ResourceTypeNotFoundException, AlertDefinitionCreationException { if (LOG.isDebugEnabled()) { LOG.debug("createAlertTemplate: " + alertTemplate); }// ww w.j a v a 2s. c o m ResourceType type = resourceTypeManager.getResourceTypeById(user, resourceTypeId); alertTemplate.setResourceType(type); // mark this as an alert "template" definition int alertTemplateId = 0; try { alertTemplateId = alertDefinitionManager.createAlertDefinition(user, alertTemplate, null); } catch (Throwable t) { throw new AlertDefinitionCreationException( "Could not create alertTemplate for " + type + " with data " + alertTemplate.toSimpleString(), t); } Subject overlord = subjectManager.getOverlord(); Throwable firstThrowable = null; List<Integer> resourceIdsForType = getCommittedResourceIdsNeedingTemplateApplication(user, alertTemplateId, resourceTypeId); List<Integer> resourceIdsInError = new ArrayList<Integer>(); for (Integer resourceId : resourceIdsForType) { try { // construct the child AlertDefinition childAlertDefinition = new AlertDefinition(alertTemplate); childAlertDefinition.setParentId(alertTemplate.getId()); // persist the child using overlord alertDefinitionManager.createAlertDefinition(overlord, childAlertDefinition, resourceId); } catch (Throwable t) { // continue on error, create as many as possible if (firstThrowable == null) { firstThrowable = t; } resourceIdsInError.add(resourceId); } } if (firstThrowable != null) { throw new AlertDefinitionCreationException("Could not create child alert definition for Resources " + resourceIdsInError + " with template" + alertTemplate.toSimpleString(), firstThrowable); } return alertTemplateId; }
From source file:org.rhq.enterprise.server.alert.AlertTemplateManagerBean.java
@RequiredPermission(Permission.MANAGE_SETTINGS) @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public AlertDefinition updateAlertTemplate(Subject user, AlertDefinition alertTemplate, boolean purgeInternals) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException, AlertNotificationValidationException { if (LOG.isDebugEnabled()) { LOG.debug("updateAlertTemplate: " + alertTemplate); }//from w w w.j a v a 2 s . c o m // first update the actual alert template AlertDefinition updated = null; try { updated = alertDefinitionManager.updateAlertDefinition(user, alertTemplate.getId(), alertTemplate, purgeInternals); // do not allow direct undeletes of an alert definition } catch (Throwable t) { throw new AlertDefinitionUpdateException( "Failed to update an AlertTemplate " + alertTemplate.toSimpleString(), t); } // overlord will be used for all system-side effects as a result of updating this alert template Subject overlord = subjectManager.getOverlord(); Throwable firstThrowable = null; // update all of the definitions that were spawned from alert templates List<Integer> alertDefinitions = getChildrenAlertDefinitionIds(overlord, alertTemplate.getId()); if (LOG.isDebugEnabled()) { LOG.debug("Need to update the following children alert definition ids: " + alertDefinitions); } List<Integer> alertDefinitionIdsInError = new ArrayList<Integer>(); for (Integer alertDefinitionId : alertDefinitions) { try { alertDefinitionManager.updateAlertDefinition(overlord, alertDefinitionId, alertTemplate, purgeInternals); } catch (Throwable t) { // continue on error, update as many as possible if (firstThrowable == null) { firstThrowable = t; } alertDefinitionIdsInError.add(alertDefinitionId); } } // if the user deleted the alert definition spawned from a template, a cascade update will recreate it List<Integer> resourceIds = getCommittedResourceIdsNeedingTemplateApplication(overlord, alertTemplate.getId(), getResourceTypeIdForAlertTemplateId(alertTemplate.getId())); if (LOG.isDebugEnabled()) { LOG.debug("Need to re-create alert definitions for the following resource ids: " + resourceIds); } List<Integer> resourceIdsInError = new ArrayList<Integer>(); for (Integer resourceId : resourceIds) { try { // construct the child AlertDefinition childAlertDefinition = new AlertDefinition(alertTemplate); childAlertDefinition.setParentId(alertTemplate.getId()); // persist the child alertDefinitionManager.createAlertDefinition(overlord, childAlertDefinition, resourceId); } catch (Throwable t) { // continue on error, update as many as possible if (firstThrowable == null) { firstThrowable = t; } resourceIdsInError.add(resourceId); } } if (firstThrowable != null) { StringBuilder error = new StringBuilder(); if (alertDefinitionIdsInError.size() != 0) { error.append("Failed to update child AlertDefinitions " + alertDefinitionIdsInError + "; "); } if (resourceIdsInError.size() != 0) { error.append( "Failed to re-create child AlertDefinition for Resources " + resourceIdsInError + "; "); } throw new AlertDefinitionUpdateException(error.toString(), firstThrowable); } return updated; }
From source file:org.rhq.enterprise.server.alert.GroupAlertDefinitionManagerBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public int createGroupAlertDefinitions(Subject subject, AlertDefinition groupAlertDefinition, Integer resourceGroupId) throws InvalidAlertDefinitionException, AlertDefinitionCreationException { ResourceGroup group = resourceGroupManager.getResourceGroupById(subject, resourceGroupId, null); groupAlertDefinition.setResourceGroup(group); int groupAlertDefinitionId = 0; try {/*w w w . j av a 2s. co m*/ groupAlertDefinitionId = alertDefinitionManager.createAlertDefinition(subject, groupAlertDefinition, null); } catch (Throwable t) { throw new AlertDefinitionCreationException("Could not create groupAlertDefinitions for " + group + " with data " + groupAlertDefinition.toSimpleString(), t); } Subject overlord = subjectManager.getOverlord(); Throwable firstThrowable = null; List<Integer> resourceIdsForGroup = getCommittedResourceIdsNeedingGroupAlertDefinitionApplication(subject, groupAlertDefinitionId, resourceGroupId); List<Integer> resourceIdsInError = new ArrayList<Integer>(); for (Integer resourceId : resourceIdsForGroup) { try { // construct the child AlertDefinition childAlertDefinition = new AlertDefinition(groupAlertDefinition); childAlertDefinition.setGroupAlertDefinition(groupAlertDefinition); // persist the child alertDefinitionManager.createAlertDefinition(overlord, childAlertDefinition, resourceId); } catch (Throwable t) { // continue on error, create as many as possible if (firstThrowable == null) { firstThrowable = t; } resourceIdsInError.add(resourceId); } } if (firstThrowable != null) { throw new AlertDefinitionCreationException("Could not create alert definition child for Resources " + resourceIdsInError + " with group " + groupAlertDefinition.toSimpleString(), firstThrowable); } return groupAlertDefinitionId; }
From source file:org.rhq.enterprise.server.alert.GroupAlertDefinitionManagerBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public AlertDefinition updateGroupAlertDefinitions(Subject subject, AlertDefinition groupAlertDefinition, boolean purgeInternals) throws InvalidAlertDefinitionException, AlertDefinitionUpdateException { if (LOG.isDebugEnabled()) { LOG.debug("updateGroupAlertDefinition: " + groupAlertDefinition); }// ww w.j a v a 2s .com // first update the actual alert group alert definition AlertDefinition updated = null; try { updated = alertDefinitionManager.updateAlertDefinition(subject, groupAlertDefinition.getId(), groupAlertDefinition, purgeInternals); // do not allow direct undeletes of an alert definition } catch (Throwable t) { throw new AlertDefinitionUpdateException( "Failed to update a GroupAlertDefinition: " + groupAlertDefinition.toSimpleString(), t); } // overlord will be used for all system-side effects as a result of updating this alert template Subject overlord = subjectManager.getOverlord(); Throwable firstThrowable = null; // update all of the definitions that were spawned from this group alert definition List<Integer> alertDefinitions = getChildrenAlertDefinitionIds(overlord, groupAlertDefinition.getId()); if (LOG.isDebugEnabled()) { LOG.debug("Need to update the following children alert definition ids: " + alertDefinitions); } List<Integer> alertDefinitionIdsInError = new ArrayList<Integer>(); for (Integer alertDefinitionId : alertDefinitions) { try { alertDefinitionManager.updateAlertDefinition(overlord, alertDefinitionId, groupAlertDefinition, purgeInternals); } catch (Throwable t) { // continue on error, update as many as possible if (firstThrowable == null) { firstThrowable = t; } alertDefinitionIdsInError.add(alertDefinitionId); } } // if the subject deleted the alertDefinition spawned from a groupAlertDefinition, cascade update will recreate it List<Integer> resourceIds = getCommittedResourceIdsNeedingGroupAlertDefinitionApplication(overlord, groupAlertDefinition.getId(), getResourceGroupIdForAlertDefinitionId(groupAlertDefinition.getId())); List<Integer> resourceIdsInError = new ArrayList<Integer>(); for (Integer resourceId : resourceIds) { try { // construct the child AlertDefinition childAlertDefinition = new AlertDefinition(groupAlertDefinition); childAlertDefinition.setGroupAlertDefinition(groupAlertDefinition); // persist the child alertDefinitionManager.createAlertDefinition(overlord, childAlertDefinition, resourceId); } catch (Throwable t) { // continue on error, update as many as possible if (firstThrowable == null) { firstThrowable = t; } resourceIdsInError.add(resourceId); } } if (firstThrowable != null) { StringBuilder error = new StringBuilder(); if (alertDefinitionIdsInError.size() != 0) { error.append("Failed to update child AlertDefinitions " + alertDefinitionIdsInError + " ; "); } if (resourceIdsInError.size() != 0) { error.append( "Failed to re-create child AlertDefinition for Resources " + resourceIdsInError + "; "); } throw new AlertDefinitionUpdateException(error.toString(), firstThrowable); } return updated; }
From source file:org.rhq.enterprise.server.bundle.BundleManagerBean.java
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @RequiredPermission(Permission.MANAGE_BUNDLE) public BundleScheduleRequest getScheduleRequest(Subject subject, int resourceDeploymentId, boolean isCleanDeployment, boolean isRevert) throws Exception { // make sure the deployment contains the info required by the schedule service BundleResourceDeploymentCriteria brdc = new BundleResourceDeploymentCriteria(); brdc.addFilterId(resourceDeploymentId); brdc.fetchResource(true);/*from w w w . j a v a2 s. co m*/ brdc.fetchBundleDeployment(true); List<BundleResourceDeployment> resourceDeployments = bundleManager .findBundleResourceDeploymentsByCriteria(subject, brdc); if (null == resourceDeployments || resourceDeployments.isEmpty()) { throw new IllegalArgumentException( "Can not deploy using invalid resourceDeploymentId [" + resourceDeploymentId + "]."); } BundleResourceDeployment resourceDeployment = resourceDeployments.get(0); ResourceCriteria rc = new ResourceCriteria(); rc.addFilterId(resourceDeployment.getResource().getId()); rc.fetchTags(true); Resource resource = resourceManager.findResourcesByCriteria(subject, rc).get(0); resourceDeployment.setResource(resource); // make sure the deployment contains the info required by the schedule service BundleDeploymentCriteria bdc = new BundleDeploymentCriteria(); bdc.addFilterId(resourceDeployment.getBundleDeployment().getId()); bdc.fetchBundleVersion(true); bdc.fetchConfiguration(true); bdc.fetchDestination(true); BundleDeployment deployment = bundleManager.findBundleDeploymentsByCriteria(subject, bdc).get(0); BundleCriteria bc = new BundleCriteria(); bc.addFilterDestinationId(deployment.getDestination().getId()); Bundle bundle = bundleManager.findBundlesByCriteria(subject, bc).get(0); ResourceTypeCriteria rtc = new ResourceTypeCriteria(); rtc.addFilterBundleTypeId(bundle.getBundleType().getId()); ResourceType resourceType = resourceTypeManager.findResourceTypesByCriteria(subject, rtc).get(0); bundle.getBundleType().setResourceType(resourceType); deployment.getBundleVersion().setBundle(bundle); deployment.getDestination().setBundle(bundle); resourceDeployment.setBundleDeployment(deployment); // now scrub the hibernate entity to make it a pojo suitable for sending to the client HibernateDetachUtility.nullOutUninitializedFields(resourceDeployment, SerializationType.SERIALIZATION); BundleScheduleRequest request = new BundleScheduleRequest(resourceDeployment); request.setCleanDeployment(isCleanDeployment); request.setRevert(isRevert); entityManager.clear(); return request; }
From source file:org.rhq.enterprise.server.cloud.instance.CacheConsistencyManagerBean.java
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void reloadServerCacheIfNeeded() { // try reload the global cache separate from the agent caches for purposes of isolated failures reloadGlobalCacheIfNeeded();//from w w w. java 2 s .c o m reloadAgentCachesAsNeeded(); }
From source file:org.rhq.enterprise.server.cloud.StorageNodeManagerBean.java
@Override @RequiredPermission(Permission.MANAGE_SETTINGS) @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void deployStorageNode(Subject subject, StorageNode storageNode) { StorageNodeCriteria c = new StorageNodeCriteria(); c.addFilterId(storageNode.getId());/*from w w w . java 2s .c om*/ c.fetchResource(true); List<StorageNode> storageNodes = storageNodeManager.findStorageNodesByCriteria(subject, c); if (storageNodes.isEmpty()) { throw new RuntimeException("Storage node not found, can not undeploy " + storageNode); } storageNode = storageNodes.get(0); switch (storageNode.getOperationMode()) { case INSTALLED: storageNodeOperationsHandler.setMode(storageNode, OperationMode.ANNOUNCE); case ANNOUNCE: storageNodeManager.resetInNewTransaction(); storageNodeOperationsHandler.announceStorageNode(subject, storageNode); break; case BOOTSTRAP: storageNodeManager.resetInNewTransaction(); storageNodeOperationsHandler.bootstrapStorageNode(subject, storageNode); break; case ADD_MAINTENANCE: storageNodeManager.resetInNewTransaction(); storageNodeOperationsHandler.performAddNodeMaintenance(subject, storageNode); break; default: // TODO what do we do with/about maintenance mode? // We do not want to deploying a node that is in the process of being // undeployed. It is too hard to make sure we are in an inconsistent state. // Instead finish the undeployment and redeploy the storage node. throw new RuntimeException("Cannot deploy " + storageNode); } }