List of usage examples for org.apache.wicket.util.string Strings isEmpty
public static boolean isEmpty(final CharSequence string)
string
is considered empty. From source file:org.apache.openmeetings.webservice.UserWebService.java
License:Apache License
@Override @WebMethod/* w w w . j a v a 2 s . c o m*/ @POST @Path("/") public UserDTO add(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "user") @QueryParam("user") UserDTO user, @WebParam(name = "confirm") @QueryParam("confirm") Boolean confirm) throws ServiceException { try { Long authUserId = sessionDao.check(sid); if (AuthLevelUtil.hasWebServiceLevel(userDao.getRights(authUserId))) { User testUser = userDao.getExternalUser(user.getExternalId(), user.getExternalType()); if (testUser != null) { throw new ServiceException("User does already exist!"); } String jName_timeZone = cfgDao.getConfValue("default.timezone", String.class, ""); if (user.getAddress() == null) { user.setAddress(new Address()); user.getAddress().setCountry(Locale.getDefault().getCountry()); } if (user.getLanguageId() == null) { user.setLanguageId(1L); } Long userId = userManagement.registerUser(user.getLogin(), user.getPassword(), user.getLastname(), user.getFirstname(), user.getAddress().getEmail(), new Date(), user.getAddress().getStreet(), user.getAddress().getAdditionalname(), user.getAddress().getFax(), user.getAddress().getZip(), user.getAddress().getCountry(), user.getAddress().getTown(), user.getLanguageId(), "", false, true, // generate SIP Data if the config is enabled jName_timeZone, confirm); if (userId == null || userId < 0) { throw new ServiceException("Unknown error"); } User u = userDao.get(userId); u.getRights().add(Right.Room); if (Strings.isEmpty(user.getExternalId()) && Strings.isEmpty(user.getExternalType())) { // activate the User u.getRights().add(Right.Login); u.getRights().add(Right.Dashboard); } else { u.setType(User.Type.external); u.setExternalId(user.getExternalId()); u.setExternalType(user.getExternalType()); } u = userDao.update(u, authUserId); return new UserDTO(u); } else { throw new ServiceException("Insufficient permissions"); //TODO code -26 } } catch (Exception err) { log.error("addNewUser", err); throw new ServiceException(err.getMessage()); } }
From source file:org.apache.openmeetings.webservice.util.AllowOriginProvider.java
License:Apache License
@Override public void handleMessage(Message outMessage) { final String allowOrigin = getRestAllowOrigin(); if (!Strings.isEmpty(allowOrigin)) { @SuppressWarnings("unchecked") Map<String, List<String>> headers = (Map<String, List<String>>) outMessage .get(Message.PROTOCOL_HEADERS); if (headers == null) { headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); outMessage.put(Message.PROTOCOL_HEADERS, headers); }/* w ww .jav a 2 s. co m*/ headers.put("Access-Control-Allow-Origin", Arrays.asList(allowOrigin)); } }
From source file:org.apache.openmeetings.webservice.util.CalendarParamConverter.java
License:Apache License
public static Calendar get(String val, String tzId) { Calendar c = Strings.isEmpty(tzId) ? Calendar.getInstance() : Calendar.getInstance(TimeZone.getTimeZone(tzId)); c.setTime(DateParamConverter.get(val)); return c;/* w w w .j av a 2 s .c o m*/ }
From source file:org.apache.openmeetings.webservice.util.CalendarParamConverter.java
License:Apache License
@Override public Calendar fromString(String val) { if (Strings.isEmpty(val)) { return null; }//from w ww . j a v a2s . c o m Calendar c = Calendar.getInstance(); c.setTime(DateParamConverter.get(val)); return c; }
From source file:org.apache.openmeetings.webservice.util.DateParamConverter.java
License:Apache License
public static Date get(String val) { if (Strings.isEmpty(val)) { return null; }/* ww w .j a va 2s . c o m*/ for (FastDateFormat df : formats) { try { return df.parse(val); } catch (ParseException e) { // no-op } } throw new IllegalArgumentException("Unparsable format: " + val); }
From source file:org.apache.syncope.client.console.pages.PlainSchemaModalPage.java
License:Apache License
@Override public void setSchemaModalPage(final PageReference pageRef, final ModalWindow window, final PlainSchemaTO schemaTO, final boolean createFlag) { final PlainSchemaTO schema = schemaTO == null ? new PlainSchemaTO() : schemaTO; final Form<PlainSchemaTO> schemaForm = new Form<>(FORM); schemaForm.setModel(new CompoundPropertyModel<>(schema)); schemaForm.setOutputMarkupId(true);/*w ww. j a v a 2 s .com*/ final AjaxTextFieldPanel name = new AjaxTextFieldPanel("key", getString("key"), new PropertyModel<String>(schema, "key")); name.addRequiredLabel(); name.setEnabled(createFlag); schemaForm.add(name); final AjaxDropDownChoicePanel<AttrSchemaType> type = new AjaxDropDownChoicePanel<>("type", getString("type"), new PropertyModel<AttrSchemaType>(schema, "type")); type.setChoices(Arrays.asList(AttrSchemaType.values())); type.addRequiredLabel(); schemaForm.add(type); // -- long, double, date final AjaxTextFieldPanel conversionPattern = new AjaxTextFieldPanel("conversionPattern", getString("conversionPattern"), new PropertyModel<String>(schema, "conversionPattern")); schemaForm.add(conversionPattern); final WebMarkupContainer conversionParams = new WebMarkupContainer("conversionParams"); conversionParams.setOutputMarkupPlaceholderTag(true); conversionParams.add(conversionPattern); schemaForm.add(conversionParams); final WebMarkupContainer typeParams = new WebMarkupContainer("typeParams"); typeParams.setOutputMarkupPlaceholderTag(true); // -- enum final AjaxTextFieldPanel enumerationValuesPanel = new AjaxTextFieldPanel("panel", "enumerationValues", new Model<String>(null)); @SuppressWarnings({ "unchecked", "rawtypes" }) final MultiFieldPanel<String> enumerationValues = new MultiFieldPanel<>("enumerationValues", new Model(), enumerationValuesPanel); enumerationValues.setModelObject(getEnumValuesAsList(schema.getEnumerationValues())); @SuppressWarnings({ "unchecked", "rawtypes" }) final MultiFieldPanel<String> enumerationKeys = new MultiFieldPanel<>("enumerationKeys", new Model(), new AjaxTextFieldPanel("panel", "enumerationKeys", new Model<String>(null))); enumerationKeys.setModelObject(getEnumValuesAsList(schema.getEnumerationKeys())); final WebMarkupContainer enumParams = new WebMarkupContainer("enumParams"); enumParams.setOutputMarkupPlaceholderTag(true); enumParams.add(enumerationValues); enumParams.add(enumerationKeys); typeParams.add(enumParams); // -- encrypted final AjaxTextFieldPanel secretKey = new AjaxTextFieldPanel("secretKey", getString("secretKey"), new PropertyModel<String>(schema, "secretKey")); final AjaxDropDownChoicePanel<CipherAlgorithm> cipherAlgorithm = new AjaxDropDownChoicePanel<>( "cipherAlgorithm", getString("cipherAlgorithm"), new PropertyModel<CipherAlgorithm>(schema, "cipherAlgorithm")); cipherAlgorithm.setChoices(Arrays.asList(CipherAlgorithm.values())); final WebMarkupContainer encryptedParams = new WebMarkupContainer("encryptedParams"); encryptedParams.setOutputMarkupPlaceholderTag(true); encryptedParams.add(secretKey); encryptedParams.add(cipherAlgorithm); typeParams.add(encryptedParams); // -- binary final AjaxTextFieldPanel mimeType = new AjaxTextFieldPanel("mimeType", getString("mimeType"), new PropertyModel<String>(schema, "mimeType")); mimeType.setChoices(mimeTypesInitializer.getMimeTypes()); final WebMarkupContainer binaryParams = new WebMarkupContainer("binaryParams"); binaryParams.setOutputMarkupPlaceholderTag(true); binaryParams.add(mimeType); typeParams.add(binaryParams); schemaForm.add(typeParams); // -- show or hide showHide(schema, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams, mimeType); type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { PlainSchemaModalPage.this.showHide(schema, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams, mimeType); target.add(typeParams); } }); final IModel<List<String>> validatorsList = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<String> load() { return schemaRestClient.getAllValidatorClasses(); } }; final AjaxDropDownChoicePanel<String> validatorClass = new AjaxDropDownChoicePanel<>("validatorClass", getString("validatorClass"), new PropertyModel<String>(schema, "validatorClass")); ((DropDownChoice) validatorClass.getField()).setNullValid(true); validatorClass.setChoices(validatorsList.getObject()); schemaForm.add(validatorClass); final AutoCompleteTextField<String> mandatoryCondition = new AutoCompleteTextField<String>( "mandatoryCondition") { private static final long serialVersionUID = -2428903969518079100L; @Override protected Iterator<String> getChoices(final String input) { List<String> choices = new ArrayList<String>(); if (Strings.isEmpty(input)) { choices = Collections.emptyList(); } else if ("true".startsWith(input.toLowerCase())) { choices.add("true"); } else if ("false".startsWith(input.toLowerCase())) { choices.add("false"); } return choices.iterator(); } }; mandatoryCondition.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); schemaForm.add(mandatoryCondition); final WebMarkupContainer pwdJexlHelp = JexlHelpUtils.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> pwdQuestionMarkJexlHelp = JexlHelpUtils.getAjaxLink(pwdJexlHelp, "questionMarkJexlHelp"); schemaForm.add(pwdQuestionMarkJexlHelp); pwdQuestionMarkJexlHelp.add(pwdJexlHelp); final AjaxCheckBoxPanel multivalue = new AjaxCheckBoxPanel("multivalue", getString("multivalue"), new PropertyModel<Boolean>(schema, "multivalue")); schemaForm.add(multivalue); final AjaxCheckBoxPanel readonly = new AjaxCheckBoxPanel("readonly", getString("readonly"), new PropertyModel<Boolean>(schema, "readonly")); schemaForm.add(readonly); final AjaxCheckBoxPanel uniqueConstraint = new AjaxCheckBoxPanel("uniqueConstraint", getString("uniqueConstraint"), new PropertyModel<Boolean>(schema, "uniqueConstraint")); schemaForm.add(uniqueConstraint); final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final PlainSchemaTO schemaTO = (PlainSchemaTO) form.getDefaultModelObject(); schemaTO.setEnumerationValues(getEnumValuesAsString(enumerationValues.getView().getModelObject())); schemaTO.setEnumerationKeys(getEnumValuesAsString(enumerationKeys.getView().getModelObject())); if (schemaTO.isMultivalue() && schemaTO.isUniqueConstraint()) { error(getString("multivalueAndUniqueConstr.validation")); feedbackPanel.refresh(target); return; } try { if (createFlag) { schemaRestClient.createPlainSchema(kind, schemaTO); } else { schemaRestClient.updatePlainSchema(kind, schemaTO); } if (pageRef.getPage() instanceof BasePage) { ((BasePage) pageRef.getPage()).setModalResult(true); } window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; schemaForm.add(submit); final AjaxButton 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); schemaForm.add(cancel); String allowedRoles = createFlag ? xmlRolesReader.getEntitlement("Schema", "create") : xmlRolesReader.getEntitlement("Schema", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); add(schemaForm); }
From source file:org.apache.syncope.client.console.panels.PlainSchemaDetails.java
License:Apache License
public PlainSchemaDetails(final String id, final PageReference pageReference, final AbstractSchemaTO schemaTO) { super(id, pageReference, schemaTO); final AjaxDropDownChoicePanel<AttrSchemaType> type = new AjaxDropDownChoicePanel<>("type", getString("type"), new PropertyModel<AttrSchemaType>(schemaTO, "type")); type.setChoices(Arrays.asList(AttrSchemaType.values())); type.setEnabled(schemaTO == null || schemaTO.getKey() == null || schemaTO.getKey().isEmpty()); type.addRequiredLabel();/*from w w w . j a va 2 s .c o m*/ schemaForm.add(type); // long, double, date final AjaxTextFieldPanel conversionPattern = new AjaxTextFieldPanel("conversionPattern", getString("conversionPattern"), new PropertyModel<String>(schemaTO, "conversionPattern")); schemaForm.add(conversionPattern); final WebMarkupContainer conversionParams = new WebMarkupContainer("conversionParams"); conversionParams.setOutputMarkupPlaceholderTag(true); conversionParams.add(conversionPattern); schemaForm.add(conversionParams); final WebMarkupContainer typeParams = new WebMarkupContainer("typeParams"); typeParams.setOutputMarkupPlaceholderTag(true); // enum final AjaxTextFieldPanel enumerationValuesPanel = new AjaxTextFieldPanel("panel", "enumerationValues", new Model<String>(null)); enumerationValues = new MultiFieldPanel.Builder<String>( new PropertyModel<List<String>>(schemaTO, "enumerationValues") { private static final long serialVersionUID = -4953564762272833993L; @Override public PropertyList<PlainSchemaTO> getObject() { return new PropertyList<PlainSchemaTO>() { @Override public String getValues() { return PlainSchemaTO.class.cast(schemaTO).getEnumerationValues(); } @Override public void setValues(final List<String> list) { PlainSchemaTO.class.cast(schemaTO) .setEnumerationValues(getEnumValuesAsString(list)); } }; } @Override public void setObject(final List<String> object) { PlainSchemaTO.class.cast(schemaTO) .setEnumerationValues(PropertyList.getEnumValuesAsString(object)); } }) { private static final long serialVersionUID = -8752965211744734798L; @Override protected String newModelObject() { return StringUtils.EMPTY; } }.build("enumerationValues", "enumerationValues", enumerationValuesPanel); enumerationKeys = new MultiFieldPanel.Builder<String>( new PropertyModel<List<String>>(schemaTO, "enumerationKeys") { private static final long serialVersionUID = -4953564762272833993L; @Override public PropertyList<PlainSchemaTO> getObject() { return new PropertyList<PlainSchemaTO>() { @Override public String getValues() { return PlainSchemaTO.class.cast(schemaTO).getEnumerationKeys(); } @Override public void setValues(final List<String> list) { PlainSchemaTO.class.cast(schemaTO) .setEnumerationKeys(PropertyList.getEnumValuesAsString(list)); } }; } @Override public void setObject(final List<String> object) { PlainSchemaTO.class.cast(schemaTO) .setEnumerationKeys(PropertyList.getEnumValuesAsString(object)); } }) { private static final long serialVersionUID = -8752965211744734798L; @Override protected String newModelObject() { return StringUtils.EMPTY; } }.build("enumerationKeys", "enumerationKeys", new AjaxTextFieldPanel("panel", "enumerationKeys", new Model<String>())); final WebMarkupContainer enumParams = new WebMarkupContainer("enumParams"); enumParams.setOutputMarkupPlaceholderTag(true); enumParams.add(enumerationValues); enumParams.add(enumerationKeys); typeParams.add(enumParams); // encrypted final AjaxTextFieldPanel secretKey = new AjaxTextFieldPanel("secretKey", getString("secretKey"), new PropertyModel<String>(schemaTO, "secretKey")); final AjaxDropDownChoicePanel<CipherAlgorithm> cipherAlgorithm = new AjaxDropDownChoicePanel<>( "cipherAlgorithm", getString("cipherAlgorithm"), new PropertyModel<CipherAlgorithm>(schemaTO, "cipherAlgorithm")); cipherAlgorithm.setChoices(Arrays.asList(CipherAlgorithm.values())); final WebMarkupContainer encryptedParams = new WebMarkupContainer("encryptedParams"); encryptedParams.setOutputMarkupPlaceholderTag(true); encryptedParams.add(secretKey); encryptedParams.add(cipherAlgorithm); typeParams.add(encryptedParams); // binary final AjaxTextFieldPanel mimeType = new AjaxTextFieldPanel("mimeType", getString("mimeType"), new PropertyModel<String>(schemaTO, "mimeType")); final WebMarkupContainer binaryParams = new WebMarkupContainer("binaryParams"); binaryParams.setOutputMarkupPlaceholderTag(true); binaryParams.add(mimeType); typeParams.add(binaryParams); schemaForm.add(typeParams); // show or hide showHide(schemaTO, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams, mimeType); type.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { PlainSchemaDetails.this.showHide(schemaTO, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams, mimeType); target.add(conversionParams); target.add(typeParams); } }); IModel<List<String>> validatorsList = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<String> load() { return new ArrayList<>(SyncopeConsoleSession.get().getPlatformInfo().getValidators()); } }; final AjaxDropDownChoicePanel<String> validatorClass = new AjaxDropDownChoicePanel<>("validatorClass", getString("validatorClass"), new PropertyModel<String>(schemaTO, "validatorClass")); ((DropDownChoice) validatorClass.getField()).setNullValid(true); validatorClass.setChoices(validatorsList.getObject()); schemaForm.add(validatorClass); AutoCompleteTextField<String> mandatoryCondition = new AutoCompleteTextField<String>("mandatoryCondition") { private static final long serialVersionUID = -2428903969518079100L; @Override protected Iterator<String> getChoices(final String input) { List<String> choices = new ArrayList<>(); if (Strings.isEmpty(input)) { choices = Collections.emptyList(); } else if ("true".startsWith(input.toLowerCase())) { choices.add("true"); } else if ("false".startsWith(input.toLowerCase())) { choices.add("false"); } return choices.iterator(); } }; mandatoryCondition.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); schemaForm.add(mandatoryCondition); schemaForm.add(Constants.getJEXLPopover(this, TooltipConfig.Placement.right)); schemaForm.add(new AjaxCheckBoxPanel("multivalue", getString("multivalue"), new PropertyModel<Boolean>(schemaTO, "multivalue"))); schemaForm.add(new AjaxCheckBoxPanel("readonly", getString("readonly"), new PropertyModel<Boolean>(schemaTO, "readonly"))); schemaForm.add(new AjaxCheckBoxPanel("uniqueConstraint", getString("uniqueConstraint"), new PropertyModel<Boolean>(schemaTO, "uniqueConstraint"))); }
From source file:org.apache.syncope.client.console.wicket.markup.html.form.SelectableRecorder.java
License:Apache License
private void updateIds(final String value) { if (Strings.isEmpty(value)) { ids = EMPTY_IDS;/*from w w w. ja va 2 s . c o m*/ } else if (value.indexOf('|') == -1) { ids = value.split(","); selectedId = null; } else { String[] splitted = value.split("\\|"); selectedId = splitted[0]; ids = splitted[1].split(","); } }
From source file:org.apache.syncope.console.pages.SchemaModalPage.java
License:Apache License
@Override public void setSchemaModalPage(final PageReference pageRef, final ModalWindow window, final SchemaTO schemaTO, final boolean createFlag) { final SchemaTO schema = schemaTO == null ? new SchemaTO() : schemaTO; final Form<SchemaTO> schemaForm = new Form<SchemaTO>(FORM); schemaForm.setModel(new CompoundPropertyModel<SchemaTO>(schema)); schemaForm.setOutputMarkupId(true);/*w w w. j a v a 2 s.c om*/ final AjaxTextFieldPanel name = new AjaxTextFieldPanel("name", getString("name"), new PropertyModel<String>(schema, "name")); name.addRequiredLabel(); name.setEnabled(createFlag); schemaForm.add(name); final AjaxDropDownChoicePanel<AttributeSchemaType> type = new AjaxDropDownChoicePanel<AttributeSchemaType>( "type", getString("type"), new PropertyModel<AttributeSchemaType>(schema, "type")); type.setChoices(Arrays.asList(AttributeSchemaType.values())); type.addRequiredLabel(); schemaForm.add(type); // -- long, double, date final AjaxTextFieldPanel conversionPattern = new AjaxTextFieldPanel("conversionPattern", getString("conversionPattern"), new PropertyModel<String>(schema, "conversionPattern")); schemaForm.add(conversionPattern); final WebMarkupContainer conversionParams = new WebMarkupContainer("conversionParams"); conversionParams.setOutputMarkupPlaceholderTag(true); conversionParams.add(conversionPattern); schemaForm.add(conversionParams); // -- enum final AjaxTextFieldPanel enumerationValuesPanel = new AjaxTextFieldPanel("panel", "enumerationValues", new Model<String>(null)); @SuppressWarnings({ "unchecked", "rawtypes" }) final MultiFieldPanel<String> enumerationValues = new MultiFieldPanel<String>("enumerationValues", new Model(), enumerationValuesPanel); enumerationValues.setModelObject(getEnumValuesAsList(schema.getEnumerationValues())); @SuppressWarnings({ "unchecked", "rawtypes" }) final MultiFieldPanel<String> enumerationKeys = new MultiFieldPanel<String>("enumerationKeys", new Model(), new AjaxTextFieldPanel("panel", "enumerationKeys", new Model<String>(null))); enumerationKeys.setModelObject(getEnumValuesAsList(schema.getEnumerationKeys())); final WebMarkupContainer enumParams = new WebMarkupContainer("enumParams"); enumParams.setOutputMarkupPlaceholderTag(true); enumParams.add(enumerationValues); enumParams.add(enumerationKeys); schemaForm.add(enumParams); // -- encrypted final AjaxTextFieldPanel secretKey = new AjaxTextFieldPanel("secretKey", getString("secretKey"), new PropertyModel<String>(schema, "secretKey")); final AjaxDropDownChoicePanel<CipherAlgorithm> cipherAlgorithm = new AjaxDropDownChoicePanel<CipherAlgorithm>( "cipherAlgorithm", getString("cipherAlgorithm"), new PropertyModel<CipherAlgorithm>(schema, "cipherAlgorithm")); cipherAlgorithm.setChoices(Arrays.asList(CipherAlgorithm.values())); final WebMarkupContainer encryptedParams = new WebMarkupContainer("encryptedParams"); encryptedParams.setOutputMarkupPlaceholderTag(true); encryptedParams.add(secretKey); encryptedParams.add(cipherAlgorithm); schemaForm.add(encryptedParams); // -- binary final AjaxTextFieldPanel mimeType = new AjaxTextFieldPanel("mimeType", getString("mimeType"), new PropertyModel<String>(schema, "mimeType")); mimeType.setChoices(mimeTypesInitializer.getMimeTypes()); final WebMarkupContainer binaryParams = new WebMarkupContainer("binaryParams"); binaryParams.setOutputMarkupPlaceholderTag(true); binaryParams.add(mimeType); schemaForm.add(binaryParams); // -- show or hide showHide(schema, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams, mimeType); type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { SchemaModalPage.this.showHide(schema, type, conversionParams, conversionPattern, enumParams, enumerationValuesPanel, enumerationValues, enumerationKeys, encryptedParams, secretKey, cipherAlgorithm, binaryParams, mimeType); target.add(schemaForm); } }); final IModel<List<String>> validatorsList = new LoadableDetachableModel<List<String>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<String> load() { return schemaRestClient.getAllValidatorClasses(); } }; final AjaxDropDownChoicePanel<String> validatorClass = new AjaxDropDownChoicePanel<String>("validatorClass", getString("validatorClass"), new PropertyModel<String>(schema, "validatorClass")); ((DropDownChoice) validatorClass.getField()).setNullValid(true); validatorClass.setChoices(validatorsList.getObject()); schemaForm.add(validatorClass); final AutoCompleteTextField<String> mandatoryCondition = new AutoCompleteTextField<String>( "mandatoryCondition") { private static final long serialVersionUID = -2428903969518079100L; @Override protected Iterator<String> getChoices(final String input) { List<String> choices = new ArrayList<String>(); if (Strings.isEmpty(input)) { choices = Collections.emptyList(); } else if ("true".startsWith(input.toLowerCase())) { choices.add("true"); } else if ("false".startsWith(input.toLowerCase())) { choices.add("false"); } return choices.iterator(); } }; mandatoryCondition.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); schemaForm.add(mandatoryCondition); final WebMarkupContainer pwdJexlHelp = JexlHelpUtil.getJexlHelpWebContainer("jexlHelp"); final AjaxLink<Void> pwdQuestionMarkJexlHelp = JexlHelpUtil.getAjaxLink(pwdJexlHelp, "questionMarkJexlHelp"); schemaForm.add(pwdQuestionMarkJexlHelp); pwdQuestionMarkJexlHelp.add(pwdJexlHelp); final AjaxCheckBoxPanel multivalue = new AjaxCheckBoxPanel("multivalue", getString("multivalue"), new PropertyModel<Boolean>(schema, "multivalue")); schemaForm.add(multivalue); final AjaxCheckBoxPanel readonly = new AjaxCheckBoxPanel("readonly", getString("readonly"), new PropertyModel<Boolean>(schema, "readonly")); schemaForm.add(readonly); final AjaxCheckBoxPanel uniqueConstraint = new AjaxCheckBoxPanel("uniqueConstraint", getString("uniqueConstraint"), new PropertyModel<Boolean>(schema, "uniqueConstraint")); schemaForm.add(uniqueConstraint); final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(SUBMIT)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final SchemaTO schemaTO = (SchemaTO) form.getDefaultModelObject(); schemaTO.setEnumerationValues(getEnumValuesAsString(enumerationValues.getView().getModelObject())); schemaTO.setEnumerationKeys(getEnumValuesAsString(enumerationKeys.getView().getModelObject())); if (schemaTO.isMultivalue() && schemaTO.isUniqueConstraint()) { error(getString("multivalueAndUniqueConstr.validation")); feedbackPanel.refresh(target); return; } try { if (createFlag) { schemaRestClient.createSchema(kind, schemaTO); } else { schemaRestClient.updateSchema(kind, schemaTO); } if (pageRef.getPage() instanceof BasePage) { ((BasePage) pageRef.getPage()).setModalResult(true); } window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; schemaForm.add(submit); final AjaxButton 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); schemaForm.add(cancel); String allowedRoles = createFlag ? xmlRolesReader.getAllAllowedRoles("Schema", "create") : xmlRolesReader.getAllAllowedRoles("Schema", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, allowedRoles); add(schemaForm); }
From source file:org.apache.syncope.console.wicket.markup.html.form.SelectableRecorder.java
License:Apache License
@Override protected void updateIds(final String value) { if (Strings.isEmpty(value)) { ids = EMPTY_IDS;//from www .ja v a2 s . com } else { if (value.indexOf('|') == -1) { ids = value.split(","); selectedId = null; } else { String[] splitted = value.split("\\|"); selectedId = splitted[0]; ids = splitted[1].split(","); } } }