Erster Teil der Application zum Anzeigen der persönlichen Profile.
git-svn-id: https://svn.libreccm.org/ccm/trunk@1040 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
75eeb3b7c6
commit
af9d21ff90
|
|
@ -9,10 +9,13 @@
|
|||
</requires>
|
||||
<provides>
|
||||
<table name="ct_public_personal_profiles"/>
|
||||
<table name="publicpersonalprofile"/>
|
||||
<initializer class="com.arsdigita.cms.contenttypes.PublicPersonalProfileInitializer"/>
|
||||
<initializer class="com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileInitializer"/>
|
||||
</provides>
|
||||
<scripts>
|
||||
<schema directory="ccm-cms-publicpersonalprofile"/>
|
||||
<data class="com.arsdigita.cms.contenttypes.PublicPersonalProfileLoader"/>
|
||||
<data class="com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfileLoader"/>
|
||||
</scripts>
|
||||
</load>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.OID;
|
||||
import com.arsdigita.web.Application;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PublicPersonalProfile extends Application {
|
||||
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.publicpersonalprofile.PublicPersonalProfile";
|
||||
|
||||
public PublicPersonalProfile(final DataObject dobj) {
|
||||
super(dobj);
|
||||
}
|
||||
|
||||
public PublicPersonalProfile(final OID oid)
|
||||
throws DataObjectNotFoundException {
|
||||
super(oid);
|
||||
}
|
||||
|
||||
public PublicPersonalProfile(final BigDecimal id)
|
||||
throws DataObjectNotFoundException {
|
||||
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServletPath() {
|
||||
return "/profiles/";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.db.DbHelper;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.kernel.ACSObjectInstantiator;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.pdl.ManifestSource;
|
||||
import com.arsdigita.persistence.pdl.NameFilter;
|
||||
import com.arsdigita.runtime.CompoundInitializer;
|
||||
import com.arsdigita.runtime.DomainInitEvent;
|
||||
import com.arsdigita.runtime.PDLInitializer;
|
||||
import com.arsdigita.runtime.RuntimeConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PublicPersonalProfileInitializer extends CompoundInitializer {
|
||||
|
||||
public PublicPersonalProfileInitializer() {
|
||||
final String jdbcUrl = RuntimeConfig.getConfig().getJDBCURL();
|
||||
final int database = DbHelper.getDatabaseFromURL(jdbcUrl);
|
||||
|
||||
add(new PDLInitializer(new ManifestSource("empty.pdl.mf",
|
||||
new NameFilter(DbHelper.
|
||||
getDatabaseSuffix(database), "pdl"))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(DomainInitEvent event) {
|
||||
super.init(event);
|
||||
|
||||
DomainObjectFactory.registerInstantiator(
|
||||
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE,
|
||||
new ACSObjectInstantiator() {
|
||||
|
||||
@Override
|
||||
public DomainObject doNewInstance(
|
||||
final DataObject dataObject) {
|
||||
return new PublicPersonalProfile(dataObject);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.kernel.ACSObjectInstantiator;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
import com.arsdigita.kernel.KernelExcursion;
|
||||
import com.arsdigita.loader.PackageLoader;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.runtime.ScriptContext;
|
||||
import com.arsdigita.web.Application;
|
||||
import com.arsdigita.web.ApplicationSetup;
|
||||
import com.arsdigita.web.ApplicationType;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PublicPersonalProfileLoader extends PackageLoader {
|
||||
|
||||
private static final Logger logger =
|
||||
Logger.getLogger(
|
||||
PublicPersonalProfileLoader.class);
|
||||
|
||||
@Override
|
||||
public void run(final ScriptContext ctx) {
|
||||
|
||||
new KernelExcursion() {
|
||||
|
||||
@Override
|
||||
protected void excurse() {
|
||||
setEffectiveParty(Kernel.getSystemParty());
|
||||
|
||||
/*ApplicationSetup setup = new ApplicationSetup(logger);
|
||||
|
||||
setup.setApplicationObjectType(
|
||||
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||
setup.setKey("profiles");
|
||||
setup.setTitle("PublicPersonalProfile");
|
||||
setup.setDescription("Display public personal profiles");
|
||||
|
||||
setup.setInstantiator(new ACSObjectInstantiator() {
|
||||
|
||||
@Override
|
||||
public DomainObject doNewInstance(
|
||||
final DataObject dataObject) {
|
||||
return new PublicPersonalProfile(dataObject);
|
||||
}
|
||||
});
|
||||
|
||||
ApplicationType type = setup.run();
|
||||
type.save();
|
||||
|
||||
if (!Application.isInstalled(
|
||||
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE,
|
||||
"/profiles/")) {
|
||||
/*Application app = Application.createRootApplication(type,
|
||||
"profiles",
|
||||
false);*/
|
||||
/*Application app = Application.createApplication(type,
|
||||
"profiles",
|
||||
"profiles",
|
||||
null);
|
||||
|
||||
app.save();
|
||||
}*/
|
||||
|
||||
ApplicationType type =
|
||||
new ApplicationType("PublicPersonalProfile",
|
||||
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE);
|
||||
type.setDescription("PublicPersonalProfile Viewer");
|
||||
|
||||
Application.createApplication(
|
||||
PublicPersonalProfile.BASE_DATA_OBJECT_TYPE,
|
||||
"profiles",
|
||||
"PublicPersonalProfiles",
|
||||
null);
|
||||
}
|
||||
}.run();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
package com.arsdigita.cms.publicpersonalprofile;
|
||||
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageFactory;
|
||||
import com.arsdigita.templating.PresentationManager;
|
||||
import com.arsdigita.templating.Templating;
|
||||
import com.arsdigita.web.Application;
|
||||
import com.arsdigita.web.BaseApplicationServlet;
|
||||
import com.arsdigita.xml.Document;
|
||||
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
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PublicPersonalProfileServlet extends BaseApplicationServlet {
|
||||
|
||||
private static final long serialVersionUID = -1495852395804455609L;
|
||||
private static final Logger logger =
|
||||
Logger.getLogger(
|
||||
PublicPersonalProfileServlet.class);
|
||||
|
||||
@Override
|
||||
protected void doService(final HttpServletRequest request,
|
||||
final HttpServletResponse response,
|
||||
final Application app) throws ServletException,
|
||||
IOException {
|
||||
String path = "";
|
||||
|
||||
logger.debug("PublicPersonalProfileServlet 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));
|
||||
|
||||
//Displays a text/plain page with a message.
|
||||
if (path.isEmpty()) {
|
||||
logger.debug("pathInfo is null, responding with default...");
|
||||
|
||||
response.setContentType("text/plain");
|
||||
response.getWriter().append("Please choose an application.");
|
||||
} else {
|
||||
Page page;
|
||||
Form form;
|
||||
Label label;
|
||||
|
||||
page = PageFactory.buildPage("SciPublications",
|
||||
"Hello World from profiles");
|
||||
form = new Form("HelloWorld");
|
||||
label = new Label(String.format("Hello World! From profiles, path = %s", path));
|
||||
|
||||
form.add(label);
|
||||
page.add(form);
|
||||
|
||||
page.lock();
|
||||
|
||||
Document document = page.buildDocument(request, response);
|
||||
PresentationManager presentationManager = Templating.
|
||||
getPresentationManager();
|
||||
presentationManager.servePage(document, request, response);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
//
|
||||
// Copyright (C) 2011 Jens Pelzetter, for the Center of Social Politics (ZeS) of
|
||||
// the University of Bremen
|
||||
// Copyright (C) 2011 Jens Pelzetter
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<xsl:stylesheet
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<xsl:import href="../../../../packages/bebop/xsl/bebop.xsl"/>
|
||||
<xsl:import href="../../../../packages/ui/xsl/ui.xsl"/>
|
||||
<xsl:import href="../../../../packages/content-section/xsl/cms-public.xsl"/>
|
||||
<xsl:import href="../../../../packages/content-section/xsl/cms-item.xsl"/>
|
||||
|
||||
</xsl:stylesheet>
|
||||
Loading…
Reference in New Issue