Example usage for java.util EnumMap EnumMap

List of usage examples for java.util EnumMap EnumMap

Introduction

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

Prototype

public EnumMap(Map<K, ? extends V> m) 

Source Link

Document

Creates an enum map initialized from the specified map.

Usage

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

protected void validatePayloadIsTosca(Wrapper<Response> responseWrapper, UploadResourceInfo uploadResourceInfo,
        User user, String toscaPayload) {
    log.debug("checking payload is valid tosca");
    boolean isValid;
    String heatDecodedPayload = (GeneralUtility.isBase64Encoded(toscaPayload))
            ? new String(Base64.decodeBase64(toscaPayload))
            : toscaPayload;/*from  www .jav a2  s.  c om*/
    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);
        Response errorResponse = buildErrorResponse(responseFormat);
        EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(
                AuditingFieldsKeysEnum.class);
        additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, uploadResourceInfo.getName());
        getComponentsUtils().auditResource(responseFormat, user, null, "", "",
                AuditingActionEnum.IMPORT_RESOURCE, additionalParam);
        responseWrapper.setInnerElement(errorResponse);
    }

}

From source file:gov.nih.nci.firebird.service.registration.ProtocolRegistrationServiceBean.java

private void notifySponsorOfRemoval(SubInvestigatorRegistration registration) {
    Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>(
            FirebirdTemplateParameter.class);
    parameterValues.put(FirebirdTemplateParameter.SUBINVESTIGATOR_REGISTRATION, registration);
    FirebirdMessage message = getTemplateService().generateMessage(
            FirebirdMessageTemplate.REMOVE_SUBINVESTIGATOR_NOTIFICATION_EMAIL_TO_SPONSOR, parameterValues);
    String sponsorEmail = getSponsorEmailAddress(registration);
    getEmailService().sendMessage(sponsorEmail, null, null, message);
}

From source file:gov.nih.nci.firebird.service.messages.TemplateServiceImplTest.java

@Test(expected = IllegalArgumentException.class)
public void testGenerateMessage_MissingTemplateParameters() {
    Template template = mock(Template.class);
    when(mockVelocityEngine.getTemplate(anyString())).thenReturn(template);
    bean.generateMessage(INVESTIGATOR_INVITATION_EMAIL,
            new EnumMap<FirebirdTemplateParameter, Object>(FirebirdTemplateParameter.class));
}

From source file:com.smartitengineering.cms.api.impl.type.ContentTypeImpl.java

public Map<ContentProcessingPhase, Collection<ContentCoProcessorDef>> getContentCoProcessorDefs() {
    final EnumMap<ContentProcessingPhase, Collection<ContentCoProcessorDef>> newMap = new EnumMap<ContentProcessingPhase, Collection<ContentCoProcessorDef>>(
            ContentProcessingPhase.class);
    newMap.putAll(procDefs);/*from w  ww  .  j av a 2  s .c  o m*/
    return newMap;
}

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

@Transactional
public List<MusicTrack> getSongs(String containerId, long startIndex, long maxCount, VisualContainer vc) {
    String[] parts = containerId.split(MessicContainer.SEPARATOR);

    List<MusicTrack> result = new ArrayList<MusicTrack>();
    List<MDOSong> songs = null;
    if (parts.length == 3) {
        Long sid = Long.valueOf(parts[2]);
        songs = new ArrayList<MDOSong>();
        songs = this.daoalbum.get(sid).getSongs();
    } else {//from   w ww. j av  a2 s.c o m
        songs = this.daosong.getAllDLNA();
    }

    int iadded = 0;

    for (long i = startIndex; i < startIndex + maxCount && i < songs.size(); i++) {
        MDOSong song = songs.get((int) i);
        MDOUser user = song.getOwner();
        String token = loginDLNA(user.getLogin(), user.getPassword());

        MusicTrack ai = new MusicTrack();
        ai.setAlbum(song.getAlbum().getName());
        ai.setArtists(new PersonWithRole[] { new PersonWithRole(song.getAlbum().getAuthor().getName()) });
        // ai.setCreator( "CreatorRefree" );
        ai.setDate("" + song.getAlbum().getYear());
        List<DescMeta> listdm = new ArrayList<DescMeta>();
        ai.setDescMetadata(listdm);
        // ai.setDescription( "description" );
        // ai.setLanguage( "es_ES" );
        // ai.setLongDescription( "long description" );
        // ai.setPublishers( new Person[]{new Person( "namepublisher" )} );
        ai.setRefID("" + song.getSid());
        ai.setRights(new String[] {});
        ai.setCreator(song.getAlbum().getAuthor().getName());
        ai.setGenres(new String[] { song.getAlbum().getGenre().getName() });
        ai.setParentID(song.getOwner().getSid() + MessicContainer.SEPARATOR
                + song.getAlbum().getAuthor().getSid() + MessicContainer.SEPARATOR + song.getAlbum().getSid());
        ai.setId(song.getOwner().getSid() + MessicContainer.SEPARATOR + song.getAlbum().getAuthor().getSid()
                + MessicContainer.SEPARATOR + song.getAlbum().getSid() + MessicContainer.SEPARATOR
                + song.getSid());
        ai.setTitle(song.getName());
        ai.setOriginalTrackNumber(song.getTrack());

        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);
        }
        Res resource = new Res();
        EnumMap<DLNAAttribute.Type, DLNAAttribute> dlnaAttributes = new EnumMap<DLNAAttribute.Type, DLNAAttribute>(
                DLNAAttribute.Type.class);

        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));

        ai.addResource(resource);
        result.add(ai);

        if (vc != null) {
            vc.addItem(ai);
        }

        iadded++;
    }

    if (vc != null) {
        vc.setChildCount(iadded);
        vc.setTotalChildCount(songs.size());
    }

    return result;
}

