Search in sources :

Example 41 with NotNull

use of javax.validation.constraints.NotNull in project OsmAnd-tools by osmandapp.

the class GpxController method attachSrtm.

@PostMapping(path = { "/process-srtm" }, produces = "application/json")
public ResponseEntity<StreamingResponseBody> attachSrtm(@RequestPart(name = "file") @Valid @NotNull @NotEmpty MultipartFile file) throws IOException {
    GPXFile gpxFile = GPXUtilities.loadGPXFile(file.getInputStream());
    GPXFile srtmGpx = calculateSrtmAltitude(gpxFile, null);
    StreamingResponseBody responseBody = outputStream -> {
        GPXUtilities.writeGpx(new OutputStreamWriter(outputStream), srtmGpx, IProgress.EMPTY_PROGRESS);
    };
    return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + file.getName()).contentType(MediaType.APPLICATION_XML).body(responseBody);
}
Also used : RequestParam(org.springframework.web.bind.annotation.RequestParam) Autowired(org.springframework.beans.factory.annotation.Autowired) WptPt(net.osmand.GPXUtilities.WptPt) RequestPart(org.springframework.web.bind.annotation.RequestPart) NotEmpty(javax.validation.constraints.NotEmpty) Valid(javax.validation.Valid) ByteArrayInputStream(java.io.ByteArrayInputStream) GPXTrackAnalysis(net.osmand.GPXUtilities.GPXTrackAnalysis) Gson(com.google.gson.Gson) IndexConstants(net.osmand.IndexConstants) Map(java.util.Map) XMLStreamException(javax.xml.stream.XMLStreamException) Speed(net.osmand.GPXUtilities.Speed) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) RestTemplate(org.springframework.web.client.RestTemplate) Resource(org.springframework.core.io.Resource) HttpSession(javax.servlet.http.HttpSession) PostMapping(org.springframework.web.bind.annotation.PostMapping) GPXFile(net.osmand.GPXUtilities.GPXFile) HttpHeaders(org.springframework.http.HttpHeaders) MediaType(org.springframework.http.MediaType) FileSystemResource(org.springframework.core.io.FileSystemResource) StreamingResponseBody(org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody) NotNull(javax.validation.constraints.NotNull) QueryParams(net.osmand.obf.OsmGpxWriteContext.QueryParams) RestController(org.springframework.web.bind.annotation.RestController) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) GPXSessionFile(net.osmand.server.controllers.pub.UserSessionResources.GPXSessionFile) List(java.util.List) HttpEntity(org.springframework.http.HttpEntity) OsmAndProUser(net.osmand.server.WebSecurityConfiguration.OsmAndProUser) IndexHeightData(net.osmand.obf.preparation.IndexHeightData) Elevation(net.osmand.GPXUtilities.Elevation) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) GPXUtilities(net.osmand.GPXUtilities) TrkSegment(net.osmand.GPXUtilities.TrkSegment) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) IProgress(net.osmand.IProgress) SQLException(java.sql.SQLException) HttpServletRequest(javax.servlet.http.HttpServletRequest) ContentDisposition(org.springframework.http.ContentDisposition) OutputStreamWriter(java.io.OutputStreamWriter) GetMapping(org.springframework.web.bind.annotation.GetMapping) Algorithms(net.osmand.util.Algorithms) Track(net.osmand.GPXUtilities.Track) Iterator(java.util.Iterator) GPXSessionContext(net.osmand.server.controllers.pub.UserSessionResources.GPXSessionContext) HttpServletResponse(javax.servlet.http.HttpServletResponse) FileOutputStream(java.io.FileOutputStream) MultiValueMap(org.springframework.util.MultiValueMap) OsmGpxWriteContext(net.osmand.obf.OsmGpxWriteContext) IOException(java.io.IOException) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) File(java.io.File) FactoryConfigurationError(javax.xml.stream.FactoryConfigurationError) MultipartFile(org.springframework.web.multipart.MultipartFile) ResponseEntity(org.springframework.http.ResponseEntity) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) InputStream(java.io.InputStream) StreamingResponseBody(org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody) OutputStreamWriter(java.io.OutputStreamWriter) GPXFile(net.osmand.GPXUtilities.GPXFile) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 42 with NotNull

use of javax.validation.constraints.NotNull in project che by eclipse.

the class RecipeEditorViewImpl method createButton.

@NotNull
private EditorButtonWidget createButton(@NotNull String title, @NotNull EditorButtonWidget.ActionDelegate delegate, @NotNull EditorButtonWidgetImpl.Background background) {
    EditorButtonWidget button = widgetFactory.createEditorButton(title, background);
    button.setDelegate(delegate);
    buttonsPanel.add(button);
    return button;
}
Also used : EditorButtonWidget(org.eclipse.che.ide.extension.machine.client.perspective.widgets.recipe.editor.button.EditorButtonWidget) NotNull(javax.validation.constraints.NotNull)

Example 43 with NotNull

