org.wso2.carbon.registry.core.Registry.commitTransaction()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(15.0k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.wso2.carbon.registry.core.Registry.commitTransaction方法的一些代码示例,展示了Registry.commitTransaction的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.commitTransaction方法的具体详情如下:
包路径:org.wso2.carbon.registry.core.Registry
类名称:Registry
方法名:commitTransaction

Registry.commitTransaction介绍

暂无

代码示例

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.core

/**
   * Commit or rollback the registry operation depends on the error condition.
   * @param isErrorOccurred Identifier for error transactions.
   * @throws IdentityException Error while committing or running rollback on the transaction.
   */
  private void commitOrRollbackTransaction(boolean isErrorOccurred) throws IdentityException {

    try {
      // Rollback the transaction if there is an error, Otherwise try to commit.
      if (isErrorOccurred) {
        registry.rollbackTransaction();
      } else {
        registry.commitTransaction();
      }
    } catch (RegistryException ex) {
      throw new IdentityException("Error occurred while trying to commit or rollback the registry operation.", ex);
    }
  }
}

代码示例来源:origin: wso2/carbon-identity-framework

/**
   * Commit or rollback the registry operation depends on the error condition.
   * @param isErrorOccurred Identifier for error transactions.
   * @throws IdentityException Error while committing or running rollback on the transaction.
   */
  private void commitOrRollbackTransaction(boolean isErrorOccurred) throws IdentityException {

    try {
      // Rollback the transaction if there is an error, Otherwise try to commit.
      if (isErrorOccurred) {
        registry.rollbackTransaction();
      } else {
        registry.commitTransaction();
      }
    } catch (RegistryException ex) {
      throw new IdentityException("Error occurred while trying to commit or rollback the registry operation.", ex);
    }
  }
}

代码示例来源:origin: wso2/carbon-identity-framework

private void deleteResource(String resource) throws RegistryException {

    registry.beginTransaction();
    // Check whether the resource still exists for concurrent cases.
    if (registry.resourceExists(resource)) {
      registry.delete(resource);
      registry.commitTransaction();
    } else {
      // Already deleted by another thread. Do nothing.
      registry.rollbackTransaction();
      if (log.isDebugEnabled()) {
        log.debug("Confirmation code already deleted in path of resource : " + resource);
      }
    }
  }
}

代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.reporting.template.core

private static boolean loadMetaData() throws ReportingException {
  try {
    RegistryService registryService = ReportingTemplateComponent.getRegistryService();
    Registry registry = registryService.getConfigSystemRegistry();
    registry.beginTransaction();
    String location = ReportConstants.REPORT_META_DATA_PATH + ReportConstants.METADATA_FILE_NAME;
    Resource resource = null;
    if (registry.resourceExists(location)) {
      resource = registry.get(location);
      loadXML(resource);
      registry.commitTransaction();
      return true;
    } else {
      registry.commitTransaction();
      return false;
    }
  } catch (RegistryException e) {
    log.error("Exception occurred in loading the mete-data of reports", e);
    throw new ReportingException("Exception occurred in loading the mete-data of reports", e);
  }
}

代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.reporting.template.core

private void loadMetaData() throws ReportingException {
  try {
    RegistryService registryService = ReportingTemplateComponent.getRegistryService();
    Registry registry = registryService.getConfigSystemRegistry();
    registry.beginTransaction();
    String location = ReportConstants.REPORT_META_DATA_PATH + ReportConstants.METADATA_FILE_NAME;
    Resource resource = null;
    if (registry.resourceExists(location)) {
      resource = registry.get(location);
      loadXML(resource);
      registry.commitTransaction();
    } else {
      createNewMetaData();
      registry.commitTransaction();
    }
  } catch (RegistryException e) {
    throw new ReportingException("Exception occured in loading the mete-data of reports", e);
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.mgt

@Override
public void invalidate(String code) throws IdentityException {
  Registry registry = null;
  try {
    registry = IdentityMgtServiceComponent.getRegistryService().
        getConfigSystemRegistry(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
    registry.beginTransaction();
    String secretKeyPath = IdentityMgtConstants.IDENTITY_MANAGEMENT_DATA +
        RegistryConstants.PATH_SEPARATOR + code.toLowerCase();
    if (registry.resourceExists(secretKeyPath)) {
      registry.delete(secretKeyPath);
    }
  } catch (RegistryException e) {
    log.error(e);
    throw IdentityException.error("Error while invalidating user recovery data for code : " + code);
  } finally {
    if (registry != null) {
      try {
        registry.commitTransaction();
      } catch (RegistryException e) {
        log.error("Error while processing registry transaction", e);
      }
    }
  }
}

代码示例来源:origin: wso2/carbon-identity-framework

@Override
public void invalidate(String code) throws IdentityException {
  Registry registry = null;
  try {
    registry = IdentityMgtServiceComponent.getRegistryService().
        getConfigSystemRegistry(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
    registry.beginTransaction();
    String secretKeyPath = IdentityMgtConstants.IDENTITY_MANAGEMENT_DATA +
        RegistryConstants.PATH_SEPARATOR + code.toLowerCase();
    if (registry.resourceExists(secretKeyPath)) {
      registry.delete(secretKeyPath);
    }
  } catch (RegistryException e) {
    log.error(e);
    throw IdentityException.error("Error while invalidating user recovery data for code : " + code);
  } finally {
    if (registry != null) {
      try {
        registry.commitTransaction();
      } catch (RegistryException e) {
        log.error("Error while processing registry transaction", e);
      }
    }
  }
}

代码示例来源:origin: org.apache.stratos/org.apache.stratos.adc.mgt

registry.commitTransaction();
} catch (RegistryException e) {
  registry.rollbackTransaction();

代码示例来源:origin: org.apache.stratos/org.apache.stratos.adc.mgt

/**
*
*/
public void addDomainMappingToRegistry(String hostName, String actualHost)
    throws ADCException, RegistryException, DomainMappingExistsException {
  try {
    registry.beginTransaction();
    Resource hostResource = registry.newResource();
    hostResource.addProperty(CartridgeConstants.DomainMappingInfo.ACTUAL_HOST, actualHost);
    if (!registry.resourceExists(CartridgeConstants.DomainMappingInfo.HOSTINFO +
                      hostName)) {
      registry.put(CartridgeConstants.DomainMappingInfo.HOSTINFO + hostName,
                hostResource);
    } else {
      registry.rollbackTransaction();
      String msg = "Requested domain is already taken!";
      log.error(msg);
      throw new DomainMappingExistsException(msg, hostName);
    }
    registry.commitTransaction();
  } catch (RegistryException e) {
    registry.rollbackTransaction();
    throw e; 
  }
}

代码示例来源:origin: org.wso2.carbon.devicemgt-plugins/org.wso2.carbon.device.mgt.mobile.impl

public static boolean putRegistryResource(String path,
                     Resource resource)
    throws MobileDeviceMgtPluginException {
  boolean status;
  try {
    MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction();
    MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource);
    MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction();
    status = true;
  } catch (RegistryException e) {
    throw new MobileDeviceMgtPluginException(
        "Error occurred while persisting registry resource : " +
        e.getMessage(), e);
  }
  return status;
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.security.mgt

registry.commitTransaction();

代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.reporting.template.core

public void saveMetadata
    () throws ReportingException {
  try {
    RegistryService registryService = ReportingTemplateComponent.getRegistryService();
    Registry registry = registryService.getConfigSystemRegistry();
    registry.beginTransaction();
    Resource reportFilesResource = registry.newResource();
    reportFilesResource.setContent(reportsElement.toString());
    String location = ReportConstants.REPORT_META_DATA_PATH + ReportConstants.METADATA_FILE_NAME;
    registry.put(location, reportFilesResource);
    registry.commitTransaction();
  } catch (RegistryException e) {
    throw new ReportingException("Exception occured in loading the meta-data of reports", e);
  }
}

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.lcm

public static boolean deleteLifecycle(String name, Registry registry, Registry rootRegistry) throws RegistryException, XMLStreamException {
  if (isLifecycleNameInUse(name, registry, rootRegistry))
    throw new RegistryException("Lifecycle could not be deleted, since it is already in use!");
  String path = getContextRoot() + name;
  if (registry.resourceExists(path)) {
    try {
      registry.beginTransaction();
      registry.delete(path);
      removeAspect(name, registry);
      registry.commitTransaction();
    } catch (Exception e) {
      registry.rollbackTransaction();
      throw new RegistryException("Unable to remove aspect", e);
    }
    return true;
  }
  return false;
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.mgt

@Override
public void store(UserRecoveryDataDO recoveryDataDO) throws IdentityException {
  Registry registry = null;
  try {
    registry = IdentityMgtServiceComponent.getRegistryService().
        getConfigSystemRegistry(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
    registry.beginTransaction();
    Resource resource = registry.newResource();
    resource.setProperty(SECRET_KEY, recoveryDataDO.getSecret());
    resource.setProperty(USER_ID, recoveryDataDO.getUserName());
    resource.setProperty(EXPIRE_TIME, recoveryDataDO.getExpireTime());
    resource.setVersionableChange(false);
    String confirmationKeyPath = IdentityMgtConstants.IDENTITY_MANAGEMENT_DATA + "/" + recoveryDataDO.getCode
        ().toLowerCase();
    registry.put(confirmationKeyPath, resource);
  } catch (RegistryException e) {
    log.error(e);
    throw IdentityException.error("Error while persisting user recovery data for user : " +
        recoveryDataDO.getUserName());
  } finally {
    if (registry != null) {
      try {
        registry.commitTransaction();
      } catch (RegistryException e) {
        log.error("Error while processing registry transaction", e);
      }
    }
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.security.mgt

private void addKeystores() throws RegistryException {
  Registry registry = SecurityServiceHolder.getRegistryService().getGovernanceSystemRegistry();
  try {
    boolean transactionStarted = Transaction.isStarted();
    if (!transactionStarted) {
      registry.beginTransaction();
    }
    if (!registry.resourceExists(SecurityConstants.KEY_STORES)) {
      Collection kstores = registry.newCollection();
      registry.put(SecurityConstants.KEY_STORES, kstores);
      Resource primResource = registry.newResource();
      if (!registry.resourceExists(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)) {
        registry.put(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE,
            primResource);
      }
    }
    if (!transactionStarted) {
      registry.commitTransaction();
    }
  } catch (Exception e) {
    registry.rollbackTransaction();
    throw e;
  }
}

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.security.mgt

private void addKeystores() throws RegistryException {
  Registry registry = SecurityServiceHolder.getRegistryService().getGovernanceSystemRegistry();
  try {
    boolean transactionStarted = Transaction.isStarted();
    if (!transactionStarted) {
      registry.beginTransaction();
    }
    if (!registry.resourceExists(SecurityConstants.KEY_STORES)) {
      Collection kstores = registry.newCollection();
      registry.put(SecurityConstants.KEY_STORES, kstores);
      Resource primResource = registry.newResource();
      if (!registry.resourceExists(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)) {
        registry.put(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE,
            primResource);
      }
    }
    if (!transactionStarted) {
      registry.commitTransaction();
    }
  } catch (Exception e) {
    registry.rollbackTransaction();
    throw e;
  }
}

代码示例来源:origin: org.wso2.carbon.business-process/org.wso2.carbon.bpel

/**
 * Handles deployment of new BPEL packages. Stores all the meta data and BPEL Package content
 * in the registry.
 *
 * @param deploymentContext containing information about current deployment
 * @throws RegistryException on registry access error.
 */
public void handleNewBPELPackageAddition(BPELDeploymentContext deploymentContext)
    throws Exception {
  try {
    if (!isDUCollectionIsThere(deploymentContext)) {
      configRegistry.beginTransaction();
      createBPELPackageParentCollectionWithProperties(deploymentContext);
      addLatestArchiveToRegistryCollection(deploymentContext);
      createCollectionWithBPELPackageContentForCurrentVersion(deploymentContext);
      configRegistry.commitTransaction();
    }
  } catch (RegistryException re) {
    handleExceptionWithRollback("Unable to handle new BPEL Package addition."
        + " Package: " + deploymentContext.getBpelPackageName(), re);
  } catch (NoSuchAlgorithmException e) {
    handleExceptionWithRollback("Unable to generate MD5. Adding BPEL package "
        + deploymentContext.getBpelPackageName() + " to registry failed.", e);
  } catch (IOException e) {
    handleExceptionWithRollback("Unable to find file to generate MD5. Adding BPEL package "
        + deploymentContext.getBpelPackageName() + " to registry failed.", e);
  }
}

代码示例来源:origin: wso2/carbon-identity-framework

private void addKeystores() throws RegistryException {
  Registry registry = SecurityServiceHolder.getRegistryService().getGovernanceSystemRegistry();
  try {
    boolean transactionStarted = Transaction.isStarted();
    if (!transactionStarted) {
      registry.beginTransaction();
    }
    if (!registry.resourceExists(SecurityConstants.KEY_STORES)) {
      Collection kstores = registry.newCollection();
      registry.put(SecurityConstants.KEY_STORES, kstores);
      Resource primResource = registry.newResource();
      if (!registry.resourceExists(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)) {
        registry.put(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE,
            primResource);
      }
    }
    if (!transactionStarted) {
      registry.commitTransaction();
    }
  } catch (Exception e) {
    registry.rollbackTransaction();
    throw e;
  }
}

代码示例来源:origin: org.wso2.carbon.business-process/org.wso2.carbon.bpel

/**
 * Update the registry meta data on BPEL package update.
 *
 * @param deploymentContext containing information about current deployment
 * @throws RegistryException on registry access error.
 */
public void handleBPELPackageUpdate(BPELDeploymentContext deploymentContext)
    throws Exception {
  try {
    if (!isDUCollectionIsThere(deploymentContext)) {
      configRegistry.beginTransaction();
      updateBPELPackageProperties(deploymentContext);
      addLatestArchiveToRegistryCollection(deploymentContext);
      createCollectionWithBPELPackageContentForCurrentVersion(deploymentContext);
      configRegistry.commitTransaction();
    }
  } catch (RegistryException re) {
    handleExceptionWithRollback("Unable to handle BPEL package update."
        + " Package: " + deploymentContext.getBpelPackageName(), re);
  } catch (NoSuchAlgorithmException e) {
    handleExceptionWithRollback("Unable to generate MD5. Adding BPEL package "
        + deploymentContext.getBpelPackageName() + " to registry failed.", e);
  } catch (IOException e) {
    handleExceptionWithRollback("Unable to find file to generate MD5. Adding BPEL package "
        + deploymentContext.getBpelPackageName() + " to registry failed.", e);
  }
}

代码示例来源:origin: org.wso2.carbon.devicemgt-plugins/org.wso2.carbon.device.mgt.mobile.impl

public static boolean createRegistryCollection(String path)
    throws MobileDeviceMgtPluginException {
  try {
    if (! MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)) {
      Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newCollection();
      MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction();
      MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource);
      MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction();
    }
    return true;
  } catch (MobileDeviceMgtPluginException e) {
    throw new MobileDeviceMgtPluginException(
        "Error occurred while creating a registry collection : " +
        e.getMessage(), e);
  } catch (RegistryException e) {
    throw new MobileDeviceMgtPluginException(
        "Error occurred while creating a registry collection : " +
        e.getMessage(), e);
  }
}

相关文章