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

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

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

Resource.getContentStream介绍

暂无

代码示例

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

public ResourceContentInputStream(Resource resource) throws RegistryException {
  this.resource = resource;
  inputStream = resource.getContentStream();
}

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

protected List<String> getServersToDiscover(Registry registry) throws RegistryException, IOException {
  Resource resource = registry.get(serverIdPropertyFilePath);
  if (resource != null) {
    Properties serverProperties = new Properties();
    serverProperties.load(resource.getContentStream());
    String serverStr = serverProperties.getProperty(SERVERS_PROPERTY);
    if (serverStr != null) {
      String[] servers = serverStr.split(SERVER_ID_SEPARATOR);
      return Arrays.asList(servers);
    }
  }
  return Collections.emptyList();
}

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

private Policy loadPolicy(Resource resource) throws org.wso2.carbon.registry.api.RegistryException, XMLStreamException {
  InputStream in = resource.getContentStream();
  XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
  xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
  xmlInputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", false);
  XMLStreamReader parser = xmlInputFactory.createXMLStreamReader(in);
  StAXOMBuilder builder = new StAXOMBuilder(parser);
  OMElement policyElement = builder.getDocumentElement();
  return PolicyEngine.getPolicy(policyElement);
}

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

private Policy loadPolicy(Resource resource) throws org.wso2.carbon.registry.api.RegistryException, XMLStreamException {
  InputStream in = resource.getContentStream();
  XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
  xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
  xmlInputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", false);
  XMLStreamReader parser = xmlInputFactory.createXMLStreamReader(in);
  StAXOMBuilder builder = new StAXOMBuilder(parser);
  OMElement policyElement = builder.getDocumentElement();
  return PolicyEngine.getPolicy(policyElement);
}

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

private Policy loadPolicy(Resource resource) throws org.wso2.carbon.registry.api.RegistryException,
    XMLStreamException {
  InputStream in = resource.getContentStream();
  XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
  xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
  XMLStreamReader parser = xmlInputFactory.createXMLStreamReader(in);
  StAXOMBuilder builder = new StAXOMBuilder(parser);
  OMElement policyElement = builder.getDocumentElement();
  return PolicyEngine.getPolicy(policyElement);
}

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

private Policy loadPolicy(Resource resource) throws org.wso2.carbon.registry.api.RegistryException,
    XMLStreamException {
  InputStream in = resource.getContentStream();
  XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
  xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
  XMLStreamReader parser = xmlInputFactory.createXMLStreamReader(in);
  StAXOMBuilder builder = new StAXOMBuilder(parser);
  OMElement policyElement = builder.getDocumentElement();
  return PolicyEngine.getPolicy(policyElement);
}

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

private Policy loadPolicy(Resource resource) throws org.wso2.carbon.registry.api.RegistryException,
    XMLStreamException {
  InputStream in = resource.getContentStream();
  XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
  xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
  XMLStreamReader parser = xmlInputFactory.createXMLStreamReader(in);
  StAXOMBuilder builder = new StAXOMBuilder(parser);
  OMElement policyElement = builder.getDocumentElement();
  return PolicyEngine.getPolicy(policyElement);
}

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

private Policy loadPolicy(Resource resource) throws org.wso2.carbon.registry.api.RegistryException, XMLStreamException {
  InputStream in = resource.getContentStream();
  XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(in);
  StAXOMBuilder builder = new StAXOMBuilder(parser);
  OMElement policyElement = builder.getDocumentElement();
  return PolicyEngine.getPolicy(policyElement);
}

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

String customPropertyDefinitions = IOUtils.toString(registry.get(customPropertyDefinitionsResourcePath).getContentStream());

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

private static void loadXML(Resource resource) throws ReportingException {
  InputStream reportDefinitionOmStream;
  StAXOMBuilder stAXOMBuilder;
  try {
    reportDefinitionOmStream = resource.getContentStream();
  } catch (RegistryException e) {
    log.error("failed to get the metadata xml", e);
    throw new ReportingException("failed to get the metadata xml", e);
  }
  XMLInputFactory xmlInputFactory;
  XMLStreamReader xmlStreamReader = null;
  xmlInputFactory = XMLInputFactory.newInstance();
  try {
    xmlStreamReader = xmlInputFactory.createXMLStreamReader(reportDefinitionOmStream);
    stAXOMBuilder = new StAXOMBuilder(xmlStreamReader);
    reportsElement = stAXOMBuilder.getDocumentElement();
    reportsElement.build();
  } catch (XMLStreamException e) {
    throw new ReportingException("failed to get the metadata xml", e);
  }
}

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

private void loadXML(Resource resource) throws ReportingException {
  InputStream reportDefinitionOmStream;
  StAXOMBuilder stAXOMBuilder;
  try {
    reportDefinitionOmStream = resource.getContentStream();
  } catch (RegistryException e) {
    throw new ReportingException("failed to get the metadata xml", e);
  }
  XMLInputFactory xmlInputFactory;
  XMLStreamReader xmlStreamReader = null;
  xmlInputFactory = XMLInputFactory.newInstance();
  try {
    xmlStreamReader = xmlInputFactory.createXMLStreamReader(reportDefinitionOmStream);
    stAXOMBuilder = new StAXOMBuilder(xmlStreamReader);
    reportsElement = stAXOMBuilder.getDocumentElement();
    reportsElement.build();
  } catch (XMLStreamException e) {
    throw new ReportingException("failed to get the metadata xml", e);
  }
}

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

InputStream in = resource.getContentStream();
XMLStreamReader parser = null;
XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();

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

public static byte[] getByteContent(Resource resource, String sourceURL)
            throws RegistryException {
  try {
    InputStream is = null;
    if (sourceURL != null) {
      is = new URL(sourceURL).openStream();
    } else {
      Object content = resource.getContent();
      if( null == content) {
        //returning an empty array, rather than 'null'.
        return new byte[0];
      }
      is = resource.getContentStream();
      if (is == null) {
        if (content instanceof byte[]) {
          return (byte[]) content;
        } else if (content instanceof String) {
          return RegistryUtils.encodeString((String) content);
        } else {
          throw new RegistryException("Unknown type found as content " + content);
        }
      }
    }
    return readBytesFromInputSteam(is);
  } catch (IOException e) {
    throw new RegistryException("Error at indexing", e);
  }
}

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

/**
 * Get stored custom outSequences from governanceSystem registry
 *
 * @throws org.wso2.carbon.appmgt.api.AppManagementException
 */
public List<String> getCustomOutSequences() throws AppManagementException {
  List<String> sequenceList = new ArrayList<String>();
  try {
    UserRegistry registry = ServiceReferenceHolder.getInstance().getRegistryService()
                           .getGovernanceSystemRegistry(tenantId);
    if (registry.resourceExists(AppMConstants.API_CUSTOM_OUTSEQUENCE_LOCATION)) {
      org.wso2.carbon.registry.api.Collection outSeqCollection =
                                    (org.wso2.carbon.registry.api.Collection) registry.get(AppMConstants.API_CUSTOM_OUTSEQUENCE_LOCATION);
      if (outSeqCollection !=null) {
        String[] outSeqChildPaths = outSeqCollection.getChildren();
        for (int i = 0; i < outSeqChildPaths.length; i++) {
          Resource outSequence = registry.get(outSeqChildPaths[i]);
          OMElement seqElment = AppManagerUtil.buildOMElement(outSequence.getContentStream());
          sequenceList.add(seqElment.getAttributeValue(new QName("name")));
        }
      }
    }
  } catch (Exception e) {
    handleException("Issue is in getting custom OutSequences from the Registry", e);
  }
  return sequenceList;
}

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

/**
 * Get stored custom inSequences from governanceSystem registry
 *
 * @throws org.wso2.carbon.appmgt.api.AppManagementException
 */
public List<String> getCustomInSequences() throws AppManagementException {
  List<String> sequenceList = new ArrayList<String>();
  try {
    UserRegistry registry = ServiceReferenceHolder.getInstance().getRegistryService()
                           .getGovernanceSystemRegistry(tenantId);
    if (registry.resourceExists(AppMConstants.API_CUSTOM_INSEQUENCE_LOCATION)) {
      org.wso2.carbon.registry.api.Collection inSeqCollection =
                                   (org.wso2.carbon.registry.api.Collection) registry.get(AppMConstants.API_CUSTOM_INSEQUENCE_LOCATION);
      if (inSeqCollection != null) {
       //   SequenceMediatorFactory factory = new SequenceMediatorFactory();
        String[] inSeqChildPaths = inSeqCollection.getChildren();
        for (int i = 0; i < inSeqChildPaths.length; i++) {
          Resource inSequence = registry.get(inSeqChildPaths[i]);
          OMElement seqElment = AppManagerUtil.buildOMElement(inSequence.getContentStream());
          sequenceList.add(seqElment.getAttributeValue(new QName("name")));
        }
      }
    }
  } catch (Exception e) {
    handleException("Issue is in getting custom InSequences from the Registry", e);
  }
  return sequenceList;
}

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

@Override
protected Set<Action> compileAllowableActions(Set<Action> aas) {
  Set<Action> result = super.compileAllowableActions(aas);
  try {
    boolean status = getNode().getContentStream() != null ? true : false;
    setAction(result, Action.CAN_GET_CONTENT_STREAM, status);
  } catch (RegistryException e) {
    log.error("Failed to get the content stream for the node " + getNode().getId() + " " , e);
    setAction(result, Action.CAN_GET_CONTENT_STREAM, false);
  }
  setAction(result, Action.CAN_SET_CONTENT_STREAM, true);
  setAction(result, Action.CAN_DELETE_CONTENT_STREAM, true);
  setAction(result, Action.CAN_GET_RENDITIONS, false);
  return result;
}

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

private InputStream getTemplateResource(String templateName) throws ReportingException {
  String localPath = "templates/";
  String jrXmlPath = ReportConstants.REPORT_BASE_PATH + localPath + templateName + ".jrxml";
  Registry registry = null;
  try {
    registry = ReportingTemplateComponent.getRegistryService().getConfigSystemRegistry();
  } catch (RegistryException e) {
    throw new ReportingException(e.getMessage(), e);
  }
  Resource resource;
  InputStream reportDefinitionOmStream;
  try {
    resource = registry.get(jrXmlPath);
    reportDefinitionOmStream = resource.getContentStream();
    return reportDefinitionOmStream;
  } catch (RegistryException e) {
    throw new ReportingException(templateName + " getting  failed from registry", e);
  }
}

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

public Icon getIcon(APIIdentifier identifier) throws AppManagementException {
  String artifactPath = AppMConstants.API_IMAGE_LOCATION + RegistryConstants.PATH_SEPARATOR +
             identifier.getProviderName() + RegistryConstants.PATH_SEPARATOR +
             identifier.getApiName() + RegistryConstants.PATH_SEPARATOR + identifier.getVersion();
  String thumbPath = artifactPath + RegistryConstants.PATH_SEPARATOR + AppMConstants.API_ICON_IMAGE;
  try {
    if (registry.resourceExists(thumbPath)) {
      Resource res = registry.get(thumbPath);
      Icon icon = new Icon(res.getContentStream(), res.getMediaType());
      return icon;
    }
  } catch (RegistryException e) {
    handleException("Error while loading WebApp icon from the registry", e);
  }
  return null;
}

代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.gateway

/**
 * Initialize the google analytics publisher by reading tenants google analytics
 * configuration from the registry
 *
 * @param tenantDomain Tenant domain of the current tenant
 */
public void init(String tenantDomain) {
  configKey = APIConstants.GA_CONFIGURATION_LOCATION;
  try {
    PrivilegedCarbonContext.startTenantFlow();
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
    Registry registry = ServiceReferenceHolder.getInstance().getRegistryService().getGovernanceSystemRegistry();
    Resource resource = registry.get(configKey);
    InputStream in = resource.getContentStream();
    StAXOMBuilder builder = new StAXOMBuilder(in);
    this.gaConfig = new GoogleAnalyticsConfig(builder.getDocumentElement());
  } catch (RegistryException | XMLStreamException e) {
    // flow should not break. Therefore ignoring the exception
    log.error("Failed to retrieve google analytics configurations for tenant:" + tenantDomain);
  } finally {
    PrivilegedCarbonContext.endTenantFlow();
  }
}

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

public ContentStream getContentStream(){
  // compile data
  ContentStreamImpl result = new ContentStreamImpl();
  result.setFileName(getName());
    
  try {
    result.setLength(BigInteger.valueOf(getPropertyLength(getNode(), CMISConstants.GREG_DATA)));
    if(getNode().getContent() != null){
      String mimeType = getNode().getProperty(CMISConstants.GREG_MIMETYPE);
      result.setMimeType(mimeType);
      //result.setMimeType(getNode().getMediaType());
    } else {
      result.setMimeType(null);
    }
    if(getNode().getContent() != null){
      InputStream inputStream = getNode().getContentStream();
      result.setStream(new BufferedInputStream(inputStream));  // stream closed by consumer
    } else {
      result.setStream(null);
    }
  } catch (RegistryException e) {
    throw new CmisRuntimeException(e.getMessage(), e);
  }
  return result;
}

相关文章