List of usage examples for java.util EnumSet allOf
public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType)
From source file:org.apache.ambari.server.controller.internal.AlertTargetResourceProvider.java
/** * Create and persist {@link AlertTargetEntity} from the map of properties. * * @param requestMaps/* ww w . j a v a2s . c o m*/ * @param requestInfoProps * @throws AmbariException */ @SuppressWarnings("unchecked") private void createAlertTargets(Set<Map<String, Object>> requestMaps, Map<String, String> requestInfoProps) throws AmbariException { for (Map<String, Object> requestMap : requestMaps) { String name = (String) requestMap.get(ALERT_TARGET_NAME); String description = (String) requestMap.get(ALERT_TARGET_DESCRIPTION); String notificationType = (String) requestMap.get(ALERT_TARGET_NOTIFICATION_TYPE); Collection<String> alertStates = (Collection<String>) requestMap.get(ALERT_TARGET_STATES); String globalProperty = (String) requestMap.get(ALERT_TARGET_GLOBAL); if (StringUtils.isEmpty(name)) { throw new IllegalArgumentException("The name of the alert target is required."); } if (StringUtils.isEmpty(notificationType)) { throw new IllegalArgumentException("The type of the alert target is required."); } Map<String, Object> properties = extractProperties(requestMap); String propertiesJson = s_gson.toJson(properties); if (StringUtils.isEmpty(propertiesJson)) { throw new IllegalArgumentException( "Alert targets must be created with their connection properties"); } String validationDirective = requestInfoProps .get(AlertTargetResourceDefinition.VALIDATE_CONFIG_DIRECTIVE); if (validationDirective != null && validationDirective.equalsIgnoreCase("true")) { validateTargetConfig(notificationType, properties); } boolean overwriteExisting = false; if (requestInfoProps.containsKey(AlertTargetResourceDefinition.OVERWRITE_DIRECTIVE)) { overwriteExisting = true; } // global not required boolean isGlobal = false; if (null != globalProperty) { isGlobal = Boolean.parseBoolean(globalProperty); } // set the states that this alert target cares about final Set<AlertState> alertStateSet; if (null != alertStates) { alertStateSet = new HashSet<AlertState>(alertStates.size()); for (String state : alertStates) { alertStateSet.add(AlertState.valueOf(state)); } } else { alertStateSet = EnumSet.allOf(AlertState.class); } // if we are overwriting an existing, determine if one exists first AlertTargetEntity entity = null; if (overwriteExisting) { entity = s_dao.findTargetByName(name); } if (null == entity) { entity = new AlertTargetEntity(); } // groups are not required on creation if (requestMap.containsKey(ALERT_TARGET_GROUPS)) { Collection<Long> groupIds = (Collection<Long>) requestMap.get(ALERT_TARGET_GROUPS); if (!groupIds.isEmpty()) { Set<AlertGroupEntity> groups = new HashSet<AlertGroupEntity>(); List<Long> ids = new ArrayList<Long>(groupIds); groups.addAll(s_dao.findGroupsById(ids)); entity.setAlertGroups(groups); } } entity.setDescription(description); entity.setNotificationType(notificationType); entity.setProperties(propertiesJson); entity.setTargetName(name); entity.setAlertStates(alertStateSet); entity.setGlobal(isGlobal); if (null == entity.getTargetId() || 0 == entity.getTargetId()) { s_dao.create(entity); } else { s_dao.merge(entity); } } }
From source file:org.apache.hadoop.tools.distcp2.mapred.TestCopyMapper.java
@Test public void testPreserve() { try {/*from ww w . ja v a2 s . co m*/ deleteState(); createSourceData(); UserGroupInformation tmpUser = UserGroupInformation.createRemoteUser("guest"); final CopyMapper copyMapper = new CopyMapper(); final Mapper<Text, FileStatus, Text, Text>.Context context = tmpUser .doAs(new PrivilegedAction<Mapper<Text, FileStatus, Text, Text>.Context>() { @Override public Mapper<Text, FileStatus, Text, Text>.Context run() { try { StubContext stubContext = new StubContext(getConfiguration(), null, 0); return stubContext.getContext(); } catch (Exception e) { LOG.error("Exception encountered ", e); throw new RuntimeException(e); } } }); EnumSet<DistCpOptions.FileAttribute> preserveStatus = EnumSet.allOf(DistCpOptions.FileAttribute.class); context.getConfiguration().set(DistCpConstants.CONF_LABEL_PRESERVE_STATUS, DistCpUtils.packAttributes(preserveStatus)); touchFile(SOURCE_PATH + "/src/file"); mkdirs(TARGET_PATH); cluster.getFileSystem().setPermission(new Path(TARGET_PATH), new FsPermission((short) 511)); final FileSystem tmpFS = tmpUser.doAs(new PrivilegedAction<FileSystem>() { @Override public FileSystem run() { try { return FileSystem.get(configuration); } catch (IOException e) { LOG.error("Exception encountered ", e); Assert.fail("Test failed: " + e.getMessage()); throw new RuntimeException("Test ought to fail here"); } } }); tmpUser.doAs(new PrivilegedAction<Integer>() { @Override public Integer run() { try { copyMapper.setup(context); copyMapper.map(new Text("/src/file"), tmpFS.getFileStatus(new Path(SOURCE_PATH + "/src/file")), context); Assert.fail("Expected copy to fail"); } catch (AccessControlException e) { Assert.assertTrue("Got exception: " + e.getMessage(), true); } catch (Exception e) { throw new RuntimeException(e); } return null; } }); } catch (Exception e) { LOG.error("Exception encountered ", e); Assert.fail("Test failed: " + e.getMessage()); } }
From source file:com.diversityarrays.kdxplore.editing.EntityPropertiesTable.java
@Override public TableCellEditor getCellEditor(int row, int column) { EntityPropertiesTableModel<?> tatm = (EntityPropertiesTableModel<?>) getModel(); PropertyDescriptor pd = tatm.getPropertyDescriptor(row); Class<?> pdClass = pd.getPropertyType(); if (TraitNameStyle.class == pdClass) { if (Trial.class != tatm.entityClass) { throw new RuntimeException("Internal error: " + tatm.entityClass.getName()); }//from w w w. j a va2 s . c o m Trial trial = (Trial) tatm.getEntity(); return TNS_Editor.create(trial); } if (Enum.class.isAssignableFrom(pdClass)) { if (PlotIdentOption.class.equals(pdClass)) { List<PlotIdentOption> list = new ArrayList<>(); for (PlotIdentOption pio : PlotIdentOption.values()) { if (PlotIdentOption.NO_X_Y_OR_PLOT_ID != pio) { list.add(pio); } } return new DefaultCellEditor( new JComboBox<PlotIdentOption>(list.toArray(new PlotIdentOption[list.size()]))); } else { @SuppressWarnings({ "rawtypes", "unchecked" }) Class<Enum> eclass = (Class<Enum>) pdClass; @SuppressWarnings({ "rawtypes", "unchecked" }) EnumSet allOf = EnumSet.allOf(eclass); return new DefaultCellEditor(new JComboBox<>(allOf.toArray())); } } return super.getCellEditor(row, column); }
From source file:org.silverpeas.migration.jcr.service.SimpleDocumentServiceTest.java
/** * Test of listForeignIdsWithWysiwyg method, of class DocumentRepository. *//*from w w w . j ava 2s . c o m*/ @Test public void listForeignIdsWithWysiwyg() throws Exception { new JcrSimpleDocumentServiceTest() { @Override public void run() throws Exception { Set<String> createdIds = new HashSet<String>(); // No WYSIWYG content exists List<String> foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg(instanceId); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(0)); // Creating an FR "attachment" content. String createdUuid = createAttachmentForTest( defaultDocumentBuilder("fId_1").setDocumentType(attachment), defaultFRContentBuilder(), "fId_1_fr").getId(); createdIds.add(createdUuid); SimpleDocument enDocument = getDocumentById(createdUuid, "en"); assertThat(enDocument, notNullValue()); assertThat(enDocument.getAttachment(), nullValue()); SimpleDocument frDocument = getDocumentById(createdUuid, "fr"); assertThat(frDocument, notNullValue()); assertThat(frDocument.getAttachment(), notNullValue()); assertThat(frDocument.getDocumentType(), is(attachment)); // Updating attachment with EN content. setEnData(frDocument); updateAttachmentForTest(frDocument, "en", "fId_1_en"); createdIds.add(frDocument.getId()); // Vrifying the attachment exists into both of tested languages. enDocument = getDocumentById(createdUuid, "en"); assertThat(enDocument, notNullValue()); assertThat(enDocument.getAttachment(), notNullValue()); assertThat(enDocument.getDocumentType(), is(attachment)); checkEnglishSimpleDocument(enDocument); frDocument = getDocumentById(createdUuid, "fr"); assertThat(frDocument, notNullValue()); assertThat(frDocument.getAttachment(), notNullValue()); assertThat(frDocument.getDocumentType(), is(attachment)); checkFrenchSimpleDocument(frDocument); // No WYSIWYG : that is what it is expected foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg(instanceId); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(0)); // Adding several documents, but no WYSIWYG Set<DocumentType> documentTypes = EnumSet.allOf(DocumentType.class); documentTypes.remove(DocumentType.wysiwyg); int id = 2; for (DocumentType documentType : documentTypes) { createdIds.add(createAttachmentForTest( defaultDocumentBuilder("fId_" + id).setDocumentType(documentType), defaultFRContentBuilder().setFilename("fId_" + id + "_wysiwyg_en.txt"), "fId_" + id + "_fr").getId()); id++; } // No WYSIWYG : that is what it is expected foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg(instanceId); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(0)); // Number of expected created documents int nbDocuments = 1 + (DocumentType.values().length - 1); assertThat(createdIds.size(), is(nbDocuments)); // Adding the first WYSIWYG EN content SimpleDocument createdDocument = createAttachmentForTest( defaultDocumentBuilder("fId_26").setDocumentType(wysiwyg), defaultENContentBuilder(), "fId_26_en"); createdIds.add(createdDocument.getId()); createAttachmentForTest(defaultDocumentBuilder("otherKmelia38", "fId_26").setDocumentType(wysiwyg), defaultENContentBuilder(), "fId_26_en"); // One wrong WYSIWYG base name foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg(instanceId); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(1)); assertThat(foreignIds, contains("fId_26")); // Updating wysiwyg file name createdDocument.setFilename("fId_26_wysiwyg_en.txt"); updateAttachmentForTest(createdDocument); // One WYSIWYG base name foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg(instanceId); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(1)); assertThat(foreignIds, contains("fId_26")); foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg("otherKmelia38"); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(1)); assertThat(foreignIds, contains("fId_26")); // Adding the FR content to the first WYSIWYG document enDocument = getDocumentById(createdDocument.getId(), "en"); setFrData(enDocument); enDocument.setFilename("fId_26_wysiwyg_fr.txt"); updateAttachmentForTest(enDocument, "fr", "fId_26_fr"); createdIds.add(enDocument.getId()); // One WYSIWYG on one Component foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg(instanceId); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(1)); assertThat(foreignIds, contains("fId_26")); foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg("otherKmelia38"); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(1)); assertThat(foreignIds, contains("fId_26")); // Adding the second WYSIWYG document (on same component) SimpleDocument secondCreatedDocument = createAttachmentForTest( defaultDocumentBuilder("fId_27").setDocumentType(wysiwyg), defaultFRContentBuilder().setFilename("fId_27_wysiwyg_fr.txt"), "fId_27_fr"); createdIds.add(secondCreatedDocument.getId()); // Two WYSIWYG on one Component foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg(instanceId); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(2)); assertThat(foreignIds, containsInAnyOrder("fId_26", "fId_27")); foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg("otherKmelia38"); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(1)); assertThat(foreignIds, contains("fId_26")); // Updating wysiwyg file name setEnData(secondCreatedDocument); secondCreatedDocument.setFilename(secondCreatedDocument.getFilename()); updateAttachmentForTest(secondCreatedDocument, "en", "fId_27_en"); // Two WYSIWYG (each one in two languages) on one Component foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg(instanceId); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(2)); assertThat(foreignIds, containsInAnyOrder("fId_26", "fId_27")); foreignIds = getSimpleDocumentService().listForeignIdsWithWysiwyg("otherKmelia38"); assertThat(foreignIds, notNullValue()); assertThat(foreignIds, hasSize(1)); assertThat(foreignIds, contains("fId_26")); assertThat(createdIds, hasSize(nbDocuments + 2)); } }.execute(); }
From source file:ch.epfl.leb.sass.server.RPCServerIT.java
/** * Test of toJsonMessages method, of class RemoteSimulationServiceHandler. *///from w ww . ja va2 s.co m @Test public void testToJsonMessages() throws UnknownSimulationIdException, TException { System.out.println("testToJsonMessages"); RemoteSimulationService.Client client = rpcClient.getClient(); JsonParser parser = new JsonParser(); // Run the simulation for a few steps to generate some messages. int simId = sims[0].getId(); for (int i = 0; i < 10; i++) { client.incrementTimeStep(simId); } // Extract the messages from the first simulation. String info = client.toJsonMessages(simId); System.out.println(info); // Ensure that all messages have a TYPE field that is registered in // MessageType. EnumSet<MessageType> set = EnumSet.allOf(MessageType.class); List<String> typeStrings = new ArrayList<>(); for (MessageType type : set) { typeStrings.add(type.name()); } String typeString; JsonArray json = parser.parse(info).getAsJsonArray(); for (JsonElement e : json) { typeString = e.getAsJsonObject().get("type").getAsString(); assert (typeStrings.contains(typeString)); } }
From source file:org.apache.zeppelin.server.ZeppelinServer.java
private static void setupRestApiContextHandler(WebAppContext webapp, ZeppelinConfiguration conf) { final ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet()); cxfServletHolder.setInitParameter("javax.ws.rs.Application", ZeppelinServer.class.getName()); cxfServletHolder.setName("rest"); cxfServletHolder.setForcedPath("rest"); webapp.setSessionHandler(new SessionHandler()); webapp.addServlet(cxfServletHolder, "/api/*"); String shiroIniPath = conf.getShiroPath(); if (!StringUtils.isBlank(shiroIniPath)) { webapp.setInitParameter("shiroConfigLocations", new File(shiroIniPath).toURI().toString()); SecurityUtils.initSecurityManager(shiroIniPath); webapp.addFilter(ShiroFilter.class, "/api/*", EnumSet.allOf(DispatcherType.class)); webapp.addEventListener(new EnvironmentLoaderListener()); }/*from w w w .j a v a 2 s . c o m*/ }
From source file:nl.strohalm.cyclos.services.access.AccessServiceSecurity.java
@Override public List<Session> searchSessions(final SessionQuery query) { if (LoggedUser.isAdministrator()) { Collection<Nature> natures = query.getNatures(); if (CollectionUtils.isEmpty(natures)) { // As usual, empty means all. We want to ensure one-by-one, so we add them here natures = EnumSet.allOf(Nature.class); }/*w ww . j a v a 2 s. com*/ if (!permissionService.hasPermission(AdminSystemPermission.STATUS_VIEW_CONNECTED_ADMINS)) { natures.remove(Nature.ADMIN); } if (!permissionService.hasPermission(AdminSystemPermission.STATUS_VIEW_CONNECTED_MEMBERS)) { natures.remove(Nature.MEMBER); } if (!permissionService.hasPermission(AdminSystemPermission.STATUS_VIEW_CONNECTED_BROKERS)) { natures.remove(Nature.BROKER); } if (!permissionService.hasPermission(AdminSystemPermission.STATUS_VIEW_CONNECTED_OPERATORS)) { natures.remove(Nature.OPERATOR); } if (natures.isEmpty()) { // Nothing left to see throw new PermissionDeniedException(); } // Apply the allowed groups Collection<Group> allowedGroups = new HashSet<Group>(); allowedGroups.addAll(permissionService.getVisibleMemberGroups()); if (natures.contains(Nature.ADMIN)) { // Add all admin groups, as they are not present on the permissionService.getVisibleMemberGroups() GroupQuery admins = new GroupQuery(); admins.setNatures(Group.Nature.ADMIN); allowedGroups.addAll(groupService.search(admins)); } if (natures.contains(Nature.OPERATOR)) { // Add all operator groups, as they are not present on the permissionService.getVisibleMemberGroups() GroupQuery operators = new GroupQuery(); operators.setIgnoreManagedBy(true); operators.setNatures(Group.Nature.OPERATOR); allowedGroups.addAll(groupService.search(operators)); } query.setGroups(PermissionHelper.checkSelection(allowedGroups, query.getGroups())); } else { // Members can only view connected operators permissionService.permission(query.getMember()).member(MemberPermission.OPERATORS_MANAGE).check(); } return accessService.searchSessions(query); }
From source file:org.totschnig.myexpenses.util.Utils.java
/** * @param ctx for retrieving resources// w w w . java 2 s . co m * @param other if not null, all features except the one provided will be returned * @return construct a list of all contrib features to be included into a TextView */ public static String getContribFeatureLabelsAsFormattedList(Context ctx, Feature other) { String result = ""; Iterator<Feature> iterator = EnumSet.allOf(Feature.class).iterator(); while (iterator.hasNext()) { Feature f = iterator.next(); if (!f.equals(other)) { result += " - " + ctx.getString(ctx.getResources().getIdentifier( "contrib_feature_" + f.toString() + "_label", "string", ctx.getPackageName())); if (iterator.hasNext()) result += "<br>"; } } return result; }
From source file:fi.vm.sade.eperusteet.ylops.service.ops.impl.OpetussuunnitelmaServiceImpl.java
@Override @Transactional(readOnly = true)//w w w.jav a2s .com public List<OpetussuunnitelmaInfoDto> getAll(Tyyppi tyyppi, Tila tila) { Set<String> organisaatiot = SecurityUtil.getOrganizations(EnumSet.allOf(RolePermission.class)); final List<Opetussuunnitelma> opetussuunnitelmat; if (tyyppi == Tyyppi.POHJA) { opetussuunnitelmat = repository.findPohja(organisaatiot); } else { opetussuunnitelmat = repository.findAllByTyyppi(tyyppi, organisaatiot); } return mapper.mapAsList(opetussuunnitelmat, OpetussuunnitelmaInfoDto.class).stream() .filter(ops -> tila == null || ops.getTila() == tila).map(dto -> { fetchKuntaNimet(dto); fetchOrganisaatioNimet(dto); return dto; }).collect(Collectors.toList()); }
From source file:me.jdknight.ums.ccml.core.CcmlRootFolderListener.java
/** * Build the media library on the provided library based off the provided base directory. * // w ww.j a va 2 s .c om * @param library The library to add to. * @param directory The directory to scan. */ private void buildMediaLibrary(ICustomCategoryMediaLibrary library, File directory) { assert (directory.isDirectory() == true); File[] directoryChildren = directory.listFiles(); if (directoryChildren != null) { for (File child : directoryChildren) { if (child.isFile() == true) { // Find if this file is a supported media type. RealFileWithVirtualFolderThumbnails mediaResource = new RealFileWithVirtualFolderThumbnails( child); Format mediaFormat = LazyCompatibility.getAssociatedExtension(child.getPath()); EMediaType mediaType = EMediaType.get(mediaFormat); // Ignore unsupported media types. if (mediaType == EMediaType.UNKNOWN) { continue; } // Check if a meta file exists. String metaFilePath = mediaResource.getFile().getPath() + ".meta"; //$NON-NLS-1$ File metaFile = new File(metaFilePath); // No meta file? Check the alternative folder (if any is provided). if (metaFile.isFile() == false) { String alternativeFolderPath = CcmlConfiguration.getInstance().getAlternativeMetaFolder(); if (alternativeFolderPath != null) { File alternativeFolder = new File(alternativeFolderPath); if (alternativeFolder.isDirectory() == true) { String originalFileName = metaFile.getName(); metaFile = new File(alternativeFolder, originalFileName); } } } // Still no meta file? Ignore. if (metaFile.isFile() == false) { continue; } _logger.trace("[CCML] Parsing meta file: " + metaFile); //$NON-NLS-1$ Map<String, List<String>> mapOfCategories = parseMetaFile(metaFile); if (mapOfCategories == null) { continue; } // Attempt to find this meta file's master reference(s). String[] masterSections = stripSpecialValues(mapOfCategories, metaFile, SPECIAL_CATEGORY_TYPE_NAME_MASTER); // Strip out any filter entries; they are not used on single meta file. stripSpecialValues(mapOfCategories, metaFile, SPECIAL_CATEGORY_TYPE_NAME_FILTER); // Add resources to a respective media category type. Set<Entry<String, List<String>>> categorySet = mapOfCategories.entrySet(); if (categorySet.isEmpty() == false) { for (String masterSection : masterSections) { for (Entry<String, List<String>> categoryReference : categorySet) { // Find/create category. String categoryName = categoryReference.getKey(); IMediaCategoryType category = library.acquireCategoryType(mediaType, masterSection, categoryName); // Add resource to it. List<String> categoryValues = categoryReference.getValue(); for (String categoryValue : categoryValues) { category.addResource(new RealFileWithVirtualFolderThumbnails(mediaResource), categoryValue); _logger.trace("[CCML] Adding resource to category a '" + categoryName //$NON-NLS-1$ + "' with a value of '" + categoryValue + "'" + //$NON-NLS-1$ //$NON-NLS-2$ (masterSection != null ? " (Master: " + masterSection + ")" : "") + ": " //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + metaFile); } } } } else { _logger.warn( "[CCML] The following meta file does not have any defined categories: " + metaFile); //$NON-NLS-1$ } } else { // Recursive - scan folder for more resources. buildMediaLibrary(library, child); } } } // We will check if this folder has a meta file for its contents. // // Check if a folder meta file exists. File folderMetaFile = new File(directory, FOLDER_FOLDER_NAME); // No meta file? Ignore. if (folderMetaFile.isFile() == false) { return; } _logger.trace("[CCML] Parsing folder meta file: " + folderMetaFile); //$NON-NLS-1$ Map<String, List<String>> mapOfCategories = parseMetaFile(folderMetaFile); if (mapOfCategories == null) { return; } // Attempt to find this meta file's master reference(s). String[] masterSections = stripSpecialValues(mapOfCategories, folderMetaFile, SPECIAL_CATEGORY_TYPE_NAME_MASTER); // Find if this meta file is specific to any media types. String[] filterValues = stripSpecialValues(mapOfCategories, folderMetaFile, SPECIAL_CATEGORY_TYPE_NAME_FILTER); boolean isFirstFilterAdded = false; EnumSet<EMediaType> mediaTypeFilter = EnumSet.allOf(EMediaType.class); for (String filterValue : filterValues) { if (filterValue != null) { EMediaType[] mediaTypes = EMediaType.values(); for (EMediaType mediaType : mediaTypes) { if (mediaType.getEnglishName().equalsIgnoreCase(filterValue) == true || mediaType.getDisplayName().equalsIgnoreCase(filterValue) == true) { // If we have actual content to filter, start fresh. if (isFirstFilterAdded == false) { mediaTypeFilter = EnumSet.noneOf(EMediaType.class); isFirstFilterAdded = true; } mediaTypeFilter.add(mediaType); break; } } } } // Compile a list of media resources for this folder. IVirtualFolderMediaResources mediaResourcePoint = getVirtualFolderForDirectoryMedia(directory); DLNAResource resource = mediaResourcePoint.getVirtualFolder(); // Add resources to a respective media category type. Set<Entry<String, List<String>>> categorySet = mapOfCategories.entrySet(); if (categorySet.isEmpty() == false) { for (String masterSection : masterSections) { for (Entry<String, List<String>> categoryReference : categorySet) { EnumSet<EMediaType> mediaTypes = mediaResourcePoint.getMediaType(); if (mediaTypes.isEmpty() == false) { for (EMediaType mediaType : mediaTypes) { // This media type filtered? If so, next. if (mediaTypeFilter.contains(mediaType) == false) { continue; } // Find/create category. String categoryName = categoryReference.getKey(); IMediaCategoryType category = library.acquireCategoryType(mediaType, masterSection, categoryName); // Add resource to it. List<String> categoryValues = categoryReference.getValue(); for (String categoryValue : categoryValues) { category.addResource(resource, categoryValue); _logger.trace("[CCML] Adding resource to category a '" + categoryName //$NON-NLS-1$ + "' with a value of '" + categoryValue + "'" + //$NON-NLS-1$ //$NON-NLS-2$ (masterSection != null ? " (Master: " + masterSection + ")" : "") + ": " //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + folderMetaFile); } } } else { _logger.warn( "[CCML] The following folder meta file does not have any content to reference: " //$NON-NLS-1$ + folderMetaFile); } } } } else { _logger.warn("[CCML] The following folder meta file does not have any defined categories: " //$NON-NLS-1$ + folderMetaFile); } }