@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void updateMarketplaceName(Marketplace marketplace, String newMarketplaceName) throws OperationNotPermittedException { LocalizerFacade facade = new LocalizerFacade(localizer, ds.getCurrentUser().getLocale()); String persistedMarketplaceName = facade.getText(marketplace.getKey(), LocalizedObjectTypes.MARKETPLACE_NAME); if (!persistedMarketplaceName.equals(newMarketplaceName)) { if (!ds.getCurrentUser().hasRole(UserRoleType.MARKETPLACE_OWNER)) { throw new OperationNotPermittedException(); } checkMarketplaceOwner(marketplace.getMarketplaceId()); localizer.storeLocalizedResource(ds.getCurrentUser().getLocale(), marketplace.getKey(), LocalizedObjectTypes.MARKETPLACE_NAME, newMarketplaceName); } }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public InstanceStatus activateInstance(String instanceId, ProvisioningSettings settings) throws APPlatformException { try { PropertyHandler paramHandler = new PropertyHandler(settings); if (paramHandler.isVirtualSystemProvisioning()) { paramHandler.setOperation(Operation.VSYSTEM_ACTIVATION); paramHandler.setState(FlowState.VSYSTEM_ACTIVATION_REQUESTED); } else { paramHandler.setOperation(Operation.VSERVER_ACTIVATION); paramHandler.setState(FlowState.VSERVER_ACTIVATION_REQUESTED); } InstanceStatus result = new InstanceStatus(); result.setChangedParameters(settings.getParameters()); result.setChangedAttributes(settings.getAttributes()); return result; } catch (Exception e) { logger.error("Error while scheduling instance activation", e); throw getPlatformException(e, "error_activation_overall"); } }
@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); } }
/** * 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.MANDATORY) public UserGroupHistory getLastValidGroupHistory(long groupKey, long endOfBillingPeriod) { Query query = dm .createNamedQuery("UserGroupHistory.findLastValidForEndPeriod"); query.setParameter("objKey", Long.valueOf(groupKey)); query.setParameter("endDate", new Date(endOfBillingPeriod)); query.setMaxResults(1); List<?> qryresult = query.getResultList(); if (qryresult.size() == 0) { return null; } else { return (UserGroupHistory) qryresult.get(0); } }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public SubscriptionHistory loadNextActiveSubscriptionHistoryForPriceModel( final long priceModelKey, final long timeMillis) { TypedQuery<SubscriptionHistory> query = dm.createNamedQuery( "SubscriptionHistory.findNextForPriceModelAndState", SubscriptionHistory.class); query.setParameter("priceModelKey", Long.valueOf(priceModelKey)); query.setParameter("modDate", new Date(timeMillis)); query.setParameter("subscriptionStates", EnumSet.of( SubscriptionStatus.ACTIVE, SubscriptionStatus.PENDING_UPD)); List<SubscriptionHistory> resultList = query.getResultList(); if (resultList.size() > 0) { return resultList.get(0); } else { return null; } }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setInterruptFlag(Long taskId, Boolean interruptFlag) { Connection connection = null; try { connection = ds.getConnection(); new OraSqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.INTERRUPT_FLAG(), interruptFlag) .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.MANDATORY) public boolean notifyAboutTimedoutSubscriptions(long currentTime) { // we could also use a separate query inclusing the checked conditions List<Subscription> subscriptions = getSubscriptionDao() .getSubscriptionsByStatus(SubscriptionStatus.PENDING); for (Subscription subscription : subscriptions) { Long timeout = subscription.getProduct().getTechnicalProduct() .getProvisioningTimeout(); if (!subscription.isTimeoutMailSent() && subscription.getCreationDate().longValue() + timeout.longValue() < currentTime) { List<PlatformUser> users = subscription.getProduct() .getTechnicalProduct().getOrganization() .getPlatformUsers(); if (notifyTechnicalAdminsAboutTimeout(subscription, users)) { // if at least one mail was sent, set the mail sent flag of // the subscription subscription.setTimeoutMailSent(true); } } } return true; }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setStatus(Long taskId, TaskStatus status) { Connection connection = null; try { connection = ds.getConnection(); new H2SqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.STATUS(), status.name()) .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 Set<UserRoleType> getAvailableUserRolesForUser(PlatformUser pu) { Query query = dm.createNamedQuery("UserRole.getAllUserRoles"); List<UserRole> userRoleList = ParameterizedTypes .list(query.getResultList(), UserRole.class); Organization org = pu.getOrganization(); Set<UserRoleType> roleList = new HashSet<>(); for (UserRole userRole : userRoleList) { if (isAllowedUserRole(org, userRole.getRoleName())) { roleList.add(userRole.getRoleName()); } } return roleList; }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setQueueNum(Long taskId, Integer queueNum) { Connection connection = null; try { connection = ds.getConnection(); new OraSqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.QUEUE_NUM(), queueNum) .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 Integer countProgress(Integer totalStep, Integer actualStep) { if (totalStep == null || totalStep <= 0) { totalStep = Integer.MAX_VALUE; } if (actualStep == null || actualStep <= 0) { actualStep = 0; } if (actualStep > totalStep) { actualStep = totalStep - 1; } BigDecimal step = new BigDecimal(100); BigDecimal divider = new BigDecimal(totalStep); step = step.divide(divider, totalStep.toString().length(), RoundingMode.HALF_UP); step = step.multiply(new BigDecimal(actualStep)); return step.intValue(); }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setStopEnabled(Long taskId, Boolean stopEnabled) { Connection connection = null; try { connection = ds.getConnection(); new H2SqlBuilder().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); } }
/** * Getting list of organization to sending info mail about ending discount * in one week (seven days). * * @param currentTimeMillis * Current millisecond. * @return Organization list for sending notification. */ @Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public List<OrganizationReference> getOrganizationForDiscountEndNotificiation( long currentTimeMillis) { // define the first and the last millisecond of needed day: // define date + 7 days long firstMillis = getMillisecondInFuture(currentTimeMillis, 7); long lastMillis = getMillisecondInFuture(currentTimeMillis, 8) - 1; // getting list of organization to sending info mail about ending // discount Query query = dm.createNamedQuery( "OrganizationReference.findOrganizationForDiscountEndNotification"); query.setParameter("firstMillis", Long.valueOf(firstMillis)); query.setParameter("lastMillis", Long.valueOf(lastMillis)); List<OrganizationReference> list = ParameterizedTypes .list(query.getResultList(), OrganizationReference.class); return list; }
@Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void performMpOwnerSharesCalculationRun(long startOfLastMonth, long endOfLastMonth, Long mpOwnerKey) throws Exception { // build the result object tree MarketplaceOwnerRevenueShareResult mpOwnerShareResult = new MpOwnerShareResultAssembler( sharesRetrievalService, ds).build(mpOwnerKey, startOfLastMonth, endOfLastMonth); // calculate all shares mpOwnerShareResult.calculateAllShares(); // serialize the result object and persist saveBillingSharesResult(startOfLastMonth, endOfLastMonth, BillingSharesResultType.MARKETPLACE_OWNER, mpOwnerShareResult, mpOwnerKey); }
/** * Starts the modification of an application instance. * <p> * The internal status <code>MODIFICATION_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 modified * @param currentSettings * a <code>ProvisioningSettings</code> object specifying the * current service parameters and configuration settings * @param newSettings * a <code>ProvisioningSettings</code> object specifying the * modified 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 modifyInstance(String instanceId, ProvisioningSettings currentSettings, ProvisioningSettings newSettings) throws APPlatformException { LOGGER.info("modifyInstance({})", LogAndExceptionConverter .getLogText(instanceId, currentSettings)); try { PropertyHandler ph = PropertyHandler.withSettings(newSettings); ph.setOperation(Operation.EC2_MODIFICATION); ph.setState(FlowState.MODIFICATION_REQUESTED); InstanceStatus result = new InstanceStatus(); result.setChangedParameters(newSettings.getParameters()); result.setChangedAttributes(newSettings.getAttributes()); return result; } catch (Throwable t) { throw LogAndExceptionConverter.createAndLogPlatformException(t, Context.MODIFICATION); } }
@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 setInterruptFlag(Long taskId, Boolean interruptFlag) { Connection connection = null; try { connection = ds.getConnection(); new H2SqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.INTERRUPT_FLAG(), interruptFlag) .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 activation of an application instance. * <p> * The internal status <code>ACTIVATION_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 activated * @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 activateInstance(String instanceId, ProvisioningSettings settings) throws APPlatformException { LOGGER.info("activateInstance({})", LogAndExceptionConverter.getLogText(instanceId, settings)); try { // Set status to store for application instance PropertyHandler ph = PropertyHandler.withSettings(settings); ph.setOperation(Operation.EC2_ACTIVATION); ph.setState(FlowState.ACTIVATION_REQUESTED); InstanceStatus result = new InstanceStatus(); result.setChangedParameters(settings.getParameters()); result.setChangedAttributes(settings.getAttributes()); return result; } catch (Throwable t) { throw LogAndExceptionConverter.createAndLogPlatformException(t, Context.ACTIVATION); } }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<JmdTaskProperty> getProperties(Long taskId) { Connection connection = null; List<JmdTaskProperty> result = new ArrayList<>(); try { connection = ds.getConnection(); result = new PostgreSqlBuilder().select(connection, Query .SELECT(JMD_TASK_PROPERTY.columns()) .FROM(TABLE.JMD_TASK_PROPERTY()) .WHERE(JMD_TASK_PROPERTY.TASK_FK(), Condition.EQUALS, taskId), JmdTaskProperty.class ); } 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 setFinished(Long taskId) { Connection connection = null; try { connection = ds.getConnection(); Column currentTimestamp = new ColumnFunction("id", "current_timestamp", DataType.DATE); new OraSqlBuilder().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.NOT_SUPPORTED) public void setStarted(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.STARTED(), 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.NOT_SUPPORTED) public Long createTask(String type, String name, String actor, String creator) { JmdTask task = new JmdTask(); task.setType(type); task.setCreator(creator); task.setCreated(taskDao.getCurrentDate()); task.setActor(actor); task.setName(name); task.setNameScdf(ScDf.toScDf(name)); task.setStatus(TaskStatus.BOOKED.name()); task.setInterruptEnabled(true); task.setInterruptFlag(false); task.setStopEnabled(true); task.setStopFlag(false); task.setKillFlag(false); task.setTotalStep(Integer.MAX_VALUE); task.setActualStep(0); task.setLastUpdate(task.getCreated()); long taskId = taskDao.addTask(task); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine(MessageFormat.format("Task with id {0} created.", taskId)); } return taskId; }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public boolean chargeForOutstandingBills() { boolean isPSPUsageEnabled = Boolean.parseBoolean(ic .getConfigurationSetting(ConfigurationKey.PSP_USAGE_ENABLED, Configuration.GLOBAL_CONTEXT).getValue()); if (isPSPUsageEnabled) { boolean result = true; // determine billing results without existing payment result Query query = dm .createNamedQuery("BillingResult.getOutstandingBillingResults"); List<BillingResult> brs = ParameterizedTypes.list( query.getResultList(), BillingResult.class); for (BillingResult br : brs) { if (!prepareForNewTransaction().chargeCustomer(br)) { result = false; } } return result; } return true; }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void modifySubscription(Subscription subscription) throws TechnicalServiceNotAliveException, TechnicalServiceOperationException { if (throwSaaSApplicationException) { if (throwSaaSApplicationExceptionWithParam) { throw new TechnicalServiceOperationException("testMessage", new Object[] { "testparam1", "testParam2" }); } else { throw new TechnicalServiceOperationException("testMessage"); } } throwSaaSApplicationException = false; throwSaaSApplicationExceptionWithParam = false; if (throwTechnicalServiceNotAliveExceptionCustomer) { throw new TechnicalServiceNotAliveException( TechnicalServiceNotAliveException.Reason.CUSTOMER); } throwTechnicalServiceNotAliveExceptionCustomer = false; }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void setQueueNum(Long taskId, Integer queueNum) { Connection connection = null; try { connection = ds.getConnection(); new PostgreSqlBuilder().update(connection, Query .UPDATE(TABLE.JMD_TASK()) .SET(JMD_TASK.QUEUE_NUM(), queueNum) .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 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.MANDATORY) public LocalizedBillingResource getLocalizedBillingResource( String localeString, UUID objectId, LocalizedBillingResourceType resourceType) { Locale locale = LocaleHandler.getLocaleFromString(localeString); LocalizedBillingResource billingResource = getLocalizedBillingResourceFromDatabase( objectId, locale.getLanguage(), resourceType); if (billingResource == null) { billingResource = getLocalizedBillingResourceFromDatabase(objectId, defaultLocale.getLanguage(), resourceType); } if (billingResource != null) { return billingResource; } else { logger.logDebug("Localized billing resource of type '" + resourceType.name() + "' of object with id '" + objectId + "' could not be found.", Log4jLogger.SYSTEM_LOG); return null; } }
@TransactionAttribute(TransactionAttributeType.MANDATORY) public String getProxyConfigurationSetting(PlatformConfigurationKey key) throws ConfigurationException { LOGGER.debug("Retrieving proxy configuration setting for key {}", key.name()); Query query = em .createNamedQuery("ConfigurationSetting.getForProxyKey"); query.setParameter("key", key.name()); try { ConfigurationSetting result = (ConfigurationSetting) query .getSingleResult(); return result.getDecryptedValue(); } catch (NoResultException e) { if (key.name().equals(APP_SUSPEND)) { return ""; } else { LOGGER.warn("No entry found for key {}", key.name()); throw new ConfigurationException(String.format( "No configuration setting found for key '%s'", key.name()), key.name()); } } }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void saveOperatorRevenueShare(long serviceKey, RevenueShareModel newRevenueShare, int newRevenueShareVersion) throws ValidationException, ConcurrentModificationException, ObjectNotFoundException, ServiceOperationException { ArgumentValidator.notNull("newRevenueShare", newRevenueShare); Product product = dm.getReference(Product.class, serviceKey); validateProductTemplate(product); validateOperatorRevenueShare(product); CatalogEntry ce = product.getCatalogEntries().get(0); try { updateRevenueShare(newRevenueShare, ce.getOperatorPriceModel(), newRevenueShareVersion); } catch (ValidationException e) { sessionCtx.setRollbackOnly(); throw e; } }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public boolean sendDiscountEndNotificationMail(long currentTimeMillis) throws MailOperationException { // getting organization with ending in one week discount List<OrganizationReference> organizationRefList = getOrganizationForDiscountEndNotificiation( currentTimeMillis); // send mails if (organizationRefList != null) { for (OrganizationReference organizationRef : organizationRefList) { Organization cust = organizationRef.getTarget(); String email = cust.getEmail(); if (email != null && email.trim().length() != 0) { cs.sendMail(cust, EmailType.ORGANIZATION_DISCOUNT_ENDING, null, null); } } } return true; }
@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 OraSqlBuilder().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 public void testGetHandlerForBeanClassAndMethod1() throws Exception { @TransactionAttribute(TransactionAttributeType.SUPPORTS) class Bean implements Runnable { @Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public void run() { } } assertSame(TransactionInvocationHandlers.TX_MANDATORY, TransactionInvocationHandlers.getHandlerFor(Bean.class, Bean.class.getMethod("run"))); }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public PriceModelHistory loadOldestPriceModelHistory(long priceModelKey, long modDate) { List<PriceModelHistory> resultList = loadPriceModelHistories( priceModelKey, modDate); if (resultList.isEmpty()) { throw new BillingRunFailed( "History data is missing for price model with key " + priceModelKey + " before " + new Date(modDate)); } return resultList.get(0); }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public InstanceStatus updateUsers(String instanceId, ProvisioningSettings settings, List<ServiceUser> users) throws APPlatformException { return null; }
@Override @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<LocalizedText> getControllerStatus(ControllerSettings settings) throws APPlatformException { // TODO Auto-generated method stub return null; }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public String loadPaymentTypeIdForSubscription(long subscriptionKey) { Query query = dm .createNamedQuery("SubscriptionHistory.getPaymentTypeId"); query.setParameter("subscriptionKey", Long.valueOf(subscriptionKey)); String result; try { result = (String) query.getSingleResult(); } catch (NoResultException e) { result = ""; } return result; }
@Override @TransactionAttribute(TransactionAttributeType.MANDATORY) public User[] createUsers(Subscription subscription, List<UsageLicense> usageLicenses) throws TechnicalServiceNotAliveException, TechnicalServiceOperationException { User[] users = new User[usageLicenses.size()]; List<User> userList = new ArrayList<>(); for (UsageLicense usageLicense : usageLicenses) { PlatformUser platformUser = usageLicense.getUser(); addedUsers.put(platformUser.getUserId(), platformUser); User user = new User(); user.setApplicationUserId(platformUser.getUserId()); user.setEmail(platformUser.getEmail()); user.setLocale(platformUser.getLocale()); user.setUserId(platformUser.getUserId()); user.setUserFirstName(platformUser.getFirstName()); user.setUserLastName(platformUser.getLastName()); RoleDefinition roleDefinition = usageLicense.getRoleDefinition(); if (roleDefinition != null) { user.setRoleIdentifier(roleDefinition.getRoleId()); } userList.add(user); } users = userList.toArray(new User[userList.size()]); userModificationCallReceived = true; return users; }