-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
got end-to-end streaming to work from UI->server->bus->server->feed
- Loading branch information
1 parent
1ed1ac4
commit 120e5f9
Showing
12 changed files
with
319 additions
and
59 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
19 changes: 19 additions & 0 deletions
19
hawkular-feed-comm/feed-comm-api/src/main/resources/schema/FileUploadRequest.schema.json
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,19 @@ | ||
{ | ||
"type": "object", | ||
"extends": { | ||
"type": "object", | ||
"javaType": "org.hawkular.bus.common.BasicMessage" | ||
}, | ||
"javaType": "org.hawkular.feedcomm.api.FileUploadRequest", | ||
"description": "A simple request to upload a file. The actual file data must be appended to this JSON message.", | ||
"additionalProperties": false, | ||
"properties": { | ||
"feedId": { | ||
"type": "string" | ||
}, | ||
"destinationFileName": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["destinationFileName"] | ||
} |
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
56 changes: 56 additions & 0 deletions
56
...mm/feed-comm-war/src/main/java/org/hawkular/feedcomm/ws/command/ui/FileUploadCommand.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,56 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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.hawkular.feedcomm.ws.command.ui; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import org.hawkular.bus.common.BinaryData; | ||
import org.hawkular.bus.common.ConnectionContextFactory; | ||
import org.hawkular.bus.common.Endpoint; | ||
import org.hawkular.bus.common.MessageId; | ||
import org.hawkular.bus.common.MessageProcessor; | ||
import org.hawkular.bus.common.producer.ProducerConnectionContext; | ||
import org.hawkular.feedcomm.api.FileUploadRequest; | ||
import org.hawkular.feedcomm.api.GenericSuccessResponse; | ||
import org.hawkular.feedcomm.ws.Constants; | ||
import org.hawkular.feedcomm.ws.MsgLogger; | ||
import org.hawkular.feedcomm.ws.command.Command; | ||
import org.hawkular.feedcomm.ws.command.CommandContext; | ||
|
||
/** | ||
* UI client requesting to send a file to a remote feed. | ||
*/ | ||
public class FileUploadCommand implements Command<FileUploadRequest, GenericSuccessResponse> { | ||
public static final Class<FileUploadRequest> REQUEST_CLASS = FileUploadRequest.class; | ||
|
||
@Override | ||
public GenericSuccessResponse execute(FileUploadRequest request, BinaryData binaryData, CommandContext context) | ||
throws Exception { | ||
|
||
try (ConnectionContextFactory ccf = new ConnectionContextFactory(context.getConnectionFactory())) { | ||
String feedId = request.getFeedId(); | ||
Endpoint endpoint = Constants.DEST_FEED_FILE_UPLOAD; | ||
ProducerConnectionContext pcc = ccf.createProducerConnectionContext(endpoint); | ||
Map<String, String> feedIdHeader = Collections.singletonMap(Constants.HEADER_FEEDID, feedId); | ||
MessageId mid = new MessageProcessor().sendWithBinaryData(pcc, request, binaryData, feedIdHeader); | ||
MsgLogger.LOG.debugf("File upload request placed on bus. mid=[%s], request=[%s]", mid, request); | ||
} | ||
|
||
return null; | ||
} | ||
} |
Oops, something went wrong.