Skip to content
Snippets Groups Projects
Commit d80ae22f authored by Eike Cochu's avatar Eike Cochu
Browse files

updated poms for project dependency

added util dependency to rest project for correct war export
removed ldac filebase
parent aa5befbc
Branches
No related tags found
No related merge requests found
Showing
with 280 additions and 43 deletions
...@@ -271,6 +271,14 @@ ...@@ -271,6 +271,14 @@
}, },
"buffers": "buffers":
[ [
{
"file": "Vagrantfile",
"settings":
{
"buffer_size": 955,
"line_ending": "Unix"
}
}
], ],
"build_system": "", "build_system": "",
"build_system_choices": "build_system_choices":
...@@ -901,8 +909,101 @@ ...@@ -901,8 +909,101 @@
"groups": "groups":
[ [
{ {
"selected": 0,
"sheets": "sheets":
[ [
{
"buffer": 0,
"file": "Vagrantfile",
"semi_transient": true,
"settings":
{
"buffer_size": 955,
"regions":
{
},
"selection":
[
[
797,
797
]
],
"settings":
{
"BracketHighlighterBusy": false,
"bh_regions":
[
"bh_c_define",
"bh_c_define_center",
"bh_c_define_open",
"bh_c_define_close",
"bh_c_define_content",
"bh_square",
"bh_square_center",
"bh_square_open",
"bh_square_close",
"bh_square_content",
"bh_single_quote",
"bh_single_quote_center",
"bh_single_quote_open",
"bh_single_quote_close",
"bh_single_quote_content",
"bh_curly",
"bh_curly_center",
"bh_curly_open",
"bh_curly_close",
"bh_curly_content",
"bh_double_quote",
"bh_double_quote_center",
"bh_double_quote_open",
"bh_double_quote_close",
"bh_double_quote_content",
"bh_tag",
"bh_tag_center",
"bh_tag_open",
"bh_tag_close",
"bh_tag_content",
"bh_angle",
"bh_angle_center",
"bh_angle_open",
"bh_angle_close",
"bh_angle_content",
"bh_round",
"bh_round_center",
"bh_round_open",
"bh_round_close",
"bh_round_content",
"bh_default",
"bh_default_center",
"bh_default_open",
"bh_default_close",
"bh_default_content",
"bh_regex",
"bh_regex_center",
"bh_regex_open",
"bh_regex_close",
"bh_regex_content",
"bh_unmatched",
"bh_unmatched_center",
"bh_unmatched_open",
"bh_unmatched_close",
"bh_unmatched_content"
],
"incomplete_sync": null,
"remote_loading": false,
"synced": false,
"syntax": "Packages/Ruby/Ruby.sublime-syntax",
"tab_size": 2,
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
}
] ]
} }
], ],
......
package de.vipra.cmd.file;
import java.io.File;
import java.io.IOException;
import de.vipra.cmd.ex.FilebaseException;
import de.vipra.cmd.model.Article;
import de.vipra.util.ex.NotImplementedException;
public class LdacFilebase extends Filebase {
public LdacFilebase(File dataDir) throws FilebaseException {
super(dataDir, "ldac");
// TODO Auto-generated constructor stub
}
@Override
public void add(Article article) throws FilebaseException {
// TODO Auto-generated method stub
}
@Override
public void remove(String id) throws FilebaseException {
throw new NotImplementedException();
}
@Override
public void write() throws IOException {
// TODO Auto-generated method stub
}
}
...@@ -11,23 +11,22 @@ ...@@ -11,23 +11,22 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> <classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes> <attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/vipra-util"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<comment></comment> <comment></comment>
<projects> <projects>
<project>vipra-cmd</project> <project>vipra-cmd</project>
<project>vipra-util</project>
</projects> </projects>
<buildSpec> <buildSpec>
<buildCommand> <buildCommand>
......
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding//src/main/java=UTF-8 encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8 encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8 encoding/<project>=UTF-8
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="util-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/vipra-util/vipra-util">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/vipra-rest/target/classes"/> <property name="java-output-path" value="/vipra-rest/target/classes"/>
<property name="context-root" value="rest"/> <property name="context-root" value="rest"/>
</wb-module> </wb-module>
......
...@@ -92,5 +92,11 @@ ...@@ -92,5 +92,11 @@
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>4.12</version>
</dependency> </dependency>
<dependency>
<groupId>de.vipra</groupId>
<artifactId>util</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
package de.vipra.rest.model;
import java.net.URI;
import java.util.Map;
import de.vipra.util.model.Model;
public abstract class Linked extends Model {
public abstract Map<String, String> getLinks();
public abstract void setLinks(Map<String, String> links);
public abstract void addLink(String name, String link);
public abstract void setBase(URI base);
}
package de.vipra.rest.model;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
public class Topic extends de.vipra.util.model.Topic {
private Map<String, String> links;
public Map<String, String> getLinks() {
return links;
}
public void setLinks(Map<String, String> links) {
this.links = links;
}
public void addLink(String name, String link) {
if (getLinks() == null) {
setLinks(new HashMap<String, String>());
}
links.put(name, link);
}
public void setBase(URI base) {
URI self = uri(base);
if (self != null) {
addLink("self", self.toString());
}
}
}
...@@ -142,7 +142,6 @@ public class ArticleResource { ...@@ -142,7 +142,6 @@ public class ArticleResource {
"item could not be updated due to an internal server error")); "item could not be updated due to an internal server error"));
return Response.serverError().entity(res).build(); return Response.serverError().entity(res).build();
} }
} }
} }
package de.vipra.rest.resource;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import de.vipra.rest.APIMediaType;
import de.vipra.rest.Messages;
import de.vipra.rest.model.APIError;
import de.vipra.rest.model.ResponseWrapper;
import de.vipra.rest.model.Topic;
import de.vipra.util.Config;
import de.vipra.util.Constants;
import de.vipra.util.ex.ConfigException;
import de.vipra.util.ex.DatabaseException;
import de.vipra.util.service.DatabaseService;
@Path("topics")
public class TopicResource {
@Context
UriInfo uri;
DatabaseService<Topic> service;
public TopicResource(@Context ServletContext servletContext) throws ConfigException, IOException {
Config config = Config.getConfig();
service = DatabaseService.getDatabaseService(config, Constants.Collection.TOPICS, Topic.class);
}
@GET
@Produces(APIMediaType.APPLICATION_JSONAPI)
public Response getTopics(@QueryParam("skip") @DefaultValue("0") int skip,
@QueryParam("limit") @DefaultValue("0") int limit) {
ArrayList<Topic> topics = service.getMultiple(skip, limit, null);
ResponseWrapper<ArrayList<Topic>> res = new ResponseWrapper<>(topics);
res.addLink("self", uri.getAbsolutePath().toString());
return Response.ok().entity(res).build();
}
@GET
@Produces(APIMediaType.APPLICATION_JSONAPI)
@Consumes(APIMediaType.APPLICATION_JSONAPI)
@Path("{id}")
public Response getTopic(@PathParam("id") String id) {
ResponseWrapper<Topic> res = new ResponseWrapper<>();
if (id == null || id.trim().length() == 0) {
res.addError(new APIError(Response.Status.BAD_REQUEST, "ID is empty",
String.format(Messages.BAD_REQUEST, "id cannot be empty")));
return Response.status(Response.Status.BAD_REQUEST).entity(res).build();
}
Topic topic = service.getSingle(id);
if (topic != null) {
topic.setBase(uri.getAbsolutePath());
res.setData(topic);
return Response.ok().entity(res).build();
} else {
res.addError(new APIError(Response.Status.NOT_FOUND, "Resource not found",
String.format(Messages.NOT_FOUND, "topic", id)));
return Response.status(Response.Status.NOT_FOUND).entity(res).build();
}
}
@PUT
@Consumes(APIMediaType.APPLICATION_JSONAPI)
@Produces(APIMediaType.APPLICATION_JSONAPI)
@Path("{id}")
public Response updateTopic(@PathParam("id") String id, Topic topic) {
ResponseWrapper<Topic> res = new ResponseWrapper<>();
try {
long updated = service.updateSingle(topic);
int updatedInt = updated > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) updated;
switch (updatedInt) {
case 0:
res.addError(new APIError(Response.Status.NOT_FOUND, "Topic not found",
String.format(Messages.NOT_FOUND, "topic", id)));
return Response.status(Response.Status.NOT_FOUND).entity(res).build();
case 1:
res.setData(topic);
return Response.ok().entity(res).build();
default:
return Response.serverError().build();
}
} catch (DatabaseException e) {
res = new ResponseWrapper<>(new APIError(Response.Status.INTERNAL_SERVER_ERROR, "item could not be updated",
"item could not be updated due to an internal server error"));
return Response.serverError().entity(res).build();
}
}
}
...@@ -17,5 +17,11 @@ ...@@ -17,5 +17,11 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.vipra</groupId> <groupId>de.vipra</groupId>
<artifactId>vipra-util</artifactId> <artifactId>util</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<properties> <properties>
......
...@@ -12,6 +12,8 @@ import org.bson.types.ObjectId; ...@@ -12,6 +12,8 @@ import org.bson.types.ObjectId;
public class MongoUtils { public class MongoUtils {
public static Bson getSorts(String sortBy) { public static Bson getSorts(String sortBy) {
if (sortBy == null)
return null;
String[] sortKeys = sortBy.split(","); String[] sortKeys = sortBy.split(",");
ArrayList<Bson> sorts = new ArrayList<Bson>(sortKeys.length); ArrayList<Bson> sorts = new ArrayList<Bson>(sortKeys.length);
for (String sort : sortKeys) { for (String sort : sortKeys) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment