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


Java Binary.getStream方法代码示例

本文整理汇总了Java中javax.jcr.Binary.getStream方法的典型用法代码示例。如果您正苦于以下问题:Java Binary.getStream方法的具体用法?Java Binary.getStream怎么用?Java Binary.getStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jcr.Binary的用法示例。


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

示例1: readFile

import javax.jcr.Binary; //导入方法依赖的package包/类
@Override
public InputStream readFile(String path,String version) throws Exception{
	if(StringUtils.isNotBlank(version)){
		repositoryInteceptor.readFile(path+":"+version);
		return readVersionFile(path, version);
	}
	repositoryInteceptor.readFile(path);
	Node rootNode=getRootNode();
	int colonPos = path.lastIndexOf(":");
	if (colonPos > -1) {
		version = path.substring(colonPos + 1, path.length());
		path = path.substring(0, colonPos);
		return readFile(path, version);
	}
	path = processPath(path);
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	Node fileNode = rootNode.getNode(path);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	return fileBinary.getStream();
}
 
开发者ID:youseries,项目名称:urule,代码行数:24,代码来源:BaseRepositoryService.java

示例2: loadResourceSecurityConfigs

import javax.jcr.Binary; //导入方法依赖的package包/类
@Override
public List<UserPermission> loadResourceSecurityConfigs(String companyId) throws Exception{
	List<UserPermission> configs=new ArrayList<UserPermission>();
	String filePath=RESOURCE_SECURITY_CONFIG_FILE+(companyId == null ? "" : companyId);
	Node rootNode=getRootNode();
	Node fileNode = rootNode.getNode(filePath);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	InputStream inputStream = fileBinary.getStream();
	String content = IOUtils.toString(inputStream, "utf-8");
	inputStream.close();
	Document document = DocumentHelper.parseText(content);
	Element rootElement = document.getRootElement();
	for (Object obj : rootElement.elements()) {
		if (!(obj instanceof Element)) {
			continue;
		}
		Element element = (Element) obj;
		if (!element.getName().equals("user-permission")) {
			continue;
		}
		UserPermission userResource=new UserPermission();
		userResource.setUsername(element.attributeValue("username"));
		userResource.setProjectConfigs(parseProjectConfigs(element));
		configs.add(userResource);
	}
	return configs;
}
 
开发者ID:youseries,项目名称:urule,代码行数:29,代码来源:RepositoryServiceImpl.java

示例3: doGet

