/** * @param resource * the {@link Resource} to search in all available groups. * @return t collection of group names containing provided resource. If the resource is not availalbe, an empty * collection will be returned. * @deprecated use {@link WroModelInspector#getGroupNamesContainingResource(String)} */ @Deprecated public Collection<String> getGroupNamesContainingResource(final String resourceUri) { return new WroModelInspector(this).getGroupNamesContainingResource(resourceUri); }
/** * Merge master model with another model. This is useful for supporting model imports. * * @param master master modele where we put imported model * @param importedModel model to import. */ protected void merge(WroModel master, WroModel importedModel) { Validate.notNull(importedModel, "imported model cannot be null!"); LOG.debug("merging importedModel: {}", importedModel); for (final String groupName : new WroModelInspector(importedModel).getGroupNames()) { if (!new WroModelInspector(master).getGroupNames().contains(groupName)) { // si les deux modeles contiennent le meme groupe, on garde celui du master final Group importedGroup = new WroModelInspector(importedModel).getGroupByName(groupName); master.addGroup(importedGroup); } } }
/** * Merge this model with another model. This is useful for supporting model imports. * * @param importedModel model to import. */ public void merge(final WroModel importedModel) { Validate.notNull(importedModel, "imported model cannot be null!"); LOG.debug("merging importedModel: {}", importedModel); for (final String groupName : new WroModelInspector(importedModel).getGroupNames()) { if (new WroModelInspector(this).getGroupNames().contains(groupName)) { throw new WroRuntimeException("Duplicate group name detected: " + groupName); } final Group importedGroup = new WroModelInspector(importedModel).getGroupByName(groupName); addGroup(importedGroup); } }
/** * Merge this model with another model. This is useful for supporting model imports. * * @param importedModel model to import. */ public void merge(final WroModel importedModel) { Validate.notNull(importedModel, "imported model cannot be null!"); LOG.debug("merging importedModel: {}", importedModel); for (final String groupName : new WroModelInspector(importedModel).getGroupNames()) { if (new WroModelInspector(this).getGroupNames().contains(groupName)) { throw new WroRuntimeException("Duplicate group name detected: " + groupName); } final Group importedGroup = new WroModelInspector(importedModel).getGroupByName(groupName); addGroup(importedGroup); } }
private List<String> getAllModelGroupNames() { return new WroModelInspector(getModel()).getGroupNames(); }
private List<String> getAllModelGroupNames() { return new WroModelInspector(getModel()).getGroupNames(); }
/** * @param name * of group to find. * @return group with searched name. * @throws runtime * exception if group is not found. * @deprecated use {@link WroModelInspector#getGroupByName(String)} */ @Deprecated public Group getGroupByName(final String name) { final WroModelInspector modelInspector = new WroModelInspector(this); final Group group = modelInspector.getGroupByName(name); if (group == null) { throw new InvalidGroupNameException(String.format("There is no such group: '%s'. Available groups are: [%s]", name, modelInspector.getGroupNamesAsString())); } return group; }
/** * @return a list containing all groups needs to be processed. */ private List<String> getTargetGroupsAsList() throws IOException { if (targetGroups == null) { final WroModel model= managerFactory.create().getModelFactory().create(); return new WroModelInspector(model).getGroupNames(); } return Arrays.asList(targetGroups.split(",")); }
groupsInProcess.add(name); final Group parsedGroup = new WroModelInspector(model).getGroupByName(name); if (parsedGroup != null) {
/** * Search for all resources for a group with a given name. */ private Collection<Resource> getResourcesForGroup(final String groupName) { final WroModelInspector modelInspector = new WroModelInspector(model); final Group foundGroup = modelInspector.getGroupByName(groupName); if (foundGroup == null) { Collection<Resource> groupResources = null; final Element groupElement = allGroupElements.get(groupName); if (groupElement == null) { throw new WroRuntimeException("Invalid group-ref: " + groupName); } groupResources = parseGroup(groupElement); return groupResources; } return foundGroup.getResources(); }
/** * Search for all resources for a group with a given name. */ private Collection<Resource> getResourcesForGroup(final String groupName) { final WroModelInspector modelInspector = new WroModelInspector(model); final Group foundGroup = modelInspector.getGroupByName(groupName); if (foundGroup == null) { final Element groupElement = allGroupElements.get(groupName); if (groupElement == null) { throw new WroRuntimeException("Invalid group-ref: " + groupName); } return parseGroup(groupElement); } return foundGroup.getResources(); }
/** * Search for all resources for a group with a given name. */ private Collection<Resource> getResourcesForGroup(final String groupName) { final WroModelInspector modelInspector = new WroModelInspector(model); final Group foundGroup = modelInspector.getGroupByName(groupName); if (foundGroup == null) { Collection<Resource> groupResources = null; final Element groupElement = allGroupElements.get(groupName); if (groupElement == null) { throw new WroRuntimeException("Invalid group-ref: " + groupName); } groupResources = parseGroup(groupElement); return groupResources; } return foundGroup.getResources(); }
/** * Store digest for all resources contained inside the list of provided groups. */ private void persistResourceFingerprints(final List<String> groupNames) { final WroModelInspector modelInspector = new WroModelInspector(getModel()); for (final String groupName : groupNames) { final Group group = modelInspector.getGroupByName(groupName); if (group != null) { for (final Resource resource : group.getResources()) { getResourceChangeHandler().remember(resource); } } } }
/** * Store digest for all resources contained inside the list of provided groups. */ private void persistResourceFingerprints(final List<String> groupNames) { final WroModelInspector modelInspector = new WroModelInspector(getModel()); for (final String groupName : groupNames) { final Group group = modelInspector.getGroupByName(groupName); if (group != null) { for (final Resource resource : group.getResources()) { getResourceChangeHandler().remember(resource); } } } }
/** * Authorizes all resources of the model to be accessed as proxy resources (only in dev mode). * * @param model * {@link WroModel} created by decorated factory. */ private void authorizeModelResources(final WroModel model) { if (model != null && context.getConfig().isDebug()) { if (authorizationManager instanceof MutableResourceAuthorizationManager) { for (final Resource resource : new WroModelInspector(model).getAllUniqueResources()) { ((MutableResourceAuthorizationManager) authorizationManager).add(resource.getUri()); } } } } };
/** * Authorizes all resources of the model to be accessed as proxy resources (only in dev mode). * * @param model * {@link WroModel} created by decorated factory. */ private void authorizeModelResources(final WroModel model) { if (model != null && context.getConfig().isDebug()) { if (authorizationManager instanceof MutableResourceAuthorizationManager) { for (final Resource resource : new WroModelInspector(model).getAllUniqueResources()) { ((MutableResourceAuthorizationManager) authorizationManager).add(resource.getUri()); } } } } };
/** * Check if resources from a group were changed. If a change is detected, the changeListener will be invoked. * * @param cacheKey * the cache key which was requested. The key contains the groupName which has to be checked for changes. */ public void check(final CacheKey cacheKey, final Callback callback) { notNull(cacheKey); LOG.debug("started"); final StopWatch watch = new StopWatch(); watch.start("detect changes"); try { final Group group = new WroModelInspector(modelFactory.create()).getGroupByName(cacheKey.getGroupName()); if (isGroupChanged(group.collectResourcesOfType(cacheKey.getType()), callback)) { callback.onGroupChanged(cacheKey); cacheStrategy.put(cacheKey, null); } resourceChangeDetector.reset(); } catch (final Exception e) { onException(e); } finally { watch.stop(); LOG.debug("resource watcher info: {}", watch.prettyPrint()); } }
/** * Check if resources from a group were changed. If a change is detected, the changeListener will be invoked. * * @param cacheKey * the cache key which was requested. The key contains the groupName which has to be checked for changes. */ public void check(final CacheKey cacheKey, final Callback callback) { notNull(cacheKey); LOG.debug("started"); final StopWatch watch = new StopWatch(); watch.start("detect changes"); try { final Group group = new WroModelInspector(modelFactory.create()).getGroupByName(cacheKey.getGroupName()); if (isGroupChanged(group.collectResourcesOfType(cacheKey.getType()), callback)) { callback.onGroupChanged(cacheKey); cacheStrategy.put(cacheKey, null); } resourceChangeDetector.reset(); } catch (final Exception e) { onException(e); } finally { watch.stop(); LOG.debug("resource watcher info: {}", watch.prettyPrint()); } }
final Group group = new WroModelInspector(model).getGroupByName(cacheKey.getGroupName()); if (group == null) { throw new WroRuntimeException("No such group available in the model: " + cacheKey.getGroupName());
final Group group = new WroModelInspector(model).getGroupByName(cacheKey.getGroupName()); if (group == null) { throw new WroRuntimeException("No such group available in the model: " + cacheKey.getGroupName());