removed useless line from upload function
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
package org.jpacrepo.service;
|
package org.jpacrepo.service;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.jpacrepo.context.ApplicationContext;
|
import org.jpacrepo.context.ApplicationContext;
|
||||||
import org.jpacrepo.context.*;
|
import org.jpacrepo.context.DefaultConfiguration;
|
||||||
import org.jpacrepo.model.HashList;
|
import org.jpacrepo.model.HashList;
|
||||||
import org.jpacrepo.model.PkgData;
|
import org.jpacrepo.model.PkgData;
|
||||||
import org.jpacrepo.model.PkgList;
|
import org.jpacrepo.model.PkgList;
|
||||||
import org.jpacrepo.model.PkgName;
|
import org.jpacrepo.model.PkgName;
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.jpacrepo.pacbase.Parser;
|
import org.jpacrepo.pacbase.Parser;
|
||||||
import org.jpacrepo.persistence.QueryEngine;
|
import org.jpacrepo.persistence.QueryEngine;
|
||||||
|
|
||||||
@@ -15,7 +15,6 @@ import javax.inject.Inject;
|
|||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.*;
|
import javax.ws.rs.core.*;
|
||||||
import javax.ws.rs.core.Context;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -161,17 +160,6 @@ public class PacmanWebService
|
|||||||
throw new BadRequestException();
|
throw new BadRequestException();
|
||||||
|
|
||||||
File file = new File(ctx.getRepoFolder(), filename);
|
File file = new File(ctx.getRepoFolder(), filename);
|
||||||
try
|
|
||||||
{
|
|
||||||
FileOutputStream fos = new FileOutputStream(file);
|
|
||||||
IOUtils.copy(input, fos);
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Files.delete(file.toPath());
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
TypedQuery<PkgData> fquery = em.createQuery(fileNameQuery, PkgData.class);
|
TypedQuery<PkgData> fquery = em.createQuery(fileNameQuery, PkgData.class);
|
||||||
fquery.setParameter("fileName", filename);
|
fquery.setParameter("fileName", filename);
|
||||||
@@ -179,16 +167,17 @@ public class PacmanWebService
|
|||||||
|
|
||||||
if (savedFiles.size() > 0)
|
if (savedFiles.size() > 0)
|
||||||
{
|
{
|
||||||
Files.delete(file.toPath());
|
|
||||||
return Response.notModified().build();
|
return Response.notModified().build();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PkgData pkg = serviceParser.parseFile(file);
|
try
|
||||||
|
{
|
||||||
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
IOUtils.copy(input, fos);
|
||||||
|
fos.close();
|
||||||
|
|
||||||
TypedQuery<PkgData> hquery = em.createQuery(hashQuery, PkgData.class);
|
PkgData pkg = serviceParser.parseFile(file);
|
||||||
hquery.setParameter("md5sum", pkg.md5sum);
|
|
||||||
savedFiles = hquery.getResultList();
|
|
||||||
|
|
||||||
TypedQuery<PkgName> nquery = em.createQuery(nameQuery, PkgName.class);
|
TypedQuery<PkgName> nquery = em.createQuery(nameQuery, PkgName.class);
|
||||||
nquery.setParameter("name", pkg.name.id);
|
nquery.setParameter("name", pkg.name.id);
|
||||||
@@ -203,6 +192,12 @@ public class PacmanWebService
|
|||||||
URI pkgUri = uriInfo.getAbsolutePathBuilder().path(pkg.fileName).build();
|
URI pkgUri = uriInfo.getAbsolutePathBuilder().path(pkg.fileName).build();
|
||||||
return Response.created(pkgUri).build();
|
return Response.created(pkgUri).build();
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Files.delete(file.toPath());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Response manageQueryResult(List<PkgData> list)
|
private Response manageQueryResult(List<PkgData> list)
|
||||||
|
Reference in New Issue
Block a user