Name der Application für SciPublications geändert. Die Application wird alle Funktionen (Export, Import, ...) anbieten, es wird keine eigenständigen Apps für Import und Export geben.

git-svn-id: https://svn.libreccm.org/ccm/trunk@729 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-02-02 21:01:18 +00:00
parent 7afcab2687
commit 2c89d68f98
10 changed files with 103 additions and 55 deletions

View File

@ -62,6 +62,7 @@ public class BebopApplicationServlet extends BaseApplicationServlet {
* *
* @throws ServletException * @throws ServletException
*/ */
@Override
public void init() throws ServletException { public void init() throws ServletException {
super.init(); super.init();
} }
@ -83,7 +84,7 @@ public class BebopApplicationServlet extends BaseApplicationServlet {
/** /**
* *
* disable client/middleware caching of specified page. * disable client/middleware caching of specified page.
* @param pathinfo - the same path used to add the page when put was called * @param pathInfo - the same path used to add the page when put was called
*/ */
protected final void disableClientCaching(String pathInfo) { protected final void disableClientCaching(String pathInfo) {
Assert.exists(pathInfo, String.class); Assert.exists(pathInfo, String.class);

View File

@ -26,7 +26,6 @@ import com.arsdigita.persistence.TransactionContext;
import com.arsdigita.profiler.Profiler; import com.arsdigita.profiler.Profiler;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.util.StringUtils; import com.arsdigita.util.StringUtils;
import com.arsdigita.web.Application;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;

View File

@ -23,6 +23,6 @@ model com.arsdigita.cms.scipublications;
import com.arsdigita.web.Application; import com.arsdigita.web.Application;
object type PublicationExporter extends Application { object type SciPublications extends Application {
reference key (publication_exporter.application_id); reference key (scipublications.application_id);
} }

View File

@ -42,7 +42,7 @@
<initializer class="com.arsdigita.cms.contenttypes.ExpertiseInitializer"/> <initializer class="com.arsdigita.cms.contenttypes.ExpertiseInitializer"/>
<initializer class="com.arsdigita.cms.contenttypes.ReviewInitializer"/> <initializer class="com.arsdigita.cms.contenttypes.ReviewInitializer"/>
<initializer class="com.arsdigita.cms.contenttypes.SciAuthorInitializer"/> <initializer class="com.arsdigita.cms.contenttypes.SciAuthorInitializer"/>
<initializer class="com.arsdigita.cms.scipublications.PublicationExporterInitializer"/> <initializer class="com.arsdigita.cms.scipublications.SciPublicationsInitializer"/>
</provides> </provides>
<scripts> <scripts>
<schema directory="ccm-sci-publications"/> <schema directory="ccm-sci-publications"/>
@ -64,6 +64,6 @@
<data class="com.arsdigita.cms.contenttypes.ExpertiseLoader"/> <data class="com.arsdigita.cms.contenttypes.ExpertiseLoader"/>
<data class="com.arsdigita.cms.contenttypes.ReviewLoader"/> <data class="com.arsdigita.cms.contenttypes.ReviewLoader"/>
<data class="com.arsdigita.cms.contenttypes.SciAuthorLoader"/> <data class="com.arsdigita.cms.contenttypes.SciAuthorLoader"/>
<data class="com.arsdigita.cms.scipublications.PublicationExporterLoader"/> <data class="com.arsdigita.cms.scipublications.SciPublicationsLoader"/>
</scripts> </scripts>
</load> </load>

View File

@ -1,27 +0,0 @@
package com.arsdigita.cms.scipublications;
import com.arsdigita.web.Application;
import com.arsdigita.web.BaseApplicationServlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author Jens Pelzetter
*/
public class PublicationExporterServlet extends BaseApplicationServlet {
private static final long serialVersionUID = -632365939651657874L;
@Override
protected void doService(HttpServletRequest request,
HttpServletResponse response,
Application app) throws ServletException,
IOException {
response.setContentType("application/text");
response.setHeader("Content-Disposition", "attachment; filename=ccm-publication-exporter.txt");
response.getWriter().append("This is the sci-publication-exporter");
}
}

View File

@ -10,25 +10,25 @@ import java.math.BigDecimal;
* *
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class PublicationExporter extends Application { public class SciPublications extends Application {
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.scipublications.PublicationExporter"; public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.scipublications.SciPublications";
public PublicationExporter(DataObject dobj) { public SciPublications(DataObject dobj) {
super(dobj); super(dobj);
} }
public PublicationExporter(OID oid) throws DataObjectNotFoundException{ public SciPublications(OID oid) throws DataObjectNotFoundException{
super(oid); super(oid);
} }
public PublicationExporter(BigDecimal key) throws DataObjectNotFoundException { public SciPublications(BigDecimal key) throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, key)); this(new OID(BASE_DATA_OBJECT_TYPE, key));
} }
@Override @Override
public String getServletPath() { public String getServletPath() {
return "/scipublicationsexporter/"; return "/scipublications/";
} }
} }

View File

@ -12,9 +12,9 @@ import com.arsdigita.runtime.RuntimeConfig;
* *
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class PublicationExporterInitializer extends CompoundInitializer { public class SciPublicationsInitializer extends CompoundInitializer {
public PublicationExporterInitializer() { public SciPublicationsInitializer() {
final String url = RuntimeConfig.getConfig().getJDBCURL(); final String url = RuntimeConfig.getConfig().getJDBCURL();
final int database = DbHelper.getDatabaseFromURL(url); final int database = DbHelper.getDatabaseFromURL(url);

View File

@ -16,10 +16,10 @@ import org.apache.log4j.Logger;
* *
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class PublicationExporterLoader extends PackageLoader { public class SciPublicationsLoader extends PackageLoader {
private static final Logger logger = Logger.getLogger( private static final Logger logger = Logger.getLogger(
PublicationExporterLoader.class); SciPublicationsLoader.class);
@Override @Override
public void run(final ScriptContext ctx) { public void run(final ScriptContext ctx) {
@ -33,16 +33,16 @@ public class PublicationExporterLoader extends PackageLoader {
ApplicationSetup setup = new ApplicationSetup(logger); ApplicationSetup setup = new ApplicationSetup(logger);
setup.setApplicationObjectType( setup.setApplicationObjectType(
PublicationExporter.BASE_DATA_OBJECT_TYPE); SciPublications.BASE_DATA_OBJECT_TYPE);
setup.setKey("scipubliationsexporter"); setup.setKey("scipubliations");
setup.setTitle("sci-publication Exporter"); setup.setTitle("sci-publications");
setup.setDescription( setup.setDescription(
"Exports publication data in various formats"); "Provides several functions like export and import for publications.");
//setup.setSingleton(true); //setup.setSingleton(true);
setup.setInstantiator(new ACSObjectInstantiator() { setup.setInstantiator(new ACSObjectInstantiator() {
@Override @Override
public DomainObject doNewInstance(DataObject dataObject) { public DomainObject doNewInstance(DataObject dataObject) {
return new PublicationExporter(dataObject); return new SciPublications(dataObject);
} }
}); });
@ -50,10 +50,10 @@ public class PublicationExporterLoader extends PackageLoader {
type.save(); type.save();
if (!Application.isInstalled( if (!Application.isInstalled(
PublicationExporter.BASE_DATA_OBJECT_TYPE, "/scipublicationsexporter/")) { SciPublications.BASE_DATA_OBJECT_TYPE, "/scipublications/")) {
Application app = Application.createApplication(type, Application app = Application.createApplication(type,
"scipublicationsexporter", "scipublications",
"PublicationExporter", "SciPublications",
null); null);
app.save(); app.save();
} }

View File

@ -0,0 +1,75 @@
package com.arsdigita.cms.scipublications;
import com.arsdigita.web.Application;
import com.arsdigita.web.BaseApplicationServlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
/**
*
* @author Jens Pelzetter
*/
public class SciPublicationsServlet extends BaseApplicationServlet {
private static final long serialVersionUID = -632365939651657874L;
private static final Logger logger = Logger.getLogger(
SciPublicationsServlet.class);
@Override
protected void doService(HttpServletRequest request,
HttpServletResponse response,
Application app) throws ServletException,
IOException {
String path = "";
logger.debug("SciPublicationsServlet is starting...");
logger.debug(String.format("pathInfo = '%s'", request.getPathInfo()));
logger.debug("Extracting path from pathInfo by removing leading and "
+ "trailing slashes...");
if (request.getPathInfo() != null) {
if ("/".equals(request.getPathInfo())) {
path = "";
} else if (request.getPathInfo().startsWith("/")
&& request.getPathInfo().endsWith("/")) {
path = request.getPathInfo().substring(1, request.getPathInfo().
length() - 1);
} else if (request.getPathInfo().startsWith("/")) {
path = request.getPathInfo().substring(1);
} else if (request.getPathInfo().endsWith("/")) {
path = request.getPathInfo().substring(0, request.getPathInfo().
length() - 1);
} else {
path = request.getPathInfo();
}
}
logger.debug(String.format("path = %s", path));
if (path.isEmpty()) {
logger.debug("pathInfo is null, responding with default...");
/*response.setContentType("application/text");
response.setHeader("Content-Disposition",
"attachment; filename=ccm-publication-exporter.txt");
response.getWriter().append("This is the sci-publication-exporter");*/
response.setContentType("text/plain");
response.getWriter().append("Please choose an application.");
//ToDo: Show a menu?
} else if("export".equals(path)) {
logger.debug("Export a publication");
response.setContentType("text/plain");
response.getWriter().append("Calling exporter...");
//ToDo: Call the exporter here.
} else {
logger.debug("Unknown pathinfo, responding with 404...");
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
}
}

View File

@ -6,13 +6,13 @@
<!-- Servlets for the sci-publications applications --> <!-- Servlets for the sci-publications applications -->
<servlet> <servlet>
<servlet-name>PublicationExporter</servlet-name> <servlet-name>SciPublications</servlet-name>
<servlet-class>com.arsdigita.cms.scipublications.PublicationExporterServlet</servlet-class> <servlet-class>com.arsdigita.cms.scipublications.SciPublicationsServlet</servlet-class>
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
<servlet-name>PublicationExporter</servlet-name> <servlet-name>SciPublications</servlet-name>
<url-pattern>/scipublicationsexporter/*</url-pattern> <url-pattern>/scipublications/*</url-pattern>
</servlet-mapping> </servlet-mapping>
</web-app> </web-app>