Skip to content

Commit

Permalink
Made entity containers optional in the meta model.
Browse files Browse the repository at this point in the history
Fixed various compile warnings.
Refactored packages for rest services.
Generalized the statistic service to report on stats for all entities and relationships.
Added pooling support for Marshaller/Unmarshaller in AbstractContentStore to allow for reuse and better efficiencies in processing since these are expensive to create.
Integrated AbstractContentStore into the content DB project.
Fixed exception handling in content DB store.
Added content DB store to the main build.
Added diagram of the meta model.
  • Loading branch information
david-waltermire committed May 21, 2011
1 parent b4d092f commit 9cb5d61
Show file tree
Hide file tree
Showing 21 changed files with 348 additions and 118 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion content-model/src/main/xsd/MetaModel.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
<xs:element name="document-model" type="DocumentModelType" abstract="true"/>
<xs:complexType name="DocumentModelType">
<xs:sequence>
<xs:element name="entity-containers" type="EntityContainersType">
<xs:element name="entity-containers" type="EntityContainersType" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import java.util.Properties;

import org.scapdev.content.core.ContentRepository;
import org.scapdev.content.core.persistence.hybrid.HybridContentPersistenceManager;
import org.scapdev.content.core.persistence.hybrid.MemoryResidentHybridContentPersistenceManager;

