http://git-wip-us.apache.org/repos/asf/syncope/blob/4e0783e1/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java ---------------------------------------------------------------------- diff --cc core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java index c4c1928,0000000..13acaab mode 100644,000000..100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/init/LoggerLoader.java @@@ -1,113 -1,0 +1,113 @@@ +/* + * 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.core.logic.init; + +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Map; +import javax.sql.DataSource; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.Appender; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.appender.db.jdbc.ColumnConfig; +import org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource; +import org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender; +import org.apache.logging.log4j.core.config.LoggerConfig; +import org.apache.syncope.core.misc.AuditManager; +import org.apache.syncope.core.misc.security.AuthContextUtils; +import org.apache.syncope.core.persistence.api.DomainsHolder; +import org.apache.syncope.core.persistence.api.SyncopeLoader; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.datasource.DataSourceUtils; +import org.springframework.stereotype.Component; + +@Component +public class LoggerLoader implements SyncopeLoader { + + @Autowired + private DomainsHolder domainsHolder; + + @Autowired + private LoggerAccessor loggerAccessor; + + @Override + public Integer getPriority() { + return 300; + } + + @Override + public void load() { + final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); + + // Audit table and DataSource for each configured domain + ColumnConfig[] columns = { + ColumnConfig.createColumnConfig(ctx.getConfiguration(), "EVENT_DATE", null, null, "true", null, null), + ColumnConfig.createColumnConfig(ctx.getConfiguration(), "LOGGER_LEVEL", "%level", null, null, null, null), + ColumnConfig.createColumnConfig(ctx.getConfiguration(), "LOGGER", "%logger", null, null, null, null), + ColumnConfig.createColumnConfig(ctx.getConfiguration(), "MESSAGE", "%message", null, null, null, null), + ColumnConfig.createColumnConfig(ctx.getConfiguration(), "THROWABLE", "%ex{full}", null, null, null, null) + }; + for (Map.Entry<String, DataSource> entry : domainsHolder.getDomains().entrySet()) { + Appender appender = ctx.getConfiguration().getAppender("audit_for_" + entry.getKey()); + if (appender == null) { + appender = JdbcAppender.createAppender( + "audit_for_" + entry.getKey(), + "false", + null, + new DataSourceConnectionSource(entry.getValue()), + "0", + "SYNCOPEAUDIT", + columns); + appender.start(); + ctx.getConfiguration().addAppender(appender); + } + + LoggerConfig logConf = new LoggerConfig(AuditManager.getDomainAuditLoggerName(entry.getKey()), null, false); + logConf.addAppender(appender, Level.DEBUG, null); + ctx.getConfiguration().addLogger(AuditManager.getDomainAuditLoggerName(entry.getKey()), logConf); + + AuthContextUtils.execWithAuthContext(entry.getKey(), new AuthContextUtils.Executable<Void>() { + + @Override + public Void exec() { + loggerAccessor.synchronizeLog4J(ctx); + return null; + } + }); + } + + ctx.updateLoggers(); + } + + private static class DataSourceConnectionSource implements ConnectionSource { + + private final DataSource dataSource; + - public DataSourceConnectionSource(final DataSource dataSource) { ++ DataSourceConnectionSource(final DataSource dataSource) { + this.dataSource = dataSource; + } + + @Override + public Connection getConnection() throws SQLException { + return DataSourceUtils.getConnection(dataSource); + } + + } +}
http://git-wip-us.apache.org/repos/asf/syncope/blob/4e0783e1/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspectImpl.java ---------------------------------------------------------------------- diff --cc core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspectImpl.java index 662cb15,0000000..62e3dba mode 100644,000000..100644 --- a/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspectImpl.java +++ b/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspectImpl.java @@@ -1,43 -1,0 +1,43 @@@ +/* + * 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.core.misc.jexl; + +import org.apache.commons.jexl2.JexlInfo; +import org.apache.commons.jexl2.introspection.JexlMethod; +import org.apache.commons.jexl2.introspection.JexlPropertyGet; +import org.apache.commons.jexl2.introspection.UberspectImpl; +import org.apache.commons.logging.Log; + +class ClassFreeUberspectImpl extends UberspectImpl { + - public ClassFreeUberspectImpl(final Log runtimeLogger) { ++ ClassFreeUberspectImpl(final Log runtimeLogger) { + super(runtimeLogger); + } + + @Override + public JexlPropertyGet getPropertyGet(final Object obj, final Object identifier, final JexlInfo info) { + return "class".equals(identifier) ? null : super.getPropertyGet(obj, identifier, info); + } + + @Override + public JexlMethod getMethod(final Object obj, final String method, final Object[] args, final JexlInfo info) { + return "getClass".equals(method) ? null : super.getMethod(obj, method, args, info); + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/4e0783e1/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/ImplementationLookup.java ---------------------------------------------------------------------- diff --cc core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/ImplementationLookup.java index fd349a9,0000000..fa8847f mode 100644,000000..100644 --- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/ImplementationLookup.java +++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/ImplementationLookup.java @@@ -1,55 -1,0 +1,55 @@@ +/* + * 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.core.persistence.api; + +import java.util.Set; +import org.apache.syncope.common.lib.policy.AccountRuleConf; +import org.apache.syncope.common.lib.policy.PasswordRuleConf; +import org.apache.syncope.common.lib.report.ReportletConf; +import org.apache.syncope.core.persistence.api.dao.AccountRule; +import org.apache.syncope.core.persistence.api.dao.PasswordRule; +import org.apache.syncope.core.persistence.api.dao.Reportlet; + +public interface ImplementationLookup extends SyncopeLoader { + - public enum Type { ++ enum Type { + + REPORTLET, + ACCOUNT_RULE, + PASSWORD_RULE, + MAPPING_ITEM_TRANSFORMER, + TASKJOBDELEGATE, + LOGIC_ACTIONS, + PROPAGATION_ACTIONS, + SYNC_ACTIONS, + PUSH_ACTIONS, + SYNC_CORRELATION_RULE, + PUSH_CORRELATION_RULE, + VALIDATOR + + } + + Set<String> getClassNames(Type type); + + Class<? extends Reportlet> getReportletClass(Class<? extends ReportletConf> reportletConfClass); + + Class<? extends AccountRule> getAccountRuleClass(Class<? extends AccountRuleConf> accountRuleConfClass); + + Class<? extends PasswordRule> getPasswordRuleClass(Class<? extends PasswordRuleConf> passwordRuleConfClass); +} http://git-wip-us.apache.org/repos/asf/syncope/blob/4e0783e1/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/ContentLoaderHandler.java ---------------------------------------------------------------------- diff --cc core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/ContentLoaderHandler.java index ddeb0e2,0000000..edd430e mode 100644,000000..100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/ContentLoaderHandler.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/ContentLoaderHandler.java @@@ -1,199 -1,0 +1,199 @@@ +/* + * 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.core.persistence.jpa.content; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.text.ParseException; +import java.util.HashMap; +import java.util.Map; +import javax.sql.DataSource; +import org.apache.commons.codec.DecoderException; +import org.apache.commons.codec.binary.Hex; +import org.apache.syncope.core.misc.DataFormat; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.ResultSetExtractor; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * SAX handler for generating SQL INSERT statements out of given XML file. + */ +class ContentLoaderHandler extends DefaultHandler { + + private static final Logger LOG = LoggerFactory.getLogger(ContentLoaderHandler.class); + + private final DataSource dataSource; + + private final String rootElement; + - public ContentLoaderHandler(final DataSource dataSource, final String rootElement) { ++ ContentLoaderHandler(final DataSource dataSource, final String rootElement) { + this.dataSource = dataSource; + this.rootElement = rootElement; + } + + private Object[] getParameters(final String tableName, final Attributes attrs) { + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); + + Map<String, Integer> colTypes = jdbcTemplate.query("SELECT * FROM " + tableName + " WHERE 0=1", + new ResultSetExtractor<Map<String, Integer>>() { + + @Override + public Map<String, Integer> extractData(final ResultSet rs) throws SQLException { + Map<String, Integer> colTypes = new HashMap<>(); + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + colTypes.put( + rs.getMetaData().getColumnName(i).toUpperCase(), + rs.getMetaData().getColumnType(i)); + } + return colTypes; + } + }); + + Object[] parameters = new Object[attrs.getLength()]; + for (int i = 0; i < attrs.getLength(); i++) { + Integer colType = colTypes.get(attrs.getQName(i).toUpperCase()); + if (colType == null) { + LOG.warn("No column type found for {}", attrs.getQName(i).toUpperCase()); + colType = Types.VARCHAR; + } + + switch (colType) { + case Types.INTEGER: + case Types.TINYINT: + case Types.SMALLINT: + try { + parameters[i] = Integer.valueOf(attrs.getValue(i)); + } catch (NumberFormatException e) { + LOG.error("Unparsable Integer '{}'", attrs.getValue(i)); + parameters[i] = attrs.getValue(i); + } + break; + + case Types.NUMERIC: + case Types.DECIMAL: + case Types.BIGINT: + try { + parameters[i] = Long.valueOf(attrs.getValue(i)); + } catch (NumberFormatException e) { + LOG.error("Unparsable Long '{}'", attrs.getValue(i)); + parameters[i] = attrs.getValue(i); + } + break; + + case Types.DOUBLE: + try { + parameters[i] = Double.valueOf(attrs.getValue(i)); + } catch (NumberFormatException e) { + LOG.error("Unparsable Double '{}'", attrs.getValue(i)); + parameters[i] = attrs.getValue(i); + } + break; + + case Types.REAL: + case Types.FLOAT: + try { + parameters[i] = Float.valueOf(attrs.getValue(i)); + } catch (NumberFormatException e) { + LOG.error("Unparsable Float '{}'", attrs.getValue(i)); + parameters[i] = attrs.getValue(i); + } + break; + + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: + try { + parameters[i] = DataFormat.parseDate(attrs.getValue(i)); + } catch (ParseException e) { + LOG.error("Unparsable Date '{}'", attrs.getValue(i)); + parameters[i] = attrs.getValue(i); + } + break; + + case Types.BIT: + case Types.BOOLEAN: + parameters[i] = "1".equals(attrs.getValue(i)) ? Boolean.TRUE : Boolean.FALSE; + break; + + case Types.BINARY: + case Types.VARBINARY: + case Types.LONGVARBINARY: + try { + parameters[i] = Hex.decodeHex(attrs.getValue(i).toCharArray()); + } catch (DecoderException | IllegalArgumentException e) { + parameters[i] = attrs.getValue(i); + } + break; + + case Types.BLOB: + try { + parameters[i] = Hex.decodeHex(attrs.getValue(i).toCharArray()); + } catch (DecoderException | IllegalArgumentException e) { + LOG.warn("Error decoding hex string to specify a blob parameter", e); + parameters[i] = attrs.getValue(i); + } catch (Exception e) { + LOG.warn("Error creating a new blob parameter", e); + } + break; + + default: + parameters[i] = attrs.getValue(i); + } + } + + return parameters; + } + + @Override + public void startElement(final String uri, final String localName, final String qName, final Attributes atts) + throws SAXException { + + // skip root element + if (rootElement.equals(qName)) { + return; + } + + StringBuilder query = new StringBuilder("INSERT INTO ").append(qName).append('('); + + StringBuilder values = new StringBuilder(); + + for (int i = 0; i < atts.getLength(); i++) { + query.append(atts.getQName(i)); + values.append('?'); + if (i < atts.getLength() - 1) { + query.append(','); + values.append(','); + } + } + query.append(") VALUES (").append(values).append(')'); + + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); + try { + jdbcTemplate.update(query.toString(), getParameters(qName, atts)); + } catch (DataAccessException e) { + LOG.error("While trying to perform {}", query, e); + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/4e0783e1/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/MultiParentNode.java ---------------------------------------------------------------------- diff --cc core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/MultiParentNode.java index 98529e8,0000000..88a14e1 mode 100644,000000..100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/MultiParentNode.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/content/MultiParentNode.java @@@ -1,106 -1,0 +1,106 @@@ +/* + * 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.core.persistence.jpa.content; + +import java.util.HashSet; +import java.util.Set; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +class MultiParentNode<T> { + + private final T object; + + private Set<MultiParentNode<T>> children; + + private int level = 0; + + private boolean exploited = false; + - public MultiParentNode(final T object) { ++ MultiParentNode(final T object) { + this.object = object; + children = new HashSet<>(); + } + + public int getLevel() { + return level; + } + + public void setLevel(final int level) { + this.level = level; + } + + boolean isExploited() { + return exploited; + } + + void setExploited(final boolean exploited) { + this.exploited = exploited; + } + + public T getObject() { + return object; + } + + public boolean isParent(final MultiParentNode<T> child) { + return children.contains(child); + } + + public boolean isChild(final MultiParentNode<T> parent) { + return parent.isParent(this); + } + + public Set<MultiParentNode<T>> getChildren() { + return children; + } + + public void addParent(final MultiParentNode<T> parent) { + if (parent != null) { + parent.children.add(this); + } + } + + public void removeParent(final MultiParentNode<T> parent) { + if (parent != null) { + parent.children.remove(this); + } + } + + public void addChild(final MultiParentNode<T> child) { + if (child != null) { + children.add(child); + } + } + + public void removeChild(final MultiParentNode<T> child) { + if (child != null) { + children.remove(child); + } + } + + @Override + public boolean equals(final Object obj) { + return EqualsBuilder.reflectionEquals(this, obj); + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/4e0783e1/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/SearchSupport.java ---------------------------------------------------------------------- diff --cc core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/SearchSupport.java index e87a22e,0000000..4c8297a mode 100644,000000..100644 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/SearchSupport.java +++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/SearchSupport.java @@@ -1,155 -1,0 +1,155 @@@ +/* + * 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.core.persistence.jpa.dao; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.syncope.common.lib.types.AnyTypeKind; +import org.apache.syncope.common.lib.types.AttrSchemaType; + +class SearchSupport { + + static class SearchView { + + protected String alias; + + protected String name; + + protected SearchView(final String alias, final String name) { + this.alias = alias; + this.name = name; + } + + @Override + public boolean equals(final Object obj) { + return EqualsBuilder.reflectionEquals(this, obj); + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + } + + private final AnyTypeKind anyTypeKind; + - public SearchSupport(final AnyTypeKind anyTypeKind) { ++ SearchSupport(final AnyTypeKind anyTypeKind) { + this.anyTypeKind = anyTypeKind; + } + + public String fieldName(final AttrSchemaType attrSchemaType) { + String result; + + switch (attrSchemaType) { + case Boolean: + result = "booleanvalue"; + break; + + case Date: + result = "datevalue"; + break; + + case Double: + result = "doublevalue"; + break; + + case Long: + result = "longvalue"; + break; + + case String: + case Enum: + result = "stringvalue"; + break; + + default: + result = null; + } + + return result; + } + + public SearchView field() { + String result = ""; + + switch (anyTypeKind) { + case ANY_OBJECT: + result = "anyObject_search"; + break; + + case GROUP: + result = "group_search"; + break; + + case USER: + default: + result = "user_search"; + break; + } + + return new SearchView("sv", result); + } + + public SearchView attr() { + return new SearchView("sva", field().name + "_attr"); + } + + public SearchView relationship() { + String kind = anyTypeKind == AnyTypeKind.USER ? "u" : "a"; + return new SearchView("sv" + kind + "m", field().name + "_" + kind + "relationship"); + } + + public SearchView membership() { + String kind = anyTypeKind == AnyTypeKind.USER ? "u" : "a"; + return new SearchView("sv" + kind + "m", field().name + "_" + kind + "membership"); + } + + public SearchView dyngroupmembership() { + String kind = anyTypeKind == AnyTypeKind.USER ? "u" : "a"; + return new SearchView("sv" + kind + "dgm", field().name + "_" + kind + "dyngmemb"); + } + + public SearchView role() { + return new SearchView("svr", field().name + "_role"); + } + + public SearchView dynrolemembership() { + return new SearchView("svdr", field().name + "_dynrmemb"); + } + + public SearchView nullAttr() { + return new SearchView("svna", field().name + "_null_attr"); + } + + public SearchView resource() { + return new SearchView("svr", field().name + "_resource"); + } + + public SearchView groupResource() { + return new SearchView("svrr", field().name + "_group_res"); + } + + public SearchView uniqueAttr() { + return new SearchView("svua", field().name + "_unique_attr"); + } + + public SearchView entitlements() { + return new SearchView("sve", field().name + "_entitlements"); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/4e0783e1/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/panels/CamelRoutePanel.java ---------------------------------------------------------------------- diff --cc ext/camel/client-console/src/main/java/org/apache/syncope/client/console/panels/CamelRoutePanel.java index 005e23f,0000000..d68a8e9 mode 100644,000000..100644 --- a/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/panels/CamelRoutePanel.java +++ b/ext/camel/client-console/src/main/java/org/apache/syncope/client/console/panels/CamelRoutePanel.java @@@ -1,178 -1,0 +1,178 @@@ +/* + * 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.client.console.panels; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import org.apache.syncope.client.console.annotations.ExtensionPanel; +import org.apache.syncope.client.console.commons.SortableDataProviderComparator; +import org.apache.syncope.client.console.rest.CamelRouteRestClient; +import org.apache.syncope.common.lib.to.CamelRouteTO; +import org.apache.syncope.common.lib.types.AnyTypeKind; +import org.apache.syncope.common.lib.types.Entitlement; +import org.apache.wicket.PageReference; +import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; +import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; +import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable; +import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; +import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder; +import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn; +import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; +import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; +import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.repeater.Item; +import org.apache.wicket.model.AbstractReadOnlyModel; +import org.apache.wicket.model.IModel; +import org.apache.wicket.model.ResourceModel; +import org.apache.wicket.spring.injection.annot.SpringBean; + +@ExtensionPanel("Camel routes") +public class CamelRoutePanel extends AbstractExtensionPanel { + + private static final long serialVersionUID = 1965360932245590233L; + + private static final int CAMELROUTE_WIN_HEIGHT = 480; + + private static final int CAMELROUTE_WIN_WIDTH = 800; + + @SpringBean + private CamelRouteRestClient restClient; + + private ModalWindow editCamelRouteWin; + + public CamelRoutePanel(final String id, final PageReference pageref) { + super(id, pageref); + + editCamelRouteWin = new ModalWindow("editCamelRouteWin"); + editCamelRouteWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY); + editCamelRouteWin.setInitialHeight(CAMELROUTE_WIN_HEIGHT); + editCamelRouteWin.setInitialWidth(CAMELROUTE_WIN_WIDTH); + editCamelRouteWin.setCookieName("editCamelRouteWin-modal"); + add(editCamelRouteWin); + + List<IColumn<CamelRouteTO, String>> routeCols = new ArrayList<>(); + routeCols.add(new PropertyColumn<CamelRouteTO, String>(new ResourceModel("key"), "key", "key")); + routeCols.add(new AbstractColumn<CamelRouteTO, String>(new ResourceModel("actions", "")) { + + private static final long serialVersionUID = 2054811145491901166L; + + @Override + public String getCssClass() { + return "action"; + } + + @Override + public void populateItem(final Item<ICellPopulator<CamelRouteTO>> cellItem, final String componentId, + final IModel<CamelRouteTO> model) { + + // Uncomment with something similar once SYNCOPE-156 is completed + /* final ActionLinksPanel panel = new + * ActionLinksPanel(componentId, model, pageref); + * + * panel.add(new ActionLink() { + * + * private static final long serialVersionUID = -3722207913631435501L; + * + * @Override + * public void onClick(final AjaxRequestTarget target) { + * + * editCamelRouteWin.setPageCreator(new ModalWindow.PageCreator() { + * + * private static final long serialVersionUID = -7834632442532690940L; + * + * @Override + * public Page createPage() { + * return new CamelRouteModalPage(pageref, editCamelRouteWin, + * restClient.read(model.getObject().getKey()), false); + * } + * + * }); + * + * editCamelRouteWin.show(target); + * } + * }, ActionLink.ActionType.EDIT, "CamelRoutes"); + * + * cellItem.add(panel); */ + } + }); + + final AjaxFallbackDefaultDataTable<CamelRouteTO, String> routeTable = + new AjaxFallbackDefaultDataTable<>("camelRouteTable", routeCols, new CamelRouteProvider(), 50); + + WebMarkupContainer routeContainer = new WebMarkupContainer("camelRoutesContainer"); + routeContainer.add(routeTable); + routeContainer.setOutputMarkupId(true); + MetaDataRoleAuthorizationStrategy.authorize(routeContainer, ENABLE, Entitlement.ROUTE_LIST); + add(routeContainer); + } + + private class CamelRouteProvider extends SortableDataProvider<CamelRouteTO, String> { + + private static final long serialVersionUID = -2917236020432105949L; + + private final SortableDataProviderComparator<CamelRouteTO> comparator; + - public CamelRouteProvider() { ++ CamelRouteProvider() { + setSort("key", SortOrder.ASCENDING); + comparator = new SortableDataProviderComparator<>(this); + } + + @Override + public Iterator<? extends CamelRouteTO> iterator(final long first, final long count) { + List<CamelRouteTO> list = new ArrayList<>(); + if (restClient.isCamelEnabledFor(AnyTypeKind.USER)) { + list.addAll(restClient.list(AnyTypeKind.USER)); + } + if (restClient.isCamelEnabledFor(AnyTypeKind.GROUP)) { + list.addAll(restClient.list(AnyTypeKind.GROUP)); + } + + Collections.sort(list, comparator); + + return list.subList((int) first, (int) first + (int) count).iterator(); + } + + @Override + public long size() { + return (restClient.isCamelEnabledFor(AnyTypeKind.USER) + ? restClient.list(AnyTypeKind.USER).size() + : 0) + + (restClient.isCamelEnabledFor(AnyTypeKind.GROUP) + ? restClient.list(AnyTypeKind.GROUP).size() + : 0); + } + + @Override + public IModel<CamelRouteTO> model(final CamelRouteTO route) { + return new AbstractReadOnlyModel<CamelRouteTO>() { + + private static final long serialVersionUID = 774694801558497248L; + + @Override + public CamelRouteTO getObject() { + return route; + } + }; + } + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/4e0783e1/installer/src/main/java/org/apache/syncope/installer/enums/Containers.java ---------------------------------------------------------------------- diff --cc installer/src/main/java/org/apache/syncope/installer/enums/Containers.java index ac8e036,ac8e036..f79de47 --- a/installer/src/main/java/org/apache/syncope/installer/enums/Containers.java +++ b/installer/src/main/java/org/apache/syncope/installer/enums/Containers.java @@@ -24,7 -24,7 +24,7 @@@ public enum Containers JBOSS("jboss"), GLASSFISH("glassfish"); -- private Containers(final String name) { ++ Containers(final String name) { this.name = name; } http://git-wip-us.apache.org/repos/asf/syncope/blob/4e0783e1/installer/src/main/java/org/apache/syncope/installer/enums/DBs.java ---------------------------------------------------------------------- diff --cc installer/src/main/java/org/apache/syncope/installer/enums/DBs.java index 085b98f,9fcc92e..3e15b8c --- a/installer/src/main/java/org/apache/syncope/installer/enums/DBs.java +++ b/installer/src/main/java/org/apache/syncope/installer/enums/DBs.java @@@ -26,7 -26,7 +26,7 @@@ public enum DBs SQLSERVER("sqlserver"), ORACLE("oracle"); -- private DBs(final String name) { ++ DBs(final String name) { this.name = name; } http://git-wip-us.apache.org/repos/asf/syncope/blob/4e0783e1/pom.xml ---------------------------------------------------------------------- diff --cc pom.xml index 50e3522,4ef0802..78179bf --- a/pom.xml +++ b/pom.xml @@@ -1140,7 -1067,65 +1140,7 @@@ under the License <artifactId>openjpa-maven-plugin</artifactId> <version>${openjpa.version}</version> </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>xml-maven-plugin</artifactId> - <version>1.0</version> - <dependencies> - <dependency> - <groupId>xalan</groupId> - <artifactId>xalan</artifactId> - <version>2.7.1</version> - </dependency> - </dependencies> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.19</version> - <configuration> - <redirectTestOutputToFile>true</redirectTestOutputToFile> - <encoding>utf-8</encoding> - <runOrder>alphabetical</runOrder> - <argLine>-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m</argLine> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-war-plugin</artifactId> - <version>2.6</version> - <configuration> - <attachClasses>true</attachClasses> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>selenium-maven-plugin</artifactId> - <version>2.3</version> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-failsafe-plugin</artifactId> - <version>2.19</version> - <configuration> - <redirectTestOutputToFile>true</redirectTestOutputToFile> - <encoding>utf-8</encoding> - <runOrder>alphabetical</runOrder> - </configuration> - <executions> - <execution> - <goals> - <goal>integration-test</goal> - <goal>verify</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <version>1.8</version> - </plugin> ++ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> @@@ -1231,43 -1179,42 +1231,43 @@@ </container> </configuration> </plugin> + <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>1.9</version> - </plugin> - <plugin> - <groupId>org.zeroturnaround</groupId> - <artifactId>jrebel-maven-plugin</artifactId> - <version>1.1.5</version> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> - <version>2.18.1</version> ++ <version>2.19</version> + <configuration> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + <encoding>utf-8</encoding> + <runOrder>alphabetical</runOrder> + <argLine>-Xms512m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m -Xss256k</argLine> + </configuration> </plugin> <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <version>2.5.0</version> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> - <version>2.18.1</version> ++ <version>2.19</version> <configuration> - <supportedProjectTypes> - <supportedProjectType>jar</supportedProjectType> - <supportedProjectType>war</supportedProjectType> - <supportedProjectType>bundle</supportedProjectType> - </supportedProjectTypes> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + <encoding>utf-8</encoding> + <runOrder>alphabetical</runOrder> </configuration> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> </plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> - <version>2.16</version> + <version>2.17</version> - <dependencies> - <dependency> - <groupId>org.apache.syncope</groupId> - <artifactId>syncope-build-tools</artifactId> - <version>${project.version}</version> - <classifier>classes</classifier> - </dependency> - </dependencies> <configuration> - <configLocation>org/apache/syncope/checkstyle.xml</configLocation> + <configLocation>${rootpom.basedir}/src/main/resources/org/apache/syncope/checkstyle.xml</configLocation> <targetJdk>${targetJdk}</targetJdk> </configuration> </plugin>
