當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。