You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by ol...@apache.org on 2014/08/28 02:38:45 UTC
svn commit: r1621007 - in
/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status:
NodeStatusInfo.java StatusService.java ValidationResultInfo.java
Author: olamy
Date: Thu Aug 28 00:38:45 2014
New Revision: 1621007
URL: http://svn.apache.org/r1621007
Log:
add a status service
Added:
incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/NodeStatusInfo.java (with props)
incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/StatusService.java (with props)
incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/ValidationResultInfo.java (with props)
Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/NodeStatusInfo.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/NodeStatusInfo.java?rev=1621007&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/NodeStatusInfo.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/NodeStatusInfo.java Thu Aug 28 00:38:45 2014
@@ -0,0 +1,92 @@
+/*
+ * 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.sirona.reporting.web.status;
+
+import org.apache.sirona.status.NodeStatus;
+import org.apache.sirona.status.ValidationResult;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @since 0.3
+ */
+public class NodeStatusInfo
+ implements Serializable
+{
+
+ private final List<ValidationResultInfo> results;
+
+ private final Date date;
+
+ private final String status;
+
+ public NodeStatusInfo( NodeStatus nodeStatus )
+ {
+ this.date = nodeStatus.getDate();
+ this.status = StatusHelper.map( nodeStatus.getStatus() );
+
+ if ( nodeStatus.getResults() != null )
+ {
+ this.results = new ArrayList<ValidationResultInfo>( nodeStatus.getResults().length );
+ for ( ValidationResult validationResult : nodeStatus.getResults() )
+ {
+ this.results.add( new ValidationResultInfo( StatusHelper.map( validationResult.getStatus() ), //
+ validationResult.getMessage(), //
+ validationResult.getName() ) );
+ }
+ }
+ else
+ {
+ this.results = new ArrayList<ValidationResultInfo>( 0 );
+ }
+ }
+
+ public NodeStatusInfo( String status, Date date, List<ValidationResultInfo> results )
+ {
+ this.status = status;
+ this.date = date;
+ this.results = results;
+ }
+
+ public List<ValidationResultInfo> getResults()
+ {
+ return results;
+ }
+
+ public Date getDate()
+ {
+ return date;
+ }
+
+ public String getStatus()
+ {
+ return status;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "NodeStatusInfo{" +
+ "results=" + results +
+ ", date=" + date +
+ ", status='" + status + '\'' +
+ '}';
+ }
+}
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/NodeStatusInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/NodeStatusInfo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/StatusService.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/StatusService.java?rev=1621007&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/StatusService.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/StatusService.java Thu Aug 28 00:38:45 2014
@@ -0,0 +1,74 @@
+/*
+ * 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.sirona.reporting.web.status;
+
+import org.apache.sirona.repositories.Repository;
+import org.apache.sirona.status.NodeStatus;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * @author Olivier Lamy
+ * @since 0.3
+ */
+@Path( "/status" )
+public class StatusService
+{
+
+ private static final String DEFAULT_ROOT = "-";
+
+ private static final String APP_DELIMITER = "#";
+
+
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ public Map<String, Map<String, NodeStatusInfo>> all()
+ {
+ final Map<String, Map<String, NodeStatusInfo>> statusesByApp =
+ new HashMap<String, Map<String, NodeStatusInfo>>();
+ for ( final Map.Entry<String, NodeStatus> entry : Repository.INSTANCE.statuses().entrySet() )
+ {
+ final String key = entry.getKey();
+ final String[] segments;
+ if ( key.contains( APP_DELIMITER ) )
+ {
+ segments = key.split( APP_DELIMITER );
+ }
+ else
+ {
+ segments = new String[]{ DEFAULT_ROOT, key };
+ }
+
+ Map<String, NodeStatusInfo> statusesOfTheApp = statusesByApp.get( segments[0] );
+ if ( statusesOfTheApp == null )
+ {
+ statusesOfTheApp = new TreeMap<String, NodeStatusInfo>();
+ statusesByApp.put( segments[0], statusesOfTheApp );
+ }
+ statusesOfTheApp.put( segments[1], new NodeStatusInfo( entry.getValue() ) );
+ }
+
+ return statusesByApp;
+ }
+
+}
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/StatusService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/StatusService.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/ValidationResultInfo.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/ValidationResultInfo.java?rev=1621007&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/ValidationResultInfo.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/ValidationResultInfo.java Thu Aug 28 00:38:45 2014
@@ -0,0 +1,66 @@
+/*
+ * 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.sirona.reporting.web.status;
+
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ * @since 0.3
+ */
+public class ValidationResultInfo
+ implements Serializable
+{
+
+ private final String status;
+
+ private final String message;
+
+ private final String name;
+
+ public ValidationResultInfo( String status, String message, String name )
+ {
+ this.status = status;
+ this.message = message;
+ this.name = name;
+ }
+
+ public String getStatus()
+ {
+ return status;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ValidationResultInfo{" +
+ "status='" + status + '\'' +
+ ", message='" + message + '\'' +
+ ", name='" + name + '\'' +
+ '}';
+ }
+}
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/ValidationResultInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/status/ValidationResultInfo.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision