Example usage for java.util EnumMap put

List of usage examples for java.util EnumMap put

Introduction

In this page you can find the example usage for java.util EnumMap put.

Prototype

public V put(K key, V value) 

Source Link

Document

Associates the specified value with the specified key in this map.

Usage

From source file:org.openecomp.sdc.be.servlets.AbstractValidationsServlet.java

private Either<org.openecomp.sdc.be.model.Resource, ResponseFormat> getAndValidateCsarYaml(
        Map<String, byte[]> csarUIPayload, org.openecomp.sdc.be.model.Resource resource, User user,
        String csarUUID) {// ww w. j a  v  a 2 s.c o  m

    Either<ImmutablePair<String, String>, ResponseFormat> getToscaYamlRes = CsarValidationUtils
            .getToscaYaml(csarUIPayload, csarUUID, getComponentsUtils());

    if (getToscaYamlRes.isRight()) {
        ResponseFormat responseFormat = getToscaYamlRes.right().value();
        log.debug("Error when try to get csar toscayamlFile with csar ID {}, error: {}", csarUUID,
                responseFormat);
        BeEcompErrorManager.getInstance().logBeDaoSystemError(
                "Creating resource from CSAR: fetching CSAR with id " + csarUUID + " failed");
        getComponentsUtils().auditResource(responseFormat, user, resource, "", "",
                AuditingActionEnum.CREATE_RESOURCE, null);
        return Either.right(responseFormat);
    }
    String toscaYaml = getToscaYamlRes.left().value().getValue();

    log.debug("checking tosca template is valid yml");
    YamlToObjectConverter yamlConvertor = new YamlToObjectConverter();
    boolean isValid = yamlConvertor.isValidYaml(toscaYaml.getBytes());
    if (!isValid) {
        ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_YAML_FILE);
        EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(
                AuditingFieldsKeysEnum.class);
        additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resource.getName());
        getComponentsUtils().auditResource(responseFormat, user, null, "", "",
                AuditingActionEnum.IMPORT_RESOURCE, additionalParam);
        return Either.right(responseFormat);
    }

    log.debug("checking payload is valid tosca");
    String heatDecodedPayload = (GeneralUtility.isBase64Encoded(toscaYaml))
            ? new String(Base64.decodeBase64(toscaYaml))
            : toscaYaml;
    Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(heatDecodedPayload);
    Either<String, ResultStatusEnum> findFirstToscaStringElement = ImportUtils
            .findFirstToscaStringElement(mappedToscaTemplate, ToscaTagNamesEnum.TOSCA_VERSION);

    if (findFirstToscaStringElement.isRight()) {
        isValid = false;
    } else {
        String defenitionVersionFound = findFirstToscaStringElement.left().value();
        if (defenitionVersionFound == null || defenitionVersionFound.isEmpty()) {
            isValid = false;
        } else {
            isValid = ImportUtils.Constants.TOSCA_DEFINITION_VERSIONS.contains(defenitionVersionFound);
        }
    }

    if (!isValid) {
        ResponseFormat responseFormat = getComponentsUtils()
                .getResponseFormat(ActionStatus.INVALID_TOSCA_TEMPLATE);
        EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(
                AuditingFieldsKeysEnum.class);
        additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resource.getName());
        getComponentsUtils().auditResource(responseFormat, user, null, "", "",
                AuditingActionEnum.IMPORT_RESOURCE, additionalParam);
        return Either.right(responseFormat);
    }
    return Either.left(resource);
}

From source file:org.lol.reddit.reddit.prepared.RedditPreparedPost.java

