com.day.cq.dam.api.Asset Java Examples

The following examples show how to use com.day.cq.dam.api.Asset. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeometrixxMediaArticleBody.java    From aem-solr-search with Apache License 2.0 8 votes vote down vote up
@PostConstruct public void init() throws SlingModelsException {

        Asset asset = resource.adaptTo(Asset.class);
        if(null == asset){
            return;
        }
        Rendition rendition = (asset.getRendition("plain") != null) ?
            asset.getRendition("plain") :
            asset.getOriginal();

        StringWriter writer = new StringWriter();
        try {
            IOUtils.copy(rendition.getStream(), writer, "UTF8");
            this.body = writer.toString();
        } catch (IOException e) {
            LOG.error("Error reading rendition: {}", rendition.getPath(), e);
        }

    }
 
Example #2
Source File: ResourceResolverConsumer.java    From AEM-Rules-for-SonarQube with Apache License 2.0 6 votes vote down vote up
public Tag findTag(String tagId, Asset asset, Session session) {
    Tag tag = null;
    ResourceResolver resourceResolver = null;

    try {
        resourceResolver = getResourceResolver(session);
        TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
        tag = tagManager.resolve(tagId);
    } finally {
        if (null != resourceResolver && resourceResolver.isLive()) {
            resourceResolver.close();
        }
    }

    return tag;
}
 
Example #3
Source File: FeaturedCategoryListImpl.java    From aem-core-cif-components with Apache License 2.0 4 votes vote down vote up
@PostConstruct
private void initModel() {
    categoryPage = SiteNavigation.getCategoryPage(currentPage);
    if (categoryPage == null) {
        categoryPage = currentPage;
    }

    List<String> categoryIds = new ArrayList<>();
    assetOverride = new HashMap<>();

    // Iterate entries of composite multifield
    Resource items = resource.getChild(ITEMS_PROP);
    if (items != null) {
        for (Resource item : items.getChildren()) {
            ValueMap props = item.getValueMap();
            String categoryId = props.get(CATEGORY_ID_PROP, String.class);
            if (StringUtils.isEmpty(categoryId)) {
                continue;
            }
            categoryIds.add(categoryId);

            // Check if an override asset was set. If yes, store it in a map for later use.
            String assetPath = props.get(ASSET_PROP, String.class);
            if (StringUtils.isEmpty((assetPath))) {
                continue;
            }

            Resource assetResource = resource.getResourceResolver().getResource(assetPath);
            if (assetResource == null) {
                continue;
            }

            Asset overrideAsset = assetResource.adaptTo(Asset.class);
            assetOverride.put(categoryId, overrideAsset);
        }

        if (categoryIds.size() > 0) {
            MagentoGraphqlClient magentoGraphqlClient = MagentoGraphqlClient.create(resource);
            if (magentoGraphqlClient != null) {
                categoriesRetriever = new CategoriesRetriever(magentoGraphqlClient);
                categoriesRetriever.setIdentifiers(categoryIds);
            }
        }
    }
}
 
Example #4
Source File: AssetImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Asset restore(String s) throws Exception {
    return null;
}
 
Example #5
Source File: AssetImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Asset addSubAsset(String s, String s2, InputStream inputStream) {
    return null;
}
 
Example #6
Source File: AssetImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<Asset> getSubAssets() {
    return null;
}
 
Example #7
Source File: RenditionImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
public RenditionImpl(Asset asset, Resource resource) {
    super(resource.getResourceResolver(), resource.adaptTo(Node.class));
    this.asset = asset;
}
 
Example #8
Source File: RenditionImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public Asset getAsset() {
    return asset;
}