forked from google/gdata-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRevisionEntry.java
More file actions
191 lines (169 loc) · 5.21 KB
/
Copy pathRevisionEntry.java
File metadata and controls
191 lines (169 loc) · 5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* Copyright (c) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.gdata.data.docs;
import com.google.gdata.data.BaseEntry;
import com.google.gdata.data.Category;
import com.google.gdata.data.ExtensionProfile;
import com.google.gdata.data.Link;
import com.google.gdata.data.Person;
/**
* Defines an entry in a feed of revisions of a document.
*
*
*/
public class RevisionEntry extends BaseEntry<RevisionEntry> {
public static final String PUBLISH_NAMESPACE =
DocsNamespace.DOCS_PREFIX + "publish";
/**
* Label for category.
*/
public static final String LABEL = "revision";
/**
* Kind category term used to label revision entries.
*/
public static final String KIND = DocsNamespace.DOCS_PREFIX + LABEL;
/**
* Category used to label revision entries.
*/
public static final Category CATEGORY =
new Category(com.google.gdata.util.Namespaces.gKind, KIND, LABEL);
public RevisionEntry() {
super();
getCategories().add(CATEGORY);
}
public RevisionEntry(BaseEntry<?> sourceEntry) {
super(sourceEntry);
}
@Override
public void declareExtensions(ExtensionProfile extProfile) {
super.declareExtensions(extProfile);
extProfile.declare(RevisionEntry.class, Md5Checksum.class);
extProfile.declare(RevisionEntry.class, Publish.class);
extProfile.declare(RevisionEntry.class, PublishAuto.class);
extProfile.declare(RevisionEntry.class, PublishOutsideDomain.class);
}
/**
* Returns the MD5 checksum calculated for the document.
*
* @return the MD5 checksum
*/
public String getMd5Checksum() {
Md5Checksum md5Checksum = getExtension(Md5Checksum.class);
return md5Checksum == null ? null : md5Checksum.getValue();
}
/**
* Set the MD5 checksum calculated for the document.
*
* @param md5Checksum the MD5 checksum
*/
public void setMd5Checksum(String md5Checksum) {
if (md5Checksum == null) {
removeExtension(Md5Checksum.class);
} else {
setExtension(new Md5Checksum(md5Checksum));
}
}
/**
* Revisions have only one author, the user who modified the document to
* create that revision. These are convenience methods for setting and
* getting a sole author.
*
* @param modifyingUser the user who modified the document/created the revision
*/
public void setModifyingUser(Person modifyingUser) {
getAuthors().clear();
if (modifyingUser != null) {
getAuthors().add(modifyingUser);
}
}
/**
* @return the user who modified the document/created the revision
*/
public Person getModifyingUser() {
if (getAuthors().size() > 0) {
return getAuthors().get(0);
}
return null;
}
/**
* Returns the publically accessible link for the published revision.
*/
public Link getPublishLink() {
return getLink(PUBLISH_NAMESPACE, Link.Type.HTML);
}
/**
* Returns whether the revision is published.
*
* @return whether revision is published
*/
public Boolean isPublish() {
Publish publish = getExtension(Publish.class);
return publish == null ? null : publish.getValue();
}
/**
* Sets whether the revision is published.
*
* @param publish true if revision is published
*/
public void setPublish(Boolean publish) {
if (publish == null) {
removeExtension(Publish.class);
} else {
setExtension(new Publish(publish));
}
}
/**
* Returns whether changes to the document are automatically re-published.
*
* @return whether auto re-published
*/
public Boolean isPublishAuto() {
PublishAuto publishAuto = getExtension(PublishAuto.class);
return publishAuto == null ? null : publishAuto.getValue();
}
/**
* Sets whether changes to the document are automatically re-published.
*
* @param publishAuto true if auto re-published
*/
public void setPublishAuto(Boolean publishAuto) {
if (publishAuto == null) {
removeExtension(PublishAuto.class);
} else {
setExtension(new PublishAuto(publishAuto));
}
}
/**
* Sets whether the document is published outside of its domain.
*
* @return whether outside domain
*/
public Boolean isPublishOutsideDomain() {
PublishOutsideDomain publishOutsideDomain = getExtension(PublishOutsideDomain.class);
return publishOutsideDomain == null ? null : publishOutsideDomain.getValue();
}
/**
* Sets whether the document is published outside of its domain.
*
* @param publishOutsideDomain true if outside domain
*/
public void setPublishOutsideDomain(Boolean publishOutsideDomain) {
if (publishOutsideDomain == null) {
removeExtension(PublishOutsideDomain.class);
} else {
setExtension(new PublishOutsideDomain(publishOutsideDomain));
}
}
}