Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Document Properties Marker
overridefalse
Short DescriptionA name in projectdoc used to identify a document is not considered a hard reference. When changing the name of a particular document, the references to the original name do not automatically change. This is by design. It may also by the cause of annoyance. This tip provides information how to deal with this.
Doctypetopichide
NameChanging Names
Short Name
Parent
Parent Property
property-nameName
hide
Audience

Name List
doctyperole
render-no-hits-as-blanktrue
namesDocumentation Gardener, Documentation Architect
property-restrict-value-rangetrue
propertyAudience
empty-as-nonetrue


Subject

Name List
doctypesubject
propertySubject


Categories

Name List
doctypecategory
names/ projectdoc / Features / Autocomplete
property-restrict-value-rangetrue
propertyCategories


Tags

Tag List
namesprojectdoc Toolbox, Confluence, REST, API, Web API Extension
propertyTags


Flagshide
Iteration

Iteration
valueproduction

hide
Type

Name List
doctypetopic-type
render-no-hits-as-blanktrue
namesTip
property-restrict-value-rangetrue
propertyType


Level of Experience

Name List
doctypeexperience-level
render-no-hits-as-blanktrue
namesExpert
propertyLevel of Experience


Expected Duration
Sponsors
Name List
doctypestakeholder
render-no-hits-as-blanktrue
propertySponsors

Sort Keyhide
projectdoc-section
Section
show-titleDescriptionfalse
Summary
titletitleDescription

This short tip shows how to change property values for a selection of documents using the Web API Extension. The approach is especially useful if a name of a document is changed and authors need to adjust all referencing documents accordingly.

Section
titlePrerequisites

Besides the projectdoc Toolbox installed on your Confluence server, the Web API Extension also needs to be installed. You may use the Web API via any REST client. This tip assumes that you have installed the REST API Browser.

Note Box
titleNo API Documentation? Seriously?

I case you ask yourself: why is there no documentation for the REST API? WTF?

The REST API Browser has a bug. Therefore we need to decide whether we deploy a REST API that cannot be used via the add-on or provide a functional REST API, but without documentation.

Sounds strange? You may vote on CONFSERVER-57887 for solving this problem!

In case you need more information on this issue, please head for our blog post Problems with the Web API and the REST API Browser.

Section
titleIdentifying Documents

The projectdoc Toolbox defines the concept of a projectdoc Document. Such a document is a Confluence Page with properties and sections.

A projectdoc Document can be identified either by its title and space or its name and doctype.

Section
titleTitle and Space Key

By design a page on a Confluence server is uniquely identified by its title and space key.

Authors can take advantage of this when they need to reference a page. In case the title is renamed, all links are also adjusted. This way all references still hold after the rename action.

References to document with links can be made with

Such a link is considered to be a hard reference. The link is tightly connected to the page.

Section
titleName and Doctype

The name and doctype of a document also identifies a document. But not necessarily uniquely. It is good practice – that can be naturally followed most of the time – to keep the name unique for each doctype. This is not enforced, though.

References to documents with names can be made with

Such a link is considered to be a soft reference. The macros take the specified name and doctype literally. In case the document actually exists, a reference is rendered. If the document goes away (either by deletion, by changing the privileges, or by renaming), then name, as a string literal, is not changed. This way the document having the Name List Macro with a name as its value, is still be found by this property value (e.g. by a search or by a query conducted by a Display Table Macro).

Example Box

This is similar to the name of a variable in a programming language. In case you change the name in a particular location, the names referring to this same variable are not automatically updated.

Programmers can, however, use a refactoring tool. Such a tool allows to select the name of a variable and change all references to the variable in one step.

This approach is analogous to the use of names in a Name List Macro. The "refactoring tool" for the projectdoc Toolbox, albeit not so sophisticated as the tools provided by your IDE, is the Web API.

This of the name list as a couple of advantages. In case authors remove a doctype homepage, references to that homepage will automatically reference the homepage in a related space. In case authors import pages to another Confluence instance, the references will immediately render as links to existing documents. 

Note Box

When changing a name the reference my not be updated automatically.

Either if the linked page is removed, the link may still exist, or if the page is created, the link will not be rendered. This is because the cache is not updated and the renderer fetches the stale information from the cache. It is only an issue with name list macros used as document property values.

This can be fixed by refreshing the page. We are working on a solution that will automate this manual step.

Section
titleWhen a name Name is wrong ...

In case authors actually need to change a name, this change cannot be by design an instant one. We are considering to include options to make the adjustment automatically in the future. Maybe by a dialog which will ask whether or not to change the names in referencing properties. This is similar to the action of deleting a page and asking whether or not the children should be removed, too.

In the meantime this is a manual step. In case there is more than a couple of pages is involved, authors should consider to use the Web API to do the job.

Caution Box
titleBackup your data!

In case the Web API changes documents the wrong way, there is no way to get back easily. You may need to find the corrupted pages and restore the last valid version from history. Therefore we recommend strongly that you check your calls on a copy of your production system. Before running a call on the production system you must make sure that you have a current backup to roll back any corruption of your data the call may have caused.

...

Section
titleWalk me through!

Since we use the strategy to show names only if the document is in Released, Production, or Deprecated state, we now recognized how lax we handled the Iteration state of documents in our documentation.

Here is an example on how we moved the iteration of all our role documents to Production.

Steps
Section
titleOpen REST Service in REST Browser
  1. Log in as admin
  2. Click i the cog (right side of the menu bar) for Confluence administration and click on General configuration
  3. Select REST API Browser from the left menu
  4. Type projectdoc in the input field on the left upper side and unselect Show only public API

  5. Select projectdoc/1/document from the services listed on the left
Section
titleSelect the Documents

To select the documents to apply the changes to, we need to find all documents in a state prior to "Released" and want to change their Iteration value to "Production".

This is the Where Clause to select these documents of doctype role: $<Doctype>=[role] && $<Iteration>~(Facade, Filled, Focused, Finished)

Check that every listed document is correctly part of the result set. If not adjust you Where Clause accordingly. If everything is correct, copy the value of id-list.

This is the list of page IDs that match your result set. Copy the values without the quote characters Make sure that you do not miss any digits (i.e. from the first or last page ID).

Section
titleApply changes

Now switch to the PATCH tab.

Add the list of page IDs from the last step to the id-list parameter.

Image RemovedImage Added

Add the following information to patch the list of documents.

Code Block
languagejs
{
   "property": [
     {
       "name": "Iteration",
       "value": "<ac:structured-macro ac:name=\"projectdoc-iteration\"><ac:parameter ac:name=\"value\">production</ac:parameter></ac:structured-macro>",
       "controls": "hide",
       "position": "replace"
     }
   ]
 }

Note that we replace the complete value, including the macro that holds the actual value of "Production". The value is the macro in the Confluence Storage Format.

This JSON document will replace the value of the Iteration property on each document referenced in the id-list.

Transclusion
document@self
idsBackup your data!

If you have a recent backup and checked this on a test environment, then click Send.

The response will contain a list of results changing the documents.

Section
titleAnd Changing the Name?

In case you need to change the name you need to wrap the name in a Name List Macro in the Confluence Storage Format.

Since the name used in property values has not been changed when authors changed the name of the document, the old name can be used to select the documents in the Where Clause.

For instance, if the name was a role name used in the Audience property, then the Where clause needs to select on the Audience Parameter of documents.

The approach is identical to the use case we have shown for changing the Iteration property above.

Section
titleSummary

We have shown some use cases for the demand of changing values for a collection of projectdoc documents.

It requires manual steps that need to be conducted very carefully. It is strongly recommended that you have a recent backup in case your calls corrupt pages in your Confluence instance.

In the future we will probably provide tools to make this task easier. In the meanwhile authors have tools to at least allow these task to be run effectively.

Section
ignore-template-buttonstrue
titleSubordinate Topics
Hide From Reader

Create from template
blueprintModuleCompleteKeyde.smartics.atlassian.confluence.smartics-projectdoc-confluence-space-core:projectdoc-blueprint-doctype-topic
buttonLabelCreate Topic

Display Table
doctypetopic
render-no-hits-as-blanktrue
render-modedefinition
selectName, Short Description
restrict-to-immediate-childrentrue
sort-bySort Key, Name

...

Section
titleReferences
Tour
render-no-hits-as-blanktrue
render-as-definition-listtrue
marker-column-property-nameTitle
replace-title-with-nametrue
TitleShort Description


Section
titleResources

Links to related information.

Tour
render-no-hits-as-blanktrue
render-as-definition-listtrue
marker-column-property-nameTitle
replace-title-with-nametrue
Piwik Set Multiple Custom Variables
NameValue
Departmentprojectdoc
Categoryprojectdoc-tip
Typehowto