01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/integration/api-impl/src/java/org/theospi/portfolio/admin/service/SiteIntegrationPlugin.java $
03: * $Id: SiteIntegrationPlugin.java 11372 2006-06-29 14:58:30Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.theospi.portfolio.admin.service;
21:
22: import org.sakaiproject.exception.IdInvalidException;
23: import org.sakaiproject.exception.IdUnusedException;
24: import org.sakaiproject.exception.IdUsedException;
25: import org.sakaiproject.exception.PermissionException;
26: import org.sakaiproject.site.api.Site;
27: import org.sakaiproject.site.api.SiteService;
28: import org.theospi.portfolio.admin.model.IntegrationOption;
29: import org.theospi.portfolio.shared.model.OspException;
30:
31: /**
32: * Created by IntelliJ IDEA.
33: * User: John Ellis
34: * Date: Mar 2, 2006
35: * Time: 1:38:40 PM
36: * To change this template use File | Settings | File Templates.
37: */
38: public class SiteIntegrationPlugin extends IntegrationPluginBase {
39:
40: private SiteService siteService;
41:
42: public IntegrationOption updateOption(IntegrationOption option) {
43: SiteOption siteOption = (SiteOption) option;
44:
45: try {
46: Site site = getSiteService()
47: .getSite(siteOption.getSiteId());
48: if (site != null) {
49: return siteOption;
50: }
51: } catch (IdUnusedException e) {
52: // no site found... this means we should go on and create it.
53: }
54:
55: try {
56: Site site = getSiteService().addSite(
57: siteOption.getSiteId(), siteOption.getSiteType());
58:
59: site.setTitle(siteOption.getSiteTitle());
60: site.setDescription(siteOption.getSiteDescription());
61: site.setPublished(true);
62:
63: getSiteService().save(site);
64: } catch (IdInvalidException e) {
65: throw new OspException(e);
66: } catch (IdUsedException e) {
67: throw new OspException(e);
68: } catch (PermissionException e) {
69: throw new OspException(e);
70: } catch (IdUnusedException e) {
71: throw new OspException(e);
72: }
73:
74: return siteOption;
75: }
76:
77: public boolean executeOption(IntegrationOption option) {
78: updateOption(option);
79: return true;
80: }
81:
82: public SiteService getSiteService() {
83: return siteService;
84: }
85:
86: public void setSiteService(SiteService siteService) {
87: this.siteService = siteService;
88: }
89: }
|