javax.ejb.TransactionAttributeType Java Examples

The following examples show how to use javax.ejb.TransactionAttributeType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IaasController.java    From development with Apache License 2.0 6 votes vote down vote up
@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");
    }
}
 
Example #2
Source File: IdentityServiceBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void resetUserPassword(PlatformUser platformUser,
        String marketplaceId)
        throws UserActiveException, MailOperationException {
    // determine if the user has an active session, if so, throw an
    // exception
    List<Session> sessionsForUserKey = prodSessionMgmt
            .getSessionsForUserKey(platformUser.getKey());
    if (sessionsForUserKey.size() > 0) {
        UserActiveException uae = new UserActiveException(
                "Reset of password for user '" + platformUser.getKey()
                        + "' failed, as the user is still active",
                new Object[] { platformUser.getUserId() });
        logger.logWarn(Log4jLogger.SYSTEM_LOG, uae,
                LogMessageIdentifier.WARN_OPERATOR_RESET_PASSWORD_FAILED);
        throw uae;
    }

    // reset the password
    resetPasswordForUser(platformUser, getMarketplace(marketplaceId));
}
 
Example #3
Source File: OpenStackController.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the current overall status of the application instance.
 * <p>
 * For retrieving the status, the method calls the status dispatcher with
 * the currently stored controller configuration settings. These settings
 * include the internal status set by the controller or the dispatcher
 * itself. The overall status of the instance depends on this internal
 * status.
 * 
 * @param instanceId
 *            the ID of the application instance to be checked
 * @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 getInstanceStatus(String instanceId,
        ProvisioningSettings settings) throws APPlatformException {
    LOGGER.debug("getInstanceStatus({})",
            LogAndExceptionConverter.getLogText(instanceId, settings));
    try {
        PropertyHandler ph = new PropertyHandler(settings);
        ProvisioningValidator.validateTimeout(instanceId, ph,
                platformService);
        Dispatcher dp = new Dispatcher(platformService, instanceId, ph);
        InstanceStatus status = dp.dispatch();
        return status;
    } catch (Exception t) {
        throw LogAndExceptionConverter.createAndLogPlatformException(t,
                Context.STATUS);
    }
}
 
Example #4
Source File: ServiceProvisioningPartnerServiceLocalBean.java    From development with Apache License 2.0 6 votes vote down vote up
@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;
    }

}
 
Example #5
Source File: PaymentServiceBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void deregisterPaymentInPSPSystem(PaymentInfo payment)
        throws PaymentDeregistrationException,
        OperationNotPermittedException {

    // check pre-conditions
    if (payment == null
            || payment.getPaymentType().getCollectionType() != PaymentCollectionType.PAYMENT_SERVICE_PROVIDER) {
        return;
    }
    PlatformUser currentUser = dm.getCurrentUser();
    PermissionCheck.owns(payment, currentUser.getOrganization(), logger);

    RequestData data = createRequestData(currentUser.getLocale(), payment);

    deregisterPaymentInfo(payment.getPaymentType().getPsp().getWsdlUrl(),
            data);

}
 
Example #6
Source File: BillingDataRetrievalServiceBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public List<SubscriptionHistory> loadSubscriptionsForCustomer(
        long organizationKey, List<Long> unitKeys, long startDate,
        long endDate, int cutOffDay) {
    if (unitKeys == null || unitKeys.isEmpty()) {
        return new ArrayList<SubscriptionHistory>();
    }
    Query query = dm
            .createNamedQuery("SubscriptionHistory.getSubscriptionsForOrganizationAndUnits_VersionDesc");
    query.setParameter("organizationKey", Long.valueOf(organizationKey));
    query.setParameter("units", unitKeys);
    query.setParameter("startDate", new Date(startDate));
    query.setParameter("endDate", new Date(endDate));
    query.setParameter("cutOffDay", Integer.valueOf(cutOffDay));
    query.setParameter("external", true);
    @SuppressWarnings("unchecked")
    List<SubscriptionHistory> result = query.getResultList();
    return result;
}
 
Example #7
Source File: MarketingPermissionServiceBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void removeMarketingPermissions(TechnicalProduct technicalProduct) {
    Query query = ds
            .createNamedQuery("MarketingPermission.findForTechnicalService");
    query.setParameter("tp", technicalProduct);
    List<MarketingPermission> result = ParameterizedTypes.list(
            query.getResultList(), MarketingPermission.class);

    // remove permissions
    Set<Long> affectedReferences = new HashSet<Long>();
    for (MarketingPermission mp : result) {
        affectedReferences.add(Long.valueOf(mp
                .getOrganizationReferenceKey()));
        ds.remove(mp);
    }

    // remove organization reference
    removeObsoleteOrgRefs(affectedReferences);
}
 
