当前位置: 首页>>代码示例>>Java>>正文


Java SessionContext.setRollbackOnly方法代码示例

本文整理汇总了Java中javax.ejb.SessionContext.setRollbackOnly方法的典型用法代码示例。如果您正苦于以下问题:Java SessionContext.setRollbackOnly方法的具体用法?Java SessionContext.setRollbackOnly怎么用?Java SessionContext.setRollbackOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ejb.SessionContext的用法示例。


在下文中一共展示了SessionContext.setRollbackOnly方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: owns

import javax.ejb.SessionContext; //导入方法依赖的package包/类
/**
 * Checks if the provided {@link Organization} is the owner of the provided
 * {@link UdaDefinition} and throws an
 * {@link OperationNotPermittedException} if this is not the case.
 * 
 * @param def
 *            the {@link UdaDefinition} to check the ownership for
 * @param org
 *            the {@link Organization} to check if it is the owner
 * @param logger
 *            the optional logger - if not <code>null</code> it logs the
 *            created exception as warning to the system log
 * @param context
 *            if not <code>null</code>,
 *            {@link SessionContext#setRollbackOnly()} will called.
 * @throws OperationNotPermittedException
 */
public static void owns(UdaDefinition def, Organization org,
        Log4jLogger logger, SessionContext context)
        throws OperationNotPermittedException {
    if (def.getOrganization() != org) {
        String message = String
                .format("Organization '%s' tried to access uda definition '%s' that is owned by a different organization",
                        org.getOrganizationId(), Long.valueOf(def.getKey()));
        OperationNotPermittedException e = new OperationNotPermittedException(
                message);
        if (logger != null) {
            logger.logWarn(
                    Log4jLogger.SYSTEM_LOG,
                    e,
                    LogMessageIdentifier.WARN_INSUFFICIENT_AUTH_BY_UDA_DEFINITION_ACCESS,
                    org.getOrganizationId(), String.valueOf(def.getKey()));
        }
        if (context != null) {
            context.setRollbackOnly();
        }
        throw e;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:40,代码来源:PermissionCheck.java

示例2: supplierOfCustomer

import javax.ejb.SessionContext; //导入方法依赖的package包/类
/**
 * Checks if the provided supplier {@link Organization} is supplier of the
 * provided customer {@link Organization} and throws an
 * {@link OperationNotPermittedException} if this is not the case.
 * 
 * @param sup
 *            the {@link Organization} to check if it is supplier of the
 *            passed customer {@link Organization}
 * @param cust
 *            the {@link Organization} to check if it is customer of the
 *            passed supplier {@link Organization}
 * @param logger
 *            the optional logger - if not <code>null</code> it logs the
 *            created exception as warning to the system log
 * @param context
 *            if not <code>null</code>,
 *            {@link SessionContext#setRollbackOnly()} will called.
 * @throws OperationNotPermittedException
 */
public static void supplierOfCustomer(Organization sup, Organization cust,
        Log4jLogger logger, SessionContext context)
        throws OperationNotPermittedException {
    List<Organization> customers = sup.getCustomersOfSupplier();
    if (!customers.contains(cust)) {
        String message = String.format(
                "Organization '%s' is not supplier of customer '%s'",
                sup.getOrganizationId(), cust.getOrganizationId());
        OperationNotPermittedException e = new OperationNotPermittedException(
                message);
        if (logger != null) {
            logger.logWarn(Log4jLogger.SYSTEM_LOG, e,
                    LogMessageIdentifier.WARN_NO_SUPPLIER_OF_CUSTOMER,
                    sup.getOrganizationId(), cust.getOrganizationId());
        }
        if (context != null) {
            context.setRollbackOnly();
        }
        throw e;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:41,代码来源:PermissionCheck.java

示例3: brokerOfCustomer

import javax.ejb.SessionContext; //导入方法依赖的package包/类
/**
 * Checks if the provided reseller {@link Organization} is a broker of the
 * provided customer {@link Organization} and throws an
 * {@link OperationNotPermittedException} if this is not the case.
 * 
 * @param broker
 *            the {@link Organization} to check if it is a broker of the
 *            passed customer {@link Organization}
 * @param cust
 *            the {@link Organization} to check if it is customer of the
 *            passed broker {@link Organization}
 * @param logger
 *            the optional logger - if not <code>null</code> it logs the
 *            created exception as warning to the system log
 * @param context
 *            if not <code>null</code>,
 *            {@link SessionContext#setRollbackOnly()} will called.
 * @throws OperationNotPermittedException
 */
public static void brokerOfCustomer(Organization broker, Organization cust,
        Log4jLogger logger, SessionContext context)
        throws OperationNotPermittedException {
    List<Organization> customers = broker.getCustomersOfBroker();
    if (!customers.contains(cust)) {
        String message = String.format(
                "Organization '%s' is not broker of customer '%s'",
                broker.getOrganizationId(), cust.getOrganizationId());
        OperationNotPermittedException e = new OperationNotPermittedException(
                message);
        if (logger != null) {
            logger.logWarn(Log4jLogger.SYSTEM_LOG, e,
                    LogMessageIdentifier.WARN_NO_BROKER_OF_CUSTOMER,
                    broker.getOrganizationId(), cust.getOrganizationId());
        }
        if (context != null) {
            context.setRollbackOnly();
        }
        throw e;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:41,代码来源:PermissionCheck.java

示例4: resellerOfCustomer

import javax.ejb.SessionContext; //导入方法依赖的package包/类
/**
 * Checks if the provided reseller {@link Organization} is reseller of the
 * provided customer {@link Organization} and throws an
 * {@link OperationNotPermittedException} if this is not the case.
 * 
 * @param reseller
 *            the {@link Organization} to check if it is reseller of the
 *            passed customer {@link Organization}
 * @param cust
 *            the {@link Organization} to check if it is customer of the
 *            passed reseller {@link Organization}
 * @param logger
 *            the optional logger - if not <code>null</code> it logs the
 *            created exception as warning to the system log
 * @param context
 *            if not <code>null</code>,
 *            {@link SessionContext#setRollbackOnly()} will called.
 * @throws OperationNotPermittedException
 */
public static void resellerOfCustomer(Organization reseller,
        Organization cust, Log4jLogger logger, SessionContext context)
        throws OperationNotPermittedException {
    List<Organization> customers = reseller.getCustomersOfReseller();
    if (!customers.contains(cust)) {
        String message = String.format(
                "Organization '%s' is not reseller of customer '%s'",
                reseller.getOrganizationId(), cust.getOrganizationId());
        OperationNotPermittedException e = new OperationNotPermittedException(
                message);
        if (logger != null) {
            logger.logWarn(Log4jLogger.SYSTEM_LOG, e,
                    LogMessageIdentifier.WARN_NO_RESELLER_OF_CUSTOMER,
                    reseller.getOrganizationId(), cust.getOrganizationId());
        }
        if (context != null) {
            context.setRollbackOnly();
        }
        throw e;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:41,代码来源:PermissionCheck.java

示例5: same

import javax.ejb.SessionContext; //导入方法依赖的package包/类
public static void same(Organization org1, Organization org2,
        Log4jLogger logger, SessionContext context)
        throws OperationNotPermittedException {
    if (org1 != org2) {
        String message = String
                .format("Organization '%s' tried to access organization '%s' but is not allowed to.",
                        org1.getOrganizationId(), org2.getOrganizationId());
        OperationNotPermittedException e = new OperationNotPermittedException(
                message);
        if (logger != null) {
            logger.logWarn(
                    Log4jLogger.SYSTEM_LOG,
                    e,
                    LogMessageIdentifier.WARN_INSUFFICIENT_AUTH_BY_ORGANIZATION_ACCESS,
                    org1.getOrganizationId(), org2.getOrganizationId());
        }
        if (context != null) {
            context.setRollbackOnly();
        }
        throw e;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:23,代码来源:PermissionCheck.java

示例6: sameUdaTarget

import javax.ejb.SessionContext; //导入方法依赖的package包/类
public static void sameUdaTarget(Organization caller, Uda uda,
        long targetKey, Log4jLogger logger, SessionContext context)
        throws OperationNotPermittedException {
    if (uda.getTargetObjectKey() != targetKey) {
        String message = String
                .format("Organization '%s' tried to change uda '%s' from target '%s' to target '%s'.",
                        caller.getOrganizationId(),
                        Long.toString(uda.getKey()),
                        Long.toString(uda.getTargetObjectKey()),
                        Long.toString(targetKey));
        OperationNotPermittedException e = new OperationNotPermittedException(
                message);
        if (logger != null) {
            logger.logWarn(
                    Log4jLogger.SYSTEM_LOG,
                    e,
                    LogMessageIdentifier.WARN_UNPERMITTED_UDA_TARGET_SWITCH,
                    caller.getOrganizationId(),
                    Long.toString(uda.getKey()),
                    Long.toString(uda.getTargetObjectKey()),
                    Long.toString(targetKey));
        }
        if (context != null) {
            context.setRollbackOnly();
        }
        throw e;
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:29,代码来源:PermissionCheck.java

示例7: canPublish

import javax.ejb.SessionContext; //导入方法依赖的package包/类
/**
 * Checks if the provided supplier {@link Organization} is allowed to
 * publish services on the provided {@link Marketplace} For non-opened
 * marketplaces a {@link MarketplaceToOrganization} connecting both with
 * publishing access granted must exist. If not, a
 * {@link OperationNotPermittedException} will be thrown. For open
 * marketplaces it is allowed to publish if a
 * {@link MarketplaceToOrganization} with publish access denied does not
 * exist. If it exists, a {@link OperationNotPermittedException} will be
 * thrown.
 * 
 * @param mp
 *            the {@link Marketplace} to publish on
 * @param sup
 *            the supplier {@link Organization} that wants to publish
 * @param logger
 *            the optional logger - if not <code>null</code> it logs the
 *            created exception as warning to the system log
 * @param context
 *            if not <code>null</code>,
 *            {@link SessionContext#setRollbackOnly()} will called.
 * @throws OperationNotPermittedException
 *             in case the supplier is not allowed to publish services on
 *             the provided marketplace
 */
public static void canPublish(Marketplace mp, Organization sup,
        Log4jLogger logger, SessionContext context)
        throws OperationNotPermittedException {

    List<MarketplaceToOrganization> list = mp
            .getMarketplaceToOrganizations();
    boolean denied = false;
    for (MarketplaceToOrganization mto : list) {
        if (sup == mto.getOrganization()
                && PublishingAccess.PUBLISHING_ACCESS_GRANTED.equals(mto
                        .getPublishingAccess())) {
            return;
        }
        if (sup == mto.getOrganization()
                && PublishingAccess.PUBLISHING_ACCESS_DENIED.equals(mto
                        .getPublishingAccess())) {
            denied = true;
            break;
        }
    }
    if (!denied && mp.isOpen()) {
        return;
    }
    String message = String
            .format("Organization '%s' tried to publish on marketplace '%s' but is not allowed.",
                    sup.getOrganizationId(), mp.getMarketplaceId());
    PublishingToMarketplaceNotPermittedException e = new PublishingToMarketplaceNotPermittedException(
            message);
    if (logger != null) {
        logger.logWarn(
                Log4jLogger.SYSTEM_LOG,
                e,
                LogMessageIdentifier.WARN_INSUFFICIENT_AUTH_BY_PUBLISH_ON_MARKETPLACE,
                sup.getOrganizationId(), mp.getMarketplaceId());
    }
    if (context != null) {
        context.setRollbackOnly();
    }
    throw e;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:66,代码来源:PermissionCheck.java


注:本文中的javax.ejb.SessionContext.setRollbackOnly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。