http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/status/StatusUtils.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/status/StatusUtils.java b/console/src/main/java/org/apache/syncope/console/commons/status/StatusUtils.java deleted file mode 100644 index cbb19b4..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/status/StatusUtils.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.commons.status; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import org.apache.syncope.common.mod.StatusMod; -import org.apache.syncope.common.to.AbstractAttributableTO; -import org.apache.syncope.common.to.AbstractSubjectTO; -import org.apache.syncope.common.to.AttributeTO; -import org.apache.syncope.common.to.ConnObjectTO; -import org.apache.syncope.console.commons.ConnIdSpecialAttributeName; -import org.apache.syncope.console.commons.Constants; -import org.apache.syncope.console.pages.panels.ImagePanel; -import org.apache.syncope.console.pages.panels.StatusPanel; -import org.apache.syncope.console.rest.AbstractSubjectRestClient; -import org.apache.wicket.Component; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.behavior.Behavior; -import org.apache.wicket.markup.ComponentTag; -import org.apache.wicket.markup.html.image.Image; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class StatusUtils implements Serializable { - - private static final long serialVersionUID = 7238009174387184309L; - - /** - * Logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(StatusUtils.class); - - public static final String IMG_STATUES = "../statuses/"; - - private final AbstractSubjectRestClient restClient; - - public StatusUtils(final AbstractSubjectRestClient restClient) { - this.restClient = restClient; - } - - public List<ConnObjectWrapper> getConnectorObjects(final AbstractSubjectTO subject) { - final List<ConnObjectWrapper> objects = new ArrayList<ConnObjectWrapper>(); - objects.addAll(getConnectorObjects(subject, subject.getResources())); - return objects; - } - - public List<ConnObjectWrapper> getConnectorObjects( - final Collection<AbstractSubjectTO> subjects, final Collection<String> resources) { - - final List<ConnObjectWrapper> objects = new ArrayList<ConnObjectWrapper>(); - - for (AbstractSubjectTO subject : subjects) { - objects.addAll(getConnectorObjects(subject, resources)); - } - - return objects; - } - - private List<ConnObjectWrapper> getConnectorObjects( - final AbstractSubjectTO subject, final Collection<String> resources) { - - final List<ConnObjectWrapper> objects = new ArrayList<ConnObjectWrapper>(); - - for (String resourceName : resources) { - ConnObjectTO objectTO = null; - try { - objectTO = restClient.getConnectorObject(resourceName, subject.getId()); - } catch (Exception e) { - LOG.warn("ConnObject '{}' not found on resource '{}'", subject.getId(), resourceName); - } - - objects.add(new ConnObjectWrapper(subject, resourceName, objectTO)); - } - - return objects; - } - - public StatusBean getStatusBean( - final AbstractAttributableTO attributable, - final String resourceName, - final ConnObjectTO objectTO, - final boolean isRole) { - final StatusBean statusBean = new StatusBean(attributable, resourceName); - - if (objectTO != null) { - final Boolean enabled = isEnabled(objectTO); - - final Status status = enabled == null - ? (isRole ? Status.ACTIVE : Status.UNDEFINED) - : enabled - ? Status.ACTIVE - : Status.SUSPENDED; - - final String accountLink = getAccountLink(objectTO); - - statusBean.setStatus(status); - statusBean.setAccountLink(accountLink); - } - - return statusBean; - } - - private Boolean isEnabled(final ConnObjectTO objectTO) { - final Map<String, AttributeTO> attributeTOs = objectTO.getAttrMap(); - - final AttributeTO status = attributeTOs.get(ConnIdSpecialAttributeName.ENABLE); - - return status != null && status.getValues() != null && !status.getValues().isEmpty() - ? Boolean.parseBoolean(status.getValues().get(0)) - : null; - } - - private String getAccountLink(final ConnObjectTO objectTO) { - final Map<String, AttributeTO> attributeTOs = objectTO == null - ? Collections.<String, AttributeTO>emptyMap() - : objectTO.getAttrMap(); - - final AttributeTO name = attributeTOs.get(ConnIdSpecialAttributeName.NAME); - - return name != null && name.getValues() != null && !name.getValues().isEmpty() - ? name.getValues().get(0) - : null; - } - - public static StatusMod buildStatusMod(final Collection<StatusBean> statuses) { - return buildStatusMod(statuses, null); - } - - public static StatusMod buildStatusMod(final Collection<StatusBean> statuses, final Boolean enable) { - StatusMod statusMod = new StatusMod(); - statusMod.setOnSyncope(false); - - for (StatusBean status : statuses) { - if (enable == null - || (enable && !status.getStatus().isActive()) || (!enable && status.getStatus().isActive())) { - - if ("syncope".equalsIgnoreCase(status.getResourceName())) { - statusMod.setOnSyncope(true); - } else { - statusMod.getResourceNames().add(status.getResourceName()); - } - - } - } - - return statusMod; - } - - public static void update( - final AbstractAttributableTO attributable, - final StatusPanel statusPanel, - final AjaxRequestTarget target, - final Collection<String> resourcesToAdd, - final Collection<String> resourcesToRemove) { - - if (statusPanel != null) { - Map<String, StatusBean> statusMap = new LinkedHashMap<String, StatusBean>(); - for (StatusBean statusBean : statusPanel.getStatusBeans()) { - statusMap.put(statusBean.getResourceName(), statusBean); - } - - for (String resourceName : resourcesToAdd) { - if (!statusMap.keySet().contains(resourceName)) { - StatusBean statusBean; - if (statusPanel.getInitialStatusBeanMap().containsKey(resourceName)) { - statusBean = statusPanel.getInitialStatusBeanMap().get(resourceName); - } else { - statusBean = new StatusBean(attributable, resourceName); - statusBean.setStatus(Status.NOT_YET_SUBMITTED); - } - - statusMap.put(statusBean.getResourceName(), statusBean); - } - } - - for (String resource : resourcesToRemove) { - statusMap.remove(resource); - } - - statusPanel.updateStatusBeans(new ArrayList<StatusBean>(statusMap.values())); - target.add(statusPanel); - } - } - - public ConnObjectTO getConnObjectTO( - final Long attributableId, final String resourceName, final List<ConnObjectWrapper> objects) { - - for (ConnObjectWrapper object : objects) { - if (attributableId.equals(object.getAttributable().getId()) - && resourceName.equalsIgnoreCase(object.getResourceName())) { - - return object.getConnObjectTO(); - } - } - - return null; - } - - public Image getStatusImage(final String componentId, final Status status) { - final String alt, title, statusName; - - switch (status) { - - case NOT_YET_SUBMITTED: - statusName = Status.UNDEFINED.toString(); - alt = "undefined icon"; - title = "Not yet submitted"; - break; - - case ACTIVE: - statusName = Status.ACTIVE.toString(); - alt = "active icon"; - title = "Enabled"; - break; - - case UNDEFINED: - statusName = Status.UNDEFINED.toString(); - alt = "undefined icon"; - title = "Undefined status"; - break; - - case OBJECT_NOT_FOUND: - statusName = Status.OBJECT_NOT_FOUND.toString(); - alt = "notfound icon"; - title = "Not found"; - break; - - default: - statusName = Status.SUSPENDED.toString(); - alt = "inactive icon"; - title = "Disabled"; - } - - final Image img = new Image(componentId, IMG_STATUES + statusName + Constants.PNG_EXT); - - img.add(new Behavior() { - - private static final long serialVersionUID = 1469628524240283489L; - - @Override - public void onComponentTag(final Component component, final ComponentTag tag) { - tag.put("alt", alt); - tag.put("title", title); - } - }); - - return img; - } - - public ImagePanel getStatusImagePanel(final String componentId, final Status status) { - final String alt, title, statusName; - - switch (status) { - - case NOT_YET_SUBMITTED: - statusName = Status.UNDEFINED.toString(); - alt = "undefined icon"; - title = "Not yet submitted"; - break; - - case ACTIVE: - statusName = Status.ACTIVE.toString(); - alt = "active icon"; - title = "Enabled"; - break; - - case UNDEFINED: - statusName = Status.UNDEFINED.toString(); - alt = "undefined icon"; - title = "Undefined status"; - break; - - case OBJECT_NOT_FOUND: - statusName = Status.OBJECT_NOT_FOUND.toString(); - alt = "notfound icon"; - title = "Not found"; - break; - - default: - statusName = Status.SUSPENDED.toString(); - alt = "inactive icon"; - title = "Disabled"; - } - - final ImagePanel imagePanel = new ImagePanel(componentId, IMG_STATUES + statusName + Constants.PNG_EXT); - imagePanel.add(new Behavior() { - - private static final long serialVersionUID = 1469628524240283489L; - - @Override - public void onComponentTag(final Component component, final ComponentTag tag) { - tag.put("alt", alt); - tag.put("title", title); - } - }); - - return imagePanel; - } -}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/init/MIMETypesInitializer.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/init/MIMETypesInitializer.java b/console/src/main/java/org/apache/syncope/console/init/MIMETypesInitializer.java deleted file mode 100644 index ef5516e..0000000 --- a/console/src/main/java/org/apache/syncope/console/init/MIMETypesInitializer.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.init; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.apache.commons.lang3.StringUtils; -import org.apache.wicket.util.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component -public class MIMETypesInitializer { - - /** - * Logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(MIMETypesInitializer.class); - - private List<String> mimeTypes; - - public void load() { - final Set<String> mediaTypes = new HashSet<String>(); - this.mimeTypes = new ArrayList<String>(); - try { - final String mimeTypesFile = IOUtils.toString(this.getClass().getResourceAsStream("/MIMETypes")); - for (String fileRow : mimeTypesFile.split("\n")) { - if (StringUtils.isNotBlank(fileRow) && !fileRow.startsWith("#")) { - mediaTypes.add(fileRow); - } - } - this.mimeTypes.addAll(mediaTypes); - Collections.sort(this.mimeTypes); - } catch (Exception e) { - LOG.error("Error reading file MIMETypes from resources", e); - } - } - - public List<String> getMimeTypes() { - LOG.debug("Returning loaded MIME types list"); - return mimeTypes; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/init/PreviewPanelClassInitializer.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/init/PreviewPanelClassInitializer.java b/console/src/main/java/org/apache/syncope/console/init/PreviewPanelClassInitializer.java deleted file mode 100644 index 5175454..0000000 --- a/console/src/main/java/org/apache/syncope/console/init/PreviewPanelClassInitializer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.init; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.apache.syncope.console.preview.BinaryPreview; -import org.apache.syncope.console.preview.PreviewerClassScanner; -import org.apache.syncope.console.wicket.markup.html.form.preview.AbstractBinaryPreviewer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class PreviewPanelClassInitializer { - - /** - * Logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(PreviewPanelClassInitializer.class); - - @Autowired - private PreviewerClassScanner classScanner; - - private List<Class<? extends AbstractBinaryPreviewer>> classes; - - public void load() { - classes = new ArrayList<Class<? extends AbstractBinaryPreviewer>>(); - for (Class<? extends AbstractBinaryPreviewer> candidate : classScanner.getComponentClasses()) { - classes.add(candidate); - } - } - - public List<Class<? extends AbstractBinaryPreviewer>> getClasses() { - LOG.debug("Returning loaded classes: {}", classes); - return classes; - } - - public Class<? extends AbstractBinaryPreviewer> getClass(final String mimeType) { - LOG.debug("Searching for previewer class for MIME type: {}", mimeType); - Class<? extends AbstractBinaryPreviewer> previewer = null; - for (Class<? extends AbstractBinaryPreviewer> candidate : classes) { - LOG.debug("Evaluating previewer class {} for MIME type {}", candidate.getName(), mimeType); - if (Arrays.asList(candidate.getAnnotation(BinaryPreview.class).mimeTypes()).contains(mimeType)) { - LOG.debug("Found existing previewer for MIME type {}: {}", mimeType, candidate.getName()); - previewer = candidate; - } - } - return previewer; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/init/SpringContextInitializer.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/init/SpringContextInitializer.java b/console/src/main/java/org/apache/syncope/console/init/SpringContextInitializer.java deleted file mode 100644 index dc2515c..0000000 --- a/console/src/main/java/org/apache/syncope/console/init/SpringContextInitializer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.init; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Configurable; -import org.springframework.stereotype.Component; - -/** - * Take care of all initializations needed by Syncope Console to run up and safe. - */ -@Component -@Configurable -public class SpringContextInitializer implements InitializingBean { - - @Autowired - private PreviewPanelClassInitializer previewPanelClassInitializer; - - @Autowired - private MIMETypesInitializer mimeTypesInitializer; - - @Override - public void afterPropertiesSet() { - previewPanelClassInitializer.load(); - mimeTypesInitializer.load(); - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/markup/html/CrontabContainer.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/markup/html/CrontabContainer.java b/console/src/main/java/org/apache/syncope/console/markup/html/CrontabContainer.java deleted file mode 100644 index b5c50b0..0000000 --- a/console/src/main/java/org/apache/syncope/console/markup/html/CrontabContainer.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.markup.html; - -import java.util.Arrays; -import org.apache.syncope.console.commons.Constants; -import org.apache.syncope.console.commons.SelectChoiceRenderer; -import org.apache.syncope.console.commons.SelectOption; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.form.FormComponent; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; - -public class CrontabContainer extends WebMarkupContainer { - - private static final long serialVersionUID = 7879593326085337650L; - - private final TextField seconds; - - private final TextField minutes; - - private final TextField hours; - - private final TextField daysOfMonth; - - private final TextField months; - - private final TextField daysOfWeek; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - public CrontabContainer(final String id, final PropertyModel<String> cronExpressionModel, - final String cronExpression) { - - super(id); - setOutputMarkupId(true); - - final SelectOption[] CRON_TEMPLATES = { - new SelectOption(getString("selOpt1"), "UNSCHEDULE"), - new SelectOption(getString("selOpt2"), "0 0/5 * * * ?"), - new SelectOption(getString("selOpt3"), "0 0 12 * * ?"), - new SelectOption(getString("selOpt4"), "0 0 0 1 * ?"), - new SelectOption(getString("selOpt5"), "0 0 0 L * ?"), - new SelectOption(getString("selOpt6"), "0 0 0 ? * 2") - }; - - final DropDownChoice<SelectOption> cronTemplateChooser = - new DropDownChoice<SelectOption>("cronTemplateChooser") { - - private static final long serialVersionUID = -5843424545478691442L; - - @Override - protected CharSequence getDefaultChoice(final String selected) { - return "<option value=\"\">" + getString("chooseForTemplate") + "</option>"; - } - }; - - cronTemplateChooser.setModel(new IModel<SelectOption>() { - - private static final long serialVersionUID = 6762568283146531315L; - - @Override - public SelectOption getObject() { - SelectOption result = null; - for (SelectOption so : CRON_TEMPLATES) { - if (so.getKeyValue().equals(cronExpressionModel.getObject())) { - - result = so; - } - } - - return result; - } - - @Override - public void setObject(final SelectOption object) { - cronExpressionModel.setObject(object == null || object.equals(CRON_TEMPLATES[0]) - ? null - : object.toString()); - } - - @Override - public void detach() { - // no detach - } - }); - cronTemplateChooser.setChoices(Arrays.asList(CRON_TEMPLATES)); - cronTemplateChooser.setChoiceRenderer(new SelectChoiceRenderer()); - add(cronTemplateChooser); - - seconds = new TextField("seconds", new Model(getCronField(cronExpression, 0))); - add(seconds); - - minutes = new TextField("minutes", new Model(getCronField(cronExpression, 1))); - add(minutes); - - hours = new TextField("hours", new Model(getCronField(cronExpression, 2))); - add(hours); - - daysOfMonth = new TextField("daysOfMonth", new Model(getCronField(cronExpression, 3))); - add(daysOfMonth); - - months = new TextField("months", new Model(getCronField(cronExpression, 4))); - add(months); - - daysOfWeek = new TextField("daysOfWeek", new Model(getCronField(cronExpression, 5))); - add(daysOfWeek); - - cronTemplateChooser.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - seconds.setModelObject(getCronField(cronTemplateChooser, 0)); - minutes.setModelObject(getCronField(cronTemplateChooser, 1)); - hours.setModelObject(getCronField(cronTemplateChooser, 2)); - daysOfMonth.setModelObject(getCronField(cronTemplateChooser, 3)); - months.setModelObject(getCronField(cronTemplateChooser, 4)); - daysOfWeek.setModelObject(getCronField(cronTemplateChooser, 5)); - target.add(CrontabContainer.this); - } - }); - } - - private String getCronField(final FormComponent formComponent, final int field) { - String cronField = null; - - if (formComponent != null) { - cronField = getCronField(formComponent.getInput(), field); - } - - return cronField; - } - - private String getCronField(final String cron, final int field) { - String cronField = null; - - if (cron != null && !cron.isEmpty() && !"UNSCHEDULE".equals(cron)) { - cronField = cron.split(" ")[field].trim(); - } - - return cronField; - } - - public String getCronExpression() { - String cronExpression = null; - - if (seconds != null && seconds.getInput() != null && minutes != null && minutes.getInput() != null - && hours != null && hours.getInput() != null && daysOfMonth != null && daysOfMonth.getInput() != null - && months != null && months.getInput() != null && daysOfWeek != null && daysOfWeek.getInput() != null) { - - cronExpression = new StringBuilder(). - append(seconds.getInput().trim()).append(" "). - append(minutes.getInput().trim()).append(" "). - append(hours.getInput().trim()).append(" "). - append(daysOfMonth.getInput().trim()).append(" "). - append(months.getInput().trim()).append(" "). - append(daysOfWeek.getInput().trim()).toString(); - } - - return cronExpression; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/markup/html/list/AltListView.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/markup/html/list/AltListView.java b/console/src/main/java/org/apache/syncope/console/markup/html/list/AltListView.java deleted file mode 100644 index cab7a97..0000000 --- a/console/src/main/java/org/apache/syncope/console/markup/html/list/AltListView.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.markup.html.list; - -import java.util.List; -import org.apache.wicket.markup.ComponentTag; -import org.apache.wicket.markup.html.list.ListItem; -import org.apache.wicket.markup.html.list.ListView; -import org.apache.wicket.model.IModel; - -public abstract class AltListView<T> extends ListView<T> { - - private static final long serialVersionUID = 251378224847354710L; - - public AltListView(final String id) { - super(id); - } - - public AltListView(final String id, final IModel<? extends List<? extends T>> model) { - super(id, model); - } - - public AltListView(final String id, final List<? extends T> list) { - super(id, list); - } - - @Override - protected ListItem<T> newItem(final int index, final IModel<T> itemModel) { - return new ListItem<T>(index, itemModel) { - - private static final long serialVersionUID = 5473483270932376694L; - - @Override - protected void onComponentTag(final ComponentTag tag) { - if (index % 2 == 0) { - tag.append("class", "alt", " "); - } - - super.onComponentTag(tag); - } - }; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/markup/html/list/ConnConfPropertyListView.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/markup/html/list/ConnConfPropertyListView.java b/console/src/main/java/org/apache/syncope/console/markup/html/list/ConnConfPropertyListView.java deleted file mode 100644 index 9597951..0000000 --- a/console/src/main/java/org/apache/syncope/console/markup/html/list/ConnConfPropertyListView.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.markup.html.list; - -import java.io.Serializable; -import java.util.List; -import java.util.Set; -import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.types.ConnConfProperty; -import org.apache.syncope.console.commons.Constants; -import org.apache.syncope.console.wicket.markup.html.form.AjaxCheckBoxPanel; -import org.apache.syncope.console.wicket.markup.html.form.AjaxPasswordFieldPanel; -import org.apache.syncope.console.wicket.markup.html.form.AjaxTextFieldPanel; -import org.apache.syncope.console.wicket.markup.html.form.FieldPanel; -import org.apache.syncope.console.wicket.markup.html.form.MultiFieldPanel; -import org.apache.syncope.console.wicket.markup.html.form.SpinnerFieldPanel; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.PasswordTextField; -import org.apache.wicket.markup.html.list.ListItem; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.util.ClassUtils; - -public class ConnConfPropertyListView extends AltListView<ConnConfProperty> { - - private static final long serialVersionUID = -5239334900329150316L; - - private static final Logger LOG = LoggerFactory.getLogger(ConnConfPropertyListView.class); - - private final boolean withOverridable; - - private final Set<ConnConfProperty> configuration; - - public ConnConfPropertyListView(final String id, final IModel<? extends List<? extends ConnConfProperty>> model, - final boolean withOverridable, final Set<ConnConfProperty> configuration) { - - super(id, model); - this.configuration = configuration; - this.withOverridable = withOverridable; - } - - @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); - - FieldPanel<? extends Serializable> 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)) { - @SuppressWarnings("unchecked") - final Class<Number> numberClass = (Class<Number>) propertySchemaClass; - field = new SpinnerFieldPanel<Number>("panel", - label.getDefaultModelObjectAsString(), numberClass, 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); - } - - final MultiFieldPanel multiFieldPanel = new MultiFieldPanel("panel", - new PropertyModel<List<String>>(property, "values"), field); - item.add(multiFieldPanel); - } else { - setNewFieldModel(field, property.getValues()); - item.add(field); - } - - if (withOverridable) { - item.add(new AjaxCheckBoxPanel("connPropAttrOverridable", - "connPropAttrOverridable", new PropertyModel<Boolean>(property, "overridable"))); - } - - configuration.add(property); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private void setNewFieldModel(final FieldPanel field, final List<Object> values) { - field.setNewModel(values); - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/pages/AbstractBasePage.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/pages/AbstractBasePage.java b/console/src/main/java/org/apache/syncope/console/pages/AbstractBasePage.java deleted file mode 100644 index d57b1b0..0000000 --- a/console/src/main/java/org/apache/syncope/console/pages/AbstractBasePage.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.pages; - -import org.apache.syncope.console.commons.Constants; -import org.apache.syncope.console.commons.XMLRolesReader; -import org.apache.syncope.console.init.MIMETypesInitializer; -import org.apache.syncope.console.pages.panels.NotificationPanel; -import org.apache.syncope.console.rest.ConfigurationRestClient; -import org.apache.syncope.console.rest.ReportRestClient; -import org.apache.syncope.console.rest.ResourceRestClient; -import org.apache.syncope.console.rest.RoleRestClient; -import org.apache.syncope.console.rest.SchemaRestClient; -import org.apache.syncope.console.rest.TaskRestClient; -import org.apache.syncope.console.rest.UserRestClient; -import org.apache.syncope.console.rest.UserSelfRestClient; -import org.apache.syncope.markup.head.MetaHeaderItem; -import org.apache.wicket.markup.head.HeaderItem; -import org.apache.wicket.markup.head.IHeaderResponse; -import org.apache.wicket.markup.head.PriorityHeaderItem; -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.wicket.spring.injection.annot.SpringBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AbstractBasePage extends WebPage { - - private static final long serialVersionUID = 8611724965544132636L; - - /** - * Logger. - */ - protected static final Logger LOG = LoggerFactory.getLogger(AbstractBasePage.class); - - protected static final String TASKS = "Tasks"; - - protected static final String FORM = "form"; - - protected static final String CANCEL = "cancel"; - - protected static final String SUBMIT = "submit"; - - protected static final String APPLY = "apply"; - - protected static final String NAME = "name"; - - protected final HeaderItem meta = new MetaHeaderItem("X-UA-Compatible", "IE=edge"); - - @SpringBean - protected XMLRolesReader xmlRolesReader; - - @SpringBean - protected UserRestClient userRestClient; - - @SpringBean - protected UserSelfRestClient userSelfRestClient; - - @SpringBean - protected RoleRestClient roleRestClient; - - @SpringBean - protected TaskRestClient taskRestClient; - - @SpringBean - protected SchemaRestClient schemaRestClient; - - @SpringBean - protected ResourceRestClient resourceRestClient; - - @SpringBean - protected ReportRestClient reportRestClient; - - @SpringBean - protected ConfigurationRestClient confRestClient; - - @SpringBean - protected MIMETypesInitializer mimeTypesInitializer; - - protected NotificationPanel feedbackPanel; - - /** - * Response flag set by the Modal Window after the operation is completed. - */ - protected boolean modalResult = false; - - public AbstractBasePage() { - this(null); - } - - public AbstractBasePage(final PageParameters parameters) { - super(parameters); - - feedbackPanel = new NotificationPanel(Constants.FEEDBACK); - feedbackPanel.setOutputMarkupId(true); - add(feedbackPanel); - } - - public NotificationPanel getFeedbackPanel() { - return feedbackPanel; - } - - public boolean isModalResult() { - return modalResult; - } - - public void setModalResult(final boolean operationResult) { - this.modalResult = operationResult; - } - - @Override - public void renderHead(final IHeaderResponse response) { - super.renderHead(response); - response.render(new PriorityHeaderItem(meta)); - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/pages/AbstractSchedTaskModalPage.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/pages/AbstractSchedTaskModalPage.java b/console/src/main/java/org/apache/syncope/console/pages/AbstractSchedTaskModalPage.java deleted file mode 100644 index 490e62f..0000000 --- a/console/src/main/java/org/apache/syncope/console/pages/AbstractSchedTaskModalPage.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.pages; - -import org.apache.syncope.common.to.SchedTaskTO; -import org.apache.syncope.common.SyncopeClientException; -import org.apache.syncope.console.commons.Constants; -import org.apache.syncope.console.commons.DateFormatROModel; -import org.apache.syncope.console.markup.html.CrontabContainer; -import org.apache.syncope.console.wicket.markup.html.form.AjaxTextFieldPanel; -import org.apache.wicket.PageReference; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.form.AjaxButton; -import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; -import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.model.ResourceModel; -import org.springframework.util.StringUtils; - -/** - * Modal window with Task form (to stop and start execution). - */ -public abstract class AbstractSchedTaskModalPage extends TaskModalPage { - - private static final long serialVersionUID = 2892005971093059242L; - - protected CrontabContainer crontab; - - public AbstractSchedTaskModalPage(final ModalWindow window, final SchedTaskTO taskTO, - final PageReference pageRef) { - - super(taskTO); - - crontab = new CrontabContainer("crontab", new PropertyModel<String>(taskTO, "cronExpression"), - taskTO.getCronExpression()); - form.add(crontab); - - final AjaxTextFieldPanel name = - new AjaxTextFieldPanel("name", "name", new PropertyModel<String>(taskTO, "name")); - name.setEnabled(true); - profile.add(name); - - final AjaxTextFieldPanel description = new AjaxTextFieldPanel("description", "description", - new PropertyModel<String>(taskTO, "description")); - description.setEnabled(true); - profile.add(description); - - final AjaxTextFieldPanel lastExec = new AjaxTextFieldPanel("lastExec", getString("lastExec"), - new DateFormatROModel(new PropertyModel<String>(taskTO, "lastExec"))); - lastExec.setEnabled(false); - profile.add(lastExec); - - final AjaxTextFieldPanel nextExec = new AjaxTextFieldPanel("nextExec", getString("nextExec"), - new DateFormatROModel(new PropertyModel<String>(taskTO, "nextExec"))); - nextExec.setEnabled(false); - profile.add(nextExec); - - final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(APPLY)) { - - private static final long serialVersionUID = -958724007591692537L; - - @Override - protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { - SchedTaskTO taskTO = (SchedTaskTO) form.getModelObject(); - taskTO.setCronExpression(StringUtils.hasText(taskTO.getCronExpression()) - ? crontab.getCronExpression() - : null); - - try { - submitAction(taskTO); - - ((BasePage) pageRef.getPage()).setModalResult(true); - - window.close(target); - } catch (SyncopeClientException e) { - LOG.error("While creating or updating task", e); - error(getString(Constants.ERROR) + ": " + e.getMessage()); - feedbackPanel.refresh(target); - } - } - - @Override - protected void onError(final AjaxRequestTarget target, final Form<?> form) { - feedbackPanel.refresh(target); - } - }; - - 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); - - if (taskTO.getId() > 0) { - MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getEntitlement(TASKS, - "update")); - } else { - MetaDataRoleAuthorizationStrategy.authorize(submit, RENDER, xmlRolesReader.getEntitlement(TASKS, - "create")); - } - - form.add(submit); - form.add(cancel); - } - - protected abstract void submitAction(SchedTaskTO taskTO); - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/pages/AbstractSchemaModalPage.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/pages/AbstractSchemaModalPage.java b/console/src/main/java/org/apache/syncope/console/pages/AbstractSchemaModalPage.java deleted file mode 100644 index e84e3f8..0000000 --- a/console/src/main/java/org/apache/syncope/console/pages/AbstractSchemaModalPage.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.pages; - -import org.apache.syncope.common.to.AbstractSchemaTO; -import org.apache.syncope.common.types.AttributableType; -import org.apache.wicket.PageReference; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; - -/** - * Modal window with Schema form. - */ -public abstract class AbstractSchemaModalPage<T extends AbstractSchemaTO> extends BaseModalPage { - - private static final long serialVersionUID = 7369215690388444748L; - - protected AttributableType kind; - - public AbstractSchemaModalPage(final AttributableType kind) { - this.kind = kind; - } - - public abstract void setSchemaModalPage(PageReference callerPageRef, ModalWindow window, T schema, - boolean createFlag); - - public AttributableType getKind() { - return kind; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/pages/AbstractStatusModalPage.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/pages/AbstractStatusModalPage.java b/console/src/main/java/org/apache/syncope/console/pages/AbstractStatusModalPage.java deleted file mode 100644 index fd7ce19..0000000 --- a/console/src/main/java/org/apache/syncope/console/pages/AbstractStatusModalPage.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.pages; - -import org.apache.wicket.markup.html.panel.Fragment; - -public class AbstractStatusModalPage extends BaseModalPage { - - private static final long serialVersionUID = 6633408683036028540L; - - public AbstractStatusModalPage() { - add(new Fragment("pwdMgtFields", "emptyFragment", this)); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/pages/AbstractSyncTaskModalPage.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/pages/AbstractSyncTaskModalPage.java b/console/src/main/java/org/apache/syncope/console/pages/AbstractSyncTaskModalPage.java deleted file mode 100644 index 1ab08e8..0000000 --- a/console/src/main/java/org/apache/syncope/console/pages/AbstractSyncTaskModalPage.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.pages; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.to.AbstractSyncTaskTO; -import org.apache.syncope.common.to.ResourceTO; -import org.apache.syncope.common.types.MatchingRule; -import org.apache.syncope.common.types.UnmatchingRule; -import org.apache.syncope.console.commons.Constants; -import org.apache.syncope.console.commons.SelectChoiceRenderer; -import org.apache.syncope.console.wicket.markup.html.form.AjaxCheckBoxPanel; -import org.apache.syncope.console.wicket.markup.html.form.AjaxDropDownChoicePanel; -import org.apache.wicket.PageReference; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.list.ListItem; -import org.apache.wicket.markup.html.list.ListView; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.LoadableDetachableModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; - -/** - * Abstract Modal window for Sync and Push Task form. - */ -public abstract class AbstractSyncTaskModalPage extends AbstractSchedTaskModalPage { - - private static final long serialVersionUID = 2148403203517274669L; - - protected AjaxDropDownChoicePanel<MatchingRule> matchingRule; - - protected AjaxDropDownChoicePanel<UnmatchingRule> unmatchingRule; - - protected abstract List<String> getSyncActions(); - - final IModel<List<String>> allResources = new LoadableDetachableModel<List<String>>() { - - private static final long serialVersionUID = 5275935387613157437L; - - @Override - protected List<String> load() { - final List<String> resourceNames = new ArrayList<String>(); - - for (ResourceTO resourceTO : resourceRestClient.getAll()) { - resourceNames.add(resourceTO.getName()); - } - - Collections.sort(resourceNames); - return resourceNames; - } - }; - - final IModel<List<String>> syncActionsClasses = new LoadableDetachableModel<List<String>>() { - - private static final long serialVersionUID = 5275935387613157438L; - - @Override - protected List<String> load() { - return getSyncActions(); - } - }; - - public AbstractSyncTaskModalPage( - final ModalWindow window, final AbstractSyncTaskTO taskTO, final PageReference pageRef) { - - super(window, taskTO, pageRef); - - final AjaxDropDownChoicePanel<String> resource = new AjaxDropDownChoicePanel<String>("resource", - getString("resourceName"), new PropertyModel<String>(taskTO, "resource")); - resource.setChoices(allResources.getObject()); - resource.setChoiceRenderer(new SelectChoiceRenderer<String>()); - resource.addRequiredLabel(); - resource.setEnabled(taskTO.getId() == 0); - resource.setStyleSheet("ui-widget-content ui-corner-all long_dynamicsize"); - - profile.add(resource); - - final WebMarkupContainer syncActionsClassNames = new WebMarkupContainer("syncActionsClassNames"); - syncActionsClassNames.setOutputMarkupId(true); - profile.add(syncActionsClassNames); - - final AjaxLink<Void> first = new IndicatingAjaxLink<Void>("first") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - taskTO.getActionsClassNames().add(StringUtils.EMPTY); - setVisible(false); - target.add(syncActionsClassNames); - } - }; - first.setOutputMarkupPlaceholderTag(true); - first.setVisible(taskTO.getActionsClassNames().isEmpty()); - syncActionsClassNames.add(first); - - final ListView<String> actionsClasses = new ListView<String>( - "actionsClasses", new PropertyModel<List<String>>(taskTO, "actionsClassNames")) { - - private static final long serialVersionUID = 9101744072914090143L; - - @Override - protected void populateItem(final ListItem<String> item) { - final String className = item.getModelObject(); - - final DropDownChoice<String> actionsClass = new DropDownChoice<String>( - "actionsClass", new Model<String>(className), syncActionsClasses.getObject()); - actionsClass.setNullValid(true); - actionsClass.setRequired(true); - actionsClass.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { - - private static final long serialVersionUID = -1107858522700306810L; - - @Override - protected void onUpdate(final AjaxRequestTarget target) { - taskTO.getActionsClassNames().set(item.getIndex(), actionsClass.getModelObject()); - target.add(syncActionsClassNames); - } - }); - actionsClass.setRequired(true); - actionsClass.setOutputMarkupId(true); - actionsClass.setRequired(true); - item.add(actionsClass); - - AjaxLink<Void> minus = new IndicatingAjaxLink<Void>("drop") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - taskTO.getActionsClassNames().remove(className); - first.setVisible(taskTO.getActionsClassNames().isEmpty()); - target.add(syncActionsClassNames); - } - }; - item.add(minus); - - final AjaxLink<Void> plus = new IndicatingAjaxLink<Void>("add") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - taskTO.getActionsClassNames().add(StringUtils.EMPTY); - target.add(syncActionsClassNames); - } - }; - plus.setOutputMarkupPlaceholderTag(true); - plus.setVisible(item.getIndex() == taskTO.getActionsClassNames().size() - 1); - item.add(plus); - } - }; - syncActionsClassNames.add(actionsClasses); - - syncActionsClassNames.setEnabled(!syncActionsClasses.getObject().isEmpty()); - - final AjaxCheckBoxPanel creates = new AjaxCheckBoxPanel("performCreate", getString("creates"), - new PropertyModel<Boolean>(taskTO, "performCreate")); - profile.add(creates); - - final AjaxCheckBoxPanel updates = new AjaxCheckBoxPanel("performUpdate", getString("updates"), - new PropertyModel<Boolean>(taskTO, "performUpdate")); - profile.add(updates); - - final AjaxCheckBoxPanel deletes = new AjaxCheckBoxPanel("performDelete", getString("updates"), - new PropertyModel<Boolean>(taskTO, "performDelete")); - profile.add(deletes); - - final AjaxCheckBoxPanel syncStatus = new AjaxCheckBoxPanel("syncStatus", getString("syncStatus"), - new PropertyModel<Boolean>(taskTO, "syncStatus")); - profile.add(syncStatus); - - matchingRule = new AjaxDropDownChoicePanel<MatchingRule>( - "matchingRule", "matchingRule", new PropertyModel<MatchingRule>(taskTO, "matchingRule")); - matchingRule.setChoices(Arrays.asList(MatchingRule.values())); - ((DropDownChoice) matchingRule.getField()).setNullValid(false); - - unmatchingRule = new AjaxDropDownChoicePanel<UnmatchingRule>( - "unmatchingRule", "unmatchingRule", new PropertyModel<UnmatchingRule>(taskTO, "unmatchingRule")); - unmatchingRule.setChoices(Arrays.asList(UnmatchingRule.values())); - ((DropDownChoice) unmatchingRule.getField()).setNullValid(false); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/pages/ActivitiModelerPopupPage.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/pages/ActivitiModelerPopupPage.java b/console/src/main/java/org/apache/syncope/console/pages/ActivitiModelerPopupPage.java deleted file mode 100644 index 1c4f203..0000000 --- a/console/src/main/java/org/apache/syncope/console/pages/ActivitiModelerPopupPage.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.pages; - -import org.apache.wicket.markup.html.WebPage; - -public class ActivitiModelerPopupPage extends WebPage { - - private static final long serialVersionUID = -7031206743629422898L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/pages/ApprovalModalPage.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/pages/ApprovalModalPage.java b/console/src/main/java/org/apache/syncope/console/pages/ApprovalModalPage.java deleted file mode 100644 index 20e57ad..0000000 --- a/console/src/main/java/org/apache/syncope/console/pages/ApprovalModalPage.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.pages; - -import java.io.Serializable; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.math.NumberUtils; -import org.apache.syncope.common.to.WorkflowFormPropertyTO; -import org.apache.syncope.common.to.WorkflowFormTO; -import org.apache.syncope.common.SyncopeClientException; -import org.apache.syncope.console.commons.Constants; -import org.apache.syncope.console.commons.MapChoiceRenderer; -import org.apache.syncope.console.markup.html.list.AltListView; -import org.apache.syncope.console.rest.ApprovalRestClient; -import org.apache.syncope.console.wicket.markup.html.form.AjaxDropDownChoicePanel; -import org.apache.syncope.console.wicket.markup.html.form.AjaxTextFieldPanel; -import org.apache.syncope.console.wicket.markup.html.form.DateTimeFieldPanel; -import org.apache.syncope.console.wicket.markup.html.form.FieldPanel; -import org.apache.syncope.console.wicket.markup.html.form.SpinnerFieldPanel; -import org.apache.wicket.Page; -import org.apache.wicket.PageReference; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.form.AjaxButton; -import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; -import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.list.ListItem; -import org.apache.wicket.markup.html.list.ListView; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.LoadableDetachableModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.ResourceModel; -import org.apache.wicket.spring.injection.annot.SpringBean; - -public class ApprovalModalPage extends BaseModalPage { - - private static final long serialVersionUID = -8847854414429745216L; - - private final static int USER_WIN_HEIGHT = 550; - - private final static int USER_WIN_WIDTH = 800; - - @SpringBean - private ApprovalRestClient restClient; - - private final ModalWindow editUserWin; - - public ApprovalModalPage(final PageReference pageRef, final ModalWindow window, final WorkflowFormTO formTO) { - super(); - - IModel<List<WorkflowFormPropertyTO>> formProps = new LoadableDetachableModel<List<WorkflowFormPropertyTO>>() { - - private static final long serialVersionUID = 3169142472626817508L; - - @Override - protected List<WorkflowFormPropertyTO> load() { - return formTO.getProperties(); - } - }; - - final ListView<WorkflowFormPropertyTO> propView = - new AltListView<WorkflowFormPropertyTO>("propView", formProps) { - - private static final long serialVersionUID = 9101744072914090143L; - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected void populateItem(final ListItem<WorkflowFormPropertyTO> item) { - final WorkflowFormPropertyTO prop = item.getModelObject(); - - Label label = new Label("key", prop.getName() == null - ? prop.getId() - : prop.getName()); - item.add(label); - - FieldPanel field; - switch (prop.getType()) { - case Boolean: - field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(), - new Model<Boolean>(Boolean.valueOf(prop.getValue()))).setChoices(Arrays.asList( - new String[] { "Yes", "No" })); - break; - - case Date: - SimpleDateFormat df = StringUtils.isNotBlank(prop.getDatePattern()) - ? new SimpleDateFormat(prop.getDatePattern()) - : new SimpleDateFormat(); - Date parsedDate = null; - if (StringUtils.isNotBlank(prop.getValue())) { - try { - parsedDate = df.parse(prop.getValue()); - } catch (ParseException e) { - LOG.error("Unparsable date: {}", prop.getValue(), e); - } - } - - field = new DateTimeFieldPanel("value", label.getDefaultModelObjectAsString(), - new Model<Date>(parsedDate), df.toLocalizedPattern()); - break; - - case Enum: - MapChoiceRenderer<String, String> enumCR = - new MapChoiceRenderer<String, String>(prop.getEnumValues()); - - field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(), - new Model(prop.getValue())).setChoiceRenderer(enumCR).setChoices(new Model() { - - private static final long serialVersionUID = -858521070366432018L; - - @Override - public Serializable getObject() { - return new ArrayList<String>(prop.getEnumValues().keySet()); - } - }); - break; - - case Long: - field = new SpinnerFieldPanel<Long>("value", label.getDefaultModelObjectAsString(), - Long.class, new Model<Long>(NumberUtils.toLong(prop.getValue())), - null, null); - break; - - case String: - default: - field = new AjaxTextFieldPanel("value", PARENT_PATH, - new Model<String>(prop.getValue())); - break; - } - - field.setReadOnly(!prop.isWritable()); - if (prop.isRequired()) { - field.addRequiredLabel(); - } - - item.add(field); - } - }; - - final AjaxButton userDetails = new IndicatingAjaxButton("userDetails", - new Model<String>(getString("userDetails"))) { - - private static final long serialVersionUID = -4804368561204623354L; - - @Override - protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { - editUserWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new ViewUserModalPage(ApprovalModalPage.this.getPageReference(), editUserWin, - userRestClient.read(formTO.getUserId())) { - - private static final long serialVersionUID = -2819994749866481607L; - - @Override - protected void closeAction(final AjaxRequestTarget target, final Form form) { - setResponsePage(ApprovalModalPage.this); - } - }; - } - }); - - editUserWin.show(target); - } - }; - MetaDataRoleAuthorizationStrategy.authorize(userDetails, ENABLE, - xmlRolesReader.getEntitlement("Users", "read")); - - 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) { - - Map<String, WorkflowFormPropertyTO> props = formTO.getPropertyMap(); - - for (int i = 0; i < propView.size(); i++) { - @SuppressWarnings("unchecked") - ListItem<WorkflowFormPropertyTO> item = (ListItem<WorkflowFormPropertyTO>) propView.get(i); - String input = ((FieldPanel) item.get("value")).getField().getInput(); - - if (!props.containsKey(item.getModelObject().getId())) { - props.put(item.getModelObject().getId(), new WorkflowFormPropertyTO()); - } - - if (item.getModelObject().isWritable()) { - switch (item.getModelObject().getType()) { - case Boolean: - props.get(item.getModelObject().getId()).setValue(String.valueOf("0".equals(input))); - break; - - case Date: - case Enum: - case String: - case Long: - default: - props.get(item.getModelObject().getId()).setValue(input); - break; - } - } - } - - formTO.setProperties(props.values()); - try { - restClient.submitForm(formTO); - - ((Todo) pageRef.getPage()).setModalResult(true); - window.close(target); - } catch (SyncopeClientException e) { - error(getString(Constants.ERROR) + ": " + e.getMessage()); - LOG.error("While submitting form {}", formTO, e); - feedbackPanel.refresh(target); - } - } - - @Override - protected void onError(final AjaxRequestTarget target, final Form<?> form) { - feedbackPanel.refresh(target); - } - }; - - 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); - } - - @Override - protected void onError(final AjaxRequestTarget target, final Form form) { - // nothing - } - }; - - cancel.setDefaultFormProcessing(false); - - Form form = new Form(FORM); - form.add(propView); - form.add(userDetails); - form.add(submit); - form.add(cancel); - - MetaDataRoleAuthorizationStrategy.authorize(form, ENABLE, xmlRolesReader.getEntitlement("Approval", - SUBMIT)); - - editUserWin = new ModalWindow("editUserWin"); - editUserWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - editUserWin.setInitialHeight(USER_WIN_HEIGHT); - editUserWin.setInitialWidth(USER_WIN_WIDTH); - editUserWin.setCookieName("edit-user-modal"); - add(editUserWin); - - add(form); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/pages/BaseModalPage.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/pages/BaseModalPage.java b/console/src/main/java/org/apache/syncope/console/pages/BaseModalPage.java deleted file mode 100644 index 47d829f..0000000 --- a/console/src/main/java/org/apache/syncope/console/pages/BaseModalPage.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.pages; - -import org.apache.syncope.console.commons.CloseOnESCBehavior; - -/** - * Syncope Modal Window. - */ -public abstract class BaseModalPage extends AbstractBasePage { - - private static final long serialVersionUID = -1443079028368471943L; - - public BaseModalPage() { - super(); - - add(new CloseOnESCBehavior("keyup")); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/pages/BasePage.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/pages/BasePage.java b/console/src/main/java/org/apache/syncope/console/pages/BasePage.java deleted file mode 100644 index 947775a..0000000 --- a/console/src/main/java/org/apache/syncope/console/pages/BasePage.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.pages; - -import org.apache.syncope.console.SyncopeApplication; -import org.apache.syncope.console.commons.Constants; -import org.apache.wicket.Component; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.IAjaxIndicatorAware; -import org.apache.wicket.behavior.Behavior; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.ComponentTag; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.link.BookmarkablePageLink; -import org.apache.wicket.request.mapper.parameter.PageParameters; - -/** - * Syncope Wicket base-page. - */ -public class BasePage extends AbstractBasePage implements IAjaxIndicatorAware { - - private static final long serialVersionUID = 1571997737305598502L; - - public BasePage() { - this(null); - } - - public BasePage(final PageParameters parameters) { - super(parameters); - - pageSetup(); - } - - private void pageSetup() { - ((SyncopeApplication) getApplication()).setupNavigationPanel(this, xmlRolesReader, true); - - final String kind = getClass().getSimpleName().toLowerCase(); - final BookmarkablePageLink kindLink = (BookmarkablePageLink) get(kind); - if (kindLink != null) { - kindLink.add(new Behavior() { - - private static final long serialVersionUID = 1469628524240283489L; - - @Override - public void onComponentTag(final Component component, final ComponentTag tag) { - tag.put("class", kind); - } - }); - - Component kindIcon = kindLink.get(0); - if (kindIcon != null) { - kindIcon.add(new Behavior() { - - private static final long serialVersionUID = 1469628524240283489L; - - @Override - public void onComponentTag(final Component component, final ComponentTag tag) { - tag.put("src", "../.." + SyncopeApplication.IMG_PREFIX + kind + Constants.PNG_EXT); - } - }); - } - } - - ((SyncopeApplication) getApplication()).setupEditProfileModal(this, userSelfRestClient); - } - - @Override - public String getAjaxIndicatorMarkupId() { - return "veil"; - } - - /** - * Set a WindowClosedCallback for a ModalWindow instance. - * - * @param window window - * @param container container - */ - protected void setWindowClosedCallback(final ModalWindow window, final WebMarkupContainer container) { - - window.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { - - private static final long serialVersionUID = 8804221891699487139L; - - @Override - public void onClose(final AjaxRequestTarget target) { - target.add(container); - if (isModalResult()) { - info(getString(Constants.OPERATION_SUCCEEDED)); - feedbackPanel.refresh(target); - setModalResult(false); - } - } - }); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/pages/BasePopupPage.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/pages/BasePopupPage.java b/console/src/main/java/org/apache/syncope/console/pages/BasePopupPage.java deleted file mode 100644 index 837c57d..0000000 --- a/console/src/main/java/org/apache/syncope/console/pages/BasePopupPage.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.console.pages; - -public class BasePopupPage extends AbstractBasePage { - - private static final long serialVersionUID = -2633667311332659505L; - -}
