Skip to content

Commit

Permalink
Activity log details page #148 [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
hmiguim committed Jan 3, 2020
1 parent 1b97881 commit 9a1ff25
Show file tree
Hide file tree
Showing 43 changed files with 1,055 additions and 370 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ public IndexResult<ActivityLogEntry> find(FindRequest findRequest, String locale
LogEntryState state = LogEntryState.SUCCESS;

controllerAssistant.checkRoles(user);
long count = 0;

try {
final IndexResult<ActivityLogEntry> result = ViewerFactory.getSolrManager().find(ActivityLogEntry.class,
findRequest.filter, findRequest.sorter, findRequest.sublist, findRequest.facets);
count = result.getTotalCount();
return I18nUtility.translate(result, ActivityLogEntry.class, locale);
} catch (GenericException | RequestNotValidException e) {
state = LogEntryState.FAILURE;
Expand All @@ -57,7 +59,8 @@ public IndexResult<ActivityLogEntry> find(FindRequest findRequest, String locale
// register action
controllerAssistant.registerAction(user, state, ViewerConstants.CONTROLLER_FILTER_PARAM,
JsonUtils.getJsonFromObject(findRequest.filter), ViewerConstants.CONTROLLER_FACET_PARAM,
JsonUtils.getJsonFromObject(findRequest.facets));
JsonUtils.getJsonFromObject(findRequest.facets), ViewerConstants.CONTROLLER_SUBLIST_PARAM,
JsonUtils.getJsonFromObject(findRequest.sublist), ViewerConstants.CONTROLLER_RETRIEVE_COUNT, count);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public User getAuthenticatedUser() {
return user;
}

@Override
public Boolean userIsAdmin() {
return UserUtility.userIsAdmin(request);
}

@Override
public User login(String username, String password) throws RESTException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public Response createSIARDFile(@FormDataParam("upl") InputStream inputStream,
throw new RESTException(e);
} finally {
// register action
controllerAssistant.registerAction(user, state);
controllerAssistant.registerAction(user, state, ViewerConstants.CONTROLLER_FILENAME_PARAM,
fileDetail.getFileName());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.databasepreservation.common.api.v1;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
Expand All @@ -15,15 +13,12 @@

import com.databasepreservation.common.client.ViewerConstants;
import com.databasepreservation.common.client.common.search.SavedSearch;
import com.databasepreservation.common.client.common.search.SearchField;
import com.databasepreservation.common.client.common.search.SearchInfo;
import com.databasepreservation.common.client.common.utils.AdvancedSearchUtils;
import com.databasepreservation.common.client.exceptions.RESTException;
import com.databasepreservation.common.client.exceptions.SavedSearchException;
import com.databasepreservation.common.client.index.FindRequest;
import com.databasepreservation.common.client.index.IndexResult;
import com.databasepreservation.common.client.models.activity.logs.LogEntryState;
import com.databasepreservation.common.client.models.structure.ViewerTable;
import com.databasepreservation.common.client.services.SearchService;
import com.databasepreservation.common.server.ViewerFactory;
import com.databasepreservation.common.server.index.utils.SolrUtils;
Expand Down Expand Up @@ -83,10 +78,13 @@ public IndexResult<SavedSearch> find(String databaseUUID, FindRequest findReques
LogEntryState state = LogEntryState.SUCCESS;

controllerAssistant.checkRoles(user);
long count = 0;

try {
return ViewerFactory.getSolrManager().find(SavedSearch.class, findRequest.filter, findRequest.sorter,
findRequest.sublist, findRequest.facets);
final IndexResult<SavedSearch> savedSearchIndexResult = ViewerFactory.getSolrManager().find(SavedSearch.class,
findRequest.filter, findRequest.sorter, findRequest.sublist, findRequest.facets);
count = savedSearchIndexResult.getTotalCount();
return savedSearchIndexResult;
} catch (GenericException | RequestNotValidException e) {
state = LogEntryState.FAILURE;
throw new RESTException(e);
Expand All @@ -95,7 +93,8 @@ public IndexResult<SavedSearch> find(String databaseUUID, FindRequest findReques
controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM,
databaseUUID,
ViewerConstants.CONTROLLER_FILTER_PARAM, JsonUtils.getJsonFromObject(findRequest.filter),
ViewerConstants.CONTROLLER_SUBLIST_PARAM, JsonUtils.getJsonFromObject(findRequest.sublist));
ViewerConstants.CONTROLLER_SUBLIST_PARAM, JsonUtils.getJsonFromObject(findRequest.sublist),
ViewerConstants.CONTROLLER_RETRIEVE_COUNT, count);
}
}

Expand Down Expand Up @@ -163,21 +162,4 @@ public void delete(String databaseUUID, String savedSearchUUID) {
ViewerConstants.CONTROLLER_SAVED_SEARCH_UUID_PARAM, savedSearchUUID);
}
}

@Override
public List<SearchField> getSearchFields(ViewerTable viewerTable) {
ControllerAssistant controllerAssistant = new ControllerAssistant() {};
User user = UserUtility.getUser(request);
LogEntryState state = LogEntryState.SUCCESS;

controllerAssistant.checkRoles(user);
try {
return AdvancedSearchUtils.getSearchFieldsFromTable(viewerTable);
} finally {
// register action
controllerAssistant.registerAction(user, viewerTable.getUuid(), state,
ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, viewerTable.getSchemaUUID(),
ViewerConstants.CONTROLLER_TABLE_ID_PARAM, viewerTable.getUuid());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.databasepreservation.common.client.ViewerConstants;
import com.databasepreservation.common.client.common.lists.columns.TooltipColumn;
import com.databasepreservation.common.client.common.lists.utils.BasicAsyncTableCell;
import com.databasepreservation.common.client.common.utils.LabelUtils;
import com.databasepreservation.common.client.common.utils.html.LabelUtils;
import com.databasepreservation.common.client.index.FindRequest;
import com.databasepreservation.common.client.index.IndexResult;
import com.databasepreservation.common.client.index.facets.Facets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.Map;

import com.databasepreservation.common.api.v1.AuthenticationResource;
import org.fusesource.restygwt.client.MethodCallback;
import org.roda.core.data.v2.index.filter.Filter;
import org.roda.core.data.v2.index.sublist.Sublist;
Expand All @@ -15,7 +16,7 @@
import com.databasepreservation.common.client.common.lists.utils.BasicAsyncTableCell;
import com.databasepreservation.common.client.common.utils.ApplicationType;
import com.databasepreservation.common.client.common.utils.JavascriptUtils;
import com.databasepreservation.common.client.common.utils.LabelUtils;
import com.databasepreservation.common.client.common.utils.html.LabelUtils;
import com.databasepreservation.common.client.index.FindRequest;
import com.databasepreservation.common.client.index.IndexResult;
import com.databasepreservation.common.client.index.facets.Facets;
Expand Down Expand Up @@ -62,115 +63,126 @@ private DatabaseList(Filter filter, Facets facets, String summary, boolean selec

@Override
protected void configureDisplay(CellTable<ViewerDatabase> display) {

display.setSelectionModel(display.getSelectionModel(), DefaultSelectionEventManager.createBlacklistManager(4,9));

Column<ViewerDatabase, SafeHtml> nameColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null
? SafeHtmlUtils.fromString(database.getMetadata().getName())
: SafeHtmlUtils.fromString("unknown");
}
};

Column<ViewerDatabase, SafeHtml> dbmsColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null
? SafeHtmlUtils.fromString(database.getMetadata().getDatabaseProduct())
: SafeHtmlUtils.fromString("unknown");
}
};

Column<ViewerDatabase, SafeHtml> dataOwnerColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null
? SafeHtmlUtils.fromString(database.getMetadata().getDataOwner())
: SafeHtmlUtils.fromString("unknown");
}
};

Column<ViewerDatabase, SafeHtml> archivalDateColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null
? SafeHtmlUtils.fromString(database.getMetadata().getArchivalDate().substring(0, 10))
: null;
}
};

Column<ViewerDatabase, String> locationColumn = new ButtonColumn<ViewerDatabase>() {
@Override
public String getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null ? PathUtils.getFileName(database.getPath())
: null;
}
};
locationColumn.setFieldUpdater((index, object, value) -> {
AuthenticationResource.Util.call((Boolean result)->{
display.setSelectionModel(display.getSelectionModel(), DefaultSelectionEventManager.createBlacklistManager(4, 9));

Column<ViewerDatabase, SafeHtml> nameColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null
? SafeHtmlUtils.fromString(database.getMetadata().getName())
: SafeHtmlUtils.fromString("unknown");
}
};

Column<ViewerDatabase, SafeHtml> description = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null
? SafeHtmlUtils.fromString(database.getMetadata().getDescription())
: SafeHtmlUtils.fromString("unknown");
}
};

Column<ViewerDatabase, SafeHtml> dbmsColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null
? SafeHtmlUtils.fromString(database.getMetadata().getDatabaseProduct())
: SafeHtmlUtils.fromString("unknown");
}
};

Column<ViewerDatabase, SafeHtml> dataOwnerColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null
? SafeHtmlUtils.fromString(database.getMetadata().getDataOwner())
: SafeHtmlUtils.fromString("unknown");
}
};

Column<ViewerDatabase, SafeHtml> archivalDateColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null
? SafeHtmlUtils.fromString(database.getMetadata().getArchivalDate().substring(0, 10))
: null;
}
};

Column<ViewerDatabase, String> locationColumn = new ButtonColumn<ViewerDatabase>() {
@Override
public String getValue(ViewerDatabase database) {
return database != null && database.getMetadata() != null ? PathUtils.getFileName(database.getPath()) : null;
}
};
locationColumn.setFieldUpdater((index, object, value) -> {
if (ApplicationType.getType().equals(ViewerConstants.DESKTOP)) {
JavascriptUtils.showItemInFolder(object.getPath());
} else {
SafeUri downloadUri = RestUtils.createFileResourceDownloadSIARDUri(object.getUuid());
Window.Location.assign(downloadUri.asString());
}
});

Column<ViewerDatabase, SafeHtml> sizeColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null ? SafeHtmlUtils.fromString(Humanize.readableFileSize(database.getSize()))
: SafeHtmlUtils.fromString("unknown");
}
};

Column<ViewerDatabase, SafeHtml> versionColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null ? SafeHtmlUtils.fromString(database.getVersion()) : SafeHtmlUtils.fromString("unknown");
}
};

Column<ViewerDatabase, SafeHtml> validColumn = new Column<ViewerDatabase, SafeHtml>(new SafeHtmlCell()) {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null ? LabelUtils.getSIARDValidationStatus(database.getValidationStatus()) : null;
}
};

Column<ViewerDatabase, SafeHtml> statusColumn = new Column<ViewerDatabase, SafeHtml>(new SafeHtmlCell()) {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null ? LabelUtils.getDatabaseStatus(database.getStatus()) : null;
}
};

Column<ViewerDatabase, String> openColumn = new ButtonColumn<ViewerDatabase>() {
@Override
public String getValue(ViewerDatabase object) {
return messages.basicActionOpen();
}
};
openColumn.setFieldUpdater((index, object, value) -> HistoryManager.gotoSIARDInfo(object.getUuid()));

addColumn(nameColumn, messages.managePageTableHeaderTextForDatabaseName(), true, TextAlign.NONE, 8);
addColumn(description, messages.managePageTableHeaderTextForDatabaseName(), true, TextAlign.NONE, 15);
addColumn(dataOwnerColumn, messages.managePageTableHeaderTextForDataOwner(), true, TextAlign.NONE, 5);
addColumn(archivalDateColumn, messages.managePageTableHeaderTextForArchivalDate(), true, TextAlign.NONE, 5);
if (ApplicationType.getType().equals(ViewerConstants.DESKTOP)) {
JavascriptUtils.showItemInFolder(object.getPath());
} else {
SafeUri downloadUri = RestUtils.createFileResourceDownloadSIARDUri(object.getUuid());
Window.Location.assign(downloadUri.asString());
addColumn(locationColumn, messages.managePageTableHeaderTextForSIARDLocation(), true, TextAlign.NONE, 8);
}
});