From source file:fr.ritaly.dungeonmaster.ai.CreatureManager.java

private final void _addCreature(Creature creature, Direction direction) {
    Validate.notNull(creature, "The given creature is null");
    Validate.notNull(direction, "The given direction is null");

    if (!Creature.Size.TWO.equals(creature.getSize())) {
        throw new IllegalArgumentException("The given creature <" + creature + "> has an invalid size (actual: "
                + creature.getSize() + ", expected: " + Creature.Size.TWO + ")");
    }/*from   w w w .j a  va  2 s  .  co m*/

    // L'emplacement doit initialement tre vide
    final List<Sector> sectors = Sector.getVisibleSectors(direction);

    for (Sector sector : sectors) {
        if ((creatures != null) && (creatures.get(sector) != null)) {
            throw new IllegalArgumentException("The cell " + sector + " of element " + position
                    + " is already occupied by a creature (" + creatures.get(sector) + ")");
        }
    }

    if (!canHost(creature)) {
        throw new IllegalArgumentException("Unable to install creature " + creature + " on cells " + sectors
                + " of element " + position + " because the remaining room is " + getFreeSectors().size());
    }

    if (creatures == null) {
        creatures = new EnumMap<Sector, Creature>(Sector.class);
    }

    for (Sector sector : sectors) {
        creatures.put(sector, creature);
    }

    if (log.isDebugEnabled()) {
        log.debug(creature + " stepped on " + position + " (" + direction + ")");
    }
}

From source file:org.apache.hadoop.yarn.client.cli.TopCLI.java

public TopCLI() throws IOException, InterruptedException {
    super();//  w w w . j  a v  a 2s . co m
    queues = new HashSet<>();
    users = new HashSet<>();
    types = new HashSet<>();
    comparator = UsedContainersComparator;
    ascendingSort = false;
    displayScreen = DisplayScreen.TOP;
    showingTopScreen = new AtomicBoolean();
    showingTopScreen.set(true);
    currentSortField = "c";
    keyFieldsMap = new HashMap<>();
    runKeyboardMonitor = new AtomicBoolean();
    runMainLoop = new AtomicBoolean();
    runKeyboardMonitor.set(true);
    runMainLoop.set(true);
    displayThread = Thread.currentThread();
    columnInformationEnumMap = new EnumMap<>(Columns.class);
    generateColumnInformationMap();
    generateKeyFieldsMap();
    sortedKeys = new ArrayList<>(keyFieldsMap.keySet());
    Collections.sort(sortedKeys);
    setTerminalSequences();
}

From source file:gov.nih.nci.firebird.service.sponsor.SponsorServiceBean.java

private FirebirdMessage getAnnualRegistrationNotificationEmailMessage(AnnualRegistration registration) {
    Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>(
            FirebirdTemplateParameter.class);
    parameterValues.put(ANNUAL_REGISTRATION, registration);
    parameterValues.put(FIREBIRD_LINK, generateReviewAnnualRegistrationLink(registration));
    return templateService.generateMessage(
            FirebirdMessageTemplate.SPONSOR_ANNUAL_REGISTRATION_SUBMISSION_NOTIFICATION_EMAIL, parameterValues);
}

From source file:io.hops.metadata.util.RMUtilities.java

public static Map<RMStateStore.KeyType, MasterKey> getSecretMamagerKeys() throws IOException {
    LightWeightRequestHandler getNMTokenSecretMamagerCurrentKeyHandler = new LightWeightRequestHandler(
            YARNOperationType.TEST) {/*  www  .j a  va  2  s. co  m*/
        @Override
        public Object performTask() throws StorageException, InvalidProtocolBufferException {
            connector.beginTransaction();
            connector.writeLock();
            SecretMamagerKeysDataAccess DA = (SecretMamagerKeysDataAccess) RMStorageFactory
                    .getDataAccess(SecretMamagerKeysDataAccess.class);
            List<SecretMamagerKey> hopKeys = (List<SecretMamagerKey>) DA.getAll();
            connector.commit();
            Map<RMStateStore.KeyType, MasterKey> keys = new EnumMap<RMStateStore.KeyType, MasterKey>(
                    RMStateStore.KeyType.class);
            MasterKey key;
            if (hopKeys != null) {
                for (SecretMamagerKey hopKey : hopKeys) {
                    key = new MasterKeyPBImpl(YarnServerCommonProtos.MasterKeyProto.parseFrom(hopKey.getKey()));
                    keys.put(RMStateStore.KeyType.valueOf(hopKey.getKeyType()), key);
                }
            }
            return keys;
        }
    };
    return (Map<RMStateStore.KeyType, MasterKey>) getNMTokenSecretMamagerCurrentKeyHandler.handle();
}

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

protected void validatePayloadIsYml(Wrapper<Response> responseWrapper, User user,
        UploadResourceInfo uploadResourceInfo, String toscaTamplatePayload) {
    log.debug("checking tosca template is valid yml");
    YamlToObjectConverter yamlConvertor = new YamlToObjectConverter();
    boolean isYamlValid = yamlConvertor.isValidYaml(toscaTamplatePayload.getBytes());
    if (!isYamlValid) {
        ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_YAML_FILE);
        Response errorResponse = buildErrorResponse(responseFormat);
        EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(
                AuditingFieldsKeysEnum.class);
        additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, uploadResourceInfo.getName());
        getComponentsUtils().auditResource(responseFormat, user, null, "", "",
                AuditingActionEnum.IMPORT_RESOURCE, additionalParam);
        responseWrapper.setInnerElement(errorResponse);
    }//w  ww. ja v a2s . c o m
}