use of javax.validation.constraints.NotNull in project che by eclipse.

the class NodeLoader method onLoadFailure.

/**
     * Called when children haven't been successfully loaded.
     * Also fire {@link org.eclipse.che.ide.ui.smartTree.event.LoadExceptionEvent} event.
     *
     * @param parent
     *         parent node, children which haven't been loaded
     * @return instance of {@link org.eclipse.che.api.promises.client.Operation} which contains promise with error
     */
@NotNull
private Operation<PromiseError> onLoadFailure(@NotNull final Node parent) {
    return new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError t) throws OperationException {
            childRequested.remove(parent);
            fireEvent(new LoadExceptionEvent(parent, t.getCause()));
        }
    };
}
Also used : PromiseError(org.eclipse.che.api.promises.client.PromiseError) Operation(org.eclipse.che.api.promises.client.Operation) LoadExceptionEvent(org.eclipse.che.ide.ui.smartTree.event.LoadExceptionEvent) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) NotNull(javax.validation.constraints.NotNull)

Example 44 with NotNull

use of javax.validation.constraints.NotNull in project che by eclipse.

the class PartButtonWidget method setIcon.

/** {@inheritDoc} */
@NotNull
@Override
public PartButton setIcon(@Nullable SVGResource iconResource) {
    this.tabIcon = iconResource;
    iconPanel.clear();
    if (tabIcon != null) {
        iconPanel.add(new SVGImage(tabIcon));
    }
    return this;
}
Also used : SVGImage(org.vectomatic.dom.svg.ui.SVGImage) NotNull(javax.validation.constraints.NotNull)

Example 45 with NotNull

use of javax.validation.constraints.NotNull in project ddf by codice.

the class MigratableUtil method copyFileFromJavaPropertyValue.

/**
     * Copies a file, whose path is taken from the value a Java properties file, to a destination.
     * directory. The file to copy must be a relative path under {@code ddf.home}, and its path
     * must not contain any symbolic link, otherwise the file will not be copied and a
     * {@link MigrationWarning} will be returned.
     *
     * @param propertyFilePath path to the Java properties file that contains the path to the
     *                         source file to copy
     * @param javaProperty     name of the property inside the Java properties file that contains
     *                         the path to the source file
     * @param exportDirectory  path to the destination
     * @param warnings         any warnings generated during this operation (e.g., source file
     *                         outside of {@code ddf.home}) will be added to this collection
     */
public void copyFileFromJavaPropertyValue(@NotNull Path propertyFilePath, @NotNull String javaProperty, @NotNull Path exportDirectory, @NotNull Collection<MigrationWarning> warnings) throws MigrationException {
    notNull(propertyFilePath, "Java properties file cannot be null");
    Properties properties = readPropertiesFile(ddfHome.resolve(propertyFilePath));
    String source = (String) properties.get(javaProperty);
    notEmpty(source, String.format("Source path property [%s] is invalid: [%s]", javaProperty, source));
    Path sourcePath = Paths.get(source);
    copy(sourcePath, exportDirectory, warnings, () -> isSourceMigratable(sourcePath, (reason) -> new PathMigrationWarning(propertyFilePath, javaProperty, sourcePath, reason), warnings));
}
Also used : Path(java.nio.file.Path) StringUtils(org.apache.commons.lang.StringUtils) Validate.notEmpty(org.apache.commons.lang.Validate.notEmpty) Properties(java.util.Properties) Logger(org.slf4j.Logger) Files(java.nio.file.Files) MigrationWarning(org.codice.ddf.migration.MigrationWarning) ExportMigrationException(org.codice.ddf.migration.ExportMigrationException) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) FileInputStream(java.io.FileInputStream) NotNull(javax.validation.constraints.NotNull) Function(java.util.function.Function) Validate.notNull(org.apache.commons.lang.Validate.notNull) BooleanSupplier(java.util.function.BooleanSupplier) Paths(java.nio.file.Paths) Path(java.nio.file.Path) MigrationException(org.codice.ddf.migration.MigrationException) InputStream(java.io.InputStream) Properties(java.util.Properties)

Aggregations

NotNull (javax.validation.constraints.NotNull)76 List (java.util.List)24 Map (java.util.Map)18 Collectors (java.util.stream.Collectors)15 Inject (javax.inject.Inject)15 Logger (org.slf4j.Logger)14 ArrayList (java.util.ArrayList)13 LoggerFactory (org.slf4j.LoggerFactory)13 HashMap (java.util.HashMap)11 Set (java.util.Set)10 Optional (java.util.Optional)9 Response (javax.ws.rs.core.Response)9 Strings (com.google.common.base.Strings)8 Lists (com.google.common.collect.Lists)8 Api (io.swagger.annotations.Api)7 ApiParam (io.swagger.annotations.ApiParam)7 IOException (java.io.IOException)7 Collection (java.util.Collection)7 Nullable (javax.annotation.Nullable)7 Valid (javax.validation.Valid)7