@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void removeLocalizedValue(long objectKey, LocalizedObjectTypes objectType, String localeString) { Query query = dm .createNamedQuery("LocalizedResource.deleteForObjectAndTypeAndLocale"); query.setParameter("objectKey", Long.valueOf(objectKey)); query.setParameter("objectType", objectType); query.setParameter("locale", localeString); query.executeUpdate(); }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public InstanceStatus activateInstance(String instanceId, ProvisioningSettings settings) throws APPlatformException { logger.info("activateInstance({})", LogAndExceptionConverter.getLogText(instanceId, settings)); try { StateMachine.initializeProvisioningSettings(settings, "activate_vm.xml"); InstanceStatus result = new InstanceStatus(); result.setChangedParameters(settings.getParameters()); return result; } catch (Throwable t) { throw LogAndExceptionConverter.createAndLogPlatformException(t, Context.ACTIVATION); } }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public List<Marketplace> getMarketplacesForSupplier() { Organization supplier = ds.getCurrentUser().getOrganization(); Query query = ds.createNamedQuery( "Marketplace.findMarketplacesForPublishingForOrg"); query.setParameter("organization_tkey", Long.valueOf(supplier.getKey())); query.setParameter("publishingAccessGranted", PublishingAccess.PUBLISHING_ACCESS_GRANTED); query.setParameter("publishingAccessDenied", PublishingAccess.PUBLISHING_ACCESS_DENIED); List<Marketplace> marketplaceList = ParameterizedTypes .list(query.getResultList(), Marketplace.class); return marketplaceList; }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<JmdTaskData> getDataList(Long taskId) { Connection connection = null; List<JmdTaskData> result = new ArrayList<>(); try { connection = ds.getConnection(); result = getDataList(connection, taskId); } catch (Exception e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "RESULT:{0}", result); } return result; }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setStopEnabled(Long taskId, Boolean stopEnabled) { Connection connection = null; try { connection = ds.getConnection(); new OraSqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.STOP_ENABLED(), stopEnabled) .WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId) ); } catch (SQLException e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setFinished(Long taskId) { Connection connection = null; try { connection = ds.getConnection(); Column currentTimestamp = new ColumnFunction("id", "current_timestamp", DataType.DATE); new H2SqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.FINISHED(), currentTimestamp) .WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId) ); } catch (SQLException e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public boolean removeOverdueOrganizations(long currentTime) { boolean successfulExecution = true; List<PlatformUser> overdueOrganizationAdmins = im .getOverdueOrganizationAdmins(currentTime); for (PlatformUser userToBeRemoved : overdueOrganizationAdmins) { try { // call has to be made by calling into the container again, so // that the new transactional behaviour is considered. prepareForNewTransaction().removeOverdueOrganization( userToBeRemoved.getOrganization()); } catch (Exception e) { successfulExecution = false; logger.logError(Log4jLogger.SYSTEM_LOG, e, LogMessageIdentifier.ERROR_ORGANIZATION_DELETION_FAILED, Long.toString( userToBeRemoved.getOrganization().getKey())); // logging is sufficient for now, so simply proceed } } return successfulExecution; }
@RolesAllowed({"Application"}) @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) @Override public void checkApplicationUserWithRemoteOutboundConnection(String userName, int invocations) { Principal caller = context.getCallerPrincipal(); if(!userName.equals(caller.getName())) { log.severe("Given user name '" + userName + "' not equal to real use name '" + caller.getName() + "'"); }else{ log.info("Try to invoke remote SimpleBean with user '" + userName + "' " + invocations + " times"); try { Simple proxy = (Simple)new InitialContext().lookup("ejb:EAP71-PLAYGROUND-server/ejb/SimpleBean!" + Simple.class.getName()); for(int i = 0 ; i < invocations ; i++) { proxy.checkApplicationUser(userName); } } catch (NamingException e) { throw new RuntimeException("No target Bean found!", e); } } return; }
/** * If BES is available process failed serviceInstances and reset * APP_SUSPEND. * * @param isRestartAPP * if true the method invoked by restartAPP else invoked by * ControllerUI * @return If true restart successfully else restart unsuccessfully */ @TransactionAttribute(TransactionAttributeType.REQUIRED) public boolean restart(boolean isRestartAPP) { final String messageKey = "mail_bes_notification_connection_success"; boolean isSuspendedByApp = false; if (!besDAO.isBESAvalible()) { if (isRestartAPP) { sendMailToAppAdmin("mail_bes_notification_error_app_admin"); } return false; } List<ServiceInstance> serviceInstances = instanceDAO .getInstancesSuspendedbyApp(); for (ServiceInstance instance : serviceInstances) { String actionLink = getResumeLinkForInstance(instance); if (actionLink == null || actionLink.isEmpty()) { isSuspendedByApp = true; continue; } sendActionMail(true, instance, messageKey, null, actionLink, false); instance.setSuspendedByApp(false); } configService .setAPPSuspend(Boolean.valueOf(isSuspendedByApp).toString()); return true; }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public String getLocalizedTextFromBundle(LocalizedObjectTypes objectType, Marketplace marketplace, String localeString, String key) { String result = null; if (objectType.getSource() == InformationSource.RESOURCE_BUNDLE) { result = getLocalizedTextFromResourceBundle( objectType.getSourceLocation(), marketplace, localeString, key); } else if (objectType.getSource() == InformationSource.DATABASE_AND_RESOURCE_BUNDLE) { result = getLocalizedTextFromResourceBundleForPlatformObjects( objectType.getSourceLocation(), localeString, key); } else { logger.logWarn(Log4jLogger.SYSTEM_LOG, LogMessageIdentifier.WARN_NON_SUPPORTED_LOCALE, String.valueOf(objectType.getSource())); } return result; }
/** * Initialize the timer for polling for the services */ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void initTimers_internal() { Collection<Timer> timers = timerService.getTimers(); boolean appTimerExist = false; for (Timer timerAPP : timers) { if (APP_TIMER_INFO.equals(timerAPP.getInfo())) { appTimerExist = true; } } if (!appTimerExist) { logger.info("Timer create."); try { String timerIntervalSetting = configService .getProxyConfigurationSetting( PlatformConfigurationKey.APP_TIMER_INTERVAL); long interval = Long.parseLong(timerIntervalSetting); timerService.createTimer(0, interval, APP_TIMER_INFO); } catch (ConfigurationException e) { timerService.createTimer(0, DEFAULT_TIMER_INTERVAL, APP_TIMER_INFO); logger.info( "Timer interval not set, switch to default 15 sec."); } } }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setQueueId(Long taskId, String queueId) { Connection connection = null; try { connection = ds.getConnection(); new OraSqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.QUEUE_ID(), queueId) .WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId) ); } catch (SQLException e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } }
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void unlockServiceInstance(String controllerId, String instanceId) throws APPlatformException { ServiceInstance service = null; try { service = instanceDAO.getInstanceById(controllerId, instanceId); } catch (ServiceInstanceNotFoundException e) { throw new APPlatformException(e.getMessage()); } if (service.isLocked()) { LOGGER.debug("unlock service instance {}", instanceId); service.setLocked(false); em.flush(); } }
@Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void abortAsyncSubscription(UUID subscriptionUUID) throws ObjectNotFoundException, SubscriptionStateException, OrganizationAuthoritiesException, OperationNotPermittedException { ArgumentValidator.notNull("subscriptionUUID", subscriptionUUID); VOSubscription subscription = getSubscription(subscriptionUUID); if (subscription == null) { throw new ObjectNotFoundException("Subscription with UUID " + subscriptionUUID + " not found!"); } completeAsyncSubscription(subscription.getSubscriptionId(), subscription.getOrganizationId(), null, false); }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public DomainHistoryObject<?> findLastHistory(DomainObject<?> obj) { if (obj == null) { return null; } String className = DomainObject.getDomainClass(obj).getName(); String histClassName = className .substring(className.lastIndexOf(".") + 1) + "History"; String qryString = histClassName + ".findByObjectDesc"; Query query = em.createNamedQuery(qryString); query.setParameter("objKey", Long.valueOf(obj.getKey())); query.setMaxResults(1); List<?> qryresult = query.getResultList(); if (qryresult.isEmpty()) { return null; } return (DomainHistoryObject<?>) qryresult.get(0); }
/** * Starts the deletion of an application instance. * <p> * The internal status <code>DELETION_REQUESTED</code> is stored as a * controller configuration setting. It is evaluated and handled by the * status dispatcher, which is invoked at regular intervals by APP through * the <code>getInstanceStatus</code> method. * * @param instanceId * the ID of the application instance to be deleted * @param settings * a <code>ProvisioningSettings</code> object specifying the * service parameters and configuration settings * @return an <code>InstanceStatus</code> instance with the overall status * of the application instance * @throws APPlatformException */ @Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public InstanceStatus deleteInstance(String instanceId, ProvisioningSettings settings) throws APPlatformException { LOGGER.info("deleteInstance({})", LogAndExceptionConverter.getLogText(instanceId, settings)); try { PropertyHandler ph = PropertyHandler.withSettings(settings); ph.setOperation(Operation.EC2_DELETION); ph.setState(FlowState.DELETION_REQUESTED); InstanceStatus result = new InstanceStatus(); result.setChangedParameters(settings.getParameters()); result.setChangedAttributes(settings.getAttributes()); return result; } catch (Throwable t) { throw LogAndExceptionConverter.createAndLogPlatformException(t, Context.DELETION); } }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void incStep(Long taskId, String processMessage) { Connection connection = null; try { connection = ds.getConnection(); Column currentTimestamp = new ColumnFunction("id1", "current_timestamp", DataType.DATE); Column inc = new ColumnFunction("id2", JMD_TASK.ACTUAL_STEP().getName() + " + 1", DataType.INTEGER); new OraSqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.LAST_UPDATE(), currentTimestamp) .SET(JMD_TASK.ACTUAL_STEP(), inc) .SET(JMD_TASK.PROCESS_MESSAGE(), processMessage) .WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId) ); } catch (SQLException e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void updateEvent(long startTimeForPeriod, long endTimeForPeriod, long subscriptionKey, BillingResult result) { final Query eventUpdateQuery = dm .createNamedQuery("GatheredEvent.setResultReferenceForEventsForSubAndPeriod"); eventUpdateQuery.setParameter("startTime", Long.valueOf(startTimeForPeriod)); eventUpdateQuery .setParameter("endTime", Long.valueOf(endTimeForPeriod)); eventUpdateQuery.setParameter("subscriptionKey", Long.valueOf(subscriptionKey)); eventUpdateQuery.setParameter("billingResult", result); eventUpdateQuery.executeUpdate(); }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setKillFlag(Long taskId, Boolean killFlag) { Connection connection = null; try { connection = ds.getConnection(); new H2SqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.KILL_FLAG(), killFlag) .WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId) ); } catch (SQLException e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public List<Organization> getSuppliersForTechnicalService( long technicalServiceKey) throws ObjectNotFoundException, OperationNotPermittedException { TechnicalProduct tpRef = ds.getReference(TechnicalProduct.class, technicalServiceKey); PermissionCheck.owns(tpRef, ds.getCurrentUser().getOrganization(), logger, null); Query query = ds .createNamedQuery("MarketingPermission.getOrgsForUsingTechnicalService"); query.setParameter("tpKey", Long.valueOf(technicalServiceKey)); query.setParameter("refType", OrganizationReferenceType.TECHNOLOGY_PROVIDER_TO_SUPPLIER); List<Organization> result = ParameterizedTypes.list( query.getResultList(), Organization.class); return result; }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public InstanceStatus deactivateInstance(String instanceId, ProvisioningSettings settings) throws APPlatformException { try { PropertyHandler paramHandler = new PropertyHandler(settings); if (paramHandler.isVirtualSystemProvisioning()) { paramHandler.setOperation(Operation.VSYSTEM_ACTIVATION); paramHandler.setState(FlowState.VSYSTEM_DEACTIVATION_REQUESTED); } else { paramHandler.setOperation(Operation.VSERVER_ACTIVATION); paramHandler.setState(FlowState.VSERVER_DEACTIVATION_REQUESTED); } InstanceStatus result = new InstanceStatus(); result.setChangedParameters(settings.getParameters()); result.setChangedAttributes(settings.getAttributes()); return result; } catch (Exception e) { logger.error("Error while scheduling instance deactivation", e); throw getPlatformException(e, "error_deactivation_overall"); } }
@TransactionAttribute(TransactionAttributeType.MANDATORY) public List<VOTimerInfo> getCurrentTimerExpirationDates() { List<VOTimerInfo> result = new ArrayList<VOTimerInfo>(); for (Timer timer : ParameterizedTypes.iterable(ctx.getTimerService() .getTimers(), Timer.class)) { Serializable info = timer.getInfo(); if (info != null && info instanceof TimerType) { TimerType type = (TimerType) info; long expirationTime = timer.getTimeRemaining() + System.currentTimeMillis(); VOTimerInfo timerInfo = new VOTimerInfo(); timerInfo.setTimerType(type.name()); timerInfo.setExpirationDate(new Date(expirationTime)); result.add(timerInfo); } } return result; }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void incStep(Long taskId, String processMessage) { Connection connection = null; try { connection = ds.getConnection(); Column currentTimestamp = new ColumnFunction("id1", "current_timestamp", DataType.DATE); Column inc = new ColumnFunction("id2", JMD_TASK.ACTUAL_STEP().getName() + " + 1", DataType.INTEGER); new H2SqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.LAST_UPDATE(), currentTimestamp) .SET(JMD_TASK.ACTUAL_STEP(), inc) .SET(JMD_TASK.PROCESS_MESSAGE(), processMessage) .WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId) ); } catch (SQLException e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } }
/** * Starts the creation of an application instance and returns the instance * ID. * <p> * The internal status <code>CREATION_REQUESTED</code> is stored as a * controller configuration setting. It is evaluated and handled by the * status dispatcher, which is invoked at regular intervals by APP through * the <code>getInstanceStatus</code> method. * * @param settings * a <code>ProvisioningSettings</code> object specifying the * service parameters and configuration settings * @return an <code>InstanceDescription</code> instance describing the * application instance * @throws APPlatformException */ @Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public InstanceDescription createInstance(ProvisioningSettings settings) throws APPlatformException { try { PropertyHandler ph = new PropertyHandler(settings); validateStackName(ph); ph.setState(FlowState.CREATION_REQUESTED); // Return generated instance information InstanceDescription id = new InstanceDescription(); id.setInstanceId("stack-" + UUID.randomUUID().toString()); id.setBaseUrl("baseurl"); id.setChangedParameters(settings.getParameters()); id.setChangedAttributes(settings.getAttributes()); LOGGER.info("createInstance({})", LogAndExceptionConverter .getLogText(id.getInstanceId(), settings)); return id; } catch (Exception t) { throw LogAndExceptionConverter.createAndLogPlatformException(t, Context.CREATION); } }
@Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void performBrokerShareCalculationRun(long startOfLastMonth, long endOfLastMonth, Long brokerKey) throws Exception { // build the result object tree BrokerRevenueShareResult brokerShareResult = new BrokerShareResultAssembler( sharesRetrievalService, billingRetrievalService).build( brokerKey, startOfLastMonth, endOfLastMonth); // calculate all shares brokerShareResult.calculateAllShares(); // serialize the result object and persist saveBillingSharesResult(startOfLastMonth, endOfLastMonth, BillingSharesResultType.BROKER, brokerShareResult, brokerKey); }
/** * Starts the deletion of an application instance. * <p> * The internal status <code>DELETION_REQUESTED</code> is stored as a * controller configuration setting. It is evaluated and handled by the * status dispatcher, which is invoked at regular intervals by APP through * the <code>getInstanceStatus</code> method. * * @param instanceId * the ID of the application instance to be deleted * @param settings * a <code>ProvisioningSettings</code> object specifying the * service parameters and configuration settings * @return an <code>InstanceStatus</code> instance with the overall status * of the application instance * @throws APPlatformException */ @Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public InstanceStatus deleteInstance(String instanceId, ProvisioningSettings settings) throws APPlatformException { LOGGER.info("deleteInstance({})", LogAndExceptionConverter.getLogText(instanceId, settings)); try { PropertyHandler ph = new PropertyHandler(settings); ph.setState(FlowState.DELETION_REQUESTED); InstanceStatus result = new InstanceStatus(); result.setChangedParameters(settings.getParameters()); result.setChangedAttributes(settings.getAttributes()); return result; } catch (Exception t) { throw LogAndExceptionConverter.createAndLogPlatformException(t, Context.DELETION); } }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void incStep(Long taskId) { Connection connection = null; try { connection = ds.getConnection(); Column currentTimestamp = new ColumnFunction("id1", "current_timestamp", DataType.DATE); Column inc = new ColumnFunction("id2", JMD_TASK.ACTUAL_STEP().getName() + " + 1", DataType.INTEGER); new H2SqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.LAST_UPDATE(), currentTimestamp) .SET(JMD_TASK.ACTUAL_STEP(), inc) .WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId) ); } catch (SQLException e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setInterruptEnabled(Long taskId, Boolean interruptEnabled) { Connection connection = null; try { connection = ds.getConnection(); new H2SqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.INTERRUPT_ENABLED(), interruptEnabled) .WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId) ); } catch (SQLException e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void incStepToTotal(Long taskId) { Connection connection = null; try { connection = ds.getConnection(); Column currentTimestamp = new ColumnFunction("id", "current_timestamp", DataType.DATE); new H2SqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.LAST_UPDATE(), currentTimestamp) .SET(JMD_TASK.ACTUAL_STEP(), JMD_TASK.TOTAL_STEP()) .WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId) ); } catch (SQLException e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } }
@Test(expected = IOException.class) public void testCallWithApplicationException2() throws Exception { @TransactionAttribute(TransactionAttributeType.NEVER) class Bean implements Callable<Void> { public Void call() throws Exception { throw new IOException(); } } DeployedSessionBean bean = new DeployedSessionBean(tmStub, sessionContext, new Bean()); bean.getInterfaceOrClass(Callable.class).call(); }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public InstanceStatus notifyInstance(String instanceId, ProvisioningSettings settings, Properties properties) throws APPlatformException { InstanceStatus status = null; if (instanceId == null || settings == null || properties == null) { return status; } PropertyHandler propertyHandler = new PropertyHandler(settings); if ("finish".equals(properties.get("command"))) { // since deletion currently does not have manual steps, the event // can be ignored if (!propertyHandler.getOperation().isDeletion()) { if (FlowState.MANUAL.equals(propertyHandler.getState())) { propertyHandler.setState(FlowState.FINISHED); status = setNotificationStatus(settings, propertyHandler); logger.debug("Got finish event => changing instance status to finished"); } else { APPlatformException pe = new APPlatformException( "Got finish event but instance is in state " + propertyHandler.getState() + " => nothing changed"); logger.debug(pe.getMessage()); throw pe; } } } return status; }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public PriceModelHistory loadLatestPriceModelHistory( SubscriptionHistory history) { Query query = dm .createNamedQuery("PriceModelHistory.findLatestBySubscriptionHistory"); query.setParameter("prdObjKey", Long.valueOf(history.getProductObjKey())); query.setParameter("modDate", history.getModdate()); return (PriceModelHistory) query.getSingleResult(); }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public JmdTaskData getData(Long taskId, String code) { Connection connection = null; JmdTaskData result = null; try { connection = ds.getConnection(); List<JmdTaskData> daoResult = new H2SqlBuilder().select(connection, Query .SELECT(JMD_TASK_DATA.columns()) .FROM(TABLE.JMD_TASK_DATA()) .WHERE(JMD_TASK_DATA.TASK_FK(), Condition.EQUALS, taskId) .AND(JMD_TASK_DATA.CODE(), Condition.EQUALS, code), JmdTaskData.class ); if (!daoResult.isEmpty()) { result = daoResult.get(0); } } catch (Exception e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "RESULT:{0}", result); } return result; }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<LocalizedText> getControllerStatus(ControllerSettings settings) throws APPlatformException { // TODO Auto-generated method stub return null; }
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public ServiceInstance markAsDeleted(ServiceInstance instance) throws ServiceInstanceNotFoundException { ServiceInstance dbInstance = find(instance); dbInstance.markForDeletion(); em.flush(); return dbInstance; }
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void restoreInstance(ServiceInstance instance) throws ServiceInstanceNotFoundException { ServiceInstance dbInstance = find(instance); dbInstance.unmarkForDeletion(); em.flush(); }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public Long addTask(JmdTask task) { Connection connection = null; Long result = null; try { connection = ds.getConnection(); Object[] values = new Dto().toArray(task, JMD_TASK.columns()); values[0] = SEQUENCE.SQ_JMD_TASK(); result = (Long) new OraSqlBuilder().insert(connection, Query .INSERT() .INTO(TABLE.JMD_TASK(), JMD_TASK.columns()) .VALUES(values) .RETURNING(JMD_TASK.ID()) ); } catch (SQLException e) { LOGGER.log(Level.SEVERE, e.toString(), e); throw new RuntimeException(e); } finally { SqlUtil.close(connection); } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "RESULT:{0}", result); } return result; }
@TransactionAttribute(TransactionAttributeType.MANDATORY) public HashMap<String, Setting> getAllProxyConfigurationSettings() throws ConfigurationException { LOGGER.debug("Retrieving all configuration settings for proxy"); HashMap<String, Setting> result = new HashMap<>(); Query query = em.createNamedQuery("ConfigurationSetting.getAllProxy"); List<?> resultList = query.getResultList(); for (Object entry : resultList) { ConfigurationSetting currentCs = (ConfigurationSetting) entry; result.put(currentCs.getSettingKey(), new Setting( currentCs.getSettingKey(), currentCs.getDecryptedValue())); } PlatformConfigurationKey[] keys = PlatformConfigurationKey.values(); StringBuffer missing = new StringBuffer(); for (int i = 0; i < keys.length; i++) { if (keys[i].isMandatory() && !result.containsKey(keys[i].name())) { if (missing.length() > 0) { missing.append(", "); } missing.append(keys[i].name()); } } if (missing.length() > 0) { throw new ConfigurationException( "The configuration is missing the following parameter(s): " + missing.toString(), missing.toString()); } return result; }
@TransactionAttribute(TransactionAttributeType.MANDATORY) public VOUserDetails getAPPAdministrator() throws ConfigurationException { VOUserDetails adminuser = new VOUserDetails(); String adminemail = getProxyConfigurationSetting( PlatformConfigurationKey.APP_ADMIN_MAIL_ADDRESS); if (!Strings.isEmpty(adminemail)) { adminuser.setEMail(adminemail); adminuser.setLocale(Messages.DEFAULT_LOCALE); } return adminuser; }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public long loadVendorKeyForSubscription(long subscriptionKey) { Query query = dm.createNamedQuery("SubscriptionHistory.getVendorKey"); query.setParameter("subscriptionKey", Long.valueOf(subscriptionKey)); Long result = (Long) query.getSingleResult(); return result.longValue(); }