List of usage examples for java.util EnumSet copyOf
public static <E extends Enum<E>> EnumSet<E> copyOf(Collection<E> c)
From source file:com.quinsoft.zeidon.standardoe.EntityCursorImpl.java
@Override public EntityInstanceImpl createEntity(CreateEntityFlags... flags) { EnumSet<CreateEntityFlags> set = EnumSet.copyOf(Arrays.asList(flags)); return createEntity(CursorPosition.NEXT, set); }
From source file:com.quinsoft.zeidon.standardoe.EntityCursorImpl.java
EntityInstanceImpl createEntity(CursorPosition position, CreateEntityFlags... flags) { EnumSet<CreateEntityFlags> set = EnumSet.copyOf(Arrays.asList(flags)); return createEntity(position, set); }
From source file:org.apache.syncope.console.pages.ConnectorModalPage.java
public ConnectorModalPage(final PageReference pageRef, final ModalWindow window, final ConnInstanceTO connInstanceTO) { super();//from w w w. j a v a2s . c om // general data setup selectedCapabilities = new ArrayList<ConnectorCapability>( connInstanceTO.getId() == 0 ? EnumSet.noneOf(ConnectorCapability.class) : connInstanceTO.getCapabilities()); mapConnBundleTOs = new HashMap<String, Map<String, Map<String, ConnBundleTO>>>(); for (ConnBundleTO connBundleTO : restClient.getAllBundles()) { // by location if (!mapConnBundleTOs.containsKey(connBundleTO.getLocation())) { mapConnBundleTOs.put(connBundleTO.getLocation(), new HashMap<String, Map<String, ConnBundleTO>>()); } final Map<String, Map<String, ConnBundleTO>> byLocation = mapConnBundleTOs .get(connBundleTO.getLocation()); // by name if (!byLocation.containsKey(connBundleTO.getBundleName())) { byLocation.put(connBundleTO.getBundleName(), new HashMap<String, ConnBundleTO>()); } final Map<String, ConnBundleTO> byName = byLocation.get(connBundleTO.getBundleName()); // by version if (!byName.containsKey(connBundleTO.getVersion())) { byName.put(connBundleTO.getVersion(), connBundleTO); } } bundleTO = getSelectedBundleTO(connInstanceTO); properties = fillProperties(bundleTO, connInstanceTO); // form - first tab final Form<ConnInstanceTO> connectorForm = new Form<ConnInstanceTO>(FORM); connectorForm.setModel(new CompoundPropertyModel<ConnInstanceTO>(connInstanceTO)); connectorForm.setOutputMarkupId(true); add(connectorForm); propertiesContainer = new WebMarkupContainer("container"); propertiesContainer.setOutputMarkupId(true); connectorForm.add(propertiesContainer); final Form<ConnInstanceTO> connectorPropForm = new Form<ConnInstanceTO>("connectorPropForm"); connectorPropForm.setModel(new CompoundPropertyModel<ConnInstanceTO>(connInstanceTO)); connectorPropForm.setOutputMarkupId(true); propertiesContainer.add(connectorPropForm); final AjaxTextFieldPanel displayName = new AjaxTextFieldPanel("displayName", "display name", new PropertyModel<String>(connInstanceTO, "displayName")); displayName.setOutputMarkupId(true); displayName.addRequiredLabel(); connectorForm.add(displayName); final AjaxDropDownChoicePanel<String> location = new AjaxDropDownChoicePanel<String>("location", "location", new Model<String>(bundleTO == null ? null : bundleTO.getLocation())); ((DropDownChoice<String>) location.getField()).setNullValid(true); location.setStyleSheet("long_dynamicsize"); location.setChoices(new ArrayList<String>(mapConnBundleTOs.keySet())); location.setRequired(true); location.addRequiredLabel(); location.setOutputMarkupId(true); location.setEnabled(connInstanceTO.getId() == 0); location.getField().setOutputMarkupId(true); connectorForm.add(location); final AjaxDropDownChoicePanel<String> connectorName = new AjaxDropDownChoicePanel<String>("connectorName", "connectorName", new Model<String>(bundleTO == null ? null : bundleTO.getBundleName())); ((DropDownChoice<String>) connectorName.getField()).setNullValid(true); connectorName.setStyleSheet("long_dynamicsize"); connectorName.setChoices(bundleTO == null ? new ArrayList<String>() : new ArrayList<String>(mapConnBundleTOs.get(connInstanceTO.getLocation()).keySet())); connectorName.setRequired(true); connectorName.addRequiredLabel(); connectorName.setEnabled(connInstanceTO.getLocation() != null); connectorName.setOutputMarkupId(true); connectorName.setEnabled(connInstanceTO.getId() == 0); connectorName.getField().setOutputMarkupId(true); connectorForm.add(connectorName); final AjaxDropDownChoicePanel<String> version = new AjaxDropDownChoicePanel<String>("version", "version", new Model<String>(bundleTO == null ? null : bundleTO.getVersion())); version.setStyleSheet("long_dynamicsize"); version.setChoices(bundleTO == null ? new ArrayList<String>() : new ArrayList<String>(mapConnBundleTOs.get(connInstanceTO.getLocation()) .get(connInstanceTO.getBundleName()).keySet())); version.setRequired(true); version.addRequiredLabel(); version.setEnabled(connInstanceTO.getBundleName() != null); version.setOutputMarkupId(true); version.addRequiredLabel(); version.getField().setOutputMarkupId(true); connectorForm.add(version); final SpinnerFieldPanel<Integer> connRequestTimeout = new SpinnerFieldPanel<Integer>("connRequestTimeout", "connRequestTimeout", Integer.class, new PropertyModel<Integer>(connInstanceTO, "connRequestTimeout"), 0, null); connRequestTimeout.getField().add(new RangeValidator<Integer>(0, Integer.MAX_VALUE)); connectorForm.add(connRequestTimeout); if (connInstanceTO.getPoolConf() == null) { connInstanceTO.setPoolConf(new ConnPoolConfTO()); } final SpinnerFieldPanel<Integer> poolMaxObjects = new SpinnerFieldPanel<Integer>("poolMaxObjects", "poolMaxObjects", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "maxObjects"), 0, null); poolMaxObjects.getField().add(new RangeValidator<Integer>(0, Integer.MAX_VALUE)); connectorForm.add(poolMaxObjects); final SpinnerFieldPanel<Integer> poolMinIdle = new SpinnerFieldPanel<Integer>("poolMinIdle", "poolMinIdle", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "minIdle"), 0, null); poolMinIdle.getField().add(new RangeValidator<Integer>(0, Integer.MAX_VALUE)); connectorForm.add(poolMinIdle); final SpinnerFieldPanel<Integer> poolMaxIdle = new SpinnerFieldPanel<Integer>("poolMaxIdle", "poolMaxIdle", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "maxIdle"), 0, null); poolMaxIdle.getField().add(new RangeValidator<Integer>(0, Integer.MAX_VALUE)); connectorForm.add(poolMaxIdle); final SpinnerFieldPanel<Long> poolMaxWait = new SpinnerFieldPanel<Long>("poolMaxWait", "poolMaxWait", Long.class, new PropertyModel<Long>(connInstanceTO.getPoolConf(), "maxWait"), 0L, null); poolMaxWait.getField().add(new RangeValidator<Long>(0L, Long.MAX_VALUE)); connectorForm.add(poolMaxWait); final SpinnerFieldPanel<Long> poolMinEvictableIdleTime = new SpinnerFieldPanel<Long>( "poolMinEvictableIdleTime", "poolMinEvictableIdleTime", Long.class, new PropertyModel<Long>(connInstanceTO.getPoolConf(), "minEvictableIdleTimeMillis"), 0L, null); poolMinEvictableIdleTime.getField().add(new RangeValidator<Long>(0L, Long.MAX_VALUE)); connectorForm.add(poolMinEvictableIdleTime); // form - first tab - onchange() location.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { ((DropDownChoice<String>) location.getField()).setNullValid(false); connInstanceTO.setLocation(location.getModelObject()); target.add(location); connectorName.setChoices( new ArrayList<String>(mapConnBundleTOs.get(location.getModelObject()).keySet())); connectorName.setEnabled(true); connectorName.getField().setModelValue(null); target.add(connectorName); version.setChoices(new ArrayList<String>()); version.getField().setModelValue(null); version.setEnabled(false); target.add(version); properties.clear(); target.add(propertiesContainer); } }); connectorName.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { ((DropDownChoice<String>) connectorName.getField()).setNullValid(false); connInstanceTO.setBundleName(connectorName.getModelObject()); target.add(connectorName); List<String> versions = new ArrayList<String>(mapConnBundleTOs.get(location.getModelObject()) .get(connectorName.getModelObject()).keySet()); version.setChoices(versions); version.setEnabled(true); if (versions.size() == 1) { selectVersion(target, connInstanceTO, version, versions.get(0)); version.getField().setModelObject(versions.get(0)); } else { version.getField().setModelValue(null); properties.clear(); target.add(propertiesContainer); } target.add(version); } }); version.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { selectVersion(target, connInstanceTO, version, version.getModelObject()); } }); // form - second tab (properties) final ListView<ConnConfProperty> connPropView = new AltListView<ConnConfProperty>("connectorProperties", new PropertyModel<List<ConnConfProperty>>(this, "properties")) { private static final long serialVersionUID = 9101744072914090143L; @Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void populateItem(final ListItem<ConnConfProperty> item) { final ConnConfProperty property = item.getModelObject(); final Label label = new Label("connPropAttrSchema", StringUtils.isBlank(property.getSchema().getDisplayName()) ? property.getSchema().getName() : property.getSchema().getDisplayName()); item.add(label); final FieldPanel field; boolean required = false; boolean isArray = false; if (property.getSchema().isConfidential() || Constants.GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType()) || Constants.GUARDED_BYTE_ARRAY.equalsIgnoreCase(property.getSchema().getType())) { field = new AjaxPasswordFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model<String>()); ((PasswordTextField) field.getField()).setResetPassword(false); required = property.getSchema().isRequired(); } else { Class<?> propertySchemaClass; try { propertySchemaClass = ClassUtils.forName(property.getSchema().getType(), ClassUtils.getDefaultClassLoader()); if (ClassUtils.isPrimitiveOrWrapper(propertySchemaClass)) { propertySchemaClass = org.apache.commons.lang3.ClassUtils .primitiveToWrapper(propertySchemaClass); } } catch (Exception e) { LOG.error("Error parsing attribute type", e); propertySchemaClass = String.class; } if (ClassUtils.isAssignable(Number.class, propertySchemaClass)) { field = new SpinnerFieldPanel<Number>("panel", label.getDefaultModelObjectAsString(), (Class<Number>) propertySchemaClass, new Model<Number>(), null, null); required = property.getSchema().isRequired(); } else if (ClassUtils.isAssignable(Boolean.class, propertySchemaClass)) { field = new AjaxCheckBoxPanel("panel", label.getDefaultModelObjectAsString(), new Model<Boolean>()); } else { field = new AjaxTextFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model<String>()); required = property.getSchema().isRequired(); } if (propertySchemaClass.isArray()) { isArray = true; } } field.setTitle(property.getSchema().getHelpMessage()); if (required) { field.addRequiredLabel(); } if (isArray) { if (property.getValues().isEmpty()) { property.getValues().add(null); } item.add(new MultiFieldPanel<String>("panel", new PropertyModel<List<String>>(property, "values"), field)); } else { field.setNewModel(property.getValues()); item.add(field); } final AjaxCheckBoxPanel overridable = new AjaxCheckBoxPanel("connPropAttrOverridable", "connPropAttrOverridable", new PropertyModel<Boolean>(property, "overridable")); item.add(overridable); connInstanceTO.getConfiguration().add(property); } }; connPropView.setOutputMarkupId(true); connectorPropForm.add(connPropView); final AjaxLink<String> check = new IndicatingAjaxLink<String>("check", new ResourceModel("check")) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { connInstanceTO.setBundleName(bundleTO.getBundleName()); connInstanceTO.setVersion(bundleTO.getVersion()); connInstanceTO.setConnectorName(bundleTO.getConnectorName()); if (restClient.check(connInstanceTO)) { info(getString("success_connection")); } else { error(getString("error_connection")); } feedbackPanel.refresh(target); } }; connectorPropForm.add(check); // form - third tab (capabilities) final IModel<List<ConnectorCapability>> capabilities = new LoadableDetachableModel<List<ConnectorCapability>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<ConnectorCapability> load() { return Arrays.asList(ConnectorCapability.values()); } }; CheckBoxMultipleChoice<ConnectorCapability> capabilitiesPalette = new CheckBoxMultipleChoice<ConnectorCapability>( "capabilitiesPalette", new PropertyModel<List<ConnectorCapability>>(this, "selectedCapabilities"), capabilities); connectorForm.add(capabilitiesPalette); // form - submit / cancel buttons final AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<String>(getString(SUBMIT))) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final ConnInstanceTO conn = (ConnInstanceTO) form.getModelObject(); conn.setConnectorName(bundleTO.getConnectorName()); conn.setBundleName(bundleTO.getBundleName()); conn.setVersion(bundleTO.getVersion()); conn.getConfiguration().clear(); conn.getConfiguration().addAll(connPropView.getModelObject()); // Set the model object's capabilities to capabilitiesPalette's converted Set conn.getCapabilities() .addAll(selectedCapabilities.isEmpty() ? EnumSet.noneOf(ConnectorCapability.class) : EnumSet.copyOf(selectedCapabilities)); // Reset pool configuration if all fields are null if (conn.getPoolConf() != null && conn.getPoolConf().getMaxIdle() == null && conn.getPoolConf().getMaxObjects() == null && conn.getPoolConf().getMaxWait() == null && conn.getPoolConf().getMinEvictableIdleTimeMillis() == null && conn.getPoolConf().getMinIdle() == null) { conn.setPoolConf(null); } try { if (connInstanceTO.getId() == 0) { restClient.create(conn); } else { restClient.update(conn); } ((Resources) pageRef.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); ((Resources) pageRef.getPage()).setModalResult(false); LOG.error("While creating or updating connector {}", conn, e); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; String roles = connInstanceTO.getId() == 0 ? xmlRolesReader.getAllAllowedRoles("Connectors", "create") : xmlRolesReader.getAllAllowedRoles("Connectors", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, roles); connectorForm.add(submit); final IndicatingAjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); connectorForm.add(cancel); }
From source file:org.netxilia.api.impl.model.SheetActor.java
private IListenableFuture<ICellCommand> sendCommand(ICellCommand command, boolean withUndo) throws NetxiliaBusinessException, CyclicDependenciesException { Assert.notNull(command);/*from w ww. j a v a 2 s . com*/ init(); Matrix<CellData> cells = null; // special construction to add a new row if (command.getTarget().getFirstRowIndex() == CellReference.LAST_ROW_INDEX) { SheetDimensions dims = storageService.getSheetDimensions(); cells = new MatrixBuilder<CellData>(new CellCreator(name.getSheetName(), dims.getRowCount(), command.getTarget().getFirstColumnIndex())).setSize(1, command.getTarget().getColumnCount()) .build(); } else { cells = getCells(command.getTarget()); // build a matrix of the needed size if the returned matrix is smaller if (cells.getRowCount() < command.getTarget().getRowCount() || cells.getColumnCount() < command.getTarget().getColumnCount()) { cells = new MatrixBuilder<CellData>(cells, new CellCreator(name.getSheetName(), command.getTarget().getFirstRowIndex(), command.getTarget().getFirstColumnIndex())) .setSize(command.getTarget().getRowCount(), command.getTarget().getColumnCount()) .build(); } } BlockCellCommandBuilder commandBuilder = withUndo ? new BlockCellCommandBuilder() : null; List<CellDataWithProperties> saveCells = new ArrayList<CellDataWithProperties>(); MutableFutureWithCounter<ICellCommand> result = new MutableFutureWithCounter<ICellCommand>(cells.size()); for (CellData cell : cells) { CellDataWithProperties newCellWithProps = command.apply(cell); if (newCellWithProps.getProperties().size() == 0) { // nothing changed result.decrement(); continue; } if (newCellWithProps.getProperties().contains(CellData.Property.value) && !newCellWithProps.getProperties().contains(CellData.Property.formula) && newCellWithProps.getCellData().getFormula() != null) { // set formula to null when a value is set EnumSet<CellData.Property> newProps = EnumSet.copyOf(newCellWithProps.getProperties()); newProps.add(CellData.Property.formula); newCellWithProps = new CellDataWithProperties(newCellWithProps.getCellData().withFormula(null), newProps); } if (commandBuilder != null) { commandBuilder.command(CellCommands.properties(new AreaReference(cell.getReference()), cell.getValue(), cell.getStyles(), cell.getFormula(), newCellWithProps.getProperties())); } if (newCellWithProps.getProperties().contains(CellData.Property.formula) && refreshEnabled) { // the formula changed. this needs the formula evaluation before setting the value calculateFormula(result, cell, newCellWithProps.getCellData(), command); continue; } // TODO: the storage may not be able to store one of the cells - should break all for one cell !? saveCells.add(newCellWithProps); result.decrement(); } saveCells(saveCells, command); if (commandBuilder == null || commandBuilder.isEmpty()) { result.set(CellCommands.doNothing(command.getTarget())); } else { result.set(commandBuilder.build()); } return result; }
From source file:org.pentaho.platform.repository2.unified.jcr.JcrRepositoryFileAclDao.java
protected RepositoryFileAcl internalUpdateAcl(final Session session, final PentahoJcrConstants pentahoJcrConstants, final Serializable fileId, final RepositoryFileAcl acl) throws RepositoryException { if (isKioskEnabled()) { throw new RuntimeException( Messages.getInstance().getString("JcrRepositoryFileDao.ERROR_0006_ACCESS_DENIED")); //$NON-NLS-1$ }/*from ww w . java2 s . c o m*/ DefaultPermissionConversionHelper permissionConversionHelper = new DefaultPermissionConversionHelper( session); Node node = session.getNodeByIdentifier(fileId.toString()); if (node == null) { throw new RepositoryException(Messages.getInstance() .getString("JackrabbitRepositoryFileAclDao.ERROR_0001_NODE_NOT_FOUND", fileId.toString())); //$NON-NLS-1$ } String absPath = node.getPath(); AccessControlManager acMgr = session.getAccessControlManager(); AccessControlList acList = getAccessControlList(acMgr, absPath); // clear all entries AccessControlEntry[] acEntries = acList.getAccessControlEntries(); for (int i = 0; i < acEntries.length; i++) { acList.removeAccessControlEntry(acEntries[i]); } JcrRepositoryFileAclUtils.setAclMetadata(session, absPath, acList, new AclMetadata(acl.getOwner().getName(), acl.isEntriesInheriting())); // add entries to now empty list but only if not inheriting; force user to start with clean slate boolean adminPrincipalExist = false; ITenant principalTenant = null; if (!acl.isEntriesInheriting()) { for (RepositoryFileAce ace : acl.getAces()) { Principal principal = null; if (RepositoryFileSid.Type.ROLE == ace.getSid().getType()) { String principalName = JcrTenantUtils.getRoleNameUtils() .getPrincipleName(ace.getSid().getName()); if (tenantAdminAuthorityName.equals(principalName)) { adminPrincipalExist = true; } principal = new SpringSecurityRolePrincipal( JcrTenantUtils.getTenantedRole(ace.getSid().getName())); } else { principal = new SpringSecurityUserPrincipal( JcrTenantUtils.getTenantedUser(ace.getSid().getName())); } acList.addAccessControlEntry(principal, permissionConversionHelper.pentahoPermissionsToPrivileges(session, ace.getPermissions())); } if (!adminPrincipalExist) { if (acl.getAces() != null && acl.getAces().size() > 0) { principalTenant = JcrTenantUtils.getRoleNameUtils() .getTenant(acl.getAces().get(0).getSid().getName()); } if (principalTenant == null || principalTenant.getId() == null) { principalTenant = JcrTenantUtils.getTenant(); } List<RepositoryFilePermission> permissionList = new ArrayList<RepositoryFilePermission>(); permissionList.add(RepositoryFilePermission.ALL); Principal adminPrincipal = new SpringSecurityRolePrincipal(JcrTenantUtils.getRoleNameUtils() .getPrincipleId(principalTenant, tenantAdminAuthorityName)); acList.addAccessControlEntry(adminPrincipal, permissionConversionHelper .pentahoPermissionsToPrivileges(session, EnumSet.copyOf(permissionList))); } } acMgr.setPolicy(absPath, acList); session.save(); return getAcl(fileId); }
From source file:ru.codeinside.adm.AdminServiceImpl.java
@Override public UserItem getUserItem(String login) { final Employee employee = em.find(Employee.class, login); final UserItem userItem = new UserItem(); userItem.setFio(employee.getFio());//from w ww . j av a2 s .c om userItem.setRoles( employee.getRoles().isEmpty() ? EnumSet.noneOf(Role.class) : EnumSet.copyOf(employee.getRoles())); final Set<String> current = new TreeSet<String>(); for (Group group : employee.getGroups()) { current.add(group.getName()); } userItem.setGroups(current); final Set<String> employeeGroups = new TreeSet<String>(); for (Group group : employee.getEmployeeGroups()) { employeeGroups.add(group.getName()); } userItem.setEmployeeGroups(employeeGroups); final Set<String> organizationGroups = new TreeSet<String>(); for (Group group : employee.getOrganizationGroups()) { organizationGroups.add(group.getName()); } userItem.setOrganizationGroups(organizationGroups); userItem.setAllSocialGroups(selectGroupNamesBySocial(true)); userItem.setLocked(employee.isLocked()); if (employee.getCertificate() != null) { userItem.setX509(employee.getCertificate().getX509()); } return userItem; }
From source file:com.quinsoft.zeidon.standardoe.ViewImpl.java
private EnumSet<WriteOiFlags> convertFlags(WriteOiFlags... flags) { return EnumSet.copyOf(Arrays.asList(flags)); }
From source file:org.ops4j.pax.web.service.tomcat.internal.TomcatServerWrapper.java
private EnumSet<DispatcherType> getDispatcherTypes(final FilterModel filterModel) { final ArrayList<DispatcherType> dispatcherTypes = new ArrayList<DispatcherType>( DispatcherType.values().length); for (final String dispatcherType : filterModel.getDispatcher()) { dispatcherTypes.add(DispatcherType.valueOf(dispatcherType.toUpperCase())); }// w ww . j av a 2 s . c o m EnumSet<DispatcherType> result = EnumSet.noneOf(DispatcherType.class); if (dispatcherTypes != null && dispatcherTypes.size() > 0) { result = EnumSet.copyOf(dispatcherTypes); } return result; }
From source file:net.solarnetwork.node.control.demandbalancer.DemandBalancer.java
/** * Set the {@code acEnergyPhaseFilter} property via a comma-delimited * string./*from w ww. j a v a2 s. c om*/ * * @param value * the comma delimited string * @see #getAcEnergyTotalPhaseOnlyPropertiesValue() */ public void getAcEnergyPhaseFilterValue(String value) { Set<String> set = StringUtils.commaDelimitedStringToSet(value); if (set == null) { acEnergyPhaseFilter = null; return; } Set<ACPhase> result = new LinkedHashSet<ACPhase>(set.size()); for (String phase : set) { try { ACPhase p = ACPhase.valueOf(phase); result.add(p); } catch (IllegalArgumentException e) { log.warn("Ignoring unsupported ACPhase value [{}]", phase); } } acEnergyPhaseFilter = EnumSet.copyOf(result); }
From source file:com.erudika.para.rest.Api1.java
@SuppressWarnings("unchecked") protected final Inflector<ContainerRequestContext, Response> grantPermitHandler(final App a) { return new Inflector<ContainerRequestContext, Response>() { public Response apply(ContainerRequestContext ctx) { App app = (a != null) ? a : RestUtils.getPrincipalApp(); String subjectid = pathParam("subjectid", ctx); String resourceName = pathParam(Config._TYPE, ctx); if (app != null) { Response resp = RestUtils.getEntity(ctx.getEntityStream(), List.class); if (resp.getStatusInfo() == Response.Status.OK) { List<String> permission = (List<String>) resp.getEntity(); Set<App.AllowedMethods> set = new HashSet<App.AllowedMethods>(permission.size()); for (String perm : permission) { App.AllowedMethods method = App.AllowedMethods.fromString(perm); if (method != null) { set.add(method); }/* ww w . j a va 2 s . co m*/ } if (!set.isEmpty()) { if (app.grantResourcePermission(subjectid, resourceName, EnumSet.copyOf(set))) { app.update(); } return Response.ok(app.getAllResourcePermissions(subjectid)).build(); } else { return RestUtils.getStatusResponse(Response.Status.BAD_REQUEST, "No allowed methods specified."); } } else { return resp; } } return RestUtils.getStatusResponse(Response.Status.NOT_FOUND, "App not found."); } }; }