Java Code Examples for javax.ejb.TransactionAttributeType

The following are top voted examples for showing how to use javax.ejb.TransactionAttributeType. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: oscm   File: LocalizerServiceBean.java   View source code 7 votes vote down vote up
@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();

}
 
Example 2
Project: oscm   File: VMController.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 3
Project: oscm   File: MarketplaceServiceLocalBean.java   View source code 6 votes vote down vote up
@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;
}
 
Example 4
Project: task-app   File: TaskDaoImpl.java   View source code 6 votes vote down vote up
@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;
}
 
Example 5
Project: task-app   File: TaskDaoImpl.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 6
Project: task-app   File: TaskDaoTestImpl.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 7
Project: oscm   File: AccountServiceBean.java   View source code 6 votes vote down vote up
@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;
}
 
Example 8
Project: jboss-eap7.1-playground   File: DelegateROCBean.java   View source code 6 votes vote down vote up
@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;
 }
 
Example 9
Project: oscm   File: APPTimerServiceBean.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 10
Project: oscm   File: LocalizerServiceBean.java   View source code 6 votes vote down vote up
@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;
}
 
Example 11
Project: oscm-app   File: APPTimerServiceBean.java   View source code 6 votes vote down vote up
/**
 * 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.");
        }
    }
}
 
Example 12
Project: task-app   File: TaskDaoImpl.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 13
Project: oscm-app   File: APPConcurrencyServiceBean.java   View source code 6 votes vote down vote up
@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();
    }
}
 
Example 14
Project: oscm   File: SubscriptionServiceBean.java   View source code 6 votes vote down vote up
@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);

}
 
Example 15
Project: oscm   File: DataServiceBean.java   View source code 6 votes vote down vote up
@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);
}
 
Example 16
Project: oscm   File: AWSController.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 17
Project: task-app   File: TaskDaoImpl.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 18
Project: oscm   File: BillingDataRetrievalServiceBean.java   View source code 6 votes vote down vote up
@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();
}
 
Example 19
Project: task-app   File: TaskDaoTestImpl.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 20
Project: oscm   File: MarketingPermissionServiceBean.java   View source code 6 votes vote down vote up
@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;
}
 
Example 21
Project: oscm   File: IaasController.java   View source code 6 votes vote down vote up
@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");
    }
}
 
Example 22
Project: oscm   File: TimerServiceBean.java   View source code 6 votes vote down vote up
@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;
}
 
Example 23
Project: task-app   File: TaskDaoTestImpl.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 24
Project: oscm   File: OpenStackController.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 25
Project: oscm   File: SharesCalculatorBean.java   View source code 6 votes vote down vote up
@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);
}
 
Example 26
Project: oscm   File: OpenStackController.java   View source code 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 27
Project: task-app   File: TaskDaoTestImpl.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 28
Project: task-app   File: TaskDaoTestImpl.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 29
Project: task-app   File: TaskDaoTestImpl.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 30
Project: oscm   File: DeployedSessionBeanTest.java   View source code 5 votes vote down vote up
@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();
}
 
Example 31
Project: oscm-app   File: IaasController.java   View source code 5 votes vote down vote up
@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;
}
 
Example 32
Project: oscm   File: BillingDataRetrievalServiceBean.java   View source code 5 votes vote down vote up
@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();
}
 
Example 33
Project: task-app   File: TaskDaoTestImpl.java   View source code 5 votes vote down vote up
@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;
}
 
Example 34
Project: oscm-app   File: IaasController.java   View source code 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public List<LocalizedText> getControllerStatus(ControllerSettings settings)
        throws APPlatformException {
    // TODO Auto-generated method stub
    return null;
}
 
Example 35
Project: oscm-app   File: ServiceInstanceDAO.java   View source code 5 votes vote down vote up
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public ServiceInstance markAsDeleted(ServiceInstance instance)
        throws ServiceInstanceNotFoundException {
    ServiceInstance dbInstance = find(instance);
    dbInstance.markForDeletion();
    em.flush();
    return dbInstance;
}
 
Example 36
Project: oscm-app   File: ServiceInstanceDAO.java   View source code 5 votes vote down vote up
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void restoreInstance(ServiceInstance instance)
        throws ServiceInstanceNotFoundException {
    ServiceInstance dbInstance = find(instance);
    dbInstance.unmarkForDeletion();
    em.flush();

}
 
Example 37
Project: task-app   File: TaskDaoImpl.java   View source code 5 votes vote down vote up
@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;
}
 
Example 38
Project: oscm-app   File: APPConfigurationServiceBean.java   View source code 5 votes vote down vote up
@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;
}
 
Example 39
Project: oscm-app   File: APPConfigurationServiceBean.java   View source code 5 votes vote down vote up
@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;
}
 
Example 40
Project: oscm   File: BillingDataRetrievalServiceBean.java   View source code 5 votes vote down vote up
@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();
}