Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Foundation
IT
Websites
membership.eclipse.org
Commits
daa699e5
Commit
daa699e5
authored
Dec 15, 2021
by
Martin Lowe
🇨🇦
Browse files
Fix image service to use get instead of ref (proxies aren't ever null)
parent
0a2e1315
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/eclipsefoundation/react/service/impl/DefaultImageStoreService.java
View file @
daa699e5
...
...
@@ -39,10 +39,12 @@ import javax.imageio.stream.ImageOutputStream;
import
javax.inject.Inject
;
import
javax.ws.rs.BadRequestException
;
import
javax.ws.rs.ServerErrorException
;
import
javax.ws.rs.core.MultivaluedMap
;
import
javax.ws.rs.core.Response
;
import
org.apache.commons.lang3.StringUtils
;
import
org.eclipsefoundation.core.model.RequestWrapper
;
import
org.eclipsefoundation.core.namespace.DefaultUrlParameterNames
;
import
org.eclipsefoundation.eclipsedb.dao.EclipseDBPersistenceDAO
;
import
org.eclipsefoundation.eclipsedb.dto.OrganizationInformation
;
import
org.eclipsefoundation.persistence.model.RDBMSQuery
;
...
...
@@ -50,6 +52,7 @@ import org.eclipsefoundation.persistence.service.FilterService;
import
org.eclipsefoundation.react.helper.ImageFileHelper
;
import
org.eclipsefoundation.react.namespace.ImageStoreFormat
;
import
org.eclipsefoundation.react.service.ImageStoreService
;
import
org.jboss.resteasy.specimpl.MultivaluedMapImpl
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -159,11 +162,19 @@ public class DefaultImageStoreService implements ImageStoreService {
if
(
config
.
persistToDb
()
&&
format
.
isPresent
()
&&
ImageStoreFormat
.
ImageStoreFormats
.
WEB
.
equals
(
format
.
get
())
&&
StringUtils
.
isNumeric
(
fileName
))
{
// get a ref to the given organization information object
OrganizationInformation
oi
=
dao
.
getReference
(
Integer
.
valueOf
(
fileName
),
OrganizationInformation
.
class
);
// if the entry doesn't exist, create one
if
(
oi
==
null
)
{
// get ref and update the object
MultivaluedMap
<
String
,
String
>
params
=
new
MultivaluedMapImpl
<>();
params
.
add
(
DefaultUrlParameterNames
.
ID
.
getName
(),
fileName
);
List
<
OrganizationInformation
>
infoRefs
=
dao
.
get
(
new
RDBMSQuery
<>(
new
RequestWrapper
(),
filters
.
get
(
OrganizationInformation
.
class
),
params
));
// if ref doesn't exist, create one
OrganizationInformation
oi
;
if
(
infoRefs
.
isEmpty
())
{
oi
=
new
OrganizationInformation
();
oi
.
setOrganizationID
(
Integer
.
valueOf
(
fileName
));
oi
.
setCompanyUrl
(
""
);
}
else
{
oi
=
infoRefs
.
get
(
0
);
}
oi
.
setLargeLogo
(
bytes
);
oi
.
setSmallLogo
(
bytes
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment