Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies while maintaining compatibility with Java 8 #1344

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions BimServer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
<version>1.7.22</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.5</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-fileupload2-javax</artifactId>
<version>2.0.0-M2</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
Expand Down Expand Up @@ -87,7 +87,7 @@
<dependency>
<groupId>com.rometools</groupId>
<artifactId>rome</artifactId>
<version>1.19.0</version>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
Expand Down Expand Up @@ -157,7 +157,7 @@
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.26-b01</version>
<version>2.46</version>
<exclusions>
<exclusion>
<groupId>org.javassist</groupId>
Expand All @@ -168,7 +168,7 @@
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.26-b01</version>
<version>2.46</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import java.util.Set;

import jersey.repackaged.com.google.common.base.Joiner;
import com.google.common.base.Joiner;

public class DensityThresholdKey {

Expand Down Expand Up @@ -47,7 +47,7 @@ public Set<String> getExcludedTypes() {

@Override
public String toString() {
return com.google.common.base.Joiner.on(", ").join(roids) + " " + nrTriangles + " " + Joiner.on(", ").join(excludedTypes);
return Joiner.on(", ").join(roids) + " " + nrTriangles + " " + Joiner.on(", ").join(excludedTypes);
}

@Override
Expand Down
185 changes: 93 additions & 92 deletions BimServer/src/org/bimserver/servlets/BulkUploadServlet.java
Original file line number Diff line number Diff line change
@@ -1,70 +1,71 @@
package org.bimserver.servlets;

/******************************************************************************
* Copyright (C) 2009-2019 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see {@literal<http://www.gnu.org/licenses/>}.
*****************************************************************************/

import java.io.BufferedInputStream;

/******************************************************************************
* Copyright (C) 2009-2018 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see {@literal<http://www.gnu.org/licenses/>}.
*****************************************************************************/

import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import javax.activation.DataHandler;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.util.Streams;
import org.bimserver.BimServer;
import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration;
import org.bimserver.interfaces.objects.SProject;
import org.bimserver.models.log.AccessMethod;
import org.bimserver.shared.exceptions.ServerException;
import org.bimserver.shared.exceptions.UserException;
import org.bimserver.shared.interfaces.ServiceInterface;
import org.bimserver.utils.ByteUtils;
import org.bimserver.utils.FakeClosingInputStream;
import org.bimserver.utils.InputStreamDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.ObjectMapper;
package org.bimserver.servlets;

/******************************************************************************
* Copyright (C) 2009-2019 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see {@literal<http://www.gnu.org/licenses/>}.
*****************************************************************************/

import java.io.BufferedInputStream;

/******************************************************************************
* Copyright (C) 2009-2018 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see {@literal<http://www.gnu.org/licenses/>}.
*****************************************************************************/

import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import javax.activation.DataHandler;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.IOUtils;
import org.apache.commons.fileupload2.core.FileItemInput;
import org.apache.commons.fileupload2.core.FileItemInputIterator;
import org.apache.commons.fileupload2.javax.JavaxServletFileUpload;

import org.bimserver.BimServer;
import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration;
import org.bimserver.interfaces.objects.SProject;
import org.bimserver.models.log.AccessMethod;
import org.bimserver.shared.exceptions.ServerException;
import org.bimserver.shared.exceptions.UserException;
import org.bimserver.shared.interfaces.ServiceInterface;
import org.bimserver.utils.ByteUtils;
import org.bimserver.utils.FakeClosingInputStream;
import org.bimserver.utils.InputStreamDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;

public class BulkUploadServlet extends SubServlet {
Expand All @@ -85,70 +86,70 @@ public void service(HttpServletRequest request, HttpServletResponse response) th
response.setHeader("Access-Control-Allow-Headers", "Content-Type");

String token = (String)request.getSession().getAttribute("token");

ObjectNode result = OBJECT_MAPPER.createObjectNode();
response.setContentType("text/json");
try {
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
boolean isMultipart = JavaxServletFileUpload.isMultipartContent(request);
long poid = -1;
String comment = null;
if (isMultipart) {
ServletFileUpload upload = new ServletFileUpload();
FileItemIterator iter = upload.getItemIterator(request);
JavaxServletFileUpload upload = new JavaxServletFileUpload();
FileItemInputIterator iter = upload.getItemIterator(request);
InputStream in = null;
String name = "";
while (iter.hasNext()) {
FileItemStream item = iter.next();
FileItemInput item = iter.next();
if (item.isFormField()) {
if ("token".equals(item.getFieldName())) {
token = Streams.asString(item.openStream());
token = IOUtils.toString(item.getInputStream(), "UTF-8");
} else if ("poid".equals(item.getFieldName())) {
poid = Long.parseLong(Streams.asString(item.openStream()));
poid = Long.parseLong(IOUtils.toString(item.getInputStream(), "UTF-8"));
} else if ("comment".equals(item.getFieldName())) {
comment = Streams.asString(item.openStream());
comment = IOUtils.toString(item.getInputStream(), "UTF-8");
}
} else {
name = item.getName();
in = item.openStream();
in = item.getInputStream();

if (poid != -1) {
ServiceInterface service = getBimServer().getServiceFactory().get(token, AccessMethod.INTERNAL).get(ServiceInterface.class);

SProject mainProject = service.getProjectByPoid(poid);

ZipInputStream zipInputStream = new ZipInputStream(in);
ZipEntry nextEntry = zipInputStream.getNextEntry();
while (nextEntry != null) {
String fullfilename = nextEntry.getName();
if (fullfilename.toLowerCase().endsWith(".ifc") || fullfilename.toLowerCase().endsWith("ifcxml") || fullfilename.toLowerCase().endsWith(".ifczip")) {
BufferedInputStream bufferedInputStream = new BufferedInputStream(zipInputStream);
if (fullfilename.toLowerCase().endsWith(".ifc") || fullfilename.toLowerCase().endsWith("ifcxml") || fullfilename.toLowerCase().endsWith(".ifczip")) {
BufferedInputStream bufferedInputStream = new BufferedInputStream(zipInputStream);
byte[] initialBytes = ByteUtils.extractHead(bufferedInputStream, 4096);
InputStreamDataSource inputStreamDataSource = new InputStreamDataSource(new FakeClosingInputStream(bufferedInputStream));
inputStreamDataSource.setName(name);
DataHandler ifcFile = new DataHandler(inputStreamDataSource);
DataHandler ifcFile = new DataHandler(inputStreamDataSource);
if (fullfilename.contains("/")) {
String path = fullfilename.substring(0, fullfilename.lastIndexOf("/"));
String filename = fullfilename.substring(fullfilename.lastIndexOf("/") + 1);
String extension = filename.substring(filename.lastIndexOf(".") + 1);
try {
try {
String schema = service.determineIfcVersion(initialBytes, fullfilename.toLowerCase().endsWith(".ifczip"));
SProject project = getOrCreatePath(service, mainProject, mainProject, path, schema);
SDeserializerPluginConfiguration deserializer = service.getSuggestedDeserializerForExtension(extension, project.getOid());
service.checkinSync(project.getOid(), comment, deserializer.getOid(), -1L, filename, ifcFile, false);
} catch (Exception e) {
LOGGER.error(e.getMessage() + " (" + fullfilename + ")");
service.checkinSync(project.getOid(), comment, deserializer.getOid(), -1L, filename, ifcFile, false);
} catch (Exception e) {
LOGGER.error(e.getMessage() + " (" + fullfilename + ")");
}
}
} else {
if (!nextEntry.isDirectory()) {
LOGGER.info("Unknown fileextenstion " + fullfilename);
} else {
if (!nextEntry.isDirectory()) {
LOGGER.info("Unknown fileextenstion " + fullfilename);
}
}
nextEntry = zipInputStream.getNextEntry();
}

// DataHandler ifcFile = new DataHandler(inputStreamDataSource);
//
// if (token != null) {
Expand All @@ -174,7 +175,7 @@ public void service(HttpServletRequest request, HttpServletResponse response) th
}
response.getWriter().write(result.toString());
}

private SProject getOrCreatePath(ServiceInterface service, SProject mainProject, SProject currentProject, String path, String schema) throws UserException, ServerException {
String name = path;
if (path.contains("/")) {
Expand Down
Loading