Example #8
Source File: MarketplaceServiceLocalBean.java    From development with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example #9
Source File: SampleController.java    From development with Apache License 2.0 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 {

    // Set status to store for application instance
    PropertyHandler paramHandler = new PropertyHandler(settings);
    paramHandler.setState(Status.CREATION_REQUESTED);

    // Return generated instance information
    InstanceDescription id = new InstanceDescription();
    id.setInstanceId("Instance_" + System.currentTimeMillis());
    id.setChangedParameters(settings.getParameters());
    id.setChangedAttributes(settings.getAttributes());
    return id;
}
 
Example #10
Source File: IdentityServiceBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public List<PlatformUser> getOrganizationUsers() {

    // The organization is determined by the currently logged in user. To
    // obtain the users for this organization, the organization domain
    // object has to be loaded, which then references the users.
    PlatformUser user = dm.getCurrentUser();

    // 1. determine the correlating organization
    Organization organization = user.getOrganization();

    Query q = dm.createNamedQuery("PlatformUser.getVisibleForOrganization");
    q.setParameter("organization", organization);

    return ParameterizedTypes.list(q.getResultList(), PlatformUser.class);
}
 
Example #11
Source File: QueryExecutorBean.java    From datawave with Apache License 2.0 6 votes vote down vote up
@POST
@Produces("*/*")
@Path("/{logicName}/async/execute")
@GZIP
@Interceptors({ResponseInterceptor.class, RequiredInterceptor.class})
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@Asynchronous
@Timed(name = "dw.query.executeQueryAsync", absolute = true)
public void executeAsync(@PathParam("logicName") String logicName, MultivaluedMap<String,String> queryParameters, @Context HttpHeaders httpHeaders,
                @Suspended AsyncResponse asyncResponse) {
    try {
        StreamingOutput output = execute(logicName, queryParameters, httpHeaders);
        asyncResponse.resume(output);
    } catch (Throwable t) {
        asyncResponse.resume(t);
    }
}
 
Example #12
Source File: AWSController.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #13
Source File: QueryExecutorBean.java    From datawave with Apache License 2.0 6 votes vote down vote up
@POST
@Produces({"application/xml", "text/xml", "application/json", "text/yaml", "text/x-yaml", "application/x-yaml", "application/x-protobuf",
        "application/x-protostuff"})
@Path("/{logicName}/createAndNext")
@GZIP
@GenerateQuerySessionId(cookieBasePath = "/DataWave/Query/")
@EnrichQueryMetrics(methodType = MethodType.CREATE_AND_NEXT)
@Interceptors({ResponseInterceptor.class, RequiredInterceptor.class})
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@Timed(name = "dw.query.createAndNext", absolute = true)
public BaseQueryResponse createQueryAndNext(@Required("logicName") @PathParam("logicName") String logicName, MultivaluedMap<String,String> queryParameters,
                @Context HttpHeaders httpHeaders) {
    CreateQuerySessionIDFilter.QUERY_ID.set(null);
    
    GenericResponse<String> createResponse = createQuery(logicName, queryParameters, httpHeaders);
    String queryId = createResponse.getResult();
    CreateQuerySessionIDFilter.QUERY_ID.set(queryId);
    return next(queryId, false);
}
 
Example #14
Source File: CredentialsCacheBean.java    From datawave with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void onRefreshComplete(@Observes RefreshLifecycle refreshLifecycle) {
    switch (refreshLifecycle) {
        case INITIATED:
            flushAllException = null;
            break;
        case COMPLETE:
            // Now that the refresh is complete, throw any flush principals exception that might have happened.
            // We want to let the rest of the refresh complete internally before throwing the error so that we
            // don't leave this server in an inconsistent state.
            if (flushAllException != null) {
                throw new RuntimeException("Error flushing principals cache: " + flushAllException.getMessage(), flushAllException);
            }
            break;
    }
}
 
Example #15
Source File: BillingDataRetrievalServiceBean.java    From development with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void updateBillingSubscriptionStatus(long subscriptionKey,
        long endOfLastBilledPeriod) throws NonUniqueBusinessKeyException {

    BillingSubscriptionStatus billingSubStatus = new BillingSubscriptionStatus();
    billingSubStatus.setSubscriptionKey(subscriptionKey);
    billingSubStatus = (BillingSubscriptionStatus) dm
            .find(billingSubStatus);

    if (billingSubStatus != null) {
        billingSubStatus.setEndOfLastBilledPeriod(Math.max(
                billingSubStatus.getEndOfLastBilledPeriod(),
                endOfLastBilledPeriod));
    } else {
        billingSubStatus = new BillingSubscriptionStatus();
        billingSubStatus.setSubscriptionKey(subscriptionKey);
        billingSubStatus.setEndOfLastBilledPeriod(endOfLastBilledPeriod);
        dm.persist(billingSubStatus);
        dm.flush();
    }
}
 