Column<ViewerDatabase, SafeHtml> sizeColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null ? SafeHtmlUtils.fromString(Humanize.readableFileSize(database.getSize()))
: SafeHtmlUtils.fromString("unknown");
if (result) {
addColumn(dbmsColumn, messages.managePageTableHeaderTextForProductName(), true, TextAlign.NONE, 10);
addColumn(sizeColumn, messages.managePageTableHeaderTextForSIARDSize(), true, TextAlign.NONE, 4);
addColumn(versionColumn, messages.managePageTableHeaderTextForSIARDVersion(), true, TextAlign.NONE, 4);
addColumn(validColumn, messages.managePageTableHeaderTextForSIARDValidationStatus(), true, TextAlign.NONE, 5);
addColumn(statusColumn, messages.managePageTableHeaderTextForDatabaseStatus(), true, TextAlign.NONE, 5);
addColumn(openColumn, messages.managePageTableHeaderTextForActions(), true, TextAlign.NONE, 5);
}
};

Column<ViewerDatabase, SafeHtml> versionColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null ? SafeHtmlUtils.fromString(database.getVersion())
: SafeHtmlUtils.fromString("unknown");
}
};

Column<ViewerDatabase, SafeHtml> validColumn = new Column<ViewerDatabase, SafeHtml>(new SafeHtmlCell()) {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null ? LabelUtils.getSIARDValidationStatus(database.getValidationStatus())
: null;
}
};

Column<ViewerDatabase, SafeHtml> statusColumn = new TooltipColumn<ViewerDatabase>() {
@Override
public SafeHtml getValue(ViewerDatabase database) {
return database != null ? LabelUtils.getDatabaseStatus(database.getStatus()) : null;
}
};

Column<ViewerDatabase, String> openColumn = new ButtonColumn<ViewerDatabase>() {
@Override
public String getValue(ViewerDatabase object) {
return messages.basicActionOpen();
}
};
openColumn.setFieldUpdater((index, object, value) -> HistoryManager.gotoSIARDInfo(object.getUuid()));

addColumn(nameColumn, messages.managePageTableHeaderTextForDatabaseName(), true, TextAlign.NONE, 15);
addColumn(dataOwnerColumn, messages.managePageTableHeaderTextForDataOwner(), true, TextAlign.NONE, 5);
addColumn(dbmsColumn, messages.managePageTableHeaderTextForProductName(), true, TextAlign.NONE, 10);
addColumn(archivalDateColumn, messages.managePageTableHeaderTextForArchivalDate(), true, TextAlign.NONE, 5);
if (ApplicationType.getType().equals(ViewerConstants.DESKTOP)) {
addColumn(locationColumn, messages.managePageTableHeaderTextForSIARDLocation(), true, TextAlign.NONE, 8);
}
addColumn(sizeColumn, messages.managePageTableHeaderTextForSIARDSize(), true, TextAlign.NONE, 4);
addColumn(versionColumn, messages.managePageTableHeaderTextForSIARDVersion(), true, TextAlign.NONE, 4);
addColumn(validColumn, messages.managePageTableHeaderTextForSIARDValidationStatus(), true, TextAlign.NONE, 5);
addColumn(statusColumn, messages.managePageTableHeaderTextForDatabaseStatus(), true, TextAlign.NONE, 5);
addColumn(openColumn, messages.managePageTableHeaderTextForActions(), true, TextAlign.NONE, 5);

Alert alert = new Alert(Alert.MessageAlertType.LIGHT, messages.noItemsToDisplay());
display.setEmptyTableWidget(alert);
Alert alert = new Alert(Alert.MessageAlertType.LIGHT, messages.noItemsToDisplay());
display.setEmptyTableWidget(alert);
}).userIsAdmin();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private String getExportURL(String zipFilename, String filename, boolean exportA

FindRequest findRequest = new FindRequest(ViewerRow.class.getName(), getFilter(), currentSorter, sublist,
Facets.NONE, false, solrColumns);
ExportRequest exportRequest = new ExportRequest(filename, zipFilename, description, exportLobs);
ExportRequest exportRequest = new ExportRequest(filename, zipFilename, description, exportLobs, false);

return ExportResourcesUtils.getExportURL(database.getUuid(), table.getUuid(), findRequest, exportRequest);
}
Expand Down
Loading

0 comments on commit 9a1ff25

Please sign in to comment.