-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor adjustment to communication between Polypheny and UI
- Loading branch information
Showing
10 changed files
with
209 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
webui/src/main/java/org/polypheny/db/webui/auth/AuthCrud.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 2019-2023 The Polypheny Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.polypheny.db.webui.auth; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import io.javalin.http.Context; | ||
import io.javalin.websocket.WsMessageContext; | ||
import java.util.UUID; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.polypheny.db.webui.Crud; | ||
import org.polypheny.db.webui.models.requests.RegisterRequest; | ||
import org.polypheny.db.webui.models.requests.RelAlgRequest; | ||
|
||
@Slf4j | ||
public class AuthCrud { | ||
|
||
private final ObjectMapper mapper = new ObjectMapper(); | ||
private final Crud crud; | ||
private final ConcurrentHashMap<UUID, PartnerStatus> partners = new ConcurrentHashMap<>(); | ||
|
||
|
||
public AuthCrud( Crud crud ) { | ||
this.crud = crud; | ||
} | ||
|
||
|
||
public void register( RelAlgRequest registerRequest, WsMessageContext context ) { | ||
String id = context.queryParam( "source" ); | ||
if ( id != null ) { | ||
log.warn( "Partner " + id + " already registered" ); | ||
return; | ||
} | ||
PartnerStatus status = new PartnerStatus( context.session ); | ||
log.warn( "New partner with id " + status.id + " registered" ); | ||
partners.put( status.id, status ); | ||
context.send( new RegisterRequest( status.id.toString() ) ); | ||
} | ||
|
||
|
||
public void deregister( Context context ) { | ||
String id = context.queryParam( "id" ); | ||
if ( id == null ) { | ||
log.warn( "Partner with empty id is not registered" ); | ||
return; | ||
} | ||
partners.remove( UUID.fromString( id ) ); | ||
} | ||
|
||
|
||
public <E> void broadcast( E msg ) { | ||
//partners.values().forEach( p -> HttpServer.getInstance().getWebSocketHandler(). ); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
webui/src/main/java/org/polypheny/db/webui/auth/PartnerStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2019-2023 The Polypheny Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.polypheny.db.webui.auth; | ||
|
||
import java.util.UUID; | ||
import lombok.Getter; | ||
import org.eclipse.jetty.websocket.api.Session; | ||
|
||
@Getter | ||
public class PartnerStatus { | ||
|
||
public final UUID id; | ||
private final Session session; | ||
|
||
|
||
public PartnerStatus( UUID id, Session session ) { | ||
this.id = id; | ||
this.session = session; | ||
} | ||
|
||
|
||
public PartnerStatus( Session session ) { | ||
this( UUID.randomUUID(), session ); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
webui/src/main/java/org/polypheny/db/webui/models/requests/RegisterRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2019-2023 The Polypheny Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.polypheny.db.webui.models.requests; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Value; | ||
|
||
@EqualsAndHashCode(callSuper = true) | ||
@Value | ||
public class RegisterRequest extends RequestModel { | ||
|
||
public String source; | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
webui/src/main/java/org/polypheny/db/webui/models/requests/RequestModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2019-2023 The Polypheny Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.polypheny.db.webui.models.requests; | ||
|
||
public class RequestModel { | ||
|
||
/** | ||
* ExpressionType of a request, e.g. QueryRequest or RelAlgRequest | ||
*/ | ||
public String type; | ||
|
||
public String payload; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters