added the mechanisms to manage community services, and the community-level

pages for doing so
This commit is contained in:
Eric J. Bowersox
2003-06-19 22:55:45 +00:00
parent c8b6a513b9
commit c6a86a167f
15 changed files with 540 additions and 1 deletions

View File

@@ -0,0 +1,64 @@
// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(java.lang);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.except);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.security);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importPackage(Packages.com.silverwrist.venice.community);
importPackage(Packages.com.silverwrist.venice.content);
importPackage(Packages.com.silverwrist.venice.frame);
importPackage(Packages.com.silverwrist.venice.iface);
req = bsf.lookupBean("request");
req_help = bsf.lookupBean("request_help");
user = vlib.getUser(req);
comm = vlib.getCommunity(req);
// Make sure we are permitted to be here.
acl = comm.getAcl();
if (!(acl.testPermission(user,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"manage.services")))
dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error",
"You are not permitted to modify this community's services."));
// Get the community service object.
commsvc = vcast.queryCommunityService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"communities"));
// Get the currently-defined list of community services.
svclist = commsvc.getAvailableServices();
// Use that to create a list of which services we have and which services we don't.
mainlist = new ArrayList();
it = svclist.iterator();
while (it.hasNext())
{ // create list entries and add them
csd = vcast.toCommunityServiceDescriptor(it.next());
tmp = new HashMap();
tmp.put("id",cast.toIntegerObject(csd.index));
tmp.put("descr",csd.description);
tmp.put("using",cast.toBooleanObject(comm.isUsingService(csd.name.namespace,csd.name.name)));
mainlist.add(tmp);
} // end while
// Create and return the view.
rc = new VelocityView(comm.name + ": Community Services","comm/admin/services.vm");
rc.setParameter("community",comm);
rc.setParameter("services",mainlist);
dynamo.scriptOutput(rc);

View File

@@ -0,0 +1,55 @@
// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(java.lang);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.except);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.security);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importPackage(Packages.com.silverwrist.venice.community);
importPackage(Packages.com.silverwrist.venice.content);
importPackage(Packages.com.silverwrist.venice.frame);
importPackage(Packages.com.silverwrist.venice.iface);
req = bsf.lookupBean("request");
req_help = bsf.lookupBean("request_help");
user = vlib.getUser(req);
comm = vlib.getCommunity(req);
// Make sure we are permitted to be here.
acl = comm.getAcl();
if (!(acl.testPermission(user,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"manage.services")))
dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error",
"You are not permitted to modify this community's services."));
// Get the community service object.
commsvc = vcast.queryCommunityService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"communities"));
// Get the service index.
ndx = req_help.getParameterInt("id",-1);
// Work from there to the service descriptor.
csd = commsvc.getServiceForID(ndx);
if (csd==null)
dynamo.scriptReturn(vlib.stdErrorBox(req,"Internal Error","Service descriptor not found."));
// Now add the service!
comm.addService(user,req,csd.name.namespace,csd.name.name);
// Bounce back to the services list.
dynamo.scriptOutput(new Redirect("SERVLET","comm/admin/services.js.vs"));

View File

@@ -0,0 +1,70 @@
// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(java.lang);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.except);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.security);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importPackage(Packages.com.silverwrist.venice.community);
importPackage(Packages.com.silverwrist.venice.content);
importPackage(Packages.com.silverwrist.venice.frame);
importPackage(Packages.com.silverwrist.venice.iface);
req = bsf.lookupBean("request");
req_help = bsf.lookupBean("request_help");
user = vlib.getUser(req);
comm = vlib.getCommunity(req);
// Make sure we are permitted to be here.
acl = comm.getAcl();
if (!(acl.testPermission(user,VeniceNamespaces.COMMUNITY_PERMS_NAMESPACE,"manage.services")))
dynamo.scriptReturn(vlib.stdErrorBox(req,"Security Error",
"You are not permitted to modify this community's services."));
// Get the community service object.
commsvc = vcast.queryCommunityService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"communities"));
// Get the service index.
ndx = req_help.getParameterInt("id",-1);
// Work from there to the service descriptor.
csd = commsvc.getServiceForID(ndx);
if (csd==null)
dynamo.scriptReturn(vlib.stdErrorBox(req,"Internal Error","Service descriptor not found."));
rc = null;
if (vlib.confirmed(req,"/comm/admin/svc_remove.js.vs","confirmation","confnum"))
{ // remove the service!
comm.removeService(user,req,csd.name.namespace,csd.name.name);
rc = new Redirect("SERVLET","comm/admin/services.js.vs");
} // end if
else
{ // create the confirmation dialog
msg = "You are about to remove the service " + csd.name.namespace + "::" + csd.name.name + " from the community '"
+ comm.name + "'! This may cause any and all data associated with this service in the community (such as "
+ "database table contents) to be <b>DESTROYED AND IRREVOCABLY LOST!</b> Are you <em>really</em> sure you "
+ "want to do this?";
rc = new ConfirmBox(req,"/comm/admin/svc_remove.js.vs","confirmation","confnum","Service Remove Confirmation",msg,
"SERVLET","comm/admin/svc_remove.js.vs?cc=" + comm.getCID() + "&id=" + ndx,"SERVLET",
"comm/admin/services.js.vs");
} // end else
dynamo.scriptOutput(rc);

View File

@@ -0,0 +1,63 @@
#*
The contents of this file are subject to the Mozilla Public License Version 1.1
(the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License.
The Original Code is the Venice Web Communities System.
The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
Contributor(s):
*#
#*
Parameters:
community = Community we're displaying the services of.
services = List of all available services, with an indication as to whether we're using them.
*#
#header2( "Community Services", $community.Name )
<p><a href="#formatURL( "SERVLET" "comm/admin/main.js.vs" )">Return to Previous Menu</a></p>
#if( $services.isEmpty() )
<p><em>There are no community-level services currently defined.</em></p>
#else
<p>Your community may make use of any or all of the following services. Click the appropriate buttons to
add or remove services for your community.</p>
<div align="center"><table border="1" cellpadding="2" cellspacing="0">
<tr>
<th><b>In Use?</b></th>
<th><b>Service Description</b></th>
<th>&nbsp;</th>
</tr>
#set( $cid = $community.getCID() )
#foreach( $s in $services )
<tr>
<td>
#if( $s.using )
<b>Yes</b>
#else
&nbsp;
#end
</td>
<td>
#if( $s.using )
<b>#encodeHTML( $s.descr )</b>
#else
#encodeHTML( $s.descr )
#end
</td>
<td>
#if( $s.using )
<a href="#formatURL( "SERVLET" "comm/admin/svc_remove.js.vs?cc=$cid&id=$s.id" )">#button( "IMAGE" "remove" )</a>
#else
<a href="#formatURL( "SERVLET" "comm/admin/svc_add.js.vs?cc=$cid&id=$s.id" )">#button( "IMAGE" "add" )</a>
#end
</td>
</tr>
#end
</table></div>
#end