data

package
v3.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2017 License: MIT Imports: 13 Imported by: 44

Documentation

Index

Constants

View Source
const (
	TAG_FILTER         = "filter"
	TAG_COMP_FILTER    = "comp-filter"
	TAG_PROP_FILTER    = "prop-filter"
	TAG_PARAM_FILTER   = "param-filter"
	TAG_TIME_RANGE     = "time-range"
	TAG_TEXT_MATCH     = "text-match"
	TAG_IS_NOT_DEFINED = "is-not-defined"

	// from the RFC, the time range `start` and `end` attributes MUST be in UTC and in this specific format
	FILTER_TIME_FORMAT = "20060102T150405Z"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CalUser

type CalUser struct {
	Name string
}

type FileResourceAdapter

type FileResourceAdapter struct {
	// contains filtered or unexported fields
}

func (*FileResourceAdapter) CalculateEtag

func (adp *FileResourceAdapter) CalculateEtag() string

func (*FileResourceAdapter) GetContent

func (adp *FileResourceAdapter) GetContent() string

func (*FileResourceAdapter) GetContentSize

func (adp *FileResourceAdapter) GetContentSize() int64

func (*FileResourceAdapter) GetModTime

func (adp *FileResourceAdapter) GetModTime() time.Time

func (*FileResourceAdapter) IsCollection

func (adp *FileResourceAdapter) IsCollection() bool

type FileStorage

type FileStorage struct {
}

FileStorage is the storage that deals with resources as files in the file system. So, a collection resource is treated as a folder/directory and its children resources are the files it contains. On the other hand, non-collection resources are just plain files.

func (*FileStorage) CreateResource

func (fs *FileStorage) CreateResource(rpath, content string) (*Resource, error)

func (*FileStorage) DeleteResource

func (fs *FileStorage) DeleteResource(rpath string) error

func (*FileStorage) GetResource

func (fs *FileStorage) GetResource(rpath string) (*Resource, bool, error)

func (*FileStorage) GetResources

func (fs *FileStorage) GetResources(rpath string, withChildren bool) ([]Resource, error)

func (*FileStorage) GetResourcesByFilters

func (fs *FileStorage) GetResourcesByFilters(rpath string, filters *ResourceFilter) ([]Resource, error)

func (*FileStorage) GetResourcesByList

func (fs *FileStorage) GetResourcesByList(rpaths []string) ([]Resource, error)

func (*FileStorage) GetShallowResource

func (fs *FileStorage) GetShallowResource(rpath string) (*Resource, bool, error)

func (*FileStorage) UpdateResource

func (fs *FileStorage) UpdateResource(rpath, content string) (*Resource, error)

type Resource

type Resource struct {
	Name string
	Path string
	// contains filtered or unexported fields
}

func NewResource

func NewResource(resPath string, adp ResourceAdapter) Resource

func (*Resource) ComponentName

func (r *Resource) ComponentName() string

func (*Resource) EndTimeUTC

func (r *Resource) EndTimeUTC() time.Time

func (*Resource) GetContentData

func (r *Resource) GetContentData() (string, bool)

func (*Resource) GetContentLength

func (r *Resource) GetContentLength() (string, bool)

func (*Resource) GetContentType

func (r *Resource) GetContentType() (string, bool)

func (*Resource) GetDisplayName

func (r *Resource) GetDisplayName() (string, bool)

func (*Resource) GetEtag

func (r *Resource) GetEtag() (string, bool)

func (*Resource) GetLastModified

func (r *Resource) GetLastModified(format string) (string, bool)

func (*Resource) GetOwner

func (r *Resource) GetOwner() (string, bool)

func (*Resource) GetOwnerPath

func (r *Resource) GetOwnerPath() (string, bool)

func (*Resource) GetPropertyParamValue

func (r *Resource) GetPropertyParamValue(paramPath ...string) string

func (*Resource) GetPropertyValue

func (r *Resource) GetPropertyValue(propPath ...string) string

func (*Resource) HasProperty

func (r *Resource) HasProperty(propPath ...string) bool

func (*Resource) HasPropertyParam

func (r *Resource) HasPropertyParam(paramPath ...string) bool

func (*Resource) IsCollection

func (r *Resource) IsCollection() bool

func (*Resource) IsPrincipal

func (r *Resource) IsPrincipal() bool

func (*Resource) Recurrences

func (r *Resource) Recurrences() []ResourceRecurrence

func (*Resource) StartTimeUTC

func (r *Resource) StartTimeUTC() time.Time

type ResourceAdapter

type ResourceAdapter interface {
	IsCollection() bool
	CalculateEtag() string
	GetContent() string
	GetContentSize() int64
	GetModTime() time.Time
}

type ResourceFilter

type ResourceFilter struct {
	// contains filtered or unexported fields
}

func ParseResourceFilters

func ParseResourceFilters(xml string) (*ResourceFilter, error)

This function creates a new filter object from a piece of XML string.

func (*ResourceFilter) Attr

func (f *ResourceFilter) Attr(attrName string) string

func (*ResourceFilter) GetTimeRangeFilter

func (f *ResourceFilter) GetTimeRangeFilter() *ResourceFilter

GetTimeRangeFilter checks if the current filter has a child "time-range" filter and returns it (wrapped in a `ResourceFilter` type). It returns nil if the current filter does not contain any "time-range" filter.

func (*ResourceFilter) Match

func (f *ResourceFilter) Match(target ResourceInterface) bool

func (*ResourceFilter) TimeAttr

func (f *ResourceFilter) TimeAttr(attrName string) *time.Time

type ResourceInterface

type ResourceInterface interface {
	ComponentName() string
	StartTimeUTC() time.Time
	EndTimeUTC() time.Time
	Recurrences() []ResourceRecurrence
	HasProperty(propPath ...string) bool
	GetPropertyValue(propPath ...string) string
	HasPropertyParam(paramName ...string) bool
	GetPropertyParamValue(paramName ...string) string
}

type ResourceRecurrence

type ResourceRecurrence struct {
	StartTime time.Time
	EndTime   time.Time
}

type Storage

type Storage interface {
	// GetResources gets a list of resources based on a given `rpath`. The
	// `rpath` is the path to the original resource that's being requested. The resultant list
	// will/must contain that original resource in it, apart from any additional resources. It also receives
	// `withChildren` flag to say if the result must also include all the original resource`s
	// children (if original is a collection resource). If `true`, the result will have the requested resource + children.
	// If `false`, it will have only the requested original resource (from the `rpath` path).
	// It returns errors if anything went wrong or if it could not find any resource on `rpath` path.
	GetResources(rpath string, withChildren bool) ([]Resource, error)
	// GetResourcesByList fetches a list of resources by path from the storage.
	// This method fetches all the `rpaths` and return an array of the reosurces found.
	// No error 404 will be returned if one of the resources cannot be found.
	// Errors are returned if any errors other than "not found" happens.
	GetResourcesByList(rpaths []string) ([]Resource, error)
	// GetResourcesByFilters returns the filtered children of a target collection resource.
	// The target collection resource is the one pointed by the `rpath` parameter. All of its children
	// will be checked against a set of `filters` and the matching ones are returned. The results
	// contains only the filtered children and does NOT include the target resource. If the target resource
	// is not a collection, an empty array is returned as the result.
	GetResourcesByFilters(rpath string, filters *ResourceFilter) ([]Resource, error)
	// GetResource gets the requested resource based on a given `rpath` path. It returns the resource (if found) or
	// nil (if not found). Also returns a flag specifying if the resource was found or not.
	GetResource(rpath string) (*Resource, bool, error)
	// GetShallowResource has the same behaviour of `storage.GetResource`. The only difference is that, for collection resources,
	// it does not return its children in the collection `storage.Resource` struct (hence the name shallow). The motive is
	// for optimizations reasons, as this function is used on places where the collection's children are not important.
	GetShallowResource(rpath string) (*Resource, bool, error)
	// CreateResource creates a new resource on the `rpath` path with a given `content`.
	CreateResource(rpath, content string) (*Resource, error)
	// UpdateResource udpates a resource on the `rpath` path with a given `content`.
	UpdateResource(rpath, content string) (*Resource, error)
	// DeleteResource deletes a resource on the `rpath` path.
	DeleteResource(rpath string) error
}

The Storage is the responsible for the CRUD operations on the caldav resources.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL