You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by jb...@apache.org on 2013/01/03 17:47:02 UTC
svn commit: r1428465 - in /syncope/trunk:
client/src/main/java/org/apache/syncope/services/
core/src/test/java/org/apache/syncope/core/rest/
Author: jbernhardt
Date: Thu Jan 3 16:47:02 2013
New Revision: 1428465
URL: http://svn.apache.org/viewvc?rev=1428465&view=rev
Log:
[SYNCOPE-259]
Introduces LoggerService
Added:
syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerService.java
syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerServiceProxy.java
Modified:
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java
Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerService.java?rev=1428465&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerService.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerService.java Thu Jan 3 16:47:02 2013
@@ -0,0 +1,72 @@
+/*
+ * 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.services;
+
+import java.util.List;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.apache.syncope.client.to.LoggerTO;
+import org.apache.syncope.types.AuditLoggerName;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import ch.qos.logback.classic.Level;
+
+@Path("logger")
+public interface LoggerService {
+
+ @GET
+ @RequestMapping(method = RequestMethod.GET, value = "/log/list")
+ List<LoggerTO> listLogs();
+
+ @GET
+ @Path("audit")
+ @RequestMapping(method = RequestMethod.GET, value = "/audit/list")
+ List<AuditLoggerName> listAudits();
+
+ @PUT
+ @Path("{name}/level")
+ @RequestMapping(method = RequestMethod.POST, value = "/log/{name}/{level}")
+ LoggerTO setLogLevel(@PathParam("name") final String name, final Level level);
+
+ @DELETE
+ @Path("{name}")
+ @RequestMapping(method = RequestMethod.GET, value = "/log/delete/{name}")
+ LoggerTO deleteLog(@PathParam("name") final String name);
+
+ /**
+ * @deprecated Refactoring needed here. Use {@link #setLogLevel(String, Level)} after refactoring is done.
+ */
+ @Deprecated
+ @RequestMapping(method = RequestMethod.PUT, value = "/audit/enable")
+ void enableAudit(final AuditLoggerName auditLoggerName);
+
+ /**
+ * @deprecated Refactoring needed here. Use {@link #deleteLog(String)} after refactoring is done.
+ */
+ @Deprecated
+ @RequestMapping(method = RequestMethod.PUT, value = "/audit/disable")
+ void disableAudit(final AuditLoggerName auditLoggerName);
+
+}
\ No newline at end of file
Added: syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerServiceProxy.java
URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerServiceProxy.java?rev=1428465&view=auto
==============================================================================
--- syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerServiceProxy.java (added)
+++ syncope/trunk/client/src/main/java/org/apache/syncope/services/LoggerServiceProxy.java Thu Jan 3 16:47:02 2013
@@ -0,0 +1,68 @@
+/*
+ * 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.services;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.syncope.client.to.LoggerTO;
+import org.apache.syncope.types.AuditLoggerName;
+import org.springframework.web.client.RestTemplate;
+
+import ch.qos.logback.classic.Level;
+
+public class LoggerServiceProxy extends SpringServiceProxy implements LoggerService {
+
+ public LoggerServiceProxy(String baseUrl, RestTemplate restTemplate) {
+ super(baseUrl, restTemplate);
+ }
+
+ @Override
+ public List<LoggerTO> listLogs() {
+ return Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/log/list", LoggerTO[].class));
+ }
+
+ @Override
+ public List<AuditLoggerName> listAudits() {
+ return Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/audit/list",
+ AuditLoggerName[].class));
+ }
+
+ @Override
+ public LoggerTO setLogLevel(String name, Level level) {
+ return restTemplate.postForObject(BASE_URL + "logger/log/{name}/{level}", null, LoggerTO.class, name,
+ level);
+ }
+
+ @Override
+ public LoggerTO deleteLog(String name) {
+ return restTemplate.getForObject(BASE_URL + "logger/log/delete/{name}", LoggerTO.class, name);
+ }
+
+ @Override
+ public void enableAudit(AuditLoggerName auditLoggerName) {
+ restTemplate.put(BASE_URL + "logger/audit/enable", auditLoggerName);
+ }
+
+ @Override
+ public void disableAudit(AuditLoggerName auditLoggerName) {
+ restTemplate.put(BASE_URL + "logger/audit/disable", auditLoggerName);
+ }
+
+}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1428465&r1=1428464&r2=1428465&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Thu Jan 3 16:47:02 2013
@@ -28,6 +28,7 @@ import org.apache.syncope.client.to.Attr
import org.apache.syncope.services.ConfigurationServiceProxy;
import org.apache.syncope.services.ConnectorServiceProxy;
import org.apache.syncope.services.EntitlementServiceProxy;
+import org.apache.syncope.services.LoggerServiceProxy;
import org.apache.syncope.services.RoleServiceProxy;
import org.apache.syncope.services.UserServiceProxy;
import org.junit.Before;
@@ -80,11 +81,13 @@ public abstract class AbstractTest {
protected RoleServiceProxy roleService;
protected EntitlementServiceProxy entitlementService;
-
+
protected ConfigurationServiceProxy configurationService;
-
+
protected ConnectorServiceProxy connectorService;
+ protected LoggerServiceProxy loggerService;
+
@Autowired
protected DataSource testDataSource;
@@ -110,5 +113,6 @@ public abstract class AbstractTest {
entitlementService = new EntitlementServiceProxy(BASE_URL, restTemplate);
configurationService = new ConfigurationServiceProxy(BASE_URL, restTemplate);
connectorService = new ConnectorServiceProxy(BASE_URL, restTemplate);
+ loggerService = new LoggerServiceProxy(BASE_URL, restTemplate);
}
}
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java?rev=1428465&r1=1428464&r2=1428465&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/LoggerTestITCase.java Thu Jan 3 16:47:02 2013
@@ -18,25 +18,29 @@
*/
package org.apache.syncope.core.rest;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
-import java.util.Arrays;
import java.util.List;
-import org.junit.Test;
+
import org.apache.syncope.client.to.LoggerTO;
import org.apache.syncope.types.AuditElements;
import org.apache.syncope.types.AuditLoggerName;
import org.apache.syncope.types.SyncopeLoggerLevel;
import org.junit.FixMethodOrder;
+import org.junit.Test;
import org.junit.runners.MethodSorters;
+import ch.qos.logback.classic.Level;
+
@FixMethodOrder(MethodSorters.JVM)
public class LoggerTestITCase extends AbstractTest {
@Test
public void listLogs() {
- List<LoggerTO> loggers =
- Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/log/list", LoggerTO[].class));
+ List<LoggerTO> loggers = loggerService.listLogs();
assertNotNull(loggers);
assertFalse(loggers.isEmpty());
for (LoggerTO logger : loggers) {
@@ -46,8 +50,8 @@ public class LoggerTestITCase extends Ab
@Test
public void listAudits() {
- List<AuditLoggerName> audits =
- Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/audit/list", AuditLoggerName[].class));
+ List<AuditLoggerName> audits = loggerService.listAudits();
+
assertNotNull(audits);
assertFalse(audits.isEmpty());
for (AuditLoggerName audit : audits) {
@@ -57,19 +61,23 @@ public class LoggerTestITCase extends Ab
@Test
public void setLevel() {
- List<LoggerTO> loggers =
- Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/log/list", LoggerTO[].class));
+ List<LoggerTO> loggers = loggerService.listLogs();
assertNotNull(loggers);
int startSize = loggers.size();
- LoggerTO logger = restTemplate.postForObject(BASE_URL + "logger/log/{name}/{level}", null, LoggerTO.class,
- "TEST", "INFO");
+ LoggerTO logger = loggerService.setLogLevel("TEST", Level.INFO);
assertNotNull(logger);
assertEquals(SyncopeLoggerLevel.INFO, logger.getLevel());
- loggers = Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/log/list", LoggerTO[].class));
+ loggers = loggerService.listLogs();
assertNotNull(loggers);
assertEquals(startSize + 1, loggers.size());
+
+ // TEST Delete
+ loggerService.deleteLog("TEST");
+ loggers = loggerService.listLogs();
+ assertNotNull(loggers);
+ assertEquals(startSize, loggers.size());
}
@Test
@@ -77,20 +85,19 @@ public class LoggerTestITCase extends Ab
AuditLoggerName auditLoggerName = new AuditLoggerName(AuditElements.Category.report,
AuditElements.ReportSubCategory.listExecutions, AuditElements.Result.failure);
- List<AuditLoggerName> audits =
- Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/audit/list", AuditLoggerName[].class));
+ List<AuditLoggerName> audits = loggerService.listAudits();
assertNotNull(audits);
assertFalse(audits.contains(auditLoggerName));
- restTemplate.put(BASE_URL + "logger/audit/enable", auditLoggerName);
+ loggerService.enableAudit(auditLoggerName);
- audits = Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/audit/list", AuditLoggerName[].class));
+ audits = loggerService.listAudits();
assertNotNull(audits);
assertTrue(audits.contains(auditLoggerName));
- restTemplate.put(BASE_URL + "logger/audit/disable", auditLoggerName);
+ loggerService.disableAudit(auditLoggerName);
- audits = Arrays.asList(restTemplate.getForObject(BASE_URL + "logger/audit/list", AuditLoggerName[].class));
+ audits = loggerService.listAudits();
assertNotNull(audits);
assertFalse(audits.contains(auditLoggerName));
}