-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feedback requested * #26380 fixing bug * #26380 remove commented attributes no longer used * #26380 changing classes to immutables * #26380 these attribute will be moved later * #26380 renaming the new classes
- Loading branch information
1 parent
2fe0e2a
commit 73b1578
Showing
23 changed files
with
630 additions
and
555 deletions.
There are no files selected for viewing
282 changes: 155 additions & 127 deletions
282
tools/dotcms-cli/api-data-model/src/main/java/com/dotcms/api/traversal/TreeNode.java
Large diffs are not rendered by default.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
...dotcms-cli/api-data-model/src/main/java/com/dotcms/common/AbstractLocalPathStructure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.dotcms.common; | ||
|
||
import com.dotcms.model.annotation.ValueType; | ||
import java.io.File; | ||
import java.nio.file.Path; | ||
import javax.annotation.Nullable; | ||
import org.immutables.value.Value; | ||
import org.immutables.value.Value.Default; | ||
import org.immutables.value.Value.Derived; | ||
|
||
/** | ||
* Represents the structure of a local file or directory path within the workspace. | ||
*/ | ||
@ValueType | ||
@Value.Immutable | ||
public interface AbstractLocalPathStructure { | ||
boolean isDirectory(); | ||
String status(); | ||
String language(); | ||
String site(); | ||
@Nullable | ||
String fileName(); | ||
String folderPath(); | ||
Path filePath(); | ||
@Default | ||
default boolean languageExists() {return false;} | ||
|
||
@Derived | ||
default String folderName() { | ||
|
||
final int nameCount = filePath().getNameCount(); | ||
|
||
String folderName = File.separator; | ||
|
||
if (nameCount > 1) { | ||
folderName = filePath().subpath(nameCount - 1, nameCount).toString(); | ||
} else if (nameCount == 1) { | ||
folderName = filePath().subpath(0, nameCount).toString(); | ||
} | ||
|
||
if (folderName.equalsIgnoreCase(this.site())) { | ||
folderName = File.separator; | ||
} | ||
|
||
return folderName; | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
...otcms-cli/api-data-model/src/main/java/com/dotcms/common/AbstractRemotePathStructure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.dotcms.common; | ||
|
||
import com.dotcms.model.annotation.ValueType; | ||
import java.nio.file.Path; | ||
import javax.annotation.Nullable; | ||
import org.immutables.value.Value; | ||
import org.immutables.value.Value.Derived; | ||
|
||
/** | ||
* Represents the site, folder path and file name components of the parsed remote path. | ||
*/ | ||
@ValueType | ||
@Value.Immutable | ||
public interface AbstractRemotePathStructure { | ||
|
||
/** | ||
* The site component of the parsed path. | ||
*/ | ||
String site(); | ||
|
||
/** | ||
* The folder path component of the parsed path. | ||
*/ | ||
Path folderPath(); | ||
|
||
/** | ||
* The file name component of the parsed path. | ||
*/ | ||
@Nullable | ||
String fileName(); | ||
|
||
@Derived | ||
default String folderName() { | ||
|
||
int nameCount = folderPath().getNameCount(); | ||
|
||
String folderName = "/"; | ||
|
||
if (nameCount > 1) { | ||
folderName = folderPath().subpath(nameCount - 1, nameCount).toString(); | ||
} else if (nameCount == 1) { | ||
folderName = folderPath().subpath(0, nameCount).toString(); | ||
} | ||
|
||
return folderName; | ||
} | ||
|
||
|
||
class Builder extends RemotePathStructure.Builder { | ||
public Builder folder(Path path) { | ||
super.fileName(null); | ||
super.folderPath(path); | ||
return this; | ||
} | ||
|
||
public Builder asset(Path path) { | ||
super.fileName(path.getFileName().toString()); | ||
super.folderPath(path.getParent()); | ||
return this; | ||
} | ||
|
||
} | ||
|
||
static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
} |
Oops, something went wrong.