org.wso2.carbon.registry.core.Registry类的使用及代码示例

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

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

Registry介绍

暂无

代码示例

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

registry.beginTransaction();
  String hostResourcePath = CartridgeConstants.DomainMappingInfo.HOSTINFO;
  if (registry.resourceExists(hostResourcePath)) {
    Resource hostResource = registry.get(hostResourcePath);
    Collection hostInfoCollection;
    if(hostResource instanceof Collection){
      Resource domainMapping = registry.get(path);
      String actualHostInRegistry = domainMapping.getProperty(CartridgeConstants.DomainMappingInfo.ACTUAL_HOST);
      if(actualHostInRegistry != null && actualHost.equalsIgnoreCase(actualHostInRegistry)){
        registry.delete(path);
  registry.commitTransaction();
} catch (RegistryException e) {
  registry.rollbackTransaction();
  log.error("Unable to remove the mapping", e);
  throw 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: 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.registry/org.wso2.carbon.registry.extensions

/**
 * Creates a collection in the given common location.
 *
 * @param commonLocation        location to create the collection.
 * @throws RegistryException    If fails to create a collection at given location.
 */
private void createCollection(String commonLocation) throws RegistryException {
  Registry systemRegistry = CommonUtil.getUnchrootedSystemRegistry(requestContext);
  //Creating a collection if not exists.
  if (!systemRegistry.resourceExists(commonLocation)) {
    systemRegistry.put(commonLocation, systemRegistry.newCollection());
  }
}

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

/**
 * Method to make an aspect to default.
 * @param path path of the resource
 * @param aspect   the aspect to be removed.
 * @param registry registry instance to be used
 */
public static void setDefaultLifeCycle(String path, String aspect, Registry registry) throws RegistryException {
  Resource resource = registry.get(path);
  if(resource != null) {
    resource.setProperty("registry.LC.name", aspect);
    registry.put(path, resource);
  }
}

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

public void updateDataRetentionPeriod(TimeRange timeRange) throws BAMException {
  try {
    Collection configCollection;
    if (registry.resourceExists(BAMRegistryResources.GLOBAL_CONFIG_PATH)) {
      configCollection = (Collection)registry.get(BAMRegistryResources.GLOBAL_CONFIG_PATH);
    } else {
      configCollection = registry.newCollection();
    }
    configCollection.setProperty(BAMRegistryResources.DATA_RETENTION_PROPERTY, timeRange.toString());
    registry.put(BAMRegistryResources.GLOBAL_CONFIG_PATH, configCollection);
  } catch (RegistryException e) {
    String msg = "Could not save the data retention policy in registry";
    log.error(msg);
    throw new BAMException(msg, e);
  }
}

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

private void persistTrustedService(String groupName, String serviceName, String trustedService,
                  String certAlias) throws SecurityConfigException {
  Registry registry;
  String resourcePath;
  Resource resource;
  try {
    resourcePath = RegistryResources.SERVICE_GROUPS + groupName
        + RegistryResources.SERVICES + serviceName + "/trustedServices";
    registry = getConfigSystemRegistry(); //TODO: Multitenancy
    if (registry != null) {
      if (registry.resourceExists(resourcePath)) {
        resource = registry.get(resourcePath);
      } else {
        resource = registry.newResource();
      }
      if (resource.getProperty(trustedService) != null) {
        resource.removeProperty(trustedService);
      }
      resource.addProperty(trustedService, certAlias);
      registry.put(resourcePath, resource);
    }
  } catch (Exception e) {
    log.error("Error occured while adding trusted service for STS", e);
    throw new SecurityConfigException("Error occured while adding trusted service for STS",
        e);
  }
}

代码示例来源:origin: org.wso2.carbon.appmgt/org.wso2.carbon.appmgt.impl

public boolean unSubscribeMobileApp(String userId, String appId) throws AppManagementException {
  String path = "users/" + userId + "/subscriptions/mobileapp/" + appId;
  boolean isUnSubscribed = false;
  try {
    if (registry.resourceExists(path)) {
      registry.delete(path);
      isUnSubscribed = true;
    }
  } catch (org.wso2.carbon.registry.api.RegistryException e) {
    handleException("Error occurred while removing subscription registry resource for mobileapp with id :" +
        appId, e);
  }
  return isUnSubscribed;
}

代码示例来源: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);
  }
}

代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.oauth2/org.wso2.carbon.identity.oauth

/***
 * Read the configuration file at server start up.
 * @param tenantId
 * @deprecated due to UI implementation.
 */
@Deprecated
public static void initTokenExpiryTimesOfSps(int tenantId) {
  try {
    Registry registry = OAuth2ServiceComponentHolder.getRegistryService().getConfigSystemRegistry(tenantId);
    if (!registry.resourceExists(OAuthConstants.TOKEN_EXPIRE_TIME_RESOURCE_PATH)) {
      Resource resource = registry.newResource();
      registry.put(OAuthConstants.TOKEN_EXPIRE_TIME_RESOURCE_PATH, resource);
    }
  } catch (RegistryException e) {
    log.error("Error while creating registry collection for :" + OAuthConstants.TOKEN_EXPIRE_TIME_RESOURCE_PATH, e);
  }
}

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

