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


Java Transactional类代码示例

本文整理汇总了Java中org.mybatis.guice.transactional.Transactional的典型用法代码示例。如果您正苦于以下问题:Java Transactional类的具体用法?Java Transactional怎么用?Java Transactional使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: cleanUpOrphanedIamRoles

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
/**
 * Delete all IAM role records that are no longer associated with an SDB.
 */
@Transactional
protected void cleanUpOrphanedIamRoles() {

    // get orphaned iam role ids
    final List<AwsIamRoleRecord> orphanedIamRoleIds = awsIamRoleDao.getOrphanedIamRoles();

    // delete orphaned iam role records from DB
    orphanedIamRoleIds.forEach(awsIamRoleRecord -> {
        try {
            logger.info("Deleting orphaned IAM role: ARN={}, lastUpdated={}",
                    awsIamRoleRecord.getAwsIamRoleArn(),
                    awsIamRoleRecord.getLastUpdatedTs());
            awsIamRoleDao.deleteIamRoleById(awsIamRoleRecord.getId());
        } catch(Exception e) {
            logger.error("There was a problem deleting orphaned IAM role with ARN: {}",
                awsIamRoleRecord.getAwsIamRoleArn(),
                e);
        }
    });
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:24,代码来源:CleanUpService.java

示例2: updateUserGroupPermission

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
/**
 * Updates a user group permission.
 *
 * @param safeDepositBoxId The safe deposit box id
 * @param userGroupPermission The user group permission
 * @param user The user making the changes
 * @param dateTime The time of the changes
 */
@Transactional
public void updateUserGroupPermission(final String safeDepositBoxId,
                                      final UserGroupPermission userGroupPermission,
                                      final String user,
                                      final OffsetDateTime dateTime) {

    final Optional<UserGroupRecord> possibleUserGroupRecord =
            userGroupDao.getUserGroupByName(userGroupPermission.getName());

    if (!possibleUserGroupRecord.isPresent()) {
        throw ApiException.newBuilder()
                .withApiErrors(DefaultApiError.ENTITY_NOT_FOUND)
                .withExceptionMessage("Unable to update permissions for user group name that doesn't exist.")
                .build();
    }

    UserGroupPermissionRecord record = new UserGroupPermissionRecord();
    record.setSdboxId(safeDepositBoxId);
    record.setUserGroupId(possibleUserGroupRecord.get().getId());
    record.setRoleId(userGroupPermission.getRoleId());
    record.setLastUpdatedBy(user);
    record.setLastUpdatedTs(dateTime);
    userGroupDao.updateUserGroupPermission(record);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:33,代码来源:UserGroupPermissionService.java

示例3: revokeUserGroupPermission

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
/**
 * Revokes a user group permission.
 *
 * @param safeDepositBoxId The safe deposit box id
 * @param userGroupPermission The user group permission
 * @param user The user making the changes
 * @param dateTime The time of the changes
 */
@Transactional
public void revokeUserGroupPermission(final String safeDepositBoxId,
                                      final UserGroupPermission userGroupPermission,
                                      final String user,
                                      final OffsetDateTime dateTime) {
    final Optional<UserGroupRecord> userGroupRecord =
            userGroupDao.getUserGroupByName(userGroupPermission.getName());

    if (!userGroupRecord.isPresent()) {
        throw ApiException.newBuilder()
                .withApiErrors(DefaultApiError.ENTITY_NOT_FOUND)
                .withExceptionMessage("Unable to revoke permissions for user group name that doesn't exist.")
                .build();
    }

    userGroupDao.deleteUserGroupPermission(safeDepositBoxId, userGroupRecord.get().getId());
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:26,代码来源:UserGroupPermissionService.java

示例4: updateKmsKey

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
/**
 * Updates the KMS CMK record for the specified IAM role and region
 * @param awsIamRoleId    The IAM role that this CMK will be associated with
 * @param awsRegion       The region to provision the key in
 * @param user            The user requesting it
 * @param lastedUpdatedTs The date when the record was last updated
 * @param lastValidatedTs The date when the record was last validated
 */
@Transactional
public void updateKmsKey(final String awsIamRoleId,
                         final String awsRegion,
                         final String user,
                         final OffsetDateTime lastedUpdatedTs,
                         final OffsetDateTime lastValidatedTs) {
    final Optional<AwsIamRoleKmsKeyRecord> kmsKey = awsIamRoleDao.getKmsKey(awsIamRoleId, awsRegion);

    if (!kmsKey.isPresent()) {
        throw ApiException.newBuilder()
                .withApiErrors(DefaultApiError.ENTITY_NOT_FOUND)
                .withExceptionMessage("Unable to update a KMS key that does not exist.")
                .build();
    }

    AwsIamRoleKmsKeyRecord kmsKeyRecord = kmsKey.get();

    AwsIamRoleKmsKeyRecord updatedKmsKeyRecord = new AwsIamRoleKmsKeyRecord();
    updatedKmsKeyRecord.setAwsIamRoleId(kmsKeyRecord.getAwsIamRoleId());
    updatedKmsKeyRecord.setLastUpdatedBy(user);
    updatedKmsKeyRecord.setLastUpdatedTs(lastedUpdatedTs);
    updatedKmsKeyRecord.setLastValidatedTs(lastValidatedTs);
    updatedKmsKeyRecord.setAwsRegion(kmsKeyRecord.getAwsRegion());
    awsIamRoleDao.updateIamRoleKmsKey(updatedKmsKeyRecord);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:34,代码来源:KmsService.java

示例5: assertPrincipalHasOwnerPermissions

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
/**
 * Updates a safe deposit box.  Currently, only the description, owner and permissions are updatable.
 *
 * @param safeDepositBox Updated safe deposit box
 * @param vaultAuthPrincipal The authenticated principal
 * @param id Safe deposit box id
 */
@Transactional
public SafeDepositBoxV2 updateSafeDepositBoxV2(final SafeDepositBoxV2 safeDepositBox,
                                               final VaultAuthPrincipal vaultAuthPrincipal,
                                               final String id) {

    final SafeDepositBoxV2 currentBox = getSDBAndValidatePrincipalAssociationV2(vaultAuthPrincipal, id);

    assertPrincipalHasOwnerPermissions(vaultAuthPrincipal, currentBox);

    String principalName = vaultAuthPrincipal.getName();
    final OffsetDateTime now = dateTimeSupplier.get();
    final SafeDepositBoxRecord boxToUpdate = buildBoxToUpdate(id, safeDepositBox, principalName, now);
    final Set<UserGroupPermission> userGroupPermissionSet = safeDepositBox.getUserGroupPermissions();
    final Set<IamPrincipalPermission> iamRolePermissionSet = safeDepositBox.getIamPrincipalPermissions();

    if (!StringUtils.equals(currentBox.getDescription(), boxToUpdate.getDescription())) {
        safeDepositBoxDao.updateSafeDepositBox(boxToUpdate);
    }

    updateOwner(currentBox.getId(), safeDepositBox.getOwner(), principalName, now);
    modifyUserGroupPermissions(currentBox, userGroupPermissionSet, principalName, now);
    modifyIamPrincipalPermissions(currentBox, iamRolePermissionSet, principalName, now);

    return getSDBAndValidatePrincipalAssociationV2(vaultAuthPrincipal, id);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:33,代码来源:SafeDepositBoxService.java

示例6: deleteSafeDepositBox

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
/**
 * Deletes a safe deposit box and associated permissions.  Also removes the policies and secrets from Vault.
 *
 * @param id The unique identifier for the safe deposit box
 */
@Transactional
public void deleteSafeDepositBox(VaultAuthPrincipal vaultAuthPrincipal, final String id) {
    final SafeDepositBoxV2 box = getSDBAndValidatePrincipalAssociationV2(vaultAuthPrincipal, id);

    assertPrincipalHasOwnerPermissions(vaultAuthPrincipal, box);

    // 1. Remove permissions and metadata from database.
    iamPrincipalPermissionService.deleteIamPrincipalPermissions(id);
    userGroupPermissionService.deleteUserGroupPermissions(id);
    safeDepositBoxDao.deleteSafeDepositBox(id);

    // 2. Recursively delete all secrets from the safe deposit box Vault path.
    deleteAllSecrets(box.getPath());

    // 3. Delete the standard policies from Vault for this safe deposit box.
    vaultPolicyService.deleteStandardPolicies(box.getName());
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:23,代码来源:SafeDepositBoxService.java

示例7: updateIamPrincipalPermission

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
/**
 * Updates a IAM role permission.
 *
 * @param safeDepositBoxId The safe deposit box id
 * @param iamPrincipalPermission The IAM principal permission
 * @param user The user making the changes
 * @param dateTime The time of the changes
 */
@Transactional
public void updateIamPrincipalPermission(final String safeDepositBoxId,
                                         final IamPrincipalPermission iamPrincipalPermission,
                                         final String user,
                                         final OffsetDateTime dateTime) {
    final Optional<AwsIamRoleRecord> iamRole =
            awsIamRoleDao.getIamRole(iamPrincipalPermission.getIamPrincipalArn());

    if (!iamRole.isPresent()) {
        throw ApiException.newBuilder()
                .withApiErrors(DefaultApiError.ENTITY_NOT_FOUND)
                .withExceptionMessage("Unable to update permissions for IAM role that doesn't exist.")
                .build();
    }

    AwsIamRolePermissionRecord record = new AwsIamRolePermissionRecord();
    record.setSdboxId(safeDepositBoxId);
    record.setAwsIamRoleId(iamRole.get().getId());
    record.setRoleId(iamPrincipalPermission.getRoleId());
    record.setLastUpdatedBy(user);
    record.setLastUpdatedTs(dateTime);
    awsIamRoleDao.updateIamRolePermission(record);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:32,代码来源:IamPrincipalPermissionService.java

示例8: revokeIamPrincipalPermission

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
/**
 * Revokes a IAM role permission.
 *
 * @param safeDepositBoxId The safe deposit box id
 * @param iamPrincipalPermission The IAM principal permission
 * @param user The user making the changes
 * @param dateTime The time of the changes
 */
@Transactional
public void revokeIamPrincipalPermission(final String safeDepositBoxId,
                                         final IamPrincipalPermission iamPrincipalPermission,
                                         final String user,
                                         final OffsetDateTime dateTime) {
    final Optional<AwsIamRoleRecord> iamRole =
            awsIamRoleDao.getIamRole(iamPrincipalPermission.getIamPrincipalArn());

    if (!iamRole.isPresent()) {
        throw ApiException.newBuilder()
                .withApiErrors(DefaultApiError.ENTITY_NOT_FOUND)
                .withExceptionMessage("Unable to revoke permissions for IAM role that doesn't exist.")
                .build();
    }

    awsIamRoleDao.deleteIamRolePermission(safeDepositBoxId, iamRole.get().getId());
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:26,代码来源:IamPrincipalPermissionService.java

示例9: getGuacamoleTunnel

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
@Override
@Transactional
public GuacamoleTunnel getGuacamoleTunnel(RemoteAuthenticatedUser user,
        SharedConnectionDefinition definition,
        GuacamoleClientInformation info)
        throws GuacamoleException {

    // Create a connection record which describes the shared connection
    ActiveConnectionRecord connectionRecord = activeConnectionRecordProvider.get();
    connectionRecord.init(user, definition.getActiveConnection(),
            definition.getSharingProfile());

    // Connect to shared connection described by the created record
    GuacamoleTunnel tunnel = assignGuacamoleTunnel(connectionRecord, info, false);

    // Register tunnel, such that it is closed when the
    // SharedConnectionDefinition is invalidated
    definition.registerTunnel(tunnel);
    return tunnel;

}
 
开发者ID:apache,项目名称:guacamole-client,代码行数:22,代码来源:AbstractGuacamoleTunnelService.java

示例10: createOrGetThrowing

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
@Transactional
private ParsedName createOrGetThrowing(ParsedName preParsed, boolean update) throws PersistenceException {
  ParsedName pn = mapper.getByName(preParsed.getScientificName(), preParsed.getRank());
  if (pn == null) {
    // try to write the name to postgres
    mapper.create(preParsed);
  } else if (update && !pn.equals(preParsed)) {
    // is it different?
    preParsed.setKey(pn.getKey());
    mapper.update(preParsed);

  } else {
    return pn;
  }
  return preParsed;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:17,代码来源:ParsedNameServiceMyBatis.java

示例11: insertNubRelationBatch

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
@Transactional(
    executorType = ExecutorType.BATCH,
    isolationLevel = TransactionIsolationLevel.READ_UNCOMMITTED,
    exceptionMessage = "Something went wrong while inserting nub relations batch for dataset {0}"
)
private void insertNubRelationBatch(UUID datasetKey, Map<Integer, Integer> relations, Iterable<Integer> usageKeyBatch) {
  for (Integer usageKey : usageKeyBatch) {
    Set<NameUsageIssue> issues = nameUsageMapper.getIssues(usageKey).getIssues();
    if (relations.get(usageKey) == null) {
      // no match, add issue if not existing yet
      if (!issues.contains(NameUsageIssue.BACKBONE_MATCH_NONE)) {
        issues.add(NameUsageIssue.BACKBONE_MATCH_NONE);
        nameUsageMapper.updateIssues(usageKey, issues);
      }

    } else {
      if (issues.remove(NameUsageIssue.BACKBONE_MATCH_NONE) || issues.remove(NameUsageIssue.BACKBONE_MATCH_FUZZY)) {
        nameUsageMapper.updateIssues(usageKey, issues);
      }
      nubRelMapper.insert(datasetKey, usageKey, relations.get(usageKey));
      // for CoL with its instable ids update source key
      if (Constants.COL_DATASET_KEY.equals(datasetKey)) {
        usageMapper.updateSourceTaxonKey(relations.get(usageKey), usageKey);
      }
    }
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:28,代码来源:UsageSyncServiceMyBatis.java

示例12: write

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
@Transactional(
    exceptionMessage = "usage sync job failed",
    executorType = ExecutorType.REUSE
)
private void write(List<Integer> neoNodeIdbatch) throws Exception {
  for (Integer id : neoNodeIdbatch) {
    NameUsage u = dao.readUsage(id);
    ParsedName pn = dao.readName(id);
    NameUsageMetrics m = dao.readMetrics(id);

    boolean insert = dao.isInsert(u);
    syncService.syncUsage(insert, u, pn, m);

    // remember usageKey and things about this record
    if (insert) {
      inserts.add(id);
    }
    usageKeys.put(id, u.getKey());
    // tell main importer about the new usageKey so we can prepare usages with good foreign keys
    dao.reportUsageKey(id, u.getKey());
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:23,代码来源:DatasetImportServiceMyBatis.java

示例13: call

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
@Override
@Transactional(
    exceptionMessage = "usage sync job failed",
    executorType = ExecutorType.REUSE
)
public List<NameUsage> call() throws Exception {
  LogContext.startDataset(datasetKey);
  LOG.debug("Starting usage sync with {} usages", usages.size());
  Iterator<ParsedName> nIter = names.iterator();
  for (NameUsage u : usages) {
    // pro parte usages are synonyms and do not have any descendants, synonyms, etc
    NameUsageMetrics m = new NameUsageMetrics();
    ParsedName pn = nIter.next();
    m.setKey(u.getKey());
    m.setNumDescendants(0);

    boolean insert = dao.isInsert(u);
    syncService.syncUsage(insert, u, pn, m);
  }
  LOG.debug("Completed batch of {} pro parte usages", usages.size());
  LogContext.endDataset();
  return usages;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:24,代码来源:DatasetImportServiceMyBatis.java

示例14: save

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
/**
 * 保存数据(插入或更新)
 * @param entity
 */
@Transactional
public void save(T entity) {
	if (null == entity.getId()) {
		dao.insert(entity);
	} else {
		dao.update(entity);
	}
}
 
开发者ID:gingerjiang,项目名称:easycms,代码行数:13,代码来源:CrudService.java

示例15: delete

import org.mybatis.guice.transactional.Transactional; //导入依赖的package包/类
@Transactional
public int delete(String ids) {
	int result = 0;
	for (String id : ids.split(",")) {
		result = dao.delete(Integer.parseInt(id));
	}
	return result;
}
 
开发者ID:gingerjiang,项目名称:easycms,代码行数:9,代码来源:ColumnService.java


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