/**
* A single place to access configuration settings for the repository and hold on to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1)
private void initRepo()
{
// initialize repository war configuration
@SuppressWarnings("unused")
RepositoryConfiguration rc = RepositoryConfiguration.INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public FileUploadXMLResponse uploadContent(@Context HttpServletRequest request)
List<FileItem> items = null;

try {
items = upload.parseRequest(request);
@SuppressWarnings("unchecked")
List<FileItem> requestItems = upload.parseRequest(request);
items = requestItems;
} catch (FileUploadException fue) {
// TODO: is the temp dir removed?
ret.setCause(fue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class FileUploadXMLResponse extends SimpleXMLResponse {

// will actually be used
// when response is serialized by jaxb
@SuppressWarnings("unused")
@XmlElement(name = "fileEntry")
private List<UploadedFileResponseEntry> filesUploaded = new LinkedList<UploadedFileResponseEntry>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@
@XmlAccessorType(XmlAccessType.FIELD)
public class UploadedFileResponseEntry
{
@SuppressWarnings("unused")
private String filename;
@SuppressWarnings("unused")
@XmlAttribute
private int entitiesProcessed;
@SuppressWarnings("unused")
@XmlAttribute
private int relationshipsProcessed;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package org.content.repository.war.rest;
package org.content.repository.war.rest.statistic;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

Expand All @@ -33,7 +32,6 @@

import org.apache.log4j.Logger;
import org.content.repository.config.RepositoryConfiguration;
import org.content.repository.war.rest.response.RepositoryStatisticsXMLResponse;
import org.scapdev.content.core.ContentRepository;
import org.scapdev.content.core.query.EntityStatistic;
import org.scapdev.content.model.MetadataModel;
Expand All @@ -58,17 +56,9 @@ public RepositoryStatisticsXMLResponse getGlobalStatistics()

Set<String> entityInfoIds = mm.getEntityInfoIds();
Map<String, ? extends EntityStatistic> stats = cr.queryStatistics(entityInfoIds);

// TODO: build response

Iterator<String> keyItr = stats.keySet().iterator();
while(keyItr.hasNext())
{
String key = keyItr.next();
EntityStatistic stat = stats.get(key);

ret.setCount(key, stat);
}
for (EntityStatistic stat : stats.values()) {
ret.add(stat);
}
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.content.repository.war.rest.statistic;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;

import org.scapdev.content.core.query.RelationshipStatistic;

@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class RelationshipItem {
@SuppressWarnings("unused")
@XmlAttribute(required=true)
private String id;
// TODO: add support for language bundle
private String title;
@SuppressWarnings("unused")
@XmlAttribute(required=true)
private int count;

public RelationshipItem () {
// No arg required by JAXB
}

public RelationshipItem(RelationshipStatistic stat) {
id = stat.getRelationshipInfo().getId();
count = stat.getCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,69 +21,33 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package org.content.repository.war.rest.response;
package org.content.repository.war.rest.statistic;

import java.util.HashMap;
import java.util.Map;
import java.util.LinkedList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import org.apache.log4j.Logger;
import org.scapdev.content.core.query.EntityStatistic;

@XmlType
@XmlRootElement(name = "repositoryStatistics")
@XmlAccessorType(XmlAccessType.FIELD)
public class RepositoryStatisticsXMLResponse
{
@XmlTransient
private static Logger LOG = Logger.getLogger(RepositoryStatisticsXMLResponse.class);

private int ovalDefinitions;
private int ovalTests;
private int ovalObjects;
private int ovalStates;
private int ovalVariables;
private int other;
public class RepositoryStatisticsXMLResponse {
// @XmlElementRef(name = "entity", type = StatItem.class)
@XmlElement
private List<StatItem> item;

// required by jaxb
public RepositoryStatisticsXMLResponse()
{

public RepositoryStatisticsXMLResponse() {
item = new LinkedList<StatItem>();
}

public void setCount(String key, EntityStatistic stat)
{
if(key.equals("urn:scap-content:entity:org.mitre.oval:test"))
{
ovalTests += stat.getCount();
}
else if(key.equals("urn:scap-content:entity:org.mitre.oval:definition"))
{
ovalDefinitions += stat.getCount();
}
else if(key.equals("urn:scap-content:entity:org.mitre.oval:object"))
{
ovalObjects += stat.getCount();
}
else if(key.equals("urn:scap-content:entity:org.mitre.oval:state"))
{
ovalStates += stat.getCount();
}
else if(key.equals("urn:scap-content:entity:org.mitre.oval:variable"))
{
ovalVariables += stat.getCount();
}
else
{
LOG.info("Adding unhandled count for key " + key);
other += stat.getCount();
}

public void add(EntityStatistic stat) {
item.add(new StatItem(stat));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.content.repository.war.rest.statistic;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

import org.scapdev.content.core.query.EntityStatistic;
import org.scapdev.content.core.query.RelationshipStatistic;

@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class StatItem {
@SuppressWarnings("unused")
@XmlAttribute(required=true)
private String id;
// TODO: add support for language bundle
private String title;
@SuppressWarnings("unused")
@XmlAttribute(required=true)
private int count;
@XmlElement
private List<RelationshipItem> relationship;

public StatItem () {
// No arg required by JAXB
}

public StatItem(EntityStatistic stat) {
this.id = stat.getEntityInfo().getId();
this.count = stat.getCount();
Collection<? extends RelationshipStatistic> relationshipStats = stat.getRelationshipInfoStatistics().values();
this.relationship = new ArrayList<RelationshipItem>(relationshipStats.size());
for (RelationshipStatistic item : relationshipStats) {
this.relationship.add(new RelationshipItem(item));
}
}
}
2 changes: 1 addition & 1 deletion content-repository-war/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<!-- ; separated list of package names to look in -->
<param-value>org.content.repository.war.rest;org.content.repository.war.rest.oval</param-value>
<param-value>org.content.repository.war.rest;org.content.repository.war.rest.oval;org.content.repository.war.rest.query;org.content.repository.war.rest.statistic</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

public class ContentException extends RuntimeException {

/**
*
*/
/** the serial version UID */
private static final long serialVersionUID = 1L;

public ContentException() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*******************************************************************************
* The MIT License
*
* Copyright (c) 2011 davidwal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
package org.scapdev.content.core.persistence;

import org.scapdev.content.core.ContentException;

public class ContentPersistenceException extends ContentException {

/** the serial version UID */
private static final long serialVersionUID = 1L;

public ContentPersistenceException() {
// TODO Auto-generated constructor stub
}

public ContentPersistenceException(String message) {
super(message);
// TODO Auto-generated constructor stub
}

public ContentPersistenceException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}

public ContentPersistenceException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import org.scapdev.content.model.MetadataModel;

public abstract class AbstractContentRetriever<DATA> implements ContentRetriever {
public abstract class AbstractContentRetriever implements ContentRetriever {
public String contentId;
public MetadataModel model;

Expand Down
Loading

0 comments on commit 9cb5d61

Please sign in to comment.