public VerticalToolbar generateToolbar(final Activity activity, boolean isComments,
        final SideToolbarOverlay overlay) {

    final VerticalToolbar toolbar = new VerticalToolbar(activity);
    final EnumSet<Action> itemsPref = PrefsUtility.pref_menus_post_toolbar_items(activity,
            PreferenceManager.getDefaultSharedPreferences(activity));

    final Action[] possibleItems = { Action.ACTION_MENU,
            isComments ? Action.LINK_SWITCH : Action.COMMENTS_SWITCH, Action.UPVOTE, Action.DOWNVOTE,
            Action.SAVE, Action.HIDE, Action.REPLY, Action.EXTERNAL, Action.SAVE_IMAGE, Action.SHARE,
            Action.COPY, Action.USER_PROFILE, Action.PROPERTIES };

    // TODO make static
    final EnumMap<Action, Integer> iconsDark = new EnumMap<Action, Integer>(Action.class);
    iconsDark.put(Action.ACTION_MENU, R.drawable.ic_action_overflow);
    iconsDark.put(Action.COMMENTS_SWITCH, R.drawable.ic_action_comments_dark);
    iconsDark.put(Action.LINK_SWITCH,
            imageUrl != null ? R.drawable.ic_action_image_dark : R.drawable.ic_action_page_dark);
    iconsDark.put(Action.UPVOTE, R.drawable.action_upvote_dark);
    iconsDark.put(Action.DOWNVOTE, R.drawable.action_downvote_dark);
    iconsDark.put(Action.SAVE, R.drawable.ic_action_star_filled_dark);
    iconsDark.put(Action.HIDE, R.drawable.ic_action_cross_dark);
    iconsDark.put(Action.REPLY, R.drawable.ic_action_reply_dark);
    iconsDark.put(Action.EXTERNAL, R.drawable.ic_action_globe_dark);
    iconsDark.put(Action.SAVE_IMAGE, R.drawable.ic_action_save_dark);
    iconsDark.put(Action.SHARE, R.drawable.ic_action_share_dark);
    iconsDark.put(Action.COPY, R.drawable.ic_action_copy_dark);
    iconsDark.put(Action.USER_PROFILE, R.drawable.ic_action_person_dark);
    iconsDark.put(Action.PROPERTIES, R.drawable.ic_action_info_dark);

    final EnumMap<Action, Integer> iconsLight = new EnumMap<Action, Integer>(Action.class);
    iconsLight.put(Action.ACTION_MENU, R.drawable.ic_action_overflow);
    iconsLight.put(Action.COMMENTS_SWITCH, R.drawable.ic_action_comments_light);
    iconsLight.put(Action.LINK_SWITCH,
            imageUrl != null ? R.drawable.ic_action_image_light : R.drawable.ic_action_page_light);
    iconsLight.put(Action.UPVOTE, R.drawable.action_upvote_light);
    iconsLight.put(Action.DOWNVOTE, R.drawable.action_downvote_light);
    iconsLight.put(Action.SAVE, R.drawable.ic_action_star_filled_light);
    iconsLight.put(Action.HIDE, R.drawable.ic_action_cross_light);
    iconsLight.put(Action.REPLY, R.drawable.ic_action_reply_light);
    iconsLight.put(Action.EXTERNAL, R.drawable.ic_action_globe_light);
    iconsLight.put(Action.SAVE_IMAGE, R.drawable.ic_action_save_light);
    iconsLight.put(Action.SHARE, R.drawable.ic_action_share_light);
    iconsLight.put(Action.COPY, R.drawable.ic_action_copy_light);
    iconsLight.put(Action.USER_PROFILE, R.drawable.ic_action_person_light);
    iconsLight.put(Action.PROPERTIES, R.drawable.ic_action_info_light);

    for (final Action action : possibleItems) {

        if (action == Action.SAVE_IMAGE && imageUrl == null)
            continue;

        if (itemsPref.contains(action)) {

            final FlatImageButton ib = new FlatImageButton(activity);

            final int buttonPadding = General.dpToPixels(activity, 10);
            ib.setPadding(buttonPadding, buttonPadding, buttonPadding, buttonPadding);

            if (action == Action.UPVOTE && isUpvoted() || action == Action.DOWNVOTE && isDownvoted()
                    || action == Action.SAVE && isSaved() || action == Action.HIDE && isHidden()) {

                ib.setBackgroundColor(Color.WHITE);
                ib.setImageResource(iconsLight.get(action));

            } else {
                ib.setImageResource(iconsDark.get(action));
                // TODO highlight on click
            }/*from  ww w  .ja  v a 2s  .co  m*/

            ib.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {

                    final Action actionToTake;

                    switch (action) {
                    case UPVOTE:
                        actionToTake = isUpvoted() ? Action.UNVOTE : Action.UPVOTE;
                        break;

                    case DOWNVOTE:
                        actionToTake = isDownvoted() ? Action.UNVOTE : Action.DOWNVOTE;
                        break;

                    case SAVE:
                        actionToTake = isSaved() ? Action.UNSAVE : Action.SAVE;
                        break;

                    case HIDE:
                        actionToTake = isHidden() ? Action.UNHIDE : Action.HIDE;
                        break;

                    default:
                        actionToTake = action;
                        break;
                    }

                    onActionMenuItemSelected(RedditPreparedPost.this, activity, actionToTake);
                    overlay.hide();
                }
            });

            toolbar.addItem(ib);
        }
    }

    return toolbar;
}

From source file:org.quantumbadger.redreader.reddit.prepared.RedditPreparedPost.java

public VerticalToolbar generateToolbar(final Activity activity, boolean isComments,
        final SideToolbarOverlay overlay) {

    final VerticalToolbar toolbar = new VerticalToolbar(activity);
    final EnumSet<Action> itemsPref = PrefsUtility.pref_menus_post_toolbar_items(activity,
            PreferenceManager.getDefaultSharedPreferences(activity));

    final Action[] possibleItems = { Action.ACTION_MENU,
            isComments ? Action.LINK_SWITCH : Action.COMMENTS_SWITCH, Action.UPVOTE, Action.DOWNVOTE,
            Action.SAVE, Action.HIDE, Action.DELETE, Action.REPLY, Action.EXTERNAL, Action.SAVE_IMAGE,
            Action.SHARE, Action.COPY, Action.USER_PROFILE, Action.PROPERTIES };

    // TODO make static
    final EnumMap<Action, Integer> iconsDark = new EnumMap<Action, Integer>(Action.class);
    iconsDark.put(Action.ACTION_MENU, R.drawable.ic_action_overflow);
    iconsDark.put(Action.COMMENTS_SWITCH, R.drawable.ic_action_comments_dark);
    iconsDark.put(Action.LINK_SWITCH,
            mIsProbablyAnImage ? R.drawable.ic_action_image_dark : R.drawable.ic_action_page_dark);
    iconsDark.put(Action.UPVOTE, R.drawable.action_upvote_dark);
    iconsDark.put(Action.DOWNVOTE, R.drawable.action_downvote_dark);
    iconsDark.put(Action.SAVE, R.drawable.ic_action_star_filled_dark);
    iconsDark.put(Action.HIDE, R.drawable.ic_action_cross_dark);
    iconsDark.put(Action.REPLY, R.drawable.ic_action_reply_dark);
    iconsDark.put(Action.EXTERNAL, R.drawable.ic_action_globe_dark);
    iconsDark.put(Action.SAVE_IMAGE, R.drawable.ic_action_save_dark);
    iconsDark.put(Action.SHARE, R.drawable.ic_action_share_dark);
    iconsDark.put(Action.COPY, R.drawable.ic_action_copy_dark);
    iconsDark.put(Action.USER_PROFILE, R.drawable.ic_action_person_dark);
    iconsDark.put(Action.PROPERTIES, R.drawable.ic_action_info_dark);

    final EnumMap<Action, Integer> iconsLight = new EnumMap<Action, Integer>(Action.class);
    iconsLight.put(Action.ACTION_MENU, R.drawable.ic_action_overflow);
    iconsLight.put(Action.COMMENTS_SWITCH, R.drawable.ic_action_comments_light);
    iconsLight.put(Action.LINK_SWITCH,
            mIsProbablyAnImage ? R.drawable.ic_action_image_light : R.drawable.ic_action_page_light);
    iconsLight.put(Action.UPVOTE, R.drawable.action_upvote_light);
    iconsLight.put(Action.DOWNVOTE, R.drawable.action_downvote_light);
    iconsLight.put(Action.SAVE, R.drawable.ic_action_star_filled_light);
    iconsLight.put(Action.HIDE, R.drawable.ic_action_cross_light);
    iconsLight.put(Action.REPLY, R.drawable.ic_action_reply_light);
    iconsLight.put(Action.EXTERNAL, R.drawable.ic_action_globe_light);
    iconsLight.put(Action.SAVE_IMAGE, R.drawable.ic_action_save_light);
    iconsLight.put(Action.SHARE, R.drawable.ic_action_share_light);
    iconsLight.put(Action.COPY, R.drawable.ic_action_copy_light);
    iconsLight.put(Action.USER_PROFILE, R.drawable.ic_action_person_light);
    iconsLight.put(Action.PROPERTIES, R.drawable.ic_action_info_light);

    for (final Action action : possibleItems) {

        if (action == Action.SAVE_IMAGE && !mIsProbablyAnImage)
            continue;

        if (itemsPref.contains(action)) {

            final FlatImageButton ib = new FlatImageButton(activity);

            final int buttonPadding = General.dpToPixels(activity, 10);
            ib.setPadding(buttonPadding, buttonPadding, buttonPadding, buttonPadding);

            if (action == Action.UPVOTE && isUpvoted() || action == Action.DOWNVOTE && isDownvoted()
                    || action == Action.SAVE && isSaved() || action == Action.HIDE && isHidden()) {

                ib.setBackgroundColor(Color.WHITE);
                ib.setImageResource(iconsLight.get(action));

            } else {
                ib.setImageResource(iconsDark.get(action));
                // TODO highlight on click
            }/*from   w  w w .j ava  2  s.co m*/

            ib.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {

                    final Action actionToTake;

                    switch (action) {
                    case UPVOTE:
                        actionToTake = isUpvoted() ? Action.UNVOTE : Action.UPVOTE;
                        break;

                    case DOWNVOTE:
                        actionToTake = isDownvoted() ? Action.UNVOTE : Action.DOWNVOTE;
                        break;

                    case SAVE:
                        actionToTake = isSaved() ? Action.UNSAVE : Action.SAVE;
                        break;

                    case HIDE:
                        actionToTake = isHidden() ? Action.UNHIDE : Action.HIDE;
                        break;

                    default:
                        actionToTake = action;
                        break;
                    }

                    onActionMenuItemSelected(RedditPreparedPost.this, activity, actionToTake);
                    overlay.hide();
                }
            });

            toolbar.addItem(ib);
        }
    }

    return toolbar;
}

