Skip to content

Commit

Permalink
Merge pull request #4609 from inception-project/bugfix/4557-Bulk-proc…
Browse files Browse the repository at this point in the history
…ess-page-should-not-show-processes-from-other-projects

#4557 - Bulk process page should not show processes from other projects
  • Loading branch information
reckart authored Mar 9, 2024
2 parents bd3cd16 + 667a38b commit 1a58b2c
Show file tree
Hide file tree
Showing 61 changed files with 1,062 additions and 472 deletions.
24 changes: 24 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Set the default behavior, in case people don't have core.autocrlf set.
# means that files that GIT determines to be text files, will be
# converted from CRLF -> LF upon being added to the repo, and
# converted from LF -> LF or CRLF when checked out (depending on the platform, I think)
# * text=auto

# We force LF for all text files because we have Checkstyle set up in such a way
# The "text" by itself says these files must be line-ending-conversion controlled on check-in / out
# The internal repo form for these is always lf,
# The eol=lf means on check-out do nothing, and on check-in, if the file has crlf, convert to lf
* text eol=lf
# *.sh text eol=lf

# Make sure that these files are treated as binary so that newlines are preserved.
# overrides GIT's determination if a file is text or not
*.bin binary
*.dump binary
*.xcas binary
*.xmi binary
# next is probably the default
*.pdf binary
*.ser binary
*.png binary
*.jpg binary
10 changes: 7 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ on:

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
jdk: [17]

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK ${{ matrix.jdk }}
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
6 changes: 6 additions & 0 deletions inception/inception-app-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-log</artifactId>
</dependency>
<dependency>
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-log-ui</artifactId>
</dependency>

<!-- INCEPTION - EDITORS -->
<dependency>
Expand Down Expand Up @@ -894,6 +898,7 @@
uber-JAR and we get ClassNotFoundExceptions at runtime.
-->
<ignoredDependency>com.nimbusds:nimbus-jose-jwt</ignoredDependency>
<ignoredDependency>org.apache.logging.log4j:log4j-api</ignoredDependency>
<!--
- Detection of this dependency is flickering. We need it for a menu-item. So
- for the moment, completely ignore it in the dependency checking.
Expand Down Expand Up @@ -928,6 +933,7 @@
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-external-search-pubmed</usedDependency>
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-active-learning</usedDependency>
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-log</usedDependency>
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-log-ui</usedDependency>
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-curation</usedDependency>
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-workload-ui</usedDependency>
<usedDependency>de.tudarmstadt.ukp.inception.app:inception-workload-dynamic</usedDependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Map;
import java.util.UUID;

import org.apache.logging.log4j.LogManager;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
Expand Down Expand Up @@ -77,6 +78,7 @@ static void setup()
var issuerUrl = oauth2Server.url(ISSUER_ID).toString();

setProperty("java.awt.headless", "true");
setProperty("database.url", "jdbc:hsqldb:mem:testdb");
setProperty("inception.home", appHome.toString());
setProperty("remote-api.enabled", "true");
setProperty("remote-api.oauth2.enabled", "true");
Expand Down Expand Up @@ -110,6 +112,7 @@ static void teardown()
}
context.close();
oauth2Server.shutdown();
LogManager.shutdown();
}

