public boolean isMapped(RestfulMapping mapping) { boolean mapped = false; for (RestfulMapping cachedMapping : this.cache.values()) { mapped = CollectionUtils.containsAny(cachedMapping.getUrls(), mapping.getUrls()) && CollectionUtils.containsAny( cachedMapping.getHttpMethods(), mapping.getHttpMethods()); if (mapped) { break; } } return mapped; }
/** * Gets the transition. * * @param ambience DOCUMENT_ME * @return transition mapping this FROM ambience or null if none maps it */ public Transition getTransition(Ambience ambience) { for (Transition transition : transitions) { if (CollectionUtils.containsAny(transition.getFrom().getGenres(), ambience.getGenres())) { return transition; } } return null; }
@Override protected void fillUserRoles( Set<SilverpeasRole> userRoles, AccessControlContext context, String userId, String componentId) { // Personal space or user tool if (componentId == null || getOrganisationController().isToolAvailable(componentId)) { userRoles.add(SilverpeasRole.admin); return; } if (Admin.ADMIN_COMPONENT_ID.equals(componentId)) { if (getOrganisationController().getUserDetail(userId).isAccessAdmin()) { userRoles.add(SilverpeasRole.admin); } return; } ComponentInst componentInst = getOrganisationController().getComponentInst(componentId); if (componentInst == null) { return; } if (componentInst.isPublic() || StringUtil.getBooleanValue( getOrganisationController().getComponentParameterValue(componentId, "publicFiles"))) { userRoles.add(SilverpeasRole.user); if (!CollectionUtils.containsAny( AccessControlOperation.PERSIST_ACTIONS, context.getOperations()) && !context.getOperations().contains(AccessControlOperation.download)) { // In that case, it is not necessary to check deeper the user rights return; } } if (getOrganisationController().isComponentAvailable(componentId, userId)) { Set<SilverpeasRole> roles = SilverpeasRole.from(getOrganisationController().getUserProfiles(userId, componentId)); // If component is available, but user has no rights -> public component if (roles.isEmpty()) { userRoles.add(SilverpeasRole.user); } else { userRoles.addAll(roles); } } }
private boolean isPublicationReadable( WAPrimaryKey pk, String instanceId, Collection<NodePK> autorizedNodes) throws RemoteException, CreateException { if (pk.getInstanceId().equals(instanceId)) { Collection<NodePK> fathers = getPublicationFathers(pk); return CollectionUtils.containsAny(autorizedNodes, fathers); } else { // special case of an alias between two ECM applications // check if publication which contains attachment is an alias into this node Collection<Alias> aliases = getPublicationAliases(pk); for (Alias alias : aliases) { NodePK aliasPK = new NodePK(alias.getId(), alias.getInstanceId()); if (autorizedNodes.contains(aliasPK)) { return true; } } } return false; }
private void prepareTabs() throws Exception { Locale locale = getApplication().getLocale(); GsonBuilder gb = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ"); Gson gson = gb.create(); Type collectionType = new TypeToken<LinkedHashMap<Integer, String>>() {}.getType(); TreeMap<Integer, String> tabList = new TreeMap<Integer, String>(); String metaDataString = getPbApplication().getBpmModule().getMetaData("PROCESSBASE_TABSHEETS_LIST"); if (metaDataString != null) { LinkedHashMap<Integer, String> tabs2 = gson.fromJson(metaDataString, collectionType); if (!tabs2.isEmpty()) { tabList.putAll(tabs2); } } PbPanelModuleService pms = getPbApplication().getPanelModuleService(); for (Entry<String, PbPanelModule> pm : pms.getModules().entrySet()) { System.out.println("moduleName = " + pm.getKey()); if (pm != null) { try { PbPanelModule panel = pm.getValue(); if (CollectionUtils.containsAny(Arrays.asList(panel.getRoles()), accessSet)) { tabs.addTab(panel, panel.getTitle(locale), null); } else { System.out.println("No rights for module = " + pm.getKey()); } } catch (Exception ex) { System.out.println("Exception with pm = " + pm.getKey()); ex.printStackTrace(); throw new RuntimeException(ex); } } } if (tabs.getSelectedTab() != null && tabs.getSelectedTab() instanceof PbPanel) { PbPanel first = (PbPanel) tabs.getSelectedTab(); first.initUI(); first.setInitialized(true); first.setSizeFull(); } }
/** * Create StorageDomain objects according to the specified VG-IDs list. * * @param vgIDs the VG-IDs list * @return storage domains list */ @SuppressWarnings("unchecked") protected List<StorageDomain> getStorageDomainsByVolumeGroupIds(List<String> vgIDs) { List<StorageDomain> storageDomains = new ArrayList<>(); // Get existing PhysicalVolumes. List<String> existingLunIds = Entities.getIds(getLunDao().getAll()); for (String vgID : vgIDs) { VDSReturnValue returnValue; try { returnValue = executeGetVGInfo(new GetVGInfoVDSCommandParameters(getParameters().getVdsId(), vgID)); } catch (RuntimeException e) { log.error("Could not get info for VG ID: '{}': {}", vgID, e.getMessage()); log.debug("Exception", e); continue; } ArrayList<LUNs> luns = (ArrayList<LUNs>) returnValue.getReturnValue(); List<String> lunIdsOnStorage = Entities.getIds(luns); if (CollectionUtils.containsAny(lunIdsOnStorage, existingLunIds)) { log.info("There are existing luns in the system which are part of VG id '{}'", vgID); continue; } // Get storage domain ID by a representative LUN LUNs lun = luns.get(0); Guid storageDomainId = lun.getStorageDomainId(); // Get storage domain using GetStorageDomainInfo StorageDomain storageDomain = getStorageDomainById(storageDomainId); if (storageDomain != null) { storageDomains.add(storageDomain); } } return storageDomains; }