From source file:org.messic.server.api.dlna.MusicService.java

@Transactional
public List<PlaylistItem> getPlaylists(String containerId, long startIndex, long maxCount, VisualContainer vc) {
    List<PlaylistItem> result = new ArrayList<PlaylistItem>();
    List<MDOPlaylist> playlists = this.daoPlaylist.getAllDLNA();

    for (long i = startIndex; i < startIndex + maxCount && i < playlists.size(); i++) {
        MDOPlaylist mdop = playlists.get((int) i);

        HashMap<MDOAuthor, String> authors = new HashMap<MDOAuthor, String>();
        List<MDOSong> songs = mdop.getSongs();
        for (int j = 0; j < songs.size(); j++) {
            MDOSong song = songs.get(j);
            authors.put(song.getAlbum().getAuthor(), "");
        }/* w w  w.  j a  v  a  2  s  . com*/

        PlaylistItem pli = new PlaylistItem();
        pli.setTitle(mdop.getName());
        pli.setDescription(mdop.getName());
        pli.setLongDescription(mdop.getName());
        pli.setDate("24/01/2013");
        MDOAuthor[] mdoauthors = new MDOAuthor[authors.size()];
        authors.keySet().toArray(mdoauthors);
        PersonWithRole[] persons = new PersonWithRole[mdoauthors.length];
        for (int k = 0; k < mdoauthors.length; k++) {
            MDOAuthor mdoa = mdoauthors[k];
            PersonWithRole pwr = new PersonWithRole(mdoa.getName());
            persons[k] = pwr;
        }
        pli.setArtists(persons);

        pli.setParentID(mdop.getOwner().getSid() + "");
        pli.setId(mdop.getOwner().getSid() + MessicContainer.SEPARATOR);

        for (int l = 0; l < mdop.getSongs().size(); l++) {
            MDOSong song = mdop.getSongs().get(l);

            MDOUser user = song.getOwner();
            String token = loginDLNA(user.getLogin(), user.getPassword());

            Res resource = new Res();
            EnumMap<DLNAAttribute.Type, DLNAAttribute> dlnaAttributes = new EnumMap<DLNAAttribute.Type, DLNAAttribute>(
                    DLNAAttribute.Type.class);

            URI originalUri = null;
            try {
                originalUri = new URI(
                        (isSecured() ? "https" : "http") + "://" + Util.getInternalIp() + ":" + getCurrentPort()
                                + "/messic/services/songs/" + song.getSid() + "/dlna?messic_token=" + token);
            } catch (URISyntaxException e) {
                log.error("failed!", e);
            } catch (Exception e) {
                log.error("failed!", e);
            }
            resource.setValue(originalUri.toString());
            DLNAProfiles originalProfile = DLNAProfiles.MP3;
            dlnaAttributes.put(DLNAAttribute.Type.DLNA_ORG_PN, new DLNAProfileAttribute(originalProfile));
            dlnaAttributes.put(DLNAAttribute.Type.DLNA_ORG_OP,
                    new DLNAOperationsAttribute(DLNAOperations.RANGE));
            dlnaAttributes.put(DLNAAttribute.Type.DLNA_ORG_CI,
                    new DLNAConversionIndicatorAttribute(DLNAConversionIndicator.NONE));
            dlnaAttributes.put(DLNAAttribute.Type.DLNA_ORG_FLAGS,
                    new DLNAFlagsAttribute(DLNAFlags.STREAMING_TRANSFER_MODE,
                            DLNAFlags.BACKGROUND_TRANSFERT_MODE, DLNAFlags.DLNA_V15));

            resource.setProtocolInfo(new DLNAProtocolInfo(Protocol.HTTP_GET, ProtocolInfo.WILDCARD, "audio/mp3",
                    dlnaAttributes));

            pli.addResource(resource);

        }

        result.add(pli);
    }
    return result;
}