@Test
Expand Down
5 changes: 5 additions & 0 deletions inception/inception-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@
<artifactId>inception-log</artifactId>
<version>32.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-log-ui</artifactId>
<version>32.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.tudarmstadt.ukp.inception.app</groupId>
<artifactId>inception-tutorial</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export class VisualizerUI {
.on('resize', this, this.onResize)
.on('spanAndAttributeTypesLoaded', this, this.spanAndAttributeTypesLoaded)
.on('doneRendering', this, this.onDoneRendering)
.on('mousemove', this, this.onMouseMove)
.on('displaySpanButtons', this, this.displaySpanButtons)
.on('acceptButtonClicked', this, this.acceptAction)
.on('rejectButtonClicked', this, this.rejectAction)
Expand Down
4 changes: 0 additions & 4 deletions inception/inception-curation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.apache.uima.UIMAException;
import org.apache.uima.cas.CAS;
import org.springframework.security.access.prepost.PreAuthorize;

import de.tudarmstadt.ukp.clarin.webanno.api.casstorage.ConcurentCasModificationException;
import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationDocument;
Expand All @@ -50,7 +49,6 @@ public interface CurationDocumentService
* @throws IOException
* if an I/O error occurs.
*/
@PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_USER')")
void writeCurationCas(CAS aCas, SourceDocument document, boolean aUpdateTimestamp)
throws IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.time.Duration;

import javax.persistence.NoResultException;
import javax.servlet.ServletContext;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -62,7 +63,6 @@
import de.tudarmstadt.ukp.clarin.webanno.model.Mode;
import de.tudarmstadt.ukp.clarin.webanno.model.Project;
import de.tudarmstadt.ukp.clarin.webanno.security.UserDao;
import de.tudarmstadt.ukp.clarin.webanno.security.model.User;
import de.tudarmstadt.ukp.inception.annotation.storage.CasStorageSession;
import de.tudarmstadt.ukp.inception.diam.messages.MViewportInit;
import de.tudarmstadt.ukp.inception.diam.messages.MViewportUpdate;
Expand Down Expand Up @@ -135,7 +135,7 @@ public DiamWebsocketController(SimpMessagingTemplate aMsgTemplate,
RepositoryProperties aRepositoryProperties, AnnotationSchemaService aSchemaService,
ProjectService aProjectService, UserDao aUserRepository,
VDocumentSerializerExtensionPoint aVDocumentSerializerExtensionPoint,
UserPreferencesService aUserPreferencesService)
UserPreferencesService aUserPreferencesService, ServletContext aServletContext)
{
msgTemplate = aMsgTemplate;
renderingPipeline = aRenderingPipeline;
Expand All @@ -148,7 +148,7 @@ public DiamWebsocketController(SimpMessagingTemplate aMsgTemplate,
userPreferencesService = aUserPreferencesService;

activeViewports = Caffeine.newBuilder() //
.expireAfterAccess(Duration.ofMinutes(30)) //
.expireAfterAccess(Duration.ofMinutes(aServletContext.getSessionTimeout())) //
.build(this::initState);
}

Expand All @@ -168,10 +168,10 @@ public void onSessionDisconnect(SessionDisconnectEvent aEvent)
@EventListener
public void onSessionUnsubscribe(SessionUnsubscribeEvent aEvent)
{
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(aEvent.getMessage());
var headers = SimpMessageHeaderAccessor.wrap(aEvent.getMessage());

String sessionId = headers.getSessionId();
String subscriptionId = headers.getSubscriptionId();
var sessionId = headers.getSessionId();
var subscriptionId = headers.getSubscriptionId();

log.trace("Unsubscribing {} from subscription {}", sessionId, subscriptionId);

Expand Down Expand Up @@ -207,30 +207,29 @@ public JsonNode onSubscribeToAnnotationDocument(SimpMessageHeaderAccessor aHeade
Principal aPrincipal, //
@DestinationVariable(PARAM_PROJECT) long aProjectId,
@DestinationVariable(PARAM_DOCUMENT) long aDocumentId,
@DestinationVariable(PARAM_USER) String aUser,
@DestinationVariable(PARAM_USER) String aDataOwner,
@DestinationVariable(PARAM_FROM) int aViewportBegin,
@DestinationVariable(PARAM_TO) int aViewportEnd,
@DestinationVariable(PARAM_FORMAT) String aFormat)
throws IOException
{
Project project = getProject(aProjectId);
var project = getProject(aProjectId);

try (CasStorageSession session = CasStorageSession.open()) {
try (var session = CasStorageSession.open()) {
MDC.put(KEY_REPOSITORY_PATH, repositoryProperties.getPath().toString());
MDC.put(KEY_USERNAME, aPrincipal.getName());

ViewportDefinition vpd = new ViewportDefinition(aProjectId, aDocumentId, aUser,
aViewportBegin, aViewportEnd, aFormat);
var vpd = new ViewportDefinition(aProjectId, aDocumentId, aDataOwner, aViewportBegin,
aViewportEnd, aFormat);

// Ensure that the viewport is registered
ViewportState vps = activeViewports.get(vpd);
var vps = activeViewports.get(vpd);

log.trace("Subscribing {} to {}", aHeaderAccessor.getSessionId(), vpd.getTopic());
vps.addSubscription(aHeaderAccessor.getSessionId(),
aHeaderAccessor.getSubscriptionId());

JsonNode json = render(project, aDocumentId, aUser, aViewportBegin, aViewportEnd,
aFormat);
var json = render(project, aDocumentId, aDataOwner, aViewportBegin, aViewportEnd, aFormat);
vps.setJson(json);
return json;
}
Expand Down Expand Up @@ -271,14 +270,14 @@ public JsonNode onSubscribeToAnnotationDocument(SimpMessageHeaderAccessor aHeade
// }
// }

private JsonNode render(Project aProject, long aDocumentId, String aUser, int aViewportBegin,
private JsonNode render(Project aProject, long aDocumentId, String aDataOwner, int aViewportBegin,
int aViewportEnd, String aFormat)
throws IOException
{
var doc = documentService.getSourceDocument(aProject.getId(), aDocumentId);
var user = userRepository.getUserOrCurationUser(aUser);
var user = userRepository.getUserOrCurationUser(aDataOwner);

var cas = documentService.readAnnotationCas(doc, aUser);
var cas = documentService.readAnnotationCas(doc, aDataOwner);

var prefs = userPreferencesService.loadPreferences(doc.getProject(), user.getUsername(),
Mode.ANNOTATION);
Expand Down Expand Up @@ -339,12 +338,12 @@ private void sendUpdate(ViewportDefinition vpd, ViewportState vps, long aProject
{
// MDC.put(KEY_REPOSITORY_PATH, repositoryProperties.getPath().toString());

try (CasStorageSession session = CasStorageSession.openNested()) {
Project project = projectService.getProject(vpd.getProjectId());
JsonNode newJson = render(project, vpd.getDocumentId(), vpd.getUser(), vpd.getBegin(),
try (var session = CasStorageSession.openNested()) {
var project = projectService.getProject(vpd.getProjectId());
var newJson = render(project, vpd.getDocumentId(), vpd.getUser(), vpd.getBegin(),
vpd.getEnd(), vpd.getFormat());

JsonNode diff = JsonDiff.asJson(vps.getJson(), newJson);
var diff = JsonDiff.asJson(vps.getJson(), newJson);

vps.setJson(newJson);

Expand All @@ -363,7 +362,7 @@ private void sendUpdate(ViewportDefinition vpd, ViewportState vps, long aProject
private Project getProject(long aProjectId) throws AccessDeniedException
{
// Get current user - this will throw an exception if the current user does not exit
User user = userRepository.getCurrentUser();
var user = userRepository.getCurrentUser();

// Get project
Project project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,22 +219,18 @@ public void tearDown()
@Test
public void thatViewportBasedMessageRoutingWorks() throws Exception
{
CountDownLatch subscriptionDone = new CountDownLatch(2);
CountDownLatch initDone = new CountDownLatch(2);
var subscriptionDone = new CountDownLatch(2);
var initDone = new CountDownLatch(2);

ViewportDefinition vpd1 = new ViewportDefinition(testAnnotationDocument, 10, 20,
FORMAT_LEGACY);
ViewportDefinition vpd2 = new ViewportDefinition(testAnnotationDocument, 30, 40,
FORMAT_LEGACY);
var vpd1 = new ViewportDefinition(testAnnotationDocument, 10, 20, FORMAT_LEGACY);
var vpd2 = new ViewportDefinition(testAnnotationDocument, 30, 40, FORMAT_LEGACY);

var sessionHandler1 = new SessionHandler(subscriptionDone, initDone, vpd1);
var sessionHandler2 = new SessionHandler(subscriptionDone, initDone, vpd2);

// try {
StompSession session1 = stompClient.connect(websocketUrl, sessionHandler1).get(1000,
SECONDS);
StompSession session2 = stompClient.connect(websocketUrl, sessionHandler2).get(1000,
SECONDS);
var session1 = stompClient.connect(websocketUrl, sessionHandler1).get(1000, SECONDS);
var session2 = stompClient.connect(websocketUrl, sessionHandler2).get(1000, SECONDS);
// }
// catch (Exception e) {
// Thread.sleep(Duration.of(3, ChronoUnit.HOURS).toMillis());
Expand Down Expand Up @@ -341,7 +337,7 @@ public ApplicationContextProvider applicationContextProvider()
public DaoAuthenticationProvider internalAuthenticationProvider(PasswordEncoder aEncoder,
@Lazy UserDetailsManager aUserDetailsManager)
{
DaoAuthenticationProvider authProvider = new InceptionDaoAuthenticationProvider();
var authProvider = new InceptionDaoAuthenticationProvider();
authProvider.setUserDetailsService(aUserDetailsManager);
authProvider.setPasswordEncoder(aEncoder);
return authProvider;
Expand All @@ -362,7 +358,7 @@ public String getId()
@Override
public void render(VDocument aResponse, RenderRequest aRequest)
{
AnnotationLayer layer = new AnnotationLayer();
var layer = new AnnotationLayer();
layer.setId(1l);
aResponse.add(
new VSpan(layer, new VID(1), new VRange(aRequest.getWindowBeginOffset(),
Expand Down
Loading

0 comments on commit 1a58b2c

Please sign in to comment.