diff --git a/ccm-cms-publicpersonalprofile/src/ccm-cms-publicpersonalprofile.load b/ccm-cms-publicpersonalprofile/src/ccm-cms-publicpersonalprofile.load index ab7433b96..5aa08522d 100644 --- a/ccm-cms-publicpersonalprofile/src/ccm-cms-publicpersonalprofile.load +++ b/ccm-cms-publicpersonalprofile/src/ccm-cms-publicpersonalprofile.load @@ -9,10 +9,13 @@ +
+ + \ No newline at end of file diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfile.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfile.java new file mode 100644 index 000000000..71a54ae28 --- /dev/null +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfile.java @@ -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/"; + } +} diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileInitializer.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileInitializer.java new file mode 100644 index 000000000..a1db18d21 --- /dev/null +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileInitializer.java @@ -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); + } + }); + } +} diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileLoader.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileLoader.java new file mode 100644 index 000000000..b91d0588f --- /dev/null +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileLoader.java @@ -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(); + + + } +} diff --git a/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileServlet.java b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileServlet.java new file mode 100644 index 000000000..31b05de15 --- /dev/null +++ b/ccm-cms-publicpersonalprofile/src/com/arsdigita/cms/publicpersonalprofile/PublicPersonalProfileServlet.java @@ -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); + } + + } +} diff --git a/ccm-sci-publications/pdl/com/arsdigita/scipublications/SciPublications.pdl b/ccm-sci-publications/pdl/com/arsdigita/scipublications/SciPublications.pdl index 32aacb911..256872b5c 100644 --- a/ccm-sci-publications/pdl/com/arsdigita/scipublications/SciPublications.pdl +++ b/ccm-sci-publications/pdl/com/arsdigita/scipublications/SciPublications.pdl @@ -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 diff --git a/ccm-sci-publications/web/__ccm__/apps/publicpersonalprofile/xsl/index.xsl b/ccm-sci-publications/web/__ccm__/apps/publicpersonalprofile/xsl/index.xsl new file mode 100644 index 000000000..c6921a246 --- /dev/null +++ b/ccm-sci-publications/web/__ccm__/apps/publicpersonalprofile/xsl/index.xsl @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file