import javax.jcr.Binary; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response)
        throws IOException, ServletException {
    //TODO: put all of the logic in a context processor (need to fix templating support filter bug first)
    String transformName = BLANK;
    if (PathInfoUtil.getSuffixSegments(request).length == 2) {
        String firstSuffixSegment = PathInfoUtil.getFirstSuffixSegment(request);
        if (this.namedImageTransformers.keySet().contains(firstSuffixSegment)) {
            transformName = firstSuffixSegment;
        }
    }
    //Adds the asset binary to the inputStream
    try {
        Resource assetResource = getAssetResource(request);

        if (DamUtil.isAsset(assetResource)) {
            Binary binary;
            String mimeType = BLANK;
            Asset asset = DamUtil.resolveToAsset(assetResource);
            Resource original = asset.getOriginal();

            Node assetNode = original.adaptTo(Node.class);
            if (assetNode.hasNode(JCR_CONTENT)) {
                Node assetInfo = assetNode.getNode(JCR_CONTENT);
                if (assetInfo.hasProperty(JCR_MIMETYPE)) {
                    mimeType = assetInfo.getProperty(JCR_MIMETYPE).getString();
                }
                if (StringUtils.isNotBlank(mimeType)) {
                    response.setContentType(mimeType);
                }
                binary = assetInfo.getProperty(JCR_DATA).getBinary();
                InputStream inputStream = binary.getStream();
                OutputStream outputStream = response.getOutputStream();

                boolean shouldTransform = StringUtils.isNotBlank(transformName);
                if (shouldTransform && ImageUtils.isImage(assetResource)) {
                    double quality = 1;
                    double maxGifQuality = 255;

                    // Transform the image
                    final Layer layer = new Layer(inputStream, new Dimension(maxWidth, maxHeight));
                    Layer newLayer = null;
                    try {
                        final NamedImageTransformer namedImageTransformer = this.namedImageTransformers.get(transformName);
                        newLayer = namedImageTransformer.transform(layer);

                        if (StringUtils.isBlank(mimeType) || !ImageIO.getImageWritersByMIMEType(mimeType).hasNext()) {
                            mimeType = getImageMimeType(layer, asset.getName());
                            response.setContentType(mimeType);
                        }
                        // For GIF images the colors will be reduced according to the quality argument.
                        if (StringUtils.equals(mimeType, GIF_MIME_TYPE)) {
                            quality = quality * maxGifQuality;
                        }

                        newLayer.write(mimeType, quality, outputStream);
                    } finally {
                        if (layer != null) {
                            layer.dispose();
                        }
                        if (newLayer != null) {
                            newLayer.dispose();
                        }
                    }

                } else {
                    ByteStreams.copy(inputStream, outputStream);
                }

                response.flushBuffer();
                outputStream.close();

            }
        }
    } catch (RepositoryException repoException) {
        LOGGER.error("Repository Exception. ", repoException);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:80,代码来源:AssetProviderServlet.java

示例4: readVersionFile

import javax.jcr.Binary; //导入方法依赖的package包/类
private InputStream readVersionFile(String path, String version) throws Exception{
	path = processPath(path);
	Node rootNode=getRootNode();
	if (!rootNode.hasNode(path)) {
		throw new RuleException("File [" + path + "] not exist.");
	}
	Node fileNode = rootNode.getNode(path);
	VersionHistory versionHistory = versionManager.getVersionHistory(fileNode.getPath());
	Version v = versionHistory.getVersion(version);
	Node fnode = v.getFrozenNode();
	Property property = fnode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	return fileBinary.getStream();
}
 
开发者ID:youseries,项目名称:urule,代码行数:15,代码来源:BaseRepositoryService.java

示例5: loadClientConfigs

import javax.jcr.Binary; //导入方法依赖的package包/类
@Override
public List<ClientConfig> loadClientConfigs(String project) throws Exception{
	if(!permissionService.isAdmin()){
		throw new NoPermissionException();
	}
	List<ClientConfig> clients=new ArrayList<ClientConfig>();
	Node rootNode=getRootNode();
	String filePath = processPath(project) + "/" + CLIENT_CONFIG_FILE;
	Node fileNode = rootNode.getNode(filePath);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	InputStream inputStream = fileBinary.getStream();
	String content = IOUtils.toString(inputStream, "utf-8");
	inputStream.close();
	Document document = DocumentHelper.parseText(content);
	Element rootElement = document.getRootElement();
	for (Object obj : rootElement.elements()) {
		if (!(obj instanceof Element)) {
			continue;
		}
		Element element = (Element) obj;
		if (!element.getName().equals("item")) {
			continue;
		}
		ClientConfig client = new ClientConfig();
		client.setName(element.attributeValue("name"));
		client.setClient(element.attributeValue("client"));
		client.setProject(project);
		clients.add(client);
	}
	return clients;
}
 
开发者ID:youseries,项目名称:urule,代码行数:33,代码来源:RepositoryServiceImpl.java

示例6: loadProjectResourcePackages

import javax.jcr.Binary; //导入方法依赖的package包/类
@Override
public List<ResourcePackage> loadProjectResourcePackages(String project) throws Exception {
	Node rootNode=getRootNode();
	String filePath = processPath(project) + "/" + RES_PACKGE_FILE;
	SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	Node fileNode = rootNode.getNode(filePath);
	Property property = fileNode.getProperty(DATA);
	Binary fileBinary = property.getBinary();
	InputStream inputStream = fileBinary.getStream();
	String content = IOUtils.toString(inputStream, "utf-8");
	inputStream.close();
	Document document = DocumentHelper.parseText(content);
	Element rootElement = document.getRootElement();
	List<ResourcePackage> packages = new ArrayList<ResourcePackage>();
	for (Object obj : rootElement.elements()) {
		if (!(obj instanceof Element)) {
			continue;
		}
		Element element = (Element) obj;
		if (!element.getName().equals("res-package")) {
			continue;
		}
		ResourcePackage p = new ResourcePackage();
		String dateStr = element.attributeValue("create_date");
		if (dateStr != null) {
			p.setCreateDate(sd.parse(dateStr));
		}
		p.setId(element.attributeValue("id"));
		p.setName(element.attributeValue("name"));
		p.setProject(project);
		List<ResourceItem> items = new ArrayList<ResourceItem>();
		for (Object o : element.elements()) {
			if (!(o instanceof Element)) {
				continue;
			}
			Element ele = (Element) o;
			if (!ele.getName().equals("res-package-item")) {
				continue;
			}
			ResourceItem item = new ResourceItem();
			item.setName(ele.attributeValue("name"));
			item.setPackageId(p.getId());
			item.setPath(ele.attributeValue("path"));
			item.setVersion(ele.attributeValue("version"));
			items.add(item);
		}
		p.setResourceItems(items);
		packages.add(p);
	}
	return packages;
}
 
开发者ID:youseries,项目名称:urule,代码行数:52,代码来源:BaseRepositoryService.java


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