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 package info.magnolia.dam.app.setup.migration;
35
36 import info.magnolia.dam.app.assets.field.translator.AssetCompositeIdKeyTranslator;
37 import info.magnolia.dam.app.ui.field.DamFilePreviewComponent;
38 import info.magnolia.jcr.util.NodeTypes;
39 import info.magnolia.module.InstallContext;
40 import info.magnolia.ui.dialog.setup.migration.ControlMigrator;
41 import info.magnolia.ui.form.field.definition.LinkFieldDefinition;
42
43 import javax.jcr.Node;
44 import javax.jcr.RepositoryException;
45
46
47
48
49 public class DamControlMigrator implements ControlMigrator {
50
51
52 @Override
53 public void migrate(Node controlNode, InstallContext installContext) throws RepositoryException {
54 if (controlNode.hasProperty("controlType")) {
55 controlNode.getProperty("controlType").remove();
56 }
57 controlNode.setProperty("targetWorkspace", "dam");
58 controlNode.setProperty("appName", "assets");
59 controlNode.setProperty("class", LinkFieldDefinition.class.getName());
60 if (!controlNode.hasNode("identifierToPathConverter")) {
61 controlNode.addNode("identifierToPathConverter", NodeTypes.ContentNode.NAME);
62 }
63 controlNode.getNode("identifierToPathConverter").setProperty("class", AssetCompositeIdKeyTranslator.class.getName());
64
65 controlNode.addNode("contentPreviewDefinition", NodeTypes.ContentNode.NAME);
66 controlNode.getNode("contentPreviewDefinition").setProperty("contentPreviewClass", DamFilePreviewComponent.class.getName());
67
68 if (!controlNode.hasProperty("description")) {
69 controlNode.setProperty("description", "Select an asset");
70 }
71
72 if (!controlNode.hasProperty("label")) {
73 controlNode.setProperty("label", "Image");
74 }
75
76 if (controlNode.hasProperty("repository")) {
77 controlNode.getProperty("repository").remove();
78 }
79
80 if (controlNode.hasProperty("type")) {
81 controlNode.getProperty("type").remove();
82 }
83
84 }
85 }