Skip to content

Commit

Permalink
#8: crce-webui module moved to core, version increased to 2.1.2-SNAPS…
Browse files Browse the repository at this point in the history
…HOT.
  • Loading branch information
Cajova-Houba committed Jan 3, 2019
1 parent 9bd1377 commit a0b3a69
Show file tree
Hide file tree
Showing 72 changed files with 3,560 additions and 3,521 deletions.
14 changes: 14 additions & 0 deletions build/compiled/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@
<optional>true</optional>
<scope>provided</scope>
</dependency>

<!-- crce-webui -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>
</dependencies>

</project>
17 changes: 17 additions & 0 deletions build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,23 @@

<dependencyManagement>
<dependencies>
<!-- crce-webui -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.9.1</version>
</dependency>

<!-- <dependency>
| dependency pom representing the global classpath of imported bundles
Expand Down
File renamed without changes.
23 changes: 14 additions & 9 deletions modules/crce-webui/pom.xml → core/crce-webui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<relativePath>../pom</relativePath>
<groupId>cz.zcu.kiv.crce</groupId>
<artifactId>crce-modules-parent</artifactId>
<version>2.1.1-SNAPSHOT</version>
<artifactId>compiled-bundle-settings</artifactId>
<version>2.1.2-SNAPSHOT</version>
<relativePath />
</parent>

<artifactId>crce-webui</artifactId>
<version>2.1.2-SNAPSHOT</version>
<packaging>war</packaging>

<name>CRCE - Web UI</name>

<properties>
<bundle.symbolicName>${namespace}.webui</bundle.symbolicName>
<bundle.namespace>${namespace}.webui</bundle.namespace>
<compatibility.api.version>2.1.2-SNAPSHOT</compatibility.api.version>
<!-- !!! -->
</properties>

Expand Down Expand Up @@ -135,18 +137,14 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>crce-core</artifactId>
<version>3.0.0-SNAPSHOT</version>
<type>pom</type>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>crce-metadata-osgi-bundle</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>crce-compatibility-api</artifactId>
<version>${project.version}</version>
<version>${compatibility.api.version}</version>
</dependency>

<!-- Test dependencies -->
Expand All @@ -167,14 +165,21 @@
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.bundlerepository</artifactId>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
package cz.zcu.kiv.crce.webui.internal;

import java.io.IOException;
import java.util.Collections;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import cz.zcu.kiv.crce.metadata.Resolver;
import cz.zcu.kiv.crce.metadata.Resource;
//import cz.zcu.kiv.crce.metadata.ResourceCreator;

public class CheckServlet extends HttpServlet {

private static final Logger logger = LoggerFactory.getLogger(CheckServlet.class);

private static final long serialVersionUID = -6116518932972052481L;

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
List<Resource> res = chooseFrom(req);
if (res == null) {
req.getRequestDispatcher("resource").forward(req, resp);
} else {
String source = (String) req.getSession().getAttribute("source");
req.getSession().setAttribute(source, res);
req.getSession().removeAttribute("source");
req.getRequestDispatcher("jsp/" + source + ".jsp").forward(req, resp);
}

}

private List<Resource> chooseFrom(HttpServletRequest req) {
String source = (String) req.getSession().getAttribute("source");
if (source == null) {
return null;
} else if (source.equals("buffer")) {
return doCheck(Activator.instance().getBuffer(req).getResources());
} else if (source.equals("store")) {
return doCheck(Activator.instance().getStore(null).getResources());
} else {
return null;
}
}

private List<Resource> doCheck(List<Resource> resources) {
logger.warn("Resolver is not designed yet in new Metadata API, returning empty list of resources. Checked resource: {}", resources);
// Resource[] resources = repository.getResources();
// Resource[] cloned = new Resource[resources.length];
// System.arraycopy(resources, 0, cloned, 0, resources.length);
// ArrayList<Resource> ext = new ArrayList<>();
// HashMap<URI, Resource> extMap = new HashMap<>();
// ResourceCreator rc = Activator.instance().getCreator();
// Resolver resolver = rc.createResolver(repository);
// for (Resource r : cloned) {
// resolver.add(r);
// r.getUri();
// extMap.put(r.getUri(), new ResourceExt(r));
// ext.add(new ResourceExt(r));
// }
// if (!resolver.resolve()) {
// for (Reason r : resolver.getUnsatisfiedRequirements()) {
// if (extMap.containsKey(r.getResource().getUri())) {
// extMap.get(r.getResource().getUri()).addRequirement(r.getRequirement());
// }
//
// }
// return extMap.values().toArray(new Resource[extMap.values().size()]);
// } else {
// return resources;
// }
return Collections.emptyList();
}
}
package cz.zcu.kiv.crce.webui.internal;

import java.io.IOException;
import java.util.Collections;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import cz.zcu.kiv.crce.metadata.Resolver;
import cz.zcu.kiv.crce.metadata.Resource;
//import cz.zcu.kiv.crce.metadata.ResourceCreator;

public class CheckServlet extends HttpServlet {

private static final Logger logger = LoggerFactory.getLogger(CheckServlet.class);

private static final long serialVersionUID = -6116518932972052481L;

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
List<Resource> res = chooseFrom(req);
if (res == null) {
req.getRequestDispatcher("resource").forward(req, resp);
} else {
String source = (String) req.getSession().getAttribute("source");
req.getSession().setAttribute(source, res);
req.getSession().removeAttribute("source");
req.getRequestDispatcher("jsp/" + source + ".jsp").forward(req, resp);
}

}

private List<Resource> chooseFrom(HttpServletRequest req) {
String source = (String) req.getSession().getAttribute("source");
if (source == null) {
return null;
} else if (source.equals("buffer")) {
return doCheck(Activator.instance().getBuffer(req).getResources());
} else if (source.equals("store")) {
return doCheck(Activator.instance().getStore(null).getResources());
} else {
return null;
}
}

private List<Resource> doCheck(List<Resource> resources) {
logger.warn("Resolver is not designed yet in new Metadata API, returning empty list of resources. Checked resource: {}", resources);
// Resource[] resources = repository.getResources();
// Resource[] cloned = new Resource[resources.length];
// System.arraycopy(resources, 0, cloned, 0, resources.length);
// ArrayList<Resource> ext = new ArrayList<>();
// HashMap<URI, Resource> extMap = new HashMap<>();
// ResourceCreator rc = Activator.instance().getCreator();
// Resolver resolver = rc.createResolver(repository);
// for (Resource r : cloned) {
// resolver.add(r);
// r.getUri();
// extMap.put(r.getUri(), new ResourceExt(r));
// ext.add(new ResourceExt(r));
// }
// if (!resolver.resolve()) {
// for (Reason r : resolver.getUnsatisfiedRequirements()) {
// if (extMap.containsKey(r.getResource().getUri())) {
// extMap.get(r.getResource().getUri()).addRequirement(r.getRequirement());
// }
//
// }
// return extMap.values().toArray(new Resource[extMap.values().size()]);
// } else {
// return resources;
// }
return Collections.emptyList();
}
}
Loading

0 comments on commit a0b3a69

Please sign in to comment.