mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
First cut of a calendar crud service (for review)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28785 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
141
source/java/org/alfresco/repo/calendar/CalendarEntryImpl.java
Normal file
141
source/java/org/alfresco/repo/calendar/CalendarEntryImpl.java
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.calendar;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.CannedQueryFactory;
|
||||
import org.alfresco.query.CannedQueryResults;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQuery;
|
||||
import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQueryFactory;
|
||||
import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQuery;
|
||||
import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.calendar.CalendarEntry;
|
||||
import org.alfresco.service.cmr.calendar.CalendarService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.alfresco.util.registry.NamedObjectRegistry;
|
||||
|
||||
/**
|
||||
* @author Nick Burch (based on existing webscript controllers in the REST API)
|
||||
* @since 4.0
|
||||
*/
|
||||
public class CalendarEntryImpl implements CalendarEntry
|
||||
{
|
||||
private NodeRef nodeRef;
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* Creates an empty Calendar Entry
|
||||
*/
|
||||
public CalendarEntryImpl()
|
||||
{}
|
||||
|
||||
/**
|
||||
* Wraps an existing Calendar Entry node
|
||||
*/
|
||||
public CalendarEntryImpl(NodeRef nodeRef, NodeService nodeService)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
protected void recordStorageDetails(NodeRef nodeRef, NodeService nodeService)
|
||||
{
|
||||
this.nodeRef = nodeRef;
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeRef getNodeRef() {
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSystemName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDescription() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getStart() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getEnd() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTags() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
143
source/java/org/alfresco/repo/calendar/CalendarServiceImpl.java
Normal file
143
source/java/org/alfresco/repo/calendar/CalendarServiceImpl.java
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.calendar;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.CannedQueryFactory;
|
||||
import org.alfresco.query.CannedQueryResults;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQuery;
|
||||
import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQueryFactory;
|
||||
import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQuery;
|
||||
import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.calendar.CalendarEntry;
|
||||
import org.alfresco.service.cmr.calendar.CalendarService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.alfresco.util.registry.NamedObjectRegistry;
|
||||
|
||||
/**
|
||||
* @author Nick Burch (based on existing webscript controllers in the REST API)
|
||||
* @since 4.0
|
||||
*/
|
||||
public class CalendarServiceImpl implements CalendarService
|
||||
{
|
||||
private static final String CALENDAR_COMPONENT = "calendar";
|
||||
|
||||
/**
|
||||
* For backwards compatibility with pre-Swift, we are asking the query to give us an accurate total count of how many
|
||||
* blog-post nodes there are. This may need to change in the future - certainly if the current 'brute force' query
|
||||
* is replaced by a database query.
|
||||
*/
|
||||
private static final int MAX_QUERY_ENTRY_COUNT = 10000;
|
||||
|
||||
private NodeService nodeService;
|
||||
private SiteService siteService;
|
||||
private TaggingService taggingService;
|
||||
private PermissionService permissionService;
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setSiteService(SiteService siteService)
|
||||
{
|
||||
this.siteService = siteService;
|
||||
}
|
||||
|
||||
public void setTaggingService(TaggingService taggingService)
|
||||
{
|
||||
this.taggingService = taggingService;
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the Calendar Container on a site, creating as required.
|
||||
*/
|
||||
private NodeRef getSiteCalendarContainer(SiteInfo site)
|
||||
{
|
||||
if(! siteService.hasContainer(site.getShortName(), CALENDAR_COMPONENT))
|
||||
{
|
||||
// TODO RunAs + Transaction
|
||||
siteService.createContainer(
|
||||
site.getShortName(), CALENDAR_COMPONENT, null, null
|
||||
);
|
||||
}
|
||||
|
||||
NodeRef container = siteService.getContainer(site.getShortName(), CALENDAR_COMPONENT);
|
||||
if(! taggingService.isTagScope(container))
|
||||
{
|
||||
// TODO RunAs + Transaction
|
||||
taggingService.addTagScope(container);
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CalendarEntry getCalendarEntry(SiteInfo site, String name)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createCalendarEntry(SiteInfo site, CalendarEntry entry)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCalendarEntry(SiteInfo site, CalendarEntry entry)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCalendarEntry(SiteInfo site, CalendarEntry entry)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.service.cmr.calendar;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* This class represents an event in a calendar.
|
||||
*
|
||||
* @author Nick Burch
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface CalendarEntry extends Serializable {
|
||||
/**
|
||||
* @return the NodeRef of the underlying calendar entry
|
||||
*/
|
||||
NodeRef getNodeRef();
|
||||
|
||||
/**
|
||||
* @return the System generated name for the event
|
||||
*/
|
||||
String getSystemName();
|
||||
|
||||
/**
|
||||
* @return the Title ("what") of the event
|
||||
*/
|
||||
String getTitle();
|
||||
|
||||
/**
|
||||
* Sets the Title ("what") of the event
|
||||
*/
|
||||
void setTitle(String title);
|
||||
|
||||
/**
|
||||
* @return the Description of the event
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Sets the Description of the event
|
||||
*/
|
||||
void setDescription();
|
||||
|
||||
/**
|
||||
* @return the Location of the event
|
||||
*/
|
||||
String getLocation();
|
||||
|
||||
// TODO More setters
|
||||
|
||||
/**
|
||||
* @return the Tags associated with the event
|
||||
*/
|
||||
List<String> getTags();
|
||||
|
||||
/**
|
||||
* @return the Start date and time
|
||||
*/
|
||||
Date getStart();
|
||||
|
||||
/**
|
||||
* @return the End date and time
|
||||
*/
|
||||
Date getEnd();
|
||||
|
||||
// TODO All Date
|
||||
|
||||
// TODO Doc folder
|
||||
|
||||
// TODO Recurrence
|
||||
|
||||
// TODO Is Outlook
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.service.cmr.calendar;
|
||||
|
||||
import org.alfresco.service.NotAuditable;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
|
||||
/**
|
||||
* The Calendar service.
|
||||
*
|
||||
* TODO Lucene free querying
|
||||
*
|
||||
* @author Nick Burch
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface CalendarService {
|
||||
/**
|
||||
* Creates a new {@link CalendarEntry} in the repository for the
|
||||
* specified site.
|
||||
*
|
||||
* @return The System Assigned Name for the new entry
|
||||
*/
|
||||
@NotAuditable
|
||||
String createCalendarEntry(SiteInfo site, CalendarEntry entry);
|
||||
|
||||
/**
|
||||
* Updates an existing {@link CalendarEntry} in the repository
|
||||
*/
|
||||
@NotAuditable
|
||||
void updateCalendarEntry(SiteInfo site, CalendarEntry entry);
|
||||
|
||||
/**
|
||||
* Deletes an existing {@link CalendarEntry} from the repository
|
||||
*/
|
||||
@NotAuditable
|
||||
void deleteCalendarEntry(SiteInfo site, CalendarEntry entry);
|
||||
|
||||
/**
|
||||
* Retrieves an existing {@link CalendarEntry} from the repository
|
||||
*/
|
||||
@NotAuditable
|
||||
CalendarEntry getCalendarEntry(SiteInfo site, String name);
|
||||
}
|
Reference in New Issue
Block a user