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

Workflow Draft - Working Space - Editing Version - Record Copy - Draft Punk #3592

Merged
merged 64 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
d9eab06
Adding Draft type of metadata to domain. Not used yet
Delawen Nov 7, 2018
56ae2f5
Adding the DataManager utilities for draft. Draft is not added yet wh…
Delawen Nov 8, 2018
c0a40a3
When trying to edit an approved metadata, it redirect the editor to t…
Delawen Nov 9, 2018
46ed135
When a Metadata (approved) is removed, remove all related drafts
Delawen Nov 12, 2018
2f21dbc
Make sure redirection from approved editor to draft editor works with…
Delawen Nov 12, 2018
f165b34
Make sure Draft is only visible to editors or more
Delawen Nov 13, 2018
dfa497b
Draft working with tests. Select buckets still not compatible
Delawen Nov 23, 2018
276e8a4
Fixing Batch/Selection. As it is based on UUID, we have to decide if …
Delawen Nov 26, 2018
c43a303
Better UI for displaying draft and non-draft version
Delawen Dec 11, 2018
c195091
When publishing a record with workflow enabled, status changes automa…
Delawen Dec 11, 2018
b29c20f
More testing and updated integration-tests
Delawen Dec 13, 2018
694c841
Adding more status changes interactions when a record goes through th…
Delawen Dec 13, 2018
269255a
Do not show Editing Instance (draft) in search results.
Delawen Dec 17, 2018
e1f93f7
Adding more tests to the draft
Delawen Feb 11, 2019
7c42672
Improving listeners to keep them synchronized with transaction finish.
Delawen Feb 20, 2019
1733de3
Integration Tests for draft
Delawen Feb 22, 2019
9aca421
Make sure download buttons on metadata view download the proper version
Delawen Feb 25, 2019
6ee8fae
Make sure the downloaded ZIP/MEF takes the proper version
Delawen Feb 25, 2019
031c77a
Improving transaction management: do transactions shorter and use a t…
Delawen Feb 25, 2019
091cea9
Improving database management: rely more on optimizations on Spring a…
Delawen Mar 13, 2019
a4e1eab
Separate some transactions because delaying the commit made the metad…
Delawen Apr 4, 2019
dc9e9a1
Cosmetic / Missing header and format (removing tabs and fix indent). …
fxprunayre Apr 17, 2019
566f9bd
Adding message if no workflow is enabled
Delawen Apr 25, 2019
60af54c
Adding draft validation status to the dashboard editor
Delawen Apr 25, 2019
d184263
Fixing concurrent issue when trying to save too quickly after validat…
Delawen Apr 29, 2019
06f9ba2
Restoring check if there is more than one metadata with the same UUID…
Delawen Apr 29, 2019
83eec37
Removing unused comment
Delawen Apr 29, 2019
20d6779
Better error messages
Delawen Apr 29, 2019
7c0913a
Better string for translation
Delawen Apr 29, 2019
15716d8
Removing commented import
Delawen May 6, 2019
f148a3b
As the rest of the calls of updateFixedInfo, consider parentUuid as null
Delawen May 6, 2019
bec12aa
Adding a foreign key on draft table to metadata table. No draft can b…
Delawen May 6, 2019
6a9d58b
Add checks to act only if draft is enabled
Delawen May 7, 2019
8b1b700
Hide ratings for draft/working copy version
Delawen May 7, 2019
9eeb603
Unifying http requests
Delawen May 7, 2019
f7711a1
Fixing icon for mdaction-get mef
Delawen May 7, 2019
b449017
Hiding duplicate option for drafts
Delawen May 7, 2019
c96cf48
We are never going to see a draft on this list, removing unused code.
Delawen May 7, 2019
1191275
Moving all listeners to same project. Now they are triggered again.
Delawen May 7, 2019
03f20b1
Styling for the `Draft` features of GN:
MichelGabriel May 8, 2019
1fff875
Make the 'draft' message full width. Display the status under the title.
MichelGabriel May 9, 2019
06738ea
Dublin core / Record view / Keywords not displayed (#3781)
fxprunayre May 8, 2019
fd584ca
Associated resources / Clarify links added when linking service and d…
fxprunayre May 8, 2019
b036297
Fixes for menubar colours for when custom colours are set in the admin.
MichelGabriel May 8, 2019
493dd3e
Fixing downloads in different forms, the approved parameter was lost …
Delawen May 9, 2019
14de187
Attachments now consider approved and draft versions.
Delawen May 10, 2019
d4dd400
Making OnlineSrcService aware of draft
Delawen May 10, 2019
c1bea7b
Bug fix: there was no id on cloneFiles draft creation phase
Delawen May 10, 2019
0bb4da2
Thumbnails working
Delawen May 10, 2019
151f86f
Adding parameter approved to list of files on editor (OnlineSrc)
Delawen May 13, 2019
e8cd87a
EditLib is created in several parts of the code. But the list of what…
Delawen May 14, 2019
f4d98a3
Full view/Formatters: Select the metadata-view div that is visible
Delawen May 14, 2019
76ee527
Do the ownership change on draft
Delawen May 14, 2019
f6c5248
Merge branch 'master' into draft2018
juanluisrp Jun 3, 2019
5d83a51
Merge branch 'master' into draft2018
josegar74 Jun 14, 2019
7a98230
Fix check of metadata owned by a user in Users API
josegar74 Jun 14, 2019
1c3656a
Metadata editing copy - don't allow delete a published copy if exists…
josegar74 Jun 14, 2019
e603452
Draft / Disable menu to set a draft as template or to apply minor edi…
fxprunayre Jun 18, 2019
5559354
Access manager - remove code to handle exception for Reviewers of any…
josegar74 Jun 18, 2019
c40be4d
Change 'Delete' button in working copy (draft) metadata to 'Cancel wo…
josegar74 Jun 18, 2019
004cc98
Fix typo
josegar74 Jun 18, 2019
529ee7f
Draft / Approved record display draft files. Using internal id.
fxprunayre Jun 18, 2019
d22b0d5
Draft / Permalink on a draft does not make sense. Same for create a c…
fxprunayre Jun 18, 2019
f461538
Merge branch 'master' into draft2018
fxprunayre Jun 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ schemas/*/doc/*/*.rst
*.old
web-ui-docs/package-lock.json
release/jetty/*
chromedriver
node_modules
package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.fao.geonet.repository.specification.UserGroupSpecs;
import org.fao.geonet.utils.Log;
import org.springframework.context.ApplicationContext;
import org.springframework.data.jpa.domain.Specification;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -119,7 +120,7 @@ void transferMetadata(ApplicationContext applicationContext, List<User> oldMetad
User oldOwner = oldMetadataOwnerList.get(i);

// Transfer metadata to user but keep old group
List<Metadata> metadataList = metadataRepository.findAll(MetadataSpecs.isOwnedByUser(oldOwner.getId()));
List<Metadata> metadataList = metadataRepository.findAll((Specification<Metadata>)MetadataSpecs.isOwnedByUser(oldOwner.getId()));
for (Metadata metadata : metadataList) {
dataManager.updateMetadataOwner(metadata.getId(), Integer.toString(newMetadataOwner.getId()),
Integer.toString(metadata.getSourceInfo().getGroupOwner()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
import org.fao.geonet.kernel.AccessManager;
import org.fao.geonet.kernel.DataManager;
import org.fao.geonet.kernel.GeonetworkDataDirectory;
import org.fao.geonet.kernel.datamanager.IMetadataUtils;
import org.fao.geonet.kernel.setting.SettingManager;
import org.fao.geonet.lib.Lib;
import org.fao.geonet.repository.MetadataRepository;
import org.fao.geonet.utils.IO;
import org.springframework.context.ApplicationContext;
import org.springframework.web.multipart.MultipartFile;
Expand Down Expand Up @@ -77,15 +79,22 @@ public FilesystemStore() {
public List<MetadataResource> getResources(ServiceContext context, String metadataUuid,
Sort sort,
String filter) throws Exception {
return getResources(context, metadataUuid, sort, filter, true);
}

@Override
public List<MetadataResource> getResources(ServiceContext context, String metadataUuid,
Sort sort,
String filter, Boolean approved) throws Exception {
List<MetadataResource> resourceList = new ArrayList<>();
ApplicationContext _appContext = ApplicationContextHolder.get();
String metadataId = getAndCheckMetadataId(metadataUuid);
String metadataId = getAndCheckMetadataId(metadataUuid, approved);
AccessManager accessManager = _appContext.getBean(AccessManager.class);
boolean canEdit = accessManager.canEdit(context, metadataId);

resourceList.addAll(getResources(context, metadataUuid, MetadataResourceVisibility.PUBLIC, filter));
resourceList.addAll(getResources(context, metadataUuid, MetadataResourceVisibility.PUBLIC, filter, approved));
if (canEdit) {
resourceList.addAll(getResources(context, metadataUuid, MetadataResourceVisibility.PRIVATE, filter));
resourceList.addAll(getResources(context, metadataUuid, MetadataResourceVisibility.PRIVATE, filter, approved));
}

if (sort == Sort.name) {
Expand All @@ -95,13 +104,20 @@ public List<MetadataResource> getResources(ServiceContext context, String metada
return resourceList;
}

@Override
@Deprecated
public List<MetadataResource> getResources(ServiceContext context, String metadataUuid,
MetadataResourceVisibility visibility,
String filter) throws Exception {
return getResources(context, metadataUuid, visibility, filter, true);
}

@Override
public List<MetadataResource> getResources(ServiceContext context, String metadataUuid,
MetadataResourceVisibility visibility,
String filter) throws Exception {
String filter, Boolean approved) throws Exception {
ApplicationContext _appContext = ApplicationContextHolder.get();
String metadataId = getAndCheckMetadataId(metadataUuid);
String metadataId = getAndCheckMetadataId(metadataUuid, approved);
GeonetworkDataDirectory dataDirectory =
_appContext.getBean(GeonetworkDataDirectory.class);
SettingManager settingManager = _appContext.getBean(SettingManager.class);
Expand Down Expand Up @@ -140,10 +156,14 @@ public List<MetadataResource> getResources(ServiceContext context, String metada

return resourceList;
}


@Override
@Deprecated
public Path getResource(ServiceContext context, String metadataUuid, String resourceId) throws Exception {
return getResource(context, metadataUuid, resourceId, true);
}

@Override
public Path getResource(ServiceContext context, String metadataUuid, String resourceId, Boolean approved) throws Exception {
// Those characters should not be allowed by URL structure
if (resourceId.contains("..") ||
resourceId.startsWith("/") ||
Expand All @@ -155,7 +175,7 @@ public Path getResource(ServiceContext context, String metadataUuid, String reso
ApplicationContext _appContext = ApplicationContextHolder.get();
AccessManager accessManager = _appContext.getBean(AccessManager.class);
GeonetworkDataDirectory dataDirectory = _appContext.getBean(GeonetworkDataDirectory.class);
String metadataId = getAndCheckMetadataId(metadataUuid);
String metadataId = getAndCheckMetadataId(metadataUuid, approved);
Path metadataDir = Lib.resource.getMetadataDir(dataDirectory, metadataId);

Path resourceFile = null;
Expand All @@ -174,6 +194,7 @@ public Path getResource(ServiceContext context, String metadataUuid, String reso
}
}


if (resourceFile != null && Files.exists(resourceFile)) {
if (resourceFile.getParent().getFileName().toString().equals(
MetadataResourceVisibility.PRIVATE.toString()) && !canDownload) {
Expand Down Expand Up @@ -212,8 +233,17 @@ private MetadataResource getResourceDescription(String metadataUuid, MetadataRes
public MetadataResource putResource(ServiceContext context, String metadataUuid,
MultipartFile file,
MetadataResourceVisibility visibility) throws Exception {
return putResource(context, metadataUuid, file, visibility, true);
}


@Override
public MetadataResource putResource(ServiceContext context, String metadataUuid,
MultipartFile file,
MetadataResourceVisibility visibility,
Boolean approved) throws Exception {
canEdit(context, metadataUuid);
Path filePath = getPath(metadataUuid, visibility, file.getOriginalFilename());
Path filePath = getPath(metadataUuid, visibility, file.getOriginalFilename(), approved);

BufferedOutputStream stream =
new BufferedOutputStream(
Expand All @@ -228,34 +258,43 @@ public MetadataResource putResource(ServiceContext context, String metadataUuid,

@Override
public MetadataResource putResource(ServiceContext context, String metadataUuid, Path file, MetadataResourceVisibility visibility) throws Exception {
return putResource(context, metadataUuid, file, visibility, true);
}

@Override
public MetadataResource putResource(ServiceContext context, String metadataUuid, Path file, MetadataResourceVisibility visibility, Boolean approved) throws Exception {
canEdit(context, metadataUuid);
Path filePath = getPath(metadataUuid, visibility, file.getFileName().toString());
Path filePath = getPath(metadataUuid, visibility, file.getFileName().toString(), approved);

FileUtils.copyFile(file.toFile(), filePath.toFile());

return getResourceDescription(metadataUuid, visibility, filePath);
}


@Override
public MetadataResource putResource(ServiceContext context, String metadataUuid, URL fileUrl, MetadataResourceVisibility visibility) throws Exception {
return putResource(context, metadataUuid, fileUrl, visibility, true);
}

@Override
public MetadataResource putResource(ServiceContext context, String metadataUuid, URL fileUrl, MetadataResourceVisibility visibility, Boolean approved) throws Exception {
canEdit(context, metadataUuid);
String fileName = FilenameUtils.getName(fileUrl.getPath());
if (fileName.contains("?")) {
fileName = fileName.substring(0, fileName.indexOf("?"));
}

Path filePath = getPath(metadataUuid, visibility, fileName);
Path filePath = getPath(metadataUuid, visibility, fileName, approved);

Files.copy(fileUrl.openStream(), filePath);

return getResourceDescription(metadataUuid, visibility, filePath);
}

private Path getPath(String metadataUuid, MetadataResourceVisibility visibility, String fileName) throws Exception {
private Path getPath(String metadataUuid, MetadataResourceVisibility visibility, String fileName, Boolean approved) throws Exception {
ApplicationContext _appContext = ApplicationContextHolder.get();
GeonetworkDataDirectory dataDirectory = _appContext.getBean(GeonetworkDataDirectory.class);
String metadataId = getAndCheckMetadataId(metadataUuid);
String metadataId = getAndCheckMetadataId(metadataUuid, approved);
Path metadataDir = Lib.resource.getMetadataDir(dataDirectory, metadataId);

Path folderPath = metadataDir.resolve(visibility.toString());
Expand All @@ -282,8 +321,13 @@ private Path getPath(String metadataUuid, MetadataResourceVisibility visibility,

@Override
public String delResource(ServiceContext context, String metadataUuid) throws Exception {
return delResource(context, metadataUuid, true);
}

@Override
public String delResource(ServiceContext context, String metadataUuid, Boolean approved) throws Exception {
ApplicationContext _appContext = ApplicationContextHolder.get();
String metadataId = getAndCheckMetadataId(metadataUuid);
String metadataId = getAndCheckMetadataId(metadataUuid, approved);

canEdit(context, metadataUuid);

Expand All @@ -296,13 +340,17 @@ public String delResource(ServiceContext context, String metadataUuid) throws Ex
return String.format("Unable to remove metadata '%s' directory.", metadataUuid);
}
}
@Override
public String delResource(ServiceContext context, String metadataUuid, String resourceId) throws Exception {
return delResource(context, metadataUuid, resourceId, true);
}


@Override
public String delResource(ServiceContext context, String metadataUuid, String resourceId) throws Exception {
public String delResource(ServiceContext context, String metadataUuid, String resourceId, Boolean approved) throws Exception {
canEdit(context, metadataUuid);

Path filePath = getResource(context, metadataUuid, resourceId);
Path filePath = getResource(context, metadataUuid, resourceId, approved);

try {
Files.deleteIfExists(filePath);
Expand All @@ -317,12 +365,20 @@ public String delResource(ServiceContext context, String metadataUuid, String re
public MetadataResource patchResourceStatus(ServiceContext context, String metadataUuid,
String resourceId,
MetadataResourceVisibility visibility) throws Exception {
return patchResourceStatus(context, metadataUuid, resourceId, visibility, true);
}

@Override
public MetadataResource patchResourceStatus(ServiceContext context, String metadataUuid,
String resourceId,
MetadataResourceVisibility visibility,
Boolean approved) throws Exception {
ApplicationContext _appContext = ApplicationContextHolder.get();
AccessManager accessManager = _appContext.getBean(AccessManager.class);
String metadataId = getAndCheckMetadataId(metadataUuid);
String metadataId = getAndCheckMetadataId(metadataUuid, approved);

if (accessManager.canEdit(context, metadataId)) {
Path filePath = getResource(context, metadataUuid, resourceId);
Path filePath = getResource(context, metadataUuid, resourceId, approved);

GeonetworkDataDirectory dataDirectory = _appContext.getBean(GeonetworkDataDirectory.class);
Path metadataDir = Lib.resource.getMetadataDir(dataDirectory, metadataId);
Expand Down Expand Up @@ -351,14 +407,19 @@ public MetadataResource patchResourceStatus(ServiceContext context, String metad
/**
* TODO: To be improve
*/
private String getAndCheckMetadataId(String metadataUuid) throws Exception {
private String getAndCheckMetadataId(String metadataUuid, Boolean approved) throws Exception {
ApplicationContext _appContext = ApplicationContextHolder.get();
String metadataId = _appContext.getBean(DataManager.class).getMetadataId(metadataUuid);
String metadataId = String.valueOf(_appContext.getBean(IMetadataUtils.class).findOneByUuid(metadataUuid).getId());
if (metadataId == null) {
throw new ResourceNotFoundException(String.format(
"Metadata with UUID '%s' not found.", metadataUuid
));
}

if(approved) {
metadataId = String.valueOf(_appContext.getBean(MetadataRepository.class)
.findOneByUuid(metadataUuid).getId());
}
return metadataId;
}

Expand All @@ -369,7 +430,7 @@ private void canEdit(ServiceContext context, String metadataUuid) throws Excepti
private void canEdit(ServiceContext context, String metadataUuid,
MetadataResourceVisibility visibility) throws Exception {
ApplicationContext _appContext = ApplicationContextHolder.get();
String metadataId = getAndCheckMetadataId(metadataUuid);
String metadataId = getAndCheckMetadataId(metadataUuid, false);
AccessManager accessManager = _appContext.getBean(AccessManager.class);
boolean canEdit = accessManager.canEdit(context, metadataId);
if ((visibility == null && !canEdit) ||
Expand Down
Loading