View Javadoc
1   /*
2    * #%L
3    * wcm.io
4    * %%
5    * Copyright (C) 2021 wcm.io
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package io.wcm.devops.conga.plugins.aem.maven.allpackage;
21  
22  import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_DEPENDENCIES;
23  import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_GROUP;
24  import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_NAME;
25  import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_PACKAGE_TYPE;
26  import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_VERSION;
27  
28  import java.io.File;
29  import java.io.IOException;
30  import java.util.Collection;
31  import java.util.Map;
32  
33  import io.wcm.devops.conga.plugins.aem.maven.model.AbstractInstallableFile;
34  import io.wcm.devops.conga.plugins.aem.maven.model.ContentPackageFile;
35  import io.wcm.tooling.commons.packmgr.util.ContentPackageProperties;
36  
37  /**
38   * References a temporary file representing an partially processed content package to be included in the "all" package.
39   */
40  final class TemporaryContentPackageFile extends AbstractInstallableFile implements ContentPackageFile {
41  
42    private final String name;
43    private final String group;
44    private final String version;
45    private final String packageType;
46    private final String dependencies;
47  
48    TemporaryContentPackageFile(File file, Collection<String> variants) throws IOException {
49      super(file, variants);
50      Map<String, Object> props = ContentPackageProperties.get(file);
51      this.name = (String)props.get(NAME_NAME);
52      this.group = (String)props.get(NAME_GROUP);
53      this.version = (String)props.get(NAME_VERSION);
54      this.packageType = (String)props.get(NAME_PACKAGE_TYPE);
55      this.dependencies = (String)props.get(NAME_DEPENDENCIES);
56    }
57  
58    @Override
59    public String getName() {
60      return this.name;
61    }
62  
63    @Override
64    public String getGroup() {
65      return this.group;
66    }
67  
68    @Override
69    public String getVersion() {
70      return this.version;
71    }
72  
73    @Override
74    public String getPackageType() {
75      return this.packageType;
76    }
77  
78    public String getDependencies() {
79      return this.dependencies;
80    }
81  
82    public String getPackageInfoWithDependencies() {
83      StringBuilder sb = new StringBuilder();
84      sb.append(getPackageInfo());
85      if (this.dependencies != null) {
86        sb.append(" (dependencies: ").append(this.dependencies).append(")");
87      }
88      return sb.toString();
89    }
90  
91    @Override
92    public boolean isDependencyChainIgnore() {
93      return false;
94    }
95  
96  }