Example #16
Source File: AWSController.java    From development with Apache License 2.0 6 votes vote down vote up
/**
 * Starts the deactivation of an application instance.
 * <p>
 * The internal status <code>DEACTIVATION_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 deactivateInstance(String instanceId,
        ProvisioningSettings settings) throws APPlatformException {
    LOGGER.info("deactivateInstance({})",
            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.DEACTIVATION_REQUESTED);

        InstanceStatus result = new InstanceStatus();
        result.setChangedParameters(settings.getParameters());
        result.setChangedAttributes(settings.getAttributes());
        return result;
    } catch (Throwable t) {
        throw LogAndExceptionConverter.createAndLogPlatformException(t,
                Context.DEACTIVATION);
    }
}
 
Example #17
Source File: BuildConfigurationRepositoryImpl.java    From pnc with Apache License 2.0 6 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public BuildConfiguration save(BuildConfiguration buildConfiguration) {
    Integer id = buildConfiguration.getId();
    BuildConfiguration persisted = queryById(id);
    if (persisted != null) {
        if (!areParametersEqual(persisted, buildConfiguration)
                || !equalAuditedValues(persisted, buildConfiguration)) {
            // always increment the revision of main entity when the child collection is updated
            // the @PreUpdate method in BuildConfiguration was removed, the calculation of whether the
            // lastModificationTime needs to be changed is done here
            buildConfiguration.setLastModificationTime(new Date());
        } else {
            // No changes to audit, reset the lastModificationUser to previous existing
            buildConfiguration.setLastModificationUser(persisted.getLastModificationUser());
        }
    }
    return springRepository.save(buildConfiguration);
}
 
Example #18
Source File: SharesCalculatorBean.java    From development with Apache License 2.0 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 #19
Source File: DefaultDatastore.java    From pnc with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public BuildRecord storeRecordForNoRebuild(BuildRecord buildRecord) {
    logger.debug("Storing record for not required build {}.", buildRecord);

    buildRecord = buildRecordRepository.save(buildRecord);
    logger.debug("Build record {} saved.", buildRecord.getId());

    return buildRecord;
}
 
Example #20
Source File: ApplicationServiceStub.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void deactivateInstance(Subscription subscription)
        throws TechnicalServiceNotAliveException,
        TechnicalServiceOperationException {
    deactivated = true;
}
 
Example #21
Source File: BillingDataRetrievalServiceBean.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
@SuppressWarnings("unchecked")
public List<PriceModelHistory> loadPriceModelHistories(
        long priceModelKeyForSubscription, long endTimeForPeriod) {

    Query query = dm
            .createNamedQuery("PriceModelHistory.findByKeyDescVersion");
    query.setParameter("objKey", Long.valueOf(priceModelKeyForSubscription));
    query.setParameter("modDate", new Date(endTimeForPeriod));
    return query.getResultList();
}
 
Example #22
Source File: AWSController.java    From development with Apache License 2.0 5 votes vote down vote up
/**
 * Does not carry out specific actions in this implementation and always
 * returns <code>null</code>.
 * 
 * @param instanceId
 *            the ID of the application instance
 * @param settings
 *            a <code>ProvisioningSettings</code> object specifying the
 *            service parameters and configuration settings
 * @param properties
 *            the events as properties consisting of a key and a value each
 * @return <code>null</code>
 * @throws APPlatformException
 */
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public InstanceStatus notifyInstance(String instanceId,
        ProvisioningSettings settings, Properties properties)
        throws APPlatformException {
    LOGGER.info("notifyInstance({})",
            LogAndExceptionConverter.getLogText(instanceId, settings));
    InstanceStatus status = null;
    if (instanceId == null || settings == null || properties == null) {
        return status;
    }
    PropertyHandler propertyHandler = new PropertyHandler(settings);

    if ("finish".equals(properties.get("command"))) {
        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 #23
Source File: AccountServiceStub.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public VOOrganization registerKnownCustomerInt(TriggerProcess tp)
        throws OrganizationAuthoritiesException, ValidationException,
        NonUniqueBusinessKeyException, MailOperationException {

    return null;
}
 
Example #24
Source File: APPConfigurationServiceBean.java    From development with Apache License 2.0 5 votes vote down vote up
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public HashMap<String, Setting> getCustomAttributes(String organizationId)
        throws ConfigurationException {

    LOGGER.debug("Retrieving custom settings for organization '{}'",
            organizationId);

    HashMap<String, Setting> result = new HashMap<>();

    if (organizationId != null) {
        TypedQuery<CustomAttribute> query = em.createNamedQuery(
                "CustomAttribute.getForOrg", CustomAttribute.class);
        query.setParameter("oid", organizationId);
        List<CustomAttribute> resultList = query.getResultList();
        try {
            for (CustomAttribute entry : resultList) {
                result.put(entry.getAttributeKey(), new Setting(
                        entry.getAttributeKey(), entry.getDecryptedValue(),
                        entry.isEncrypted(), entry.getControllerId()));
            }
        } catch (BadResultException e) {
            throw new ConfigurationException(e.getMessage());
        }
    }

    return result;
}
 
Example #25
Source File: AccountServiceStub.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void updateAccountInformation(Organization organization,
        VOUserDetails user, String marketplaceId)
        throws ValidationException, NonUniqueBusinessKeyException,
        OperationNotPermittedException, TechnicalServiceNotAliveException,
        TechnicalServiceOperationException, DistinguishedNameException,
        ConcurrentModificationException {

}
 
Example #26
Source File: IdentityServiceBean.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public List<PlatformUser> getOverdueOrganizationAdmins(long currentTime) {
    String period = cs.getConfigurationSetting(
            ConfigurationKey.PERMITTED_PERIOD_UNCONFIRMED_ORGANIZATIONS,
            Configuration.GLOBAL_CONTEXT).getValue();
    long maxTime = currentTime - Long.parseLong(period);

    Query query = dm
            .createNamedQuery("PlatformUser.getOverdueOrganizationAdmins");
    query.setParameter("status", UserAccountStatus.LOCKED_NOT_CONFIRMED);
    query.setParameter("date", Long.valueOf(maxTime));
    return ParameterizedTypes.list(query.getResultList(),
            PlatformUser.class);
}
 
Example #27
Source File: IaasController.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public InstanceStatus deleteUsers(String instanceId,
        ProvisioningSettings settings, List<ServiceUser> users)
        throws APPlatformException {
    return null;
}
 
Example #28
Source File: ServiceProvisioningPartnerServiceLocalBean.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
@SuppressWarnings("unchecked")
public List<Product> getPartnerProductsForTemplate(long serviceKey)
        throws ObjectNotFoundException, ServiceOperationException {

    Product product = dm.getReference(Product.class, serviceKey);
    validateProductTemplate(product);

    Query query = dm
            .createNamedQuery("Product.getPartnerCopiesForTemplate");
    query.setParameter("template", product);
    return query.getResultList();
}
 
Example #29
Source File: VMController.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public InstanceDescription createInstance(ProvisioningSettings settings)
        throws APPlatformException {

    try {
        VMPropertyHandler ph = new VMPropertyHandler(settings);
        ph.setRequestingUser(settings.getRequestingUser());

        InstanceDescription id = new InstanceDescription();
        id.setInstanceId(Long.toString(System.currentTimeMillis()));
        id.setChangedParameters(settings.getParameters());

        if (platformService.exists(Controller.ID, id.getInstanceId())) {
            logger.error(
                    "Other instance with same name already registered in CTMG: ["
                            + id.getInstanceId() + "]");
            throw new APPlatformException(
                    Messages.getAll("error_instance_exists",
                            new Object[] { id.getInstanceId() }));
        }

        validateParameters(null, ph, settings.getOrganizationId(),
                id.getInstanceId());

        logger.info("createInstance({})", LogAndExceptionConverter
                .getLogText(id.getInstanceId(), settings));

        StateMachine.initializeProvisioningSettings(settings,
                "create_vm.xml");
        return id;
    } catch (Exception e) {
        throw LogAndExceptionConverter.createAndLogPlatformException(e,
                Context.CREATION);
    }
}
 
Example #30
Source File: SessionServiceBean.java    From development with Apache License 2.0 5 votes vote down vote up
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public Session getPlatformSessionForSessionId(String sessionId) {
    logger.logDebug("getPlatformSessionForSessionId(String) sessionId");
    // find all entries for the given session id
    Query query = dm.createNamedQuery("Session.findEntriesForSessionId");
    query.setParameter("sessionId", sessionId);
    query.setParameter("sessionType", SessionType.PLATFORM_SESSION);
    return (Session) query.getSingleResult();
}