http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/ActionTableCheckGroup.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/ActionTableCheckGroup.java b/console/src/main/java/org/apache/syncope/console/commons/ActionTableCheckGroup.java deleted file mode 100644 index 54730e3..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/ActionTableCheckGroup.java +++ /dev/null @@ -1,40 +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; - -import java.util.Collection; -import org.apache.wicket.markup.html.form.CheckGroup; -import org.apache.wicket.model.IModel; - -public class ActionTableCheckGroup<T> extends CheckGroup<T> { - - private static final long serialVersionUID = 1288270558573401394L; - - public ActionTableCheckGroup(final String id, final Collection<T> collection) { - super(id, collection); - } - - public ActionTableCheckGroup(final String id, final IModel<Collection<T>> model) { - super(id, model); - } - - public boolean isCheckable(final T element) { - return true; - } -}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/AttrLayoutType.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/AttrLayoutType.java b/console/src/main/java/org/apache/syncope/console/commons/AttrLayoutType.java deleted file mode 100644 index 3e5f9db..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/AttrLayoutType.java +++ /dev/null @@ -1,105 +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; - -import java.util.ArrayList; -import java.util.List; -import org.apache.syncope.common.types.AttributableType; - -public enum AttrLayoutType { - - ADMIN_USER("admin.user.layout", Mode.ADMIN, AttributableType.USER), - SELF_USER("self.user.layout", Mode.SELF, AttributableType.USER), - ADMIN_ROLE("admin.role.layout", Mode.ADMIN, AttributableType.ROLE), - SELF_ROLE("self.role.layout", Mode.SELF, AttributableType.ROLE), - ADMIN_MEMBERSHIP("admin.membership.layout", Mode.ADMIN, AttributableType.MEMBERSHIP), - SELF_MEMBERSHIP("self.membership.layout", Mode.SELF, AttributableType.MEMBERSHIP); - - private final String confKey; - - private final Mode mode; - - private final AttributableType attrType; - - AttrLayoutType(final String confKey, final Mode mode, final AttributableType attrType) { - this.confKey = confKey; - this.mode = mode; - this.attrType = attrType; - } - - public String getConfKey() { - return confKey; - } - - public Mode getMode() { - return mode; - } - - public AttributableType getAttrType() { - return attrType; - } - - public static List<String> confKeys() { - List<String> confKeys = new ArrayList<String>(); - for (AttrLayoutType value : values()) { - confKeys.add(value.getConfKey()); - } - - return confKeys; - } - - public static AttrLayoutType valueOf(final Mode mode, final AttributableType attrType) { - AttrLayoutType result = null; - if (mode == Mode.ADMIN) { - switch (attrType) { - case USER: - result = ADMIN_USER; - break; - - case MEMBERSHIP: - result = ADMIN_MEMBERSHIP; - break; - - case ROLE: - result = ADMIN_ROLE; - break; - - default: - } - } else if (mode == Mode.SELF) { - switch (attrType) { - case USER: - result = SELF_USER; - break; - - case MEMBERSHIP: - result = SELF_MEMBERSHIP; - break; - - case ROLE: - result = SELF_ROLE; - break; - - default: - } - } - - return result; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/AttributableDataProvider.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/AttributableDataProvider.java b/console/src/main/java/org/apache/syncope/console/commons/AttributableDataProvider.java deleted file mode 100644 index 66062d0..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/AttributableDataProvider.java +++ /dev/null @@ -1,105 +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; - -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import org.apache.syncope.common.to.AbstractAttributableTO; -import org.apache.syncope.console.rest.AbstractSubjectRestClient; -import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder; -import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; -import org.apache.wicket.model.CompoundPropertyModel; -import org.apache.wicket.model.IModel; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AttributableDataProvider extends SortableDataProvider<AbstractAttributableTO, String> { - - private static final long serialVersionUID = 6267494272884913376L; - - private static final Logger LOG = LoggerFactory.getLogger(AttributableDataProvider.class); - - private final SortableAttributableProviderComparator comparator; - - private String fiql = null; - - private final int paginatorRows; - - private final boolean filtered; - - private final AbstractSubjectRestClient restClient; - - public AttributableDataProvider(final AbstractSubjectRestClient restClient, - final int paginatorRows, final boolean filtered) { - - super(); - - this.restClient = restClient; - this.filtered = filtered; - this.paginatorRows = paginatorRows; - - // default sorting - setSort("id", SortOrder.ASCENDING); - - this.comparator = new SortableAttributableProviderComparator(this); - } - - public void setFIQL(final String fiql) { - this.fiql = fiql; - } - - @Override - public Iterator<? extends AbstractAttributableTO> iterator(final long first, final long count) { - List<? extends AbstractAttributableTO> result; - - final int page = ((int) first / paginatorRows); - - if (filtered) { - result = fiql == null - ? Collections.<AbstractAttributableTO>emptyList() - : restClient.search(fiql, (page < 0 ? 0 : page) + 1, paginatorRows, getSort()); - } else { - result = restClient.list((page < 0 ? 0 : page) + 1, paginatorRows, getSort()); - } - - Collections.sort(result, comparator); - return result.iterator(); - } - - @Override - public long size() { - long result; - - if (filtered) { - result = fiql == null - ? 0 - : restClient.searchCount(fiql); - } else { - result = restClient.count(); - } - - return result; - } - - @Override - public IModel<AbstractAttributableTO> model(final AbstractAttributableTO object) { - return new CompoundPropertyModel<AbstractAttributableTO>(object); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/CloseOnESCBehavior.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/CloseOnESCBehavior.java b/console/src/main/java/org/apache/syncope/console/commons/CloseOnESCBehavior.java deleted file mode 100644 index 4055408..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/CloseOnESCBehavior.java +++ /dev/null @@ -1,54 +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; - -import org.apache.wicket.Component; -import org.apache.wicket.ajax.AjaxEventBehavior; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.attributes.AjaxCallListener; -import org.apache.wicket.ajax.attributes.AjaxRequestAttributes; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; - -public class CloseOnESCBehavior extends AjaxEventBehavior { - - private static final long serialVersionUID = 5826308247642534260L; - - public CloseOnESCBehavior(String event) { - super(event); - } - - @Override - protected void onEvent(final AjaxRequestTarget target) { - ModalWindow.closeCurrent(target); - } - - @Override - protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { - super.updateAjaxAttributes(attributes); - - attributes.getAjaxCallListeners().add(new AjaxCallListener() { - private static final long serialVersionUID = 7160235486520935153L; - - @Override - public CharSequence getPrecondition(final Component aComponent) { - return " if(Wicket.Event.keyCode(attrs.event) != 27){return false;}"; - } - }); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/ConnIdAttribute.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/ConnIdAttribute.java b/console/src/main/java/org/apache/syncope/console/commons/ConnIdAttribute.java deleted file mode 100644 index d0e275b..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/ConnIdAttribute.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.commons; - -public final class ConnIdAttribute { - - public static final String ENABLE = "__ENABLE__"; - - public static final String NAME = "__NAME__"; - - public static final String UID = "__UID__"; - - public static final String PASSWORD = "__PASSWORD__"; - - private ConnIdAttribute() { - // private constructor for static utility class - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/ConnIdSpecialAttributeName.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/ConnIdSpecialAttributeName.java b/console/src/main/java/org/apache/syncope/console/commons/ConnIdSpecialAttributeName.java deleted file mode 100644 index 4207b2b..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/ConnIdSpecialAttributeName.java +++ /dev/null @@ -1,34 +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; - -public final class ConnIdSpecialAttributeName { - - public static final String ENABLE = "__ENABLE__"; - - public static final String NAME = "__NAME__"; - - public static final String UID = "__UID__"; - - public static final String PASSWORD = "__PASSWORD__"; - - private ConnIdSpecialAttributeName() { - // private constructor for static utility class - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/Constants.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/Constants.java b/console/src/main/java/org/apache/syncope/console/commons/Constants.java deleted file mode 100644 index 92f8d77..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/Constants.java +++ /dev/null @@ -1,110 +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; - -public final class Constants { - - public static final String ON_CLICK = "onclick"; - - public static final String ON_CHANGE = "onchange"; - - public static final String ON_BLUR = "onblur"; - - public static final String PNG_EXT = ".png"; - - public static final String FEEDBACK = "feedback"; - - public static final String OPERATION_SUCCEEDED = "operation_succeeded"; - - public static final String OPERATION_ERROR = "operation_error"; - - public static final String SEARCH_ERROR = "search_error"; - - public static final String ERROR = "error"; - - public static final String PARAM_PASSWORD_RESET_TOKEN = "pwdResetToken"; - - public static final String PREF_USERS_DETAILS_VIEW = "users.details.view"; - - public static final String PREF_USERS_ATTRIBUTES_VIEW = "users.attributes.view"; - - public static final String PREF_USERS_DERIVED_ATTRIBUTES_VIEW = "users.derived.attributes.view"; - - public static final String PREF_USERS_VIRTUAL_ATTRIBUTES_VIEW = "users.virtual.attributes.view"; - - public static final String PREF_CONF_SCHEMA_PAGINATOR_ROWS = "conf.schema.paginator.rows"; - - public static final String PREF_USER_SCHEMA_PAGINATOR_ROWS = "user.schema.paginator.rows"; - - public static final String PREF_USER_DER_SCHEMA_PAGINATOR_ROWS = "user.derived.schema.paginator.rows"; - - public static final String PREF_USER_VIR_SCHEMA_PAGINATOR_ROWS = "user.virtual.schema.paginator.rows"; - - public static final String PREF_ROLE_SCHEMA_PAGINATOR_ROWS = "role.schema.paginator.rows"; - - public static final String PREF_ROLE_DER_SCHEMA_PAGINATOR_ROWS = "role.derived.schema.paginator.rows"; - - public static final String PREF_ROLE_VIR_SCHEMA_PAGINATOR_ROWS = "role.virtual.schema.paginator.rows"; - - public static final String PREF_MEMBERSHIP_SCHEMA_PAGINATOR_ROWS = "membership.schema.paginator.rows"; - - public static final String PREF_MEMBERSHIP_DER_SCHEMA_PAGINATOR_ROWS = "membership.derived.aschema.paginator.rows"; - - public static final String PREF_MEMBERSHIP_VIR_SCHEMA_PAGINATOR_ROWS = "membership.virtual.aschema.paginator.rows"; - - public static final String PREF_USERS_PAGINATOR_ROWS = "users.paginator.rows"; - - public static final String PREF_RESOURCES_PAGINATOR_ROWS = "resources.paginator.rows"; - - public static final String PREF_CONNECTORS_PAGINATOR_ROWS = "connectors.paginator.rows"; - - public static final String PREF_NOTIFICATION_PAGINATOR_ROWS = "notification.paginator.rows"; - - public static final String PREF_PROPAGATION_TASKS_PAGINATOR_ROWS = "proagationtasks.paginator.rows"; - - public static final String PREF_NOTIFICATION_TASKS_PAGINATOR_ROWS = "notificationtasks.paginator.rows"; - - public static final String PREF_SCHED_TASKS_PAGINATOR_ROWS = "schedtasks.paginator.rows"; - - public static final String PREF_SYNC_TASKS_PAGINATOR_ROWS = "synctasks.paginator.rows"; - - public static final String PREF_TODO_PAGINATOR_ROWS = "todo.paginator.rows"; - - public static final String PREF_REPORT_PAGINATOR_ROWS = "report.paginator.rows"; - - public static final String PAGEPARAM_CREATE = "CREATE"; - - public static final String PAGEPARAM_CURRENT_PAGE = "_current_page"; - - public static final String PREF_POLICY_PAGINATOR_ROWS = "policy.paginator.rows"; - - /** - * ConnId's GuardedString is not in the classpath. - */ - public static final String GUARDED_STRING = "org.identityconnectors.common.security.GuardedString"; - - /** - * ConnId's GuardedByteArray is not in the classpath. - */ - public static final String GUARDED_BYTE_ARRAY = "org.identityconnectors.common.security.GuardedByteArray"; - - private Constants() { - // private constructor for static utility class - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/DateFormatROModel.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/DateFormatROModel.java b/console/src/main/java/org/apache/syncope/console/commons/DateFormatROModel.java deleted file mode 100644 index 070e551..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/DateFormatROModel.java +++ /dev/null @@ -1,50 +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; - -import java.util.Date; -import org.apache.syncope.console.SyncopeSession; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.PropertyModel; - -public class DateFormatROModel implements IModel<String> { - - private static final long serialVersionUID = 6677274580927636121L; - - private final PropertyModel model; - - public DateFormatROModel(final PropertyModel model) { - this.model = model; - } - - @Override - public String getObject() { - return model.getObject() == null - ? "" - : SyncopeSession.get().getDateFormat().format((Date) model.getObject()); - } - - @Override - public void setObject(final String object) { - } - - @Override - public void detach() { - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/HttpResourceStream.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/HttpResourceStream.java b/console/src/main/java/org/apache/syncope/console/commons/HttpResourceStream.java deleted file mode 100644 index d2aa9e0..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/HttpResourceStream.java +++ /dev/null @@ -1,101 +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; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.apache.commons.lang3.StringUtils; -import org.apache.wicket.util.lang.Bytes; -import org.apache.wicket.util.resource.AbstractResourceStream; -import org.apache.wicket.util.resource.IFixedLocationResourceStream; -import org.apache.wicket.util.resource.ResourceStreamNotFoundException; - -public class HttpResourceStream extends AbstractResourceStream implements IFixedLocationResourceStream { - - private static final long serialVersionUID = 5811207817876330189L; - - private transient InputStream inputStream; - - private String contentType; - - private String location; - - private String filename; - - public HttpResourceStream(final Response response) { - super(); - - Object entity = response.getEntity(); - if (response.getStatusInfo().getStatusCode() == Response.Status.OK.getStatusCode() - && (entity instanceof InputStream)) { - - this.inputStream = (InputStream) entity; - this.contentType = response.getHeaderString(HttpHeaders.CONTENT_TYPE); - this.location = response.getLocation() == null ? null : response.getLocation().toASCIIString(); - String contentDisposition = response.getHeaderString(HttpHeaders.CONTENT_DISPOSITION); - if (StringUtils.isNotBlank(contentDisposition)) { - String[] splitted = contentDisposition.split("="); - if (splitted != null && splitted.length > 1) { - this.filename = splitted[1].trim(); - } - } - } - } - - @Override - public InputStream getInputStream() - throws ResourceStreamNotFoundException { - - return inputStream == null - ? new ByteArrayInputStream(new byte[0]) - : inputStream; - } - - @Override - public Bytes length() { - return inputStream == null - ? Bytes.bytes(0) - : null; - } - - @Override - public void close() throws IOException { - // No need for explict closing - } - - @Override - public String locationAsString() { - return location; - } - - @Override - public String getContentType() { - return contentType == null - ? MediaType.APPLICATION_OCTET_STREAM - : contentType; - } - - public String getFilename() { - return filename; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/JexlHelpUtil.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/JexlHelpUtil.java b/console/src/main/java/org/apache/syncope/console/commons/JexlHelpUtil.java deleted file mode 100644 index 6dadaee..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/JexlHelpUtil.java +++ /dev/null @@ -1,61 +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; - -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.link.ExternalLink; - -public final class JexlHelpUtil { - - private static final String JEXL_SYNTAX_URL = "http://commons.apache.org/jexl/reference/syntax.html"; - - private JexlHelpUtil() { - // private constructor for static utility class - } - - public static WebMarkupContainer getJexlHelpWebContainer(final String wicketId) { - final WebMarkupContainer jexlHelp = new WebMarkupContainer(wicketId); - jexlHelp.setVisible(false); - jexlHelp.setOutputMarkupPlaceholderTag(true); - jexlHelp.setOutputMarkupId(true); - jexlHelp.add(new ExternalLink("jexlLink", JEXL_SYNTAX_URL)); - return jexlHelp; - } - - public static AjaxLink<Void> getAjaxLink(final WebMarkupContainer wmc, final String wicketId) { - AjaxLink<Void> questionMarkJexlHelp = new AjaxLink<Void>(wicketId) { - - private static final long serialVersionUID = -1838017408000591382L; - - private boolean toogle = false; - - @Override - public void onClick(final AjaxRequestTarget target) { - // using bitwise inversion as suggested by - // http://pmd.sourceforge.net/pmd-4.2.5/rules/controversial.html#BooleanInversion - toogle ^= true; - wmc.setVisible(toogle); - target.add(wmc); - } - }; - return questionMarkJexlHelp; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/MapChoiceRenderer.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/MapChoiceRenderer.java b/console/src/main/java/org/apache/syncope/console/commons/MapChoiceRenderer.java deleted file mode 100644 index c41b916..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/MapChoiceRenderer.java +++ /dev/null @@ -1,43 +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; - -import java.util.Map; -import org.apache.wicket.markup.html.form.IChoiceRenderer; - -public class MapChoiceRenderer<T, K> implements IChoiceRenderer<T> { - - private static final long serialVersionUID = -7452881117778186644L; - - private final Map<T, K> map; - - public MapChoiceRenderer(final Map<T, K> map) { - this.map = map; - } - - @Override - public Object getDisplayValue(final T key) { - return map.get(key); - } - - @Override - public String getIdValue(final T key, final int index) { - return key.toString(); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/Mode.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/Mode.java b/console/src/main/java/org/apache/syncope/console/commons/Mode.java deleted file mode 100644 index 8bb6f4f..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/Mode.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.commons; - -public enum Mode { - - ADMIN, - SELF, - TEMPLATE; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/PreferenceManager.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/PreferenceManager.java b/console/src/main/java/org/apache/syncope/console/commons/PreferenceManager.java deleted file mode 100644 index f9bbaa2..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/PreferenceManager.java +++ /dev/null @@ -1,177 +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; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.core.type.TypeReference; -import java.io.IOException; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import org.apache.commons.lang3.math.NumberUtils; -import org.apache.wicket.request.Request; -import org.apache.wicket.request.Response; -import org.apache.wicket.util.cookies.CookieDefaults; -import org.apache.wicket.util.cookies.CookieUtils; -import org.apache.wicket.util.crypt.Base64; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.util.StringUtils; - -public class PreferenceManager { - - /** - * Logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(PreferenceManager.class); - - private static final String PREFMAN_KEY = "prefMan"; - - private static final int ONE_YEAR_TIME = 60 * 60 * 24 * 365; - - private static final TypeReference<Map<String, String>> MAP_TYPE_REF = new TypeReference<Map<String, String>>() { - }; - - private static final List<Integer> PAGINATOR_CHOICES = Arrays.asList(new Integer[] { 10, 25, 50 }); - - private final ObjectMapper mapper; - - private final CookieUtils cookieUtils; - - public PreferenceManager() { - this.mapper = new ObjectMapper(); - - CookieDefaults cookieDefaults = new CookieDefaults(); - cookieDefaults.setMaxAge(ONE_YEAR_TIME); - this.cookieUtils = new CookieUtils(cookieDefaults); - } - - public List<Integer> getPaginatorChoices() { - return PAGINATOR_CHOICES; - } - - private Map<String, String> getPrefs(final String value) { - Map<String, String> prefs; - try { - if (StringUtils.hasText(value)) { - prefs = mapper.readValue(value, MAP_TYPE_REF); - } else { - throw new Exception("Invalid cookie value '" + value + "'"); - } - } catch (Exception e) { - LOG.debug("No preferences found", e); - prefs = new HashMap<String, String>(); - } - - return prefs; - } - - private String setPrefs(final Map<String, String> prefs) throws IOException { - StringWriter writer = new StringWriter(); - mapper.writeValue(writer, prefs); - - return writer.toString(); - } - - public String get(final Request request, final String key) { - String result = null; - - String prefString = cookieUtils.load(PREFMAN_KEY); - if (prefString != null) { - final Map<String, String> prefs = getPrefs(new String(Base64.decodeBase64(prefString.getBytes()))); - result = prefs.get(key); - } - - return result; - } - - public Integer getPaginatorRows(final Request request, final String key) { - Integer result = getPaginatorChoices().get(0); - - String value = get(request, key); - if (value != null) { - result = NumberUtils.toInt(value, 10); - } - - return result; - } - - public List<String> getList(final Request request, final String key) { - final List<String> result = new ArrayList<String>(); - - final String compound = get(request, key); - - if (StringUtils.hasText(compound)) { - String[] items = compound.split(";"); - result.addAll(Arrays.asList(items)); - } - - return result; - } - - public void set(final Request request, final Response response, final Map<String, List<String>> prefs) { - String prefString = cookieUtils.load(PREFMAN_KEY); - - final Map<String, String> current = new HashMap<String, String>(); - if (prefString != null) { - current.putAll(getPrefs(new String(Base64.decodeBase64(prefString.getBytes())))); - } - - // after retrieved previous setting in order to overwrite the key ... - for (Entry<String, List<String>> entry : prefs.entrySet()) { - current.put(entry.getKey(), StringUtils.collectionToDelimitedString(entry.getValue(), ";")); - } - - try { - cookieUtils.save(PREFMAN_KEY, new String(Base64.encodeBase64(setPrefs(current).getBytes()))); - } catch (IOException e) { - LOG.error("Could not save {} info: {}", getClass().getSimpleName(), current, e); - } - } - - public void set(final Request request, final Response response, final String key, final String value) { - String prefString = cookieUtils.load(PREFMAN_KEY); - - final Map<String, String> current = new HashMap<String, String>(); - if (prefString != null) { - current.putAll(getPrefs(new String(Base64.decodeBase64(prefString.getBytes())))); - } - - // after retrieved previous setting in order to overwrite the key ... - current.put(key, value); - - try { - cookieUtils.save(PREFMAN_KEY, new String(Base64.encodeBase64(setPrefs(current).getBytes()))); - } catch (IOException e) { - LOG.error("Could not save {} info: {}", getClass().getSimpleName(), current, e); - } - } - - public void setList(final Request request, final Response response, final String key, final List<String> values) { - set(request, response, key, StringUtils.collectionToDelimitedString(values, ";")); - } - - public void setList(final Request request, final Response response, final Map<String, List<String>> prefs) { - set(request, response, prefs); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/RoleTreeBuilder.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/RoleTreeBuilder.java b/console/src/main/java/org/apache/syncope/console/commons/RoleTreeBuilder.java deleted file mode 100644 index f827e64..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/RoleTreeBuilder.java +++ /dev/null @@ -1,116 +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; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeModel; -import org.apache.syncope.common.to.RoleTO; -import org.apache.syncope.console.rest.RoleRestClient; -import org.springframework.beans.factory.annotation.Autowired; - -public class RoleTreeBuilder { - - @Autowired - private RoleRestClient restClient; - - private final RoleTOComparator comparator = new RoleTOComparator(); - - private List<RoleTO> allRoles; - - private List<RoleTO> getChildRoles(final long parentRoleId, final List<RoleTO> roles) { - List<RoleTO> result = new ArrayList<RoleTO>(); - for (RoleTO role : roles) { - if (role.getParent() == parentRoleId) { - result.add(role); - } - } - - Collections.sort(result, comparator); - return result; - } - - private void populateSubtree(final DefaultMutableTreeNode subRoot, final List<RoleTO> roles) { - RoleTO role = (RoleTO) subRoot.getUserObject(); - - DefaultMutableTreeNode child; - for (RoleTO subRoleTO : getChildRoles(role.getId(), roles)) { - child = new DefaultMutableTreeNode(subRoleTO); - subRoot.add(child); - populateSubtree(child, roles); - } - } - - public List<RoleTO> getAllRoles() { - return this.allRoles; - } - - public TreeModel build() { - this.allRoles = this.restClient.list(); - return build(this.allRoles); - } - - public TreeModel build(final List<RoleTO> roles) { - DefaultMutableTreeNode fakeroot = new DefaultMutableTreeNode(new FakeRootRoleTO()); - - populateSubtree(fakeroot, roles); - - return new DefaultTreeModel(fakeroot); - } - - private static class RoleTOComparator implements Comparator<RoleTO>, Serializable { - - private static final long serialVersionUID = 7085057398406518811L; - - @Override - public int compare(final RoleTO r1, final RoleTO r2) { - if (r1.getId() < r2.getId()) { - return -1; - } - if (r1.getId() == r2.getId()) { - return 0; - } - - return 1; - } - } - - private static class FakeRootRoleTO extends RoleTO { - - private static final long serialVersionUID = 4839183625773925488L; - - public FakeRootRoleTO() { - super(); - - setId(0); - setName(""); - setParent(-1); - } - - @Override - public String getDisplayName() { - return ""; - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/RoleUtils.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/RoleUtils.java b/console/src/main/java/org/apache/syncope/console/commons/RoleUtils.java deleted file mode 100644 index 8624824..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/RoleUtils.java +++ /dev/null @@ -1,36 +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; - -import org.apache.syncope.common.to.RoleTO; - -public class RoleUtils { - - public static RoleTO findRole(final RoleTreeBuilder roleTreeBuilder, final long roleId) { - RoleTO found = null; - if (roleTreeBuilder.getAllRoles() != null) { - for (RoleTO roleTO : roleTreeBuilder.getAllRoles()) { - if (roleTO.getId() == roleId) { - found = roleTO; - } - } - } - return found; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/SchemaModalPageFactory.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/SchemaModalPageFactory.java b/console/src/main/java/org/apache/syncope/console/commons/SchemaModalPageFactory.java deleted file mode 100644 index 429fd40..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/SchemaModalPageFactory.java +++ /dev/null @@ -1,58 +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; - -import org.apache.syncope.common.types.AttributableType; -import org.apache.syncope.common.types.SchemaType; -import org.apache.syncope.console.pages.AbstractSchemaModalPage; -import org.apache.syncope.console.pages.DerSchemaModalPage; -import org.apache.syncope.console.pages.PlainSchemaModalPage; -import org.apache.syncope.console.pages.VirSchemaModalPage; - -public final class SchemaModalPageFactory { - - private static final long serialVersionUID = -3533177688264693505L; - - private SchemaModalPageFactory() { - // empty constructor for static utility class - } - - @SuppressWarnings("unchecked") - public static <T extends AbstractSchemaModalPage> T getSchemaModalPage( - final AttributableType entity, final SchemaType schemaType) { - - T page; - - switch (schemaType) { - case DERIVED: - page = (T) new DerSchemaModalPage(entity); - break; - - case VIRTUAL: - page = (T) new VirSchemaModalPage(entity); - break; - - default: - page = (T) new PlainSchemaModalPage(entity); - break; - } - - return page; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/SelectChoiceRenderer.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/SelectChoiceRenderer.java b/console/src/main/java/org/apache/syncope/console/commons/SelectChoiceRenderer.java deleted file mode 100644 index 4d26f62..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/SelectChoiceRenderer.java +++ /dev/null @@ -1,40 +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; - -import org.apache.wicket.markup.html.form.IChoiceRenderer; - -public class SelectChoiceRenderer<T> implements IChoiceRenderer<T> { - - private static final long serialVersionUID = -3242441544405909243L; - - @Override - public Object getDisplayValue(T obj) { - if (obj instanceof SelectOption) { - return ((SelectOption) obj).getDisplayValue(); - } else { - return obj.toString(); - } - } - - @Override - public String getIdValue(T obj, int i) { - return obj.toString(); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/SelectOption.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/SelectOption.java b/console/src/main/java/org/apache/syncope/console/commons/SelectOption.java deleted file mode 100644 index 15d03a8..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/SelectOption.java +++ /dev/null @@ -1,72 +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; - -import java.io.Serializable; -import org.apache.commons.lang3.builder.HashCodeBuilder; - -public class SelectOption implements Serializable { - - private static final long serialVersionUID = 2961127533930849828L; - - private String displayValue; - - private String keyValue; - - public SelectOption(final String displayValue, final String keyValue) { - this.displayValue = displayValue; - this.keyValue = keyValue; - } - - public String getDisplayValue() { - return displayValue; - } - - public void setDisplayValue(final String displayValue) { - this.displayValue = displayValue; - } - - public String getKeyValue() { - return keyValue; - } - - public void setKeyValue(final String keyValue) { - this.keyValue = keyValue; - } - - @Override - public boolean equals(final Object obj) { - if (obj == null || !(obj instanceof SelectOption)) { - return false; - } - - return (keyValue == null && ((SelectOption) obj).keyValue == null) || keyValue != null - && keyValue.equals(((SelectOption) obj).keyValue); - } - - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public String toString() { - return keyValue; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/SortableAttributableProviderComparator.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/SortableAttributableProviderComparator.java b/console/src/main/java/org/apache/syncope/console/commons/SortableAttributableProviderComparator.java deleted file mode 100644 index 2d9552e..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/SortableAttributableProviderComparator.java +++ /dev/null @@ -1,123 +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; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.apache.syncope.common.to.AbstractAttributableTO; -import org.apache.syncope.common.to.AttributeTO; -import org.apache.syncope.common.types.SchemaType; -import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; -import org.apache.wicket.model.AbstractReadOnlyModel; - -public class SortableAttributableProviderComparator extends SortableDataProviderComparator<AbstractAttributableTO> { - - private static final long serialVersionUID = 1775967163571699258L; - - private static final Set<String> INLINE_PROPS = new HashSet<String>(Arrays.asList( - new String[]{"id", "status", "token", "username"})); - - public SortableAttributableProviderComparator(final SortableDataProvider<AbstractAttributableTO, String> provider) { - super(provider); - } - - @Override - public int compare(final AbstractAttributableTO attributable1, AbstractAttributableTO attributable2) { - if (INLINE_PROPS.contains(provider.getSort().getProperty())) { - return super.compare(attributable1, attributable2); - } - - return super.compare(new AttrModel(attributable1), new AttrModel(attributable2)); - } - - @SuppressWarnings("rawtypes") - private class AttrModel extends AbstractReadOnlyModel<Comparable> { - - private static final long serialVersionUID = -7856686374020091808L; - - private final Map<String, AttributeTO> attrs; - - private final Map<String, AttributeTO> derAttrs; - - private final Map<String, AttributeTO> virAttrs; - - public AttrModel(final AbstractAttributableTO attributableTO) { - super(); - - this.attrs = attributableTO.getAttrMap(); - this.derAttrs = attributableTO.getDerAttrMap(); - this.virAttrs = attributableTO.getVirAttrMap(); - } - - /** - * @see UserAttrColumn constructor - */ - @Override - public Comparable getObject() { - int hashPos = provider.getSort().getProperty().indexOf('#'); - - SchemaType schemaType = null; - final String schema; - if (hashPos == -1) { - schema = provider.getSort().getProperty(); - } else { - String[] splitted = provider.getSort().getProperty().split("#"); - try { - schemaType = SchemaType.valueOf(splitted[0]); - } catch (IllegalArgumentException e) { - // this should never happen - } - schema = provider.getSort().getProperty().substring(hashPos + 1); - } - - - final AttributeTO attr; - if (schemaType == null) { - attr = this.attrs.get(schema); - } else { - switch (schemaType) { - case NORMAL: - default: - attr = this.attrs.get(schema); - break; - - case DERIVED: - attr = this.derAttrs.get(schema); - break; - - case VIRTUAL: - attr = this.virAttrs.get(schema); - break; - } - } - - Comparable result = null; - - List<String> values = attr == null ? null : attr.getValues(); - if (values != null && !values.isEmpty()) { - result = values.iterator().next(); - } - - return result; - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/SortableDataProviderComparator.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/SortableDataProviderComparator.java b/console/src/main/java/org/apache/syncope/console/commons/SortableDataProviderComparator.java deleted file mode 100644 index b773afb..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/SortableDataProviderComparator.java +++ /dev/null @@ -1,66 +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; - -import java.io.Serializable; -import java.util.Comparator; -import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.PropertyModel; - -public class SortableDataProviderComparator<T extends Object> implements Comparator<T>, Serializable { - - private static final long serialVersionUID = -8897687699977460543L; - - protected final SortableDataProvider<T, String> provider; - - public SortableDataProviderComparator(final SortableDataProvider<T, String> provider) { - this.provider = provider; - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - protected int compare(final IModel<Comparable> model1, final IModel<Comparable> model2) { - int result; - - if (model1.getObject() == null && model2.getObject() == null) { - result = 0; - } else if (model1.getObject() == null) { - result = 1; - } else if (model2.getObject() == null) { - result = -1; - } else { - result = model1.getObject().compareTo(model2.getObject()); - } - - result = provider.getSort().isAscending() - ? result - : -result; - - return result; - } - - @SuppressWarnings("rawtypes") - @Override - public int compare(final T object1, final T object2) { - IModel<Comparable> model1 = new PropertyModel<Comparable>(object1, provider.getSort().getProperty()); - IModel<Comparable> model2 = new PropertyModel<Comparable>(object2, provider.getSort().getProperty()); - - return compare(model1, model2); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/XMLRolesReader.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/XMLRolesReader.java b/console/src/main/java/org/apache/syncope/console/commons/XMLRolesReader.java deleted file mode 100644 index 69cf4ec..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/XMLRolesReader.java +++ /dev/null @@ -1,118 +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; - -import java.util.HashMap; -import java.util.Map; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * XMLRolesReader singleton class. - */ -public class XMLRolesReader { - - /** - * Logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(XMLRolesReader.class); - - private String authorizations; - - private Map<Pair<String, String>, String> authMap; - - public void setAuthorizations(final String authorizations) { - this.authorizations = authorizations; - } - - private void init() { - authMap = new HashMap<Pair<String, String>, String>(); - - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware(true); - try { - DocumentBuilder db = dbf.newDocumentBuilder(); - Document doc = db.parse(getClass().getResource("/" + authorizations).openStream()); - doc.getDocumentElement().normalize(); - - Node authNode = null; - NodeList root = doc.getChildNodes(); - for (int i = 0; i < root.getLength() && authNode == null; i++) { - if ("auth".equals(root.item(i).getNodeName())) { - authNode = root.item(i); - } - } - if (authNode == null) { - throw new IllegalArgumentException("Could not find root <auth> node"); - } - - NodeList pages = authNode.getChildNodes(); - for (int i = 0; i < pages.getLength(); i++) { - if ("page".equals(pages.item(i).getNodeName())) { - String page = pages.item(i).getAttributes().getNamedItem("id").getTextContent(); - - NodeList actions = pages.item(i).getChildNodes(); - for (int j = 0; j < actions.getLength(); j++) { - if ("action".equals(actions.item(j).getNodeName())) { - String action = actions.item(j).getAttributes().getNamedItem("id").getTextContent(); - - NodeList entitlements = actions.item(j).getChildNodes(); - for (int k = 0; k < entitlements.getLength(); k++) { - if ("entitlement".equals(entitlements.item(k).getNodeName())) { - String entitlement = entitlements.item(k).getTextContent(); - authMap.put(new ImmutablePair<String, String>(page, action), entitlement); - } - } - } - } - } - } - } catch (Exception e) { - LOG.error("While initializing parsing of {}", authorizations, e); - } - } - - /** - * Get entitlement required for page / action. - * - * @param pageId page - * @param actionId action - * @return entitlement required - */ - public String getEntitlement(final String pageId, final String actionId) { - synchronized (this) { - if (authMap == null) { - init(); - } - } - - Pair<String, String> key = new ImmutablePair<String, String>(pageId, actionId); - return authMap.containsKey(key) - ? authMap.get(key) - : StringUtils.EMPTY; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/status/AbstractStatusBeanProvider.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/status/AbstractStatusBeanProvider.java b/console/src/main/java/org/apache/syncope/console/commons/status/AbstractStatusBeanProvider.java deleted file mode 100644 index e533dc1..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/status/AbstractStatusBeanProvider.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.commons.status; - -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import org.apache.syncope.console.commons.SortableDataProviderComparator; -import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder; -import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; -import org.apache.wicket.model.AbstractReadOnlyModel; -import org.apache.wicket.model.IModel; - -public abstract class AbstractStatusBeanProvider extends SortableDataProvider<StatusBean, String> { - - private static final long serialVersionUID = 4287357360778016173L; - - private SortableDataProviderComparator<StatusBean> comparator; - - public AbstractStatusBeanProvider(final String sort) { - //Default sorting - setSort(sort, SortOrder.ASCENDING); - comparator = new SortableDataProviderComparator<StatusBean>(this); - } - - @Override - public Iterator<StatusBean> iterator(final long first, final long count) { - List<StatusBean> list = getStatusBeans(); - Collections.sort(list, comparator); - return list.subList((int) first, (int) first + (int) count).iterator(); - } - - @Override - public long size() { - return getStatusBeans().size(); - } - - @Override - public IModel<StatusBean> model(final StatusBean resource) { - return new AbstractReadOnlyModel<StatusBean>() { - - private static final long serialVersionUID = -7802635613997243712L; - - @Override - public StatusBean getObject() { - return resource; - } - }; - } - - public abstract List<StatusBean> getStatusBeans(); - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/status/ConnObjectWrapper.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/status/ConnObjectWrapper.java b/console/src/main/java/org/apache/syncope/console/commons/status/ConnObjectWrapper.java deleted file mode 100644 index 540fd62..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/status/ConnObjectWrapper.java +++ /dev/null @@ -1,55 +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 org.apache.syncope.common.to.AbstractAttributableTO; -import org.apache.syncope.common.to.ConnObjectTO; - -public class ConnObjectWrapper implements Serializable { - - private static final long serialVersionUID = 9083721948999924299L; - - private final AbstractAttributableTO attributable; - - private final String resourceName; - - private final ConnObjectTO connObjectTO; - - public ConnObjectWrapper(final AbstractAttributableTO attributable, final String resourceName, - final ConnObjectTO connObjectTO) { - - this.attributable = attributable; - this.resourceName = resourceName; - this.connObjectTO = connObjectTO; - } - - public AbstractAttributableTO getAttributable() { - return attributable; - } - - public String getResourceName() { - return resourceName; - } - - public ConnObjectTO getConnObjectTO() { - return connObjectTO; - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/status/Status.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/status/Status.java b/console/src/main/java/org/apache/syncope/console/commons/status/Status.java deleted file mode 100644 index 762de4e..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/status/Status.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.commons.status; - -public enum Status { - - NOT_YET_SUBMITTED(""), - CREATED("created"), - ACTIVE("active"), - SUSPENDED("inactive"), - UNDEFINED("undefined"), - OBJECT_NOT_FOUND("objectnotfound"); - - public boolean isActive() { - return this == ACTIVE; - } - - private Status(final String name) { - this.name = name; - } - - private final String name; - - @Override - public String toString() { - return name; - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/console/src/main/java/org/apache/syncope/console/commons/status/StatusBean.java ---------------------------------------------------------------------- diff --git a/console/src/main/java/org/apache/syncope/console/commons/status/StatusBean.java b/console/src/main/java/org/apache/syncope/console/commons/status/StatusBean.java deleted file mode 100644 index fea7480..0000000 --- a/console/src/main/java/org/apache/syncope/console/commons/status/StatusBean.java +++ /dev/null @@ -1,103 +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 org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.ReflectionToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import org.apache.syncope.common.to.AbstractAttributableTO; -import org.apache.syncope.common.to.RoleTO; -import org.apache.syncope.common.to.UserTO; - -public class StatusBean implements Serializable { - - private static final long serialVersionUID = -5207260204921071129L; - - private final Long attributableId; - - private final String attributableName; - - private final String resourceName; - - private String accountLink = null; - - private Status status = Status.OBJECT_NOT_FOUND; - - private boolean linked = true; - - public StatusBean(final AbstractAttributableTO attributable, String resourceName) { - this.attributableId = attributable.getId(); - this.attributableName = attributable instanceof UserTO - ? ((UserTO) attributable).getUsername() : ((RoleTO) attributable).getName(); - this.resourceName = resourceName; - } - - public String getAccountLink() { - return accountLink; - } - - public void setAccountLink(final String accountLink) { - this.accountLink = accountLink; - } - - public String getResourceName() { - return resourceName; - } - - public Status getStatus() { - return status; - } - - public void setStatus(final Status status) { - this.status = status; - } - - public Long getAttributableId() { - return attributableId; - } - - public String getAttributableName() { - return attributableName; - } - - public boolean isLinked() { - return linked; - } - - public void setLinked(boolean linked) { - this.linked = linked; - } - - @Override - public String toString() { - return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); - } - - @Override - public boolean equals(final Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } -}
