Remove JAXB, now supporting any version of JAVA
This commit is contained in:
@@ -19,10 +19,6 @@
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import com.wisemapping.exceptions.*;
|
||||
import com.wisemapping.importer.ImportFormat;
|
||||
import com.wisemapping.importer.Importer;
|
||||
import com.wisemapping.importer.ImporterException;
|
||||
import com.wisemapping.importer.ImporterFactory;
|
||||
import com.wisemapping.model.*;
|
||||
import com.wisemapping.rest.model.*;
|
||||
import com.wisemapping.security.Utils;
|
||||
@@ -549,27 +545,6 @@ public class MindmapController extends BaseController {
|
||||
response.setHeader("ResourceId", Integer.toString(delegated.getId()));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/freemind"})
|
||||
@ResponseStatus(value = HttpStatus.CREATED)
|
||||
public void createMapFromFreemind(@RequestBody byte[] freemindXml, @RequestParam(required = true) String title, @RequestParam(required = false) String description, @NotNull HttpServletResponse response) throws IOException, WiseMappingException {
|
||||
|
||||
// Convert map ...
|
||||
final Mindmap mindMap;
|
||||
try {
|
||||
final Importer importer = ImporterFactory.getInstance().getImporter(ImportFormat.FREEMIND);
|
||||
final ByteArrayInputStream stream = new ByteArrayInputStream(freemindXml);
|
||||
mindMap = importer.importMap(title, "", stream);
|
||||
} catch (ImporterException e) {
|
||||
// @Todo: This should be an illegal argument exception. Review the all the other cases.
|
||||
throw buildValidationException("xml", "The selected file does not seems to be a valid Freemind or WiseMapping file. Contact support in case the problem persists.");
|
||||
} catch (Throwable e) {
|
||||
throw new ImportUnexpectedException(e, freemindXml);
|
||||
}
|
||||
|
||||
// Save new map ...
|
||||
createMap(new RestMindmap(mindMap, null), response, title, description);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"},produces = {"application/xml", "application/json","text/plain"})
|
||||
@ResponseStatus(value = HttpStatus.CREATED)
|
||||
public void createDuplicate(@RequestBody RestMindmapInfo restMindmap, @PathVariable int id, @NotNull HttpServletResponse response) throws IOException, WiseMappingException {
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright [2015] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* 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 com.wisemapping.rest.view;
|
||||
|
||||
import com.wisemapping.importer.ImportFormat;
|
||||
import com.wisemapping.importer.Importer;
|
||||
import com.wisemapping.importer.ImporterException;
|
||||
import com.wisemapping.importer.ImporterFactory;
|
||||
import com.wisemapping.model.Mindmap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.web.servlet.view.AbstractView;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImportTransformationView extends AbstractView {
|
||||
|
||||
private final String contentType;
|
||||
private final Importer importer;
|
||||
|
||||
public ImportTransformationView(@NotNull final String contentType) throws ImporterException {
|
||||
ImporterFactory exporterFactory = ImporterFactory.getInstance();
|
||||
importer = exporterFactory.getImporter(ImportFormat.FREEMIND);
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderMergedOutputModel(@NotNull Map<String, Object> viewMap, @NotNull HttpServletRequest request, @NotNull final HttpServletResponse response) throws Exception {
|
||||
final String content = (String) viewMap.get("content");
|
||||
final String filename = (String) viewMap.get("filename");
|
||||
|
||||
// Convert to map ...
|
||||
final InputStream is = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
|
||||
final Mindmap mindMap = importer.importMap("filename", "filename", is);
|
||||
|
||||
// Set file name...:http://stackoverflow.com/questions/5325322/java-servlet-download-filename-special-characters/13359949#13359949
|
||||
final String fileName = (filename != null ? filename : "map") + "." + "xwise";
|
||||
setContentDisposition(request, response, fileName);
|
||||
|
||||
// Write the conversion content ...
|
||||
final ServletOutputStream outputStream = response.getOutputStream();
|
||||
outputStream.print(mindMap.getXmlStr());
|
||||
}
|
||||
|
||||
private void setContentDisposition(HttpServletRequest request, HttpServletResponse response, String fileName) {
|
||||
final String userAgent = request.getHeader("user-agent");
|
||||
String disposition = fileName;
|
||||
boolean isInternetExplorer = (userAgent.contains("MSIE"));
|
||||
try {
|
||||
byte[] fileNameBytes = fileName.getBytes((isInternetExplorer) ? ("windows-1250") : ("utf-8"));
|
||||
String dispositionFileName = "";
|
||||
for (byte b : fileNameBytes) {
|
||||
dispositionFileName += (char) (b & 0xff);
|
||||
}
|
||||
disposition = "attachment; filename=\"" + dispositionFileName + "\"";
|
||||
} catch (UnsupportedEncodingException ence) {
|
||||
// ... handle exception ...
|
||||
}
|
||||
response.setHeader("Content-disposition", disposition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user