Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioG70 committed Aug 1, 2024
1 parent 346e3ab commit 8a863bb
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 37 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/databasepreservation/DBVTK.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public FilterRegistrationBean<OnOffFilter> casSingleSignOutFilter() {
FilterRegistrationBean<OnOffFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasSingleSignOutFilter");
registrationBean.addInitParameter("inner-filter-class", "org.jasig.cas.client.session.SingleSignOutFilter");
registrationBean.addInitParameter("inner-filter-class", "org.apereo.cas.client.session.SingleSignOutFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addInitParameter("casServerUrlPrefix", "http://localhost:8888/cas");
registrationBean.addUrlPatterns("/*");
Expand All @@ -149,7 +149,7 @@ public FilterRegistrationBean<OnOffFilter> casValidationFilter() {
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasValidationFilter");
registrationBean.addInitParameter("inner-filter-class",
"org.jasig.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter");
"org.apereo.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addInitParameter("casServerUrlPrefix", "https://localhost:8443/cas");
registrationBean.addInitParameter("serverName", "https://localhost:8888");
Expand All @@ -168,7 +168,7 @@ public FilterRegistrationBean<OnOffFilter> casAuthenticationFilter() {
FilterRegistrationBean<OnOffFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasAuthenticationFilter");
registrationBean.addInitParameter("inner-filter-class", "org.jasig.cas.client.authentication.AuthenticationFilter");
registrationBean.addInitParameter("inner-filter-class", "org.apereo.cas.client.authentication.AuthenticationFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addInitParameter("casServerLoginUrl", "https://localhost:8443/cas/login");
registrationBean.addUrlPatterns("/login");
Expand All @@ -182,7 +182,7 @@ public FilterRegistrationBean<OnOffFilter> casRequestWrapperFilter() {
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasRequestWrapperFilter");
registrationBean.addInitParameter("inner-filter-class",
"org.jasig.cas.client.util.HttpServletRequestWrapperFilter");
"org.apereo.cas.client.util.HttpServletRequestWrapperFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addUrlPatterns("/*");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public StringResponse create(String path) {
final ControllerAssistant controllerAssistant = new ControllerAssistant() {};

LogEntryState state = LogEntryState.SUCCESS;
User user = controllerAssistant.checkRoles(request);
//User user = controllerAssistant.checkRoles(request);

try {
return new StringResponse(SIARDController.loadMetadataFromLocal(path));
Expand All @@ -92,7 +92,7 @@ public StringResponse create(String path) {
throw new RESTException(e);
} finally {
// register action
controllerAssistant.registerAction(user, state, ViewerConstants.CONTROLLER_FILENAME_PARAM, path);
//controllerAssistant.registerAction(user, state, ViewerConstants.CONTROLLER_FILENAME_PARAM, path);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.roda.core.data.exceptions.AlreadyExistsException;
import org.roda.core.data.exceptions.GenericException;
Expand Down Expand Up @@ -75,6 +78,26 @@ public List<String> list() {
}
}

private java.nio.file.Path zipDirectory(java.nio.file.Path dirPath) throws IOException {
java.nio.file.Path zipFilePath = dirPath.resolveSibling(dirPath.getFileName().toString() + ".zip");
try (FileOutputStream fos = new FileOutputStream(zipFilePath.toFile());
ZipOutputStream zos = new ZipOutputStream(fos)) {
java.nio.file.Files.walk(dirPath)
.filter(path -> !java.nio.file.Files.isDirectory(path))
.forEach(path -> {
ZipEntry zipEntry = new ZipEntry(dirPath.relativize(path).toString());
try {
zos.putNextEntry(zipEntry);
java.nio.file.Files.copy(path, zos);
zos.closeEntry();
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
return zipFilePath;
}

@Override
public ResponseEntity<Resource> getSIARDFile(String filename) {
ControllerAssistant controllerAssistant = new ControllerAssistant() {};
Expand All @@ -87,6 +110,11 @@ public ResponseEntity<Resource> getSIARDFile(String filename) {
java.nio.file.Path basePath = Paths.get(ViewerConfiguration.getInstance().getViewerConfigurationAsString("/",
ViewerConfiguration.PROPERTY_BASE_UPLOAD_PATH));
java.nio.file.Path siardPath = siardFilesPath.resolve(filename);

if (java.nio.file.Files.isDirectory(siardPath)) {
siardPath = zipDirectory(siardPath);
}

if (java.nio.file.Files.exists(siardPath) && !java.nio.file.Files.isDirectory(siardPath)
&& (ViewerConfiguration.checkPathIsWithin(siardPath, siardFilesPath)
|| ViewerConfiguration.checkPathIsWithin(siardPath, basePath))) {
Expand All @@ -98,9 +126,11 @@ public ResponseEntity<Resource> getSIARDFile(String filename) {
} else {
throw new NotFoundException("SIARD file not found");
}
} catch (NotFoundException | FileNotFoundException e) {
} catch (NotFoundException | FileNotFoundException e) {
state = LogEntryState.FAILURE;
throw new RESTException(e);
} catch (IOException e) {
throw new RESTException(e);
} finally {
// register action
controllerAssistant.registerAction(user, state, ViewerConstants.CONTROLLER_FILENAME_PARAM, filename);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private MetadataField getMetadataField(String label, String value) {
}

final MetadataField instance = MetadataField.createInstance(label,
messages.managePageTableHeaderTextForDatabaseStatus());
"");
instance.setCSS("metadata-field", "metadata-information-element-label", "metadata-information-element-value");

return instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,18 @@ private void setupFooterButtons() {
if (ApplicationType.getType().equals(ViewerConstants.APPLICATION_ENV_DESKTOP)) {
message = messages.SIARDHomePageTextForDeleteAllFromDesktop();
}
CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(), message,
messages.basicActionCancel(), messages.basicActionConfirm(), CommonDialogs.Level.DANGER, "500px",
new DefaultAsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if (result) {
deleteAll();
}
}
});
Dialogs.showInformationDialog(messages.SIARDHomePageDialogTitleForDelete(),
"SIARD deletion only supports SIARD version 2.1.", messages.basicActionUnderstood(), "btn btn-link");
// CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(), message,
// messages.basicActionCancel(), messages.basicActionConfirm(), CommonDialogs.Level.DANGER, "500px",
// new DefaultAsyncCallback<Boolean>() {
// @Override
// public void onSuccess(Boolean result) {
// if (result) {
// deleteAll();
// }
// }
// });
} else if (ViewerDatabaseStatus.INGESTING.equals(database.getStatus())) {
Dialogs.showInformationDialog(messages.SIARDManagerPageInformationDialogTitle(),
messages.SIARDManagerPageTextForWaitForFinishing(), messages.basicActionClose(), "btn btn-link");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.databasepreservation.common.client.common.DefaultAsyncCallback;
import com.databasepreservation.common.client.common.NavigationPanel;
import com.databasepreservation.common.client.common.dialogs.CommonDialogs;
import com.databasepreservation.common.client.common.dialogs.Dialogs;
import com.databasepreservation.common.client.common.fields.GenericField;
import com.databasepreservation.common.client.common.fields.MetadataField;
import com.databasepreservation.common.client.common.utils.ApplicationType;
Expand Down Expand Up @@ -66,7 +67,9 @@ public NavigationPanel build() {
btnEditMetadata.setText(messages.SIARDHomePageButtonTextEditMetadata());
btnEditMetadata.addStyleName("btn btn-outline-primary btn-edit");
btnEditMetadata.addClickHandler(clickEvent -> {
HistoryManager.gotoSIARDEditMetadata(database.getUuid());
Dialogs.showInformationDialog("Edit metadata information",
"Metadata edition only supports SIARD version 2.1.", messages.basicActionUnderstood(), "btn btn-link");
//HistoryManager.gotoSIARDEditMetadata(database.getUuid());
});

// Migration button
Expand Down Expand Up @@ -109,19 +112,21 @@ public NavigationPanel build() {
if (database.getPath() != null && !database.getPath().isEmpty()) {
btnDelete.setText(messages.SIARDHomePageButtonTextForDeleteIngested());
btnDelete.addClickHandler(event -> {
if (!database.getStatus().equals(ViewerDatabaseStatus.REMOVING)
&& !database.getStatus().equals(ViewerDatabaseStatus.INGESTING)) {
CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(),
messages.SIARDHomePageTextForDeleteSIARD(), messages.basicActionCancel(), messages.basicActionConfirm(),
CommonDialogs.Level.DANGER, "500px", new DefaultAsyncCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
if (result) {
delete();
}
}
});
}
Dialogs.showInformationDialog("Delete metadata information",
"Metadata deletion only supports SIARD version 2.1.", messages.basicActionUnderstood(), "btn btn-link");
// if (!database.getStatus().equals(ViewerDatabaseStatus.REMOVING)
// && !database.getStatus().equals(ViewerDatabaseStatus.INGESTING)) {
// CommonDialogs.showConfirmDialog(messages.SIARDHomePageDialogTitleForDelete(),
// messages.SIARDHomePageTextForDeleteSIARD(), messages.basicActionCancel(), messages.basicActionConfirm(),
// CommonDialogs.Level.DANGER, "500px", new DefaultAsyncCallback<Boolean>() {
// @Override
// public void onSuccess(Boolean result) {
// if (result) {
// delete();
// }
// }
// });
// }
});
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<filter-class>com.databasepreservation.common.filter.OnOffFilter</filter-class>
<init-param>
<param-name>inner-filter-class</param-name>
<param-value>org.jasig.cas.client.session.SingleSignOutFilter</param-value>
<param-value>org.apereo.cas.client.session.SingleSignOutFilter</param-value>
</init-param>
<init-param>
<param-name>config-prefix</param-name>
Expand All @@ -100,7 +100,7 @@
</filter-mapping>
<listener>
<!-- Listener to clean sessions -->
<listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
<listener-class>org.apereo.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
</listener>

<!-- validation filter must appear before the authentication filter -->
Expand All @@ -109,7 +109,7 @@
<filter-class>com.databasepreservation.common.filter.OnOffFilter</filter-class>
<init-param>
<param-name>inner-filter-class</param-name>
<param-value>org.jasig.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter</param-value>
<param-value>org.apereo.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter</param-value>
</init-param>
<init-param>
<param-name>config-prefix</param-name>
Expand Down Expand Up @@ -150,7 +150,7 @@
<filter-class>com.databasepreservation.common.filter.OnOffFilter</filter-class>
<init-param>
<param-name>inner-filter-class</param-name>
<param-value>org.jasig.cas.client.authentication.AuthenticationFilter</param-value>
<param-value>org.apereo.cas.client.authentication.AuthenticationFilter</param-value>
</init-param>
<init-param>
<param-name>config-prefix</param-name>
Expand All @@ -175,7 +175,7 @@
<filter-class>com.databasepreservation.common.filter.OnOffFilter</filter-class>
<init-param>
<param-name>inner-filter-class</param-name>
<param-value>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</param-value>
<param-value>org.apereo.cas.client.util.HttpServletRequestWrapperFilter</param-value>
</init-param>
<init-param>
<param-name>config-prefix</param-name>
Expand Down

0 comments on commit 8a863bb

Please sign in to comment.