@@ -53,22 +53,22 @@ public class PrologContentCreator {
5353 /**
5454 * <code>true</code> if the creator must be set in DITA Topic.
5555 */
56- private boolean setTopicCreator = true ;
56+ private boolean isAllowedTopicCreatorUpdate = true ;
5757
5858 /**
5959 * <code>true</code> if the creator must be set in DITA Map.
6060 */
61- private boolean setMapCreator = true ;
61+ private boolean isAllowedMapCreatorUpdate = true ;
6262
6363 /**
6464 * <code>true</code> if the contributor must be update in DITA Topic.
6565 */
66- private boolean updateTopicContributor = true ;
66+ private boolean isAllowedTopicContributorUpdate = true ;
6767
6868 /**
6969 * <code>true</code> if the contributor must be update in DITA Map.
7070 */
71- private boolean updateMapContributor = true ;
71+ private boolean isAllowedMapContributorUpdate = true ;
7272
7373 /**
7474 * <code>true</code> if the prolog update is allowed in DITA Topic.
@@ -83,22 +83,22 @@ public class PrologContentCreator {
8383 /**
8484 * <code>true</code> if the created date must be set in DITA Topic.
8585 */
86- private boolean setTopicCreatedDate = true ;
86+ private boolean isAllowedTopicCreatedDateUpdate = true ;
8787
8888 /**
8989 * <code>true</code> if the created date must be set in DITA Map.
9090 */
91- private boolean setMapCreatedDate = true ;
91+ private boolean isAllowedMapCreatedDateUpdate = true ;
9292
9393 /**
9494 * <code>true</code> if the revised date must be update in DITA Topic.
9595 */
96- private boolean updateTopicRevisedDate = true ;
96+ private boolean isAllowedTopicRevisedDateUpdate = true ;
9797
9898 /**
9999 * <code>true</code> if the revised date must be update in DITA Map.
100100 */
101- private boolean updateMapRevisedDate = true ;
101+ private boolean isAllowedMapRevisedDateUpdate = true ;
102102
103103 /**
104104 * The maximum number of revised elements
@@ -212,8 +212,8 @@ public String getPrologFragment(boolean isNewDocument, DocumentType documentType
212212 */
213213 public String getCreatorFragment (DocumentType documentType ) {
214214 String fragment = null ;
215- if ((setTopicCreator && documentType .equals (DocumentType .TOPIC ))
216- || (setMapCreator && !documentType .equals (DocumentType .TOPIC ))) {
215+ if ((isAllowedTopicCreatorUpdate && documentType .equals (DocumentType .TOPIC ))
216+ || (isAllowedMapCreatorUpdate && !documentType .equals (DocumentType .TOPIC ))) {
217217 fragment = creatorFragment .toString ();
218218 }
219219 return fragment ;
@@ -228,8 +228,8 @@ public String getCreatorFragment(DocumentType documentType) {
228228 */
229229 public String getContributorFragment (DocumentType documentType ) {
230230 String fragment = null ;
231- if ((updateTopicContributor && documentType .equals (DocumentType .TOPIC ))
232- || (updateMapContributor && !documentType .equals (DocumentType .TOPIC ))) {
231+ if ((isAllowedTopicContributorUpdate && documentType .equals (DocumentType .TOPIC ))
232+ || (isAllowedMapContributorUpdate && !documentType .equals (DocumentType .TOPIC ))) {
233233 fragment = contributorXML .toString ();
234234 }
235235 return fragment ;
@@ -244,8 +244,8 @@ public String getContributorFragment(DocumentType documentType) {
244244 */
245245 public String getCreatedDateFragment (DocumentType documentType ) {
246246 String fragment = null ;
247- if ((setTopicCreatedDate && documentType .equals (DocumentType .TOPIC ))
248- || (setMapCreatedDate && !documentType .equals (DocumentType .TOPIC ))) {
247+ if ((isAllowedTopicCreatedDateUpdate && documentType .equals (DocumentType .TOPIC ))
248+ || (isAllowedMapCreatedDateUpdate && !documentType .equals (DocumentType .TOPIC ))) {
249249 fragment = createdDateXML .toString ();
250250 }
251251 return fragment ;
@@ -260,8 +260,8 @@ public String getCreatedDateFragment(DocumentType documentType) {
260260 */
261261 public String getRevisedDateFragment (DocumentType documentType ) {
262262 String fragment = null ;
263- if ((updateTopicRevisedDate && documentType .equals (DocumentType .TOPIC ))
264- || (updateMapRevisedDate && !documentType .equals (DocumentType .TOPIC ))) {
263+ if ((isAllowedTopicRevisedDateUpdate && documentType .equals (DocumentType .TOPIC ))
264+ || (isAllowedMapRevisedDateUpdate && !documentType .equals (DocumentType .TOPIC ))) {
265265 fragment = revisedDateFragment .toString ();
266266 }
267267 return fragment ;
@@ -352,22 +352,22 @@ private void loadOptions() {
352352 isAllowedMapUpdate = Boolean .parseBoolean (value );
353353
354354 value = optionsStorage .getOption (OptionKeys .TOPIC_SET_CREATOR , String .valueOf (true ));
355- setTopicCreator = Boolean .parseBoolean (value ) && isAllowedTopicUpdate ;
355+ isAllowedTopicCreatorUpdate = Boolean .parseBoolean (value ) && isAllowedTopicUpdate ;
356356 value = optionsStorage .getOption (OptionKeys .MAP_SET_CREATOR , String .valueOf (true ));
357- setMapCreator = Boolean .parseBoolean (value ) && isAllowedMapUpdate ;
357+ isAllowedMapCreatorUpdate = Boolean .parseBoolean (value ) && isAllowedMapUpdate ;
358358 value = optionsStorage .getOption (OptionKeys .TOPIC_UPDATE_CONTRIBUTOR , String .valueOf (true ));
359- updateTopicContributor = Boolean .parseBoolean (value ) && isAllowedTopicUpdate ;
359+ isAllowedTopicContributorUpdate = Boolean .parseBoolean (value ) && isAllowedTopicUpdate ;
360360 value = optionsStorage .getOption (OptionKeys .MAP_UPDATE_CONTRIBUTOR , String .valueOf (true ));
361- updateMapContributor = Boolean .parseBoolean (value ) && isAllowedMapUpdate ;
361+ isAllowedMapContributorUpdate = Boolean .parseBoolean (value ) && isAllowedMapUpdate ;
362362
363363 value = optionsStorage .getOption (OptionKeys .TOPIC_SET_CREATED_DATE , String .valueOf (true ));
364- setTopicCreatedDate = Boolean .parseBoolean (value ) && isAllowedTopicUpdate ;
364+ isAllowedTopicCreatedDateUpdate = Boolean .parseBoolean (value ) && isAllowedTopicUpdate ;
365365 value = optionsStorage .getOption (OptionKeys .MAP_SET_CREATED_DATE , String .valueOf (true ));
366- setMapCreatedDate = Boolean .parseBoolean (value ) && isAllowedMapUpdate ;
366+ isAllowedMapCreatedDateUpdate = Boolean .parseBoolean (value ) && isAllowedMapUpdate ;
367367 value = optionsStorage .getOption (OptionKeys .TOPIC_UPDATE_REVISED_DATES , String .valueOf (true ));
368- updateTopicRevisedDate = Boolean .parseBoolean (value ) && isAllowedTopicUpdate ;
368+ isAllowedTopicRevisedDateUpdate = Boolean .parseBoolean (value ) && isAllowedTopicUpdate ;
369369 value = optionsStorage .getOption (OptionKeys .MAP_UPDATE_REVISED_DATES , String .valueOf (true ));
370- updateMapRevisedDate = Boolean .parseBoolean (value ) && isAllowedMapUpdate ;
370+ isAllowedMapRevisedDateUpdate = Boolean .parseBoolean (value ) && isAllowedMapUpdate ;
371371
372372 value = optionsStorage .getOption (OptionKeys .CUSTOM_CREATOR_TYPE_VALUE , "" );
373373 if (value != null && !value .isEmpty ()) {
@@ -380,11 +380,37 @@ private void loadOptions() {
380380 }
381381 }
382382
383+ /**
384+ * Check if it's allowed the update for the given document type.
385+ *
386+ * @param documentType The document type: {@link DocumentType#TOPIC},
387+ * {@link DocumentType#MAP} or {@link DocumentType#BOOKMAP}
388+ * @return
389+ */
390+ public boolean isAllowedUpdate (DocumentType documentType ) {
391+ boolean isAllowed = false ;
392+ if (documentType .equals (DocumentType .TOPIC )) {
393+ isAllowed = isAllowedTopicCreatorUpdate || isAllowedTopicContributorUpdate
394+ || isAllowedTopicCreatedDateUpdate || isAllowedTopicRevisedDateUpdate ;
395+ } else {
396+ isAllowed = isAllowedMapCreatorUpdate || isAllowedMapContributorUpdate
397+ || isAllowedMapCreatedDateUpdate || isAllowedMapRevisedDateUpdate ;
398+ }
399+ return isAllowed ;
400+ }
383401
402+ /**
403+ * Get the value of type attribute for creator.
404+ * @return The value of type attribute for creator.
405+ */
384406 public String getCreatorTypeValue () {
385407 return creatorTypeValue ;
386408 }
387409
410+ /**
411+ * Get the value of type attribute for contributor.
412+ * @return The value of type attribute for contributor.
413+ */
388414 public String getContributorTypeValue () {
389415 return contributorTypeValue ;
390416 }
0 commit comments