public PublisherDataHolder retrieveSubscriber(String id, boolean returnSecrets) throws EntitlementException {
  try {
    if (registry.resourceExists(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER +
        RegistryConstants.PATH_SEPARATOR + id)) {
      Resource resource = registry.get(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER +
          RegistryConstants.PATH_SEPARATOR + id);
      return new PublisherDataHolder(resource, returnSecrets);
    }
  } catch (RegistryException e) {
    log.error("Error while retrieving subscriber detail of id : " + id, e);
    throw new EntitlementException("Error while retrieving subscriber detail of id : " + id, e);
  }
  throw new EntitlementException("No Subscriber is defined for given Id");
}

代码示例来源: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.identity/org.wso2.carbon.security.mgt

private void persistPolicy(AxisService service, OMElement policy, String policyID) throws RegistryException {
  //Registry registryToLoad = SecurityServiceHolder.getRegistryService().getConfigSystemRegistry();
  Resource resource = registry.newResource();
  resource.setContent(policy.toString());
  String servicePath = getRegistryServicePath(service);
  String policyResourcePath = servicePath + RegistryResources.POLICIES + policyID;
  registry.put(policyResourcePath, resource);
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

@Override
public void createLink(RequestContext requestContext) throws RegistryException {
  String symlinkPath = requestContext.getResourcePath().getPath();
  String targetResourcePath = requestContext.getTargetPath();
  if (requestContext.getRegistry().resourceExists(targetResourcePath)) {
    Resource r = requestContext.getRegistry().get(targetResourcePath);
    r.addProperty("registry.resource.symlink.path", symlinkPath);
    requestContext.getRegistry().put(targetResourcePath, r);
  }
}

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.dashboard

public static void removeRegistryResource(String resourcePath) throws RegistryException {
  int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
  Registry registry = ServiceHolder.getRegistryService().getConfigSystemRegistry(tenantId);
  if (registry.resourceExists(resourcePath)) {
    Resource resource = registry.get(resourcePath);
    registry.delete(resourcePath);
  }
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

private static void removeEndpointDependencies(String servicePath, Registry registry) throws RegistryException {
  // update lock check removed from for loop to prevent the database lock
    Association[] associations = registry.getAllAssociations(servicePath);
    for (Association association : associations) {
      String path = association.getDestinationPath();
      if (registry.resourceExists(path)) {
        Resource endpointResource = registry.get(path);
        if (CommonConstants.ENDPOINT_MEDIA_TYPE.equals(endpointResource.getMediaType())) {
          registry.removeAssociation(servicePath, path, CommonConstants.DEPENDS);
          registry.removeAssociation(path, servicePath, CommonConstants.USED_BY);
        }
      }
    }
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

private void deleteChildRecursively(String path,Registry registry) throws RegistryException {
    Resource currentResource = registry.get(path);

    if((currentResource instanceof Collection) && ((Collection)currentResource).getChildCount() == 0 ){
      String[] childPaths = ((Collection)currentResource).getChildren();
      for (String childPath : childPaths) {
        deleteChildRecursively(childPath,registry);
      }
      registry.delete(path);
    } else {
      registry.delete(path);
    }

  }
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

private static void saveEndpoint(RequestContext context, Registry registry, String url, String associatedPath,
                 Map<String, String> properties, Registry systemRegistry, String environment)
                 throws RegistryException {
  String pathExpression = getEndpointLocation(context, url, systemRegistry, environment);
  String urlToPath = deriveEndpointFromUrl(url);
  String endpointAbsoluteBasePath = RegistryUtils.getAbsolutePath(registry.getRegistryContext(),
      org.wso2.carbon.registry.core.RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH +
      environment);
  if (!systemRegistry.resourceExists(endpointAbsoluteBasePath)) {
    systemRegistry.put(endpointAbsoluteBasePath, systemRegistry.newCollection());
  }
  String relativePath = environment + urlToPath;
  String endpointAbsolutePath = pathExpression;
  saveEndpointValues(context, registry, url, associatedPath, properties, systemRegistry, relativePath,
            endpointAbsolutePath);
}

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

public boolean hasXmppSettings(String userId) {
    boolean hasSettings = false;

    try {
      hasSettings = registry.resourceExists(IdentityRegistryResources.XMPP_SETTINGS_ROOT
          + userId);
    } catch (RegistryException e) {
      log.error("Error when checking the availability of the user " + userId, e);
    }

    return hasSettings;
  }
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.cmis

/**
 * Factory method creating a new <code>RegistryNode</code> from a node at a given Registry path.
 *
 * @param path  Registry path of the node
 * @return  A new instance representing the Registry node at <code>path</code>
 * @throws CmisObjectNotFoundException  if <code>path</code> does not identify a Registry node
 * @throws CmisRuntimeException
 */
public RegistryObject getNode(String path) throws RegistryException {
  return create(repository.get(path));
}

相关文章