Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #381

Merged
merged 207 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
bb7f010
update page content.
wildone Jul 5, 2023
6d4f23e
add extra example.
wildone Jul 10, 2023
f881b90
cleanup css.
wildone Jul 10, 2023
f375a79
update port to not conflict with juputerlab.
wildone Jul 14, 2023
13a56a1
add new space actions.
wildone Aug 30, 2023
2aefbbc
add log4j version property.
wildone Aug 30, 2023
d91294f
update config.
wildone Aug 30, 2023
99a97fe
fix missing ref.
wildone Aug 30, 2023
bd83c69
change dialog text field type to password.
wildone Aug 30, 2023
6ec8dce
add jcr utils.
wildone Aug 30, 2023
075f3a5
update git utils.
wildone Aug 30, 2023
51b27bd
update space actions.
wildone Aug 30, 2023
3015276
update url suffix to have double brackets.
wildone Jan 29, 2024
4038171
fix namespace.
wildone Jan 29, 2024
8e7ede3
fix regex replace to remove params if not found.
wildone Jan 29, 2024
edcda03
Merge branch 'feature/gitexport' into develop
wildone Jan 29, 2024
c09b8da
add helper function.
wildone Jan 29, 2024
4059aab
ensure forms submission works.
wildone Jan 29, 2024
702e3f1
use sdubmit url for form writing.
wildone Jan 30, 2024
498527f
add helper aria dialog.
wildone Feb 28, 2024
85289fc
add helper image dialog.
wildone Feb 28, 2024
5b3caa1
add role to aria dialog.
wildone Feb 28, 2024
4b64174
rename components.
wildone Feb 28, 2024
fc7550e
update new component examples.
wildone Feb 28, 2024
e2e29cb
update aria select to use generic attribute structure.
wildone Feb 28, 2024
f7a160a
add helper attribute select model.
wildone Feb 28, 2024
fae7c5b
add embed component.
wildone Feb 28, 2024
6099799
fix columns.
wildone Feb 28, 2024
0aa82f7
add stix form components.
wildone Mar 13, 2024
e3583d4
add console print.
wildone Mar 13, 2024
45cd2e2
update forms to include stix inputs.
wildone Mar 13, 2024
9c0785f
refactor accordion.
wildone Mar 13, 2024
9e1b896
update container to include aria and stix forms.
wildone Mar 13, 2024
8937dd3
add frontend code to main clientlibs.
wildone Mar 13, 2024
215ffa3
add embed model.
wildone Mar 13, 2024
4495ea7
add accordion model.
wildone Mar 13, 2024
4538e38
update utils.
wildone Mar 13, 2024
c535ce3
add sample pages.
wildone Mar 13, 2024
940b011
ensure image component uses picture container.
wildone Mar 13, 2024
eeb57ad
add teaser.
wildone Mar 13, 2024
c6b7f4f
update input type on stix forms.
wildone Mar 13, 2024
59c7a03
update field labels.
wildone Mar 25, 2024
b4a2e8a
add composite field.
wildone Mar 25, 2024
9992fc0
add stix composite fields.
wildone Mar 25, 2024
b3505a0
add parsys component to only render nodes that have sling resource type.
wildone Mar 26, 2024
c588f52
add new dialog component to list component actions.
wildone Apr 2, 2024
d2a3a25
update vs config.
wildone Apr 2, 2024
7ad1878
add events actions to form.
wildone Apr 2, 2024
0dbe636
add new dialog select to support groups.
wildone Apr 2, 2024
7b70817
update helpers.
wildone Apr 2, 2024
62cb4ee
update event names to use events namespace.
wildone Apr 2, 2024
f10136a
update composite to use parsys that does not print non sling nodes.
wildone Apr 2, 2024
7750cdf
update form event tab.
wildone Apr 2, 2024
0e02cb5
update form to use non breaking parsys.
wildone Apr 2, 2024
77a77f1
update form dialog with event config.
wildone Apr 2, 2024
37087bc
add form custom component actions for display in dialog.
wildone Apr 2, 2024
7632897
move files operations into its own namespace.
wildone Apr 2, 2024
726015b
add additional events.
wildone Apr 2, 2024
ac8feab
update field notes.
wildone Apr 2, 2024
eb8bc04
add js vendor library jsonpath.
wildone Apr 3, 2024
69a1215
fix typo.
wildone Apr 8, 2024
278c785
update form urls.
wildone Apr 16, 2024
76b122e
add default name to form field model.
wildone Apr 16, 2024
9dfeb7e
add a no suffix extention.
wildone Apr 16, 2024
c8087f1
add ability to add form field hints.
wildone Apr 16, 2024
920f410
enable form label.
wildone Apr 16, 2024
b0d3f9e
move select utils into its namespace.
wildone Apr 16, 2024
5273440
add missing form field attribute.
wildone Apr 16, 2024
799a78a
move editor utils into its namespace.
wildone Apr 16, 2024
7a58034
fix meta for form radio.
wildone Apr 16, 2024
242df84
update form template urls to remove url params to be handled by flows.
wildone Apr 16, 2024
d76b67e
refactor events namespace with default and custom events.
wildone Apr 16, 2024
b3ba0cf
refactor forms component event and data handling.
wildone Apr 16, 2024
bce057a
update stix to use core composite functions.
wildone Apr 16, 2024
767c610
update names.
wildone Apr 18, 2024
8f41e88
add helpers to watch dom elements.
wildone Apr 22, 2024
3d2bb38
add sortable vendor lib.
wildone Apr 22, 2024
677e3bc
add composite list type.
wildone Apr 22, 2024
e346dfc
update addRow to return new row id.
wildone Apr 22, 2024
7ea6abf
update component behaviour to init on being added to dom dynamicaly.
wildone Apr 23, 2024
4313c9e
update form component behavior initialization and watch for new compo…
wildone Apr 23, 2024
7aefa28
fix aria attribute on container.
wildone Apr 23, 2024
24aa7f6
add user readonly toggle for composite.
wildone Apr 23, 2024
e53ba97
ensure composite list contents displayed as column.
wildone Apr 23, 2024
21e5b87
update ability to set value on composite field.
wildone Apr 23, 2024
f1d4f3a
update composite to handle only known input types.
wildone Apr 23, 2024
d5e778e
update text dom loading.
wildone Apr 23, 2024
a13f683
add new template container.
wildone Apr 23, 2024
8641baf
add template container to accordion.
wildone Apr 23, 2024
9be5090
fix dom watch selectors.
wildone Apr 29, 2024
88f5bf0
add latest version of choicehjs vendor lib.
wildone Apr 29, 2024
7c11639
ensure id attributes for each form field is prefixed with id of parent.
wildone Apr 30, 2024
331060b
ensure form component name is resource name.
wildone May 7, 2024
0725f3b
update label to ensure for works.
wildone May 7, 2024
04719fa
update debug label.
wildone May 7, 2024
445e772
set default for accrodion templated value.
wildone May 7, 2024
8d09fd0
fix breadcrumb.
wildone May 7, 2024
32f422f
add missing options to acordion item.
wildone May 7, 2024
bde9632
cleanup js namespace signatures.
wildone May 7, 2024
864a982
add ability to add new accordion item from template.
wildone May 7, 2024
5628acd
fix selectors.
wildone May 7, 2024
8ff66ae
fix js to use jquery syntax.
wildone May 8, 2024
e4c3b10
fix jquery syntax.
wildone May 8, 2024
5b2e66e
fix jquery usage.
wildone May 8, 2024
61104da
move events to base component.
wildone May 8, 2024
fc30ea5
do not output emprty and null values.
wildone May 9, 2024
63610c0
add aocnfig field to events.
wildone May 13, 2024
acfc007
clenaup emmitting events.
wildone May 13, 2024
c32573e
update usage of emitLocalEvent.
wildone May 13, 2024
4bb4fab
add hint.
wildone May 13, 2024
107cd6b
fix button toggle elements.
wildone May 20, 2024
14285a1
fix button toggle.
wildone May 20, 2024
60dbb67
format button template.
wildone May 20, 2024
61c870d
move global hidden style to page styles.
wildone May 20, 2024
334348f
refactor custom event name into variable.
wildone May 22, 2024
f4d0c6f
reactor accordion to allow adding new templates.
wildone May 23, 2024
887a128
fix typo.
wildone May 23, 2024
7559bf3
fix init logic for button.
wildone May 23, 2024
40a7c58
update js to use jquery.
wildone Jun 20, 2024
a35e56b
update models to allow field override via selectors.
wildone Jun 20, 2024
45705d7
update form element model ids usage.
wildone Jun 20, 2024
0c5b252
add data-fieldId to label.
wildone Jun 20, 2024
a6ae702
remove junk text.
wildone Jun 20, 2024
6b0d6d8
add title to button.
wildone Jun 20, 2024
dde3dde
add sendMessage to embed.
wildone Jun 20, 2024
57db97f
update select to load js.
wildone Jun 20, 2024
84b2421
add author helpers to template.
wildone Jun 20, 2024
4c09f1f
add windowListener to raise events.
wildone Jun 20, 2024
62b1c94
update select to load js.
wildone Jun 20, 2024
881f810
update console messages.
wildone Jun 21, 2024
0bf1d82
fix error handling in dropdown init.
wildone Jun 21, 2024
afac6ef
ensure form field has label and field optional.
wildone Jun 21, 2024
3a48dd3
add value option to input field.
wildone Jun 21, 2024
9238d3e
add template component-info.
wildone Jun 21, 2024
7d3377a
update component badges to use template.
wildone Jun 21, 2024
e5ccfd9
ensure all form components available for composite field.
wildone Jun 21, 2024
ef75418
add placeholder for container.
wildone Jun 24, 2024
20c4db2
update dialog label.
wildone Jun 24, 2024
61b3ae4
update placeholder.
wildone Jun 24, 2024
5ebab9f
add css helper to hide field if its type of hidden.
wildone Jun 24, 2024
9c310cd
fix index handling.
wildone Jun 25, 2024
1b1000f
update form submit to use defaults on submit.
wildone Jun 26, 2024
09b6cd6
fix log message.
wildone Jun 26, 2024
9f4c13c
fix form submit event params.
wildone Jun 26, 2024
e752ec2
fix selectors for accordion.
wildone Jun 28, 2024
75edf8a
update common form event config.
wildone Jun 28, 2024
c7230c6
use parsys that does not break on nodes that dont have a resource type.
wildone Jun 28, 2024
86a0ebd
add events to add templates to components to composite and container.
wildone Jun 28, 2024
8a7bbc9
update typo.
wildone Jun 28, 2024
436d171
ensure embed fits its container.
wildone Jul 15, 2024
0622458
fix default options on alignment tab.
wildone Jul 15, 2024
ddedb11
update container badge to show id.
wildone Jul 15, 2024
381fdd5
update global html body tag fit.
wildone Jul 15, 2024
7fde68c
add missign aria dialog tab to footer.
wildone Jul 15, 2024
a0376b9
add dialog to body container.
wildone Jul 15, 2024
63d45e4
add container styles.
wildone Jul 15, 2024
d1d67df
update dialogs to add missing tabs.
wildone Jul 15, 2024
0ba5f83
replace forEach with while loop for children iterator.
wildone Jul 15, 2024
9f776b9
ensure all resources have an id.
wildone Jul 15, 2024
b3582ba
add missing dialog tab.
wildone Jul 15, 2024
0a7d58e
user resource parent id generating child id instead of resource name.
wildone Jul 15, 2024
86f43e8
do not duplicate id in field name.
wildone Jul 15, 2024
982897d
update debug config.
wildone Jul 15, 2024
c4e722e
use resource id on composite wrapper div.
wildone Jul 15, 2024
e9b0a55
add feature to highligh form comoponents if they have duplicate id.
wildone Jul 15, 2024
c0a0777
add missing dialog tabs.
wildone Jul 16, 2024
9f85047
fix typo.
wildone Jul 17, 2024
fa8677c
inherit from core forms components.
wildone Jul 17, 2024
12e0e84
update debug group with paths.
wildone Jul 17, 2024
4d9c661
update debug messages.
wildone Jul 17, 2024
cc6db4f
update debug messages.
wildone Jul 17, 2024
95e01d7
refactor and add event proxy event type.
wildone Jul 19, 2024
fe36a5f
add action names.
wildone Jul 19, 2024
7f4bfe6
update events dialog with event proxy.
wildone Jul 19, 2024
7e0f8e8
add event proxy to embed.
wildone Jul 19, 2024
ac9433d
add jsconfig.
wildone Aug 14, 2024
8cc41df
update js config.
wildone Aug 14, 2024
4662f11
update tms messages.
wildone Aug 14, 2024
8b5f867
add new topic and fix socket send.
wildone Aug 14, 2024
0426ba8
update error messages.
wildone Aug 14, 2024
2cc785a
refactor embed message emit and add new actions.
wildone Aug 14, 2024
1b20fad
add debug.
wildone Aug 15, 2024
aeb8e2c
add config for intellisence.
wildone Aug 15, 2024
29c9638
add hint.
wildone Aug 15, 2024
0904487
add ability to get data for iframe with events and though tms.
wildone Aug 15, 2024
55f53d2
update to use event data as payload.
wildone Aug 15, 2024
7c5779a
update to allow data request api to use config as json.
wildone Sep 8, 2024
b7fe006
add edit mode css token.
wildone Sep 8, 2024
7395b59
stop aside growth in edit more.
wildone Sep 8, 2024
3ad4b90
move header above asides.
wildone Sep 8, 2024
2bc5d20
add logging.
wildone Sep 9, 2024
aff91e6
update form event register.
wildone Sep 9, 2024
eaca945
update logging.
wildone Sep 9, 2024
22f6be2
fix form input check for editor and select.
wildone Sep 9, 2024
69712cb
add logs.
wildone Sep 14, 2024
2c33651
ensure form load with query string is async.
wildone Sep 14, 2024
b0b6c8d
default to form post if not set.
wildone Sep 15, 2024
b59345c
fix textarea tag to remove empty lines.
wildone Sep 15, 2024
1308f5a
fix accordion template insert.
wildone Sep 21, 2024
e8cfcbc
stop openning of nested accordions on open.
wildone Sep 21, 2024
65d267f
when accordion item is opened, check parents and open them.
wildone Sep 21, 2024
29554ad
enable event json config and fix iframe event window filtering.
wildone Sep 30, 2024
0604844
update evenet emit logic to match by topic or action.
wildone Sep 30, 2024
6eee4f9
update event type dropdown to not select any value by default.
wildone Oct 7, 2024
3253b21
update default event type to be listen.
wildone Oct 7, 2024
239dc1f
add sample content.
wildone Oct 10, 2024
2213eca
add sample content.
wildone Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"configurations": [
{
"type": "java",
"name": "Debug (Attach)",
"name": "Debug (Attach 8115)",
"projectName": "websight",
"request": "attach",
"projectName": "CMS",
"hostName": "localhost",
"port": "8115"
}
Expand Down
1 change: 1 addition & 0 deletions application/backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<commonmark.version>0.20.0</commonmark.version>
<jgit.version>6.5.0.202303070854-r</jgit.version>
<slf4j.version>2.0.7</slf4j.version>
<log4j.version>2.20.0</log4j.version>
<JavaEWAH.version>1.2.3</JavaEWAH.version>
</properties>
<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ai.typerefinery.websight.actions.spaces;

import org.jetbrains.annotations.NotNull;
import org.osgi.service.component.annotations.Component;
import pl.ds.websight.ui.framework.actions.service.Condition;
import pl.ds.websight.ui.framework.actions.service.WebAction;
import pl.ds.websight.ui.framework.actions.service.WebActionConfig;
import pl.ds.websight.ui.framework.actions.service.conditions.HasPrivilegesCondition;

@Component
public class ExportSpaceWebAction implements WebAction {
private static final WebActionConfig CONFIG = WebActionConfig.Builder.newWebActionConfig("/apps/typerefinery/components/actions/spaces/exportspace.js")
.forAllModules()
.forTypes(new String[] { "ws:Space" }).forViewTypes(new String[] { "row" })
.withCondition((Condition)new HasPrivilegesCondition(new String[] { "ws:publish" })).withRanking(600)
.build();

@NotNull
public WebActionConfig getConfig() {
return CONFIG;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ai.typerefinery.websight.actions.spaces;

import org.jetbrains.annotations.NotNull;
import org.osgi.service.component.annotations.Component;
import pl.ds.websight.ui.framework.actions.service.Condition;
import pl.ds.websight.ui.framework.actions.service.WebAction;
import pl.ds.websight.ui.framework.actions.service.WebActionConfig;
import pl.ds.websight.ui.framework.actions.service.conditions.HasPrivilegesCondition;

@Component
public class ImportSpaceWebAction implements WebAction {
private static final WebActionConfig CONFIG = WebActionConfig.Builder.newWebActionConfig("/apps/typerefinery/components/actions/spaces/importspace.js")
.forAllModules()
.forTypes(new String[] { "ws:Space" }).forViewTypes(new String[] { "row" })
.withCondition((Condition)new HasPrivilegesCondition(new String[] { "ws:publish" })).withRanking(600)
.build();

@NotNull
public WebActionConfig getConfig() {
return CONFIG;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package ai.typerefinery.websight.actions.spaces;

import java.net.URI;

import org.apache.commons.lang3.StringUtils;

public class SpaceConfigModel {

public static final String PAGES_SPACE_RESOURCE_TYPE = "typerefinery/components/structure/pagesspace";
public static final String ASSEPS_SPACE_RESOURCE_TYPE = "typerefinery/components/structure/assetsspace";

public static final String DEFAULT_GIT_USER_NAME = "typerefinery";
public static final String DEFAULT_GIT_USER_EMAIL = "deploy@typerefinery.ai";

public static final String DEFAULT_LOCAL_PATH = "content";
public static final String DEFAULT_LOCAL_CONTENT_ROOT_PATH = "contentroot";
public static final String DEFAULT_GIT_CONTENT_ROOT_ENV_VAR = "GIT_CONTENT_ROOT";
public static final String DEFAULT_PACKAGE_GROUP = "space-backup";
public static final String DEFAULT_PACKAGE_PREFIX = "space-backup-";
public static final String DEFAULT_PACKAGE_VERSION = "1.0.0";
public static final String DEFAULT_GIT_PROVIDER = "github";

public String repositoryUrl;
public String token;
public String branch;
public String branchContent;
public String configUsername = DEFAULT_GIT_USER_NAME;
public String configEmail = DEFAULT_GIT_USER_EMAIL;

public String getGitProvider() {
if (StringUtils.isEmpty(repositoryUrl)) {
return DEFAULT_GIT_PROVIDER;
}
URI repositoryUri = URI.create(repositoryUrl);

return repositoryUri.getHost();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package ai.typerefinery.websight.actions.spaces;

import java.util.Map;

import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ai.typerefinery.websight.actions.spaces.rest.PublishSpaceRestAction;
import pl.ds.websight.pages.core.api.Page;
import pl.ds.websight.rest.framework.RestActionResult;

public class SpaceUtil {

private static final Logger LOG = LoggerFactory.getLogger(PublishSpaceRestAction.class);

public static SpaceConfigModel getSpaceConfig(Resource space) {
SpaceConfigModel spaceConfig = new SpaceConfigModel();
try {
Resource pagesRoot = space.getChild("pages");
// quick fail if pagesRoot is null
if (pagesRoot == null) {
LOG.error("No pages to deploy.");
return spaceConfig;
}

Resource adminChild = pagesRoot.getChild("_admin");
// quick fail if adminChild is null
if (adminChild == null) {
LOG.error("No admin page with config to deploy.");
return spaceConfig;
}

Page adminChildPage = adminChild.adaptTo(Page.class);
Map<String, Object> adminChildProperties = adminChildPage.getContentProperties();
if (adminChildProperties == null) {
LOG.error("Admin config page does not have any properties.");
return spaceConfig;
}
// ValueMap adminChildValueMap = adminChild.getValueMap(

spaceConfig.repositoryUrl = adminChildProperties.containsKey("deployGithubRepositoryUrl")
? adminChildProperties.get("deployGithubRepositoryUrl").toString()
: "";
spaceConfig.branch = adminChildProperties.containsKey("deployGithubBranch")
? adminChildProperties.get("deployGithubBranch").toString()
: "";
spaceConfig.token = adminChildProperties.containsKey("deployGithubToken")
? adminChildProperties.get("deployGithubToken").toString()
: "";
spaceConfig.configUsername = adminChildProperties.containsKey("deployGithubUserName")
? adminChildProperties.get("deployGithubUserName").toString()
: "";

spaceConfig.configEmail = adminChildProperties.containsKey("deployGithubUserEmail")
? adminChildProperties.get("deployGithubUserEmail").toString()
: "";
spaceConfig.branchContent = adminChildProperties.containsKey("contentGithubBranch")
? adminChildProperties.get("contentGithubBranch").toString()
: "";

} catch (Exception e) {
LOG.error("Error getting space config.", e);
}
return spaceConfig;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package ai.typerefinery.websight.actions.spaces.rest;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.vault.packaging.Packaging;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.event.jobs.JobManager;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ai.typerefinery.websight.actions.spaces.SpaceConfigModel;
import ai.typerefinery.websight.actions.spaces.SpaceUtil;
import ai.typerefinery.websight.repository.RepositoryUtil;
import ai.typerefinery.websight.utils.git.GitConfig;
import ai.typerefinery.websight.utils.git.GitUtil;
import pl.ds.websight.rest.framework.RestAction;
import pl.ds.websight.rest.framework.RestActionResult;
import pl.ds.websight.rest.framework.annotations.PrimaryTypes;
import pl.ds.websight.rest.framework.annotations.SlingAction;
import static ai.typerefinery.websight.actions.spaces.SpaceConfigModel.*;

@SlingAction
@PrimaryTypes({ "ws:PagesSpace" })
@Component
public class ExportSpaceRestAction extends AbstractSpacesRestAction<SpacesRestModel, Void>
implements RestAction<SpacesRestModel, Void> {

private static final Logger LOG = LoggerFactory.getLogger(ExportSpaceRestAction.class);

@Reference
private Packaging packaging;

@Reference
private JobManager jobManager;

RestActionResult<Void> execute(SpacesRestModel model, List<Resource> resources) {

// publish pages and assets recursively
boolean isCommit = model.getCommit();

// this would only run on one space
for (Resource resource : resources) {

try {

// get space config
SpaceConfigModel spaceConfig = SpaceUtil.getSpaceConfig(resource);

if (StringUtils.isNotBlank(spaceConfig.repositoryUrl)) {

// get environment variable GIT_CONTENT_ROOT
String docrootPath = System.getenv(DEFAULT_GIT_CONTENT_ROOT_ENV_VAR);
if (StringUtils.isBlank(docrootPath)) {
docrootPath = DEFAULT_LOCAL_CONTENT_ROOT_PATH;
}

// create new folder docroot/export/githuib/<space-name>
Path contentSpacePath = Paths.get(docrootPath,DEFAULT_LOCAL_PATH, spaceConfig.getGitProvider(), resource.getName());
contentSpacePath.toFile().mkdirs();

GitConfig gitConfig = null;
// clone git repo to docroot/export/githuib/<space-name>
try {
// create git config object
gitConfig = new GitConfig(
spaceConfig.repositoryUrl,
contentSpacePath,
spaceConfig.branchContent,
spaceConfig.token,
spaceConfig.configEmail,
spaceConfig.configUsername
);

// get git object
GitUtil.initializeGit(gitConfig, true, true);

// get latest from git remote
GitUtil.pull(gitConfig, null);

} catch (Exception ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
return RestActionResult.failure("Failed", MessageFormat.format("Error while exporting to github, {}", ex.getMessage()));
}

// export pages to docroot/export/githuib/<space-name>
RepositoryUtil.jcrExport(resource.getResourceResolver(), contentSpacePath.toString(), resource.getPath(), true);

Path jcrRootToCommit = Paths.get(contentSpacePath.toString(), "jcr_root");

if (isCommit && jcrRootToCommit.toFile().exists()) {

try {

// add all files to git
GitUtil.createCommit(gitConfig, ".", "Exported from " + resource.getPath());

// push to git remote
GitUtil.push(gitConfig);

} catch (Exception ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
return RestActionResult.failure("Failed", MessageFormat.format("Error while exporting to github, {}", ex.getMessage()));
}
} else {
LOG.info("Not committing to github.");
}

} else {
LOG.error("Repository URL is blank, not exporting to github.");
return RestActionResult.failure("Failed", "Please configure space with Git config.");
}

return RestActionResult.success("Success", "Space exported successfully.");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return RestActionResult.failure("Failed", "Error exporting space.");
}

}

return RestActionResult.failure("Failed", "Could not export space.");
}

private RestActionResult<Void> getSuccessResult(int assetsCount) {
String message = "Publishing requested";
String messageDetails = String.format("Publishing requested successfully for %d %s",
new Object[] { Integer.valueOf(assetsCount),
(assetsCount == 1) ? "asset" : "assets" });
return RestActionResult.success(message, messageDetails);
}

String getFailureMessage(SpacesRestModel model) {
return "Error while requesting publishing";
}
}
Loading
Loading