From source file:org.apache.hadoop.hdfs.server.namenode.FSEditLogLoader.java

private void incrOpCount(FSEditLogOpCodes opCode, EnumMap<FSEditLogOpCodes, Holder<Integer>> opCounts,
        Step step, Counter counter) {/*w  w  w  .j  av a2s . c o  m*/
    Holder<Integer> holder = opCounts.get(opCode);
    if (holder == null) {
        holder = new Holder<Integer>(1);
        opCounts.put(opCode, holder);
    } else {
        holder.held++;
    }
    counter.increment();
}

From source file:tasly.greathealth.oms.web.inventory.rest.resources.ItemInfoResource.java

@SuppressWarnings("null")
@PUT/*from ww w  .  j  a va  2 s.c  o m*/
@Path("/flag0skus")
public Response updateFlagSku(final SkuList skuList) throws Exception {
    int flag;
    EnumMap<HandleReturn, Object> handleReturn = new EnumMap<HandleReturn, Object>(HandleReturn.class);
    boolean updateStatus = false;
    final List<String> skus = skuList.getSkus();
    if (skus.size() > 0 || skus != null) {
        for (final String sku : skus) {
            final ItemInfo itemInfo = itemInfoFacade.getBySku(sku);
            flag = itemInfo.getStockManageFlag();
            if (flag == 0) {
                final List<TaslyItemLocationData> checkTaslyItemLocationDatas = taslyItemLocationService
                        .getByItemID(sku);
                if (checkTaslyItemLocationDatas == null || checkTaslyItemLocationDatas.size() == 0) {
                    omsLOG.error("sku:" + sku + ",no ItemLocation data!");
                    continue;
                } else {
                    try {

                        handleReturn = itemQuantityService.handleUpdateMethod(checkTaslyItemLocationDatas, sku,
                                flag, 0);
                    } catch (final Exception e) {
                        omsLOG.error("handle sku:" + sku + " failed and error is " + e);
                        handleReturn.put(HandleReturn.handleStatus, false);
                    }
                    if ((boolean) handleReturn.get(HandleReturn.handleStatus)) {
                        try {
                            updateStatus = itemQuantityService.updateMethod(sku, flag, 0);
                            if (updateStatus) {
                                omsLOG.debug("sku:" + sku + ",flag=0 allocated ok!");
                            }
                        } catch (final Exception e) {
                            omsLOG.error("update sku:" + sku + " failed and error is " + e);
                        }
                    }
                }
            }
        }
        omsLOG.info("Update quantity where flag=0 finished.");
    }
    return Response.status(Response.Status.OK).build();
}

From source file:gov.nih.nci.caarray.web.action.project.ProjectFilesAction.java

/**
 * Computes a file status count for each type of file status.
 *
 * @return Map, map contains key value pair (status, count)
 *//*  w w  w  . j  a  va 2 s.  co  m*/
public EnumMap<FileStatus, Integer> computeFileStatusCounts() {
    final EnumMap<FileStatus, Integer> countMap = new EnumMap<FileStatus, Integer>(FileStatus.class);

    for (final FileStatus f : FileStatus.values()) {
        countMap.put(f, 0);
    }

    for (final CaArrayFile f : getFiles()) {
        countMap.put(FileStatus.valueOf(f.getStatus()), countMap.get(FileStatus.valueOf(f.getStatus())) + 1);
    }
    return countMap;
}

From source file:tasly.greathealth.oms.web.inventory.rest.resources.ItemInfoResource.java

@SuppressWarnings("null")
@GET/*from w ww  .  ja  va  2s .  com*/
@Path("/flag0update")
public Response updateQuantity() {
    omsLOG.info("Begin to update quantity where flag=0.");
    final Collection<ItemInfo> itemInfos = itemInfoFacade.getAll();
    int flag;
    String sku;
    EnumMap<HandleReturn, Object> handleReturn = new EnumMap<HandleReturn, Object>(HandleReturn.class);
    boolean updateStatus = false;
    if (itemInfos.size() == 0 || itemInfos == null) {
        omsLOG.error("Get all itemInfos failed!");
    } else {
        for (final ItemInfo itemInfo : itemInfos) {
            flag = itemInfo.getStockManageFlag();
            sku = itemInfo.getSku();
            if (flag == 0) {
                final List<TaslyItemLocationData> checkTaslyItemLocationDatas = taslyItemLocationService
                        .getByItemID(sku);
                if (checkTaslyItemLocationDatas == null || checkTaslyItemLocationDatas.size() == 0) {
                    omsLOG.error("sku:" + sku + ",no ItemLocation data!");
                    continue;
                } else {
                    try {
                        handleReturn = itemQuantityService.handleUpdateMethod(checkTaslyItemLocationDatas, sku,
                                flag, 0);
                    } catch (final Exception e) {
                        omsLOG.error("handle sku:" + sku + " failed and error is " + e);
                        handleReturn.put(HandleReturn.handleStatus, false);
                    }
                    if ((boolean) handleReturn.get(HandleReturn.handleStatus)) {
                        try {
                            updateStatus = itemQuantityService.updateMethod(sku, flag, 0);
                            if (updateStatus) {
                                omsLOG.debug("sku:" + sku + ",flag=0 allocated ok!");
                            }
                        } catch (final Exception e) {
                            omsLOG.error("update sku:" + sku + " failed and error is " + e);
                        }
                    }
                }
            }
        }
    }
    omsLOG.info("Update quantity where flag=0 finished.");
    return Response.status(Response.Status.OK).build();
}

From source file:org.openecomp.sdc.be.components.impl.ComponentBusinessLogic.java

public Either<ImmutablePair<String, byte[]>, ResponseFormat> getToscaModelByComponentUuid(
        ComponentTypeEnum componentType, String uuid, EnumMap<AuditingFieldsKeysEnum, Object> additionalParam) {
    // get info//from www.j  ava  2s .  com
    ComponentOperation componentOperation = getComponentOperation(componentType);
    Either<Component, StorageOperationStatus> latestVersion = componentOperation
            .getLatestComponentByUuid(componentType.getNodeType(), uuid);
    if (latestVersion.isRight()) {
        ResponseFormat response = componentsUtils.getResponseFormat(
                componentsUtils.convertFromStorageResponse(latestVersion.right().value(), componentType));
        return Either.right(response);

    }
    Component component = latestVersion.left().value();
    additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, component.getName());
    // TODO remove after migration - handle artifact not found(no
    // placeholder)
    if (null == component.getToscaArtifacts() || component.getToscaArtifacts().isEmpty()) {
        return Either.right(componentsUtils.getResponseFormat(ActionStatus.ARTIFACT_NOT_FOUND,
                ArtifactTypeEnum.TOSCA_CSAR.name()));
    }
    ArtifactDefinition csarArtifact = component.getToscaArtifacts().values().stream()
            .filter(p -> p.getArtifactType().equals(ArtifactTypeEnum.TOSCA_CSAR.getType())).findAny().get();
    return artifactsBusinessLogic.handleDownloadToscaModelRequest(component, csarArtifact, true, false);
}

From source file:org.safecreative.api.wrapper.SafeCreativeAPIWrapper.java

/**
 * Get a map of the license features./*from  ww w  .j a  v  a 2 s.co  m*/
 *
 * @return Map of license features.
 * @throws ApiException
 */
@SuppressWarnings("unchecked")
public EnumMap<License.Feature, LicenseFeatureObject> getLicenseFeatures() throws ApiException {
    setApiUrl();
    String result = callComponent("license.features");
    XStream xs = createXStream();

    // alias for license features
    xs.registerConverter(new LicenseFeatureConverter());

    List<LicenseFeatureObject> features = readList(result, "features", "feature", LicenseFeatureObject.class,
            xs);
    log.debug("License features {}", features);

    // generate map
    EnumMap<License.Feature, LicenseFeatureObject> featuresMap = new EnumMap<License.Feature, LicenseFeatureObject>(
            License.Feature.class);
    for (LicenseFeatureObject feature : features) {
        featuresMap.put(feature.getFeature(), feature);
    }

    return featuresMap;
}