Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

Commit

Permalink
Some code formmatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiensaquet committed May 3, 2016
1 parent e0f2316 commit 44079cf
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 74 deletions.
Expand Up @@ -26,9 +26,9 @@
import de.mpg.imeji.logic.reader.ReaderFacade;
import de.mpg.imeji.logic.search.Search;
import de.mpg.imeji.logic.search.Search.SearchObjectTypes;
import de.mpg.imeji.logic.search.SearchQueryParser;
import de.mpg.imeji.logic.search.factory.SearchFactory;
import de.mpg.imeji.logic.search.factory.SearchFactory.SEARCH_IMPLEMENTATIONS;
import de.mpg.imeji.logic.search.SearchQueryParser;
import de.mpg.imeji.logic.search.jenasearch.ImejiSPARQL;
import de.mpg.imeji.logic.search.jenasearch.JenaCustomQueries;
import de.mpg.imeji.logic.search.model.SearchQuery;
Expand All @@ -49,8 +49,8 @@
* @version $Revision$ $LastChangedDate$
*/
public class AlbumController extends ImejiController {
private static final ReaderFacade reader = new ReaderFacade(Imeji.albumModel);
private static final WriterFacade writer = new WriterFacade(Imeji.albumModel);
private static final ReaderFacade READER = new ReaderFacade(Imeji.albumModel);
private static final WriterFacade WRITER = new WriterFacade(Imeji.albumModel);
private Search search =
SearchFactory.create(SearchObjectTypes.ALBUM, SEARCH_IMPLEMENTATIONS.ELASTIC);

Expand All @@ -75,7 +75,7 @@ public Album create(Album album, User user) throws ImejiException {
prepareCreate(album, user);
ShareBusinessController shareController = new ShareBusinessController();
shareController.shareToCreator(user, album.getId().toString());
writer.create(WriterFacade.toList(album), null, user);
WRITER.create(WriterFacade.toList(album), null, user);
return album;
}

Expand Down Expand Up @@ -116,7 +116,7 @@ public Album retrieveLazy(URI albumUri, User user) throws ImejiException {
public List<Album> retrieveBatchLazy(List<String> uris, User user, int limit, int offset)
throws ImejiException {
List<Album> albums = prepareBatchRetrieve(uris, limit, offset);
reader.readLazy(J2JHelper.cast2ObjectList(albums), user);
READER.readLazy(J2JHelper.cast2ObjectList(albums), user);
return albums;
}

Expand Down Expand Up @@ -150,7 +150,7 @@ public List<Album> retrieveBatch(List<String> uris, User user, int limit, int of
*/
public Album update(Album album, User user) throws ImejiException {
prepareUpdate(album, user);
writer.update(WriterFacade.toList(album), null, user, true);
WRITER.update(WriterFacade.toList(album), null, user, true);
return retrieve(album.getId(), user);
}

Expand All @@ -163,7 +163,7 @@ public Album update(Album album, User user) throws ImejiException {
* @throws ImejiException
*/
public void delete(Album album, User user) throws ImejiException {
writer.delete(WriterFacade.toList(album), user);
WRITER.delete(WriterFacade.toList(album), user);
}

/**
Expand Down Expand Up @@ -346,7 +346,7 @@ private List<Album> prepareBatchRetrieve(List<String> uris, int limit, int offse
public List<Album> retrieveAll(User user) throws ImejiException {
List<String> uris = ImejiSPARQL.exec(JenaCustomQueries.selectAlbumAll(), Imeji.albumModel);
List<Album> albums = prepareBatchRetrieve(uris, -1, 0);
reader.read(J2JHelper.cast2ObjectList(albums), user);
READER.read(J2JHelper.cast2ObjectList(albums), user);
return albums;
}

Expand Down
Expand Up @@ -54,8 +54,8 @@
* @version $Revision$ $LastChangedDate$
*/
public class CollectionController extends ImejiController {
private static final ReaderFacade reader = new ReaderFacade(Imeji.collectionModel);
private static final WriterFacade writer = new WriterFacade(Imeji.collectionModel);
private static final ReaderFacade READER = new ReaderFacade(Imeji.collectionModel);
private static final WriterFacade WRITER = new WriterFacade(Imeji.collectionModel);
private static final Logger LOGGER = Logger.getLogger(CollectionController.class);
private Search search =
SearchFactory.create(SearchObjectTypes.COLLECTION, SEARCH_IMPLEMENTATIONS.ELASTIC);
Expand Down Expand Up @@ -118,7 +118,7 @@ public CollectionImeji create(CollectionImeji c, MetadataProfile p, User user,
c.setProfile(p.getId());
}

writer.create(WriterFacade.toList(c), p, user);
WRITER.create(WriterFacade.toList(c), p, user);
// Prepare grants
ShareBusinessController shareController = new ShareBusinessController();
user = shareController.shareToCreator(user, c.getId().toString());
Expand All @@ -141,7 +141,7 @@ public CollectionImeji create(CollectionImeji c, MetadataProfile p, User user,
* @throws ImejiException
*/
public CollectionImeji retrieve(URI uri, User user) throws ImejiException {
return (CollectionImeji) reader.read(uri.toString(), user, new CollectionImeji());
return (CollectionImeji) READER.read(uri.toString(), user, new CollectionImeji());
}

/**
Expand All @@ -153,7 +153,7 @@ public CollectionImeji retrieve(URI uri, User user) throws ImejiException {
* @throws ImejiException
*/
public CollectionImeji retrieveLazy(URI uri, User user) throws ImejiException {
return (CollectionImeji) reader.readLazy(uri.toString(), user, new CollectionImeji());
return (CollectionImeji) READER.readLazy(uri.toString(), user, new CollectionImeji());
}

/**
Expand All @@ -169,7 +169,7 @@ public CollectionImeji retrieveLazy(URI uri, User user) throws ImejiException {
public Collection<CollectionImeji> retrieveBatchLazy(List<String> uris, int limit, int offset,
User user) throws ImejiException {
List<CollectionImeji> cols = prepareBatchRetrieve(uris, limit, offset);
reader.readLazy(J2JHelper.cast2ObjectList(cols), user);
READER.readLazy(J2JHelper.cast2ObjectList(cols), user);
return cols;

}
Expand Down Expand Up @@ -214,7 +214,7 @@ public Collection<CollectionImeji> retrieveAll(User user) throws ImejiException
*/
public CollectionImeji update(CollectionImeji ic, User user) throws ImejiException {
prepareUpdate(ic, user);
writer.update(WriterFacade.toList(ic), null, user, true);
WRITER.update(WriterFacade.toList(ic), null, user, true);
return retrieve(ic.getId(), user);
}

Expand Down Expand Up @@ -256,7 +256,7 @@ public void updateLogo(CollectionImeji ic, File f, User u)
*/
public CollectionImeji updateLazy(CollectionImeji ic, User user) throws ImejiException {
prepareUpdate(ic, user);
writer.updateLazy(WriterFacade.toList(ic), null, user);
WRITER.updateLazy(WriterFacade.toList(ic), null, user);
return retrieveLazy(ic.getId(), user);
}

Expand Down Expand Up @@ -359,7 +359,7 @@ public void delete(CollectionImeji collection, User user) throws ImejiException
}
}

writer.delete(WriterFacade.toList(collection), user);
WRITER.delete(WriterFacade.toList(collection), user);
}
}

Expand Down
Expand Up @@ -66,8 +66,8 @@
*/
public class ItemController extends ImejiController {
private static final Logger LOGGER = Logger.getLogger(ItemController.class);
private static final ReaderFacade reader = new ReaderFacade(Imeji.imageModel);
private static final WriterFacade writer = new WriterFacade(Imeji.imageModel);
private static final ReaderFacade READER = new ReaderFacade(Imeji.imageModel);
private static final WriterFacade WRITER = new WriterFacade(Imeji.imageModel);
public static final String NO_THUMBNAIL_URL = "NO_THUMBNAIL_URL";
private final Search search =
SearchFactory.create(SearchObjectTypes.ITEM, SEARCH_IMPLEMENTATIONS.ELASTIC);
Expand Down Expand Up @@ -216,7 +216,7 @@ public void create(Collection<Item> items, URI coll, User user) throws ImejiExce
}
cleanMetadata(items);
ProfileController pc = new ProfileController();
writer.create(J2JHelper.cast2ObjectList((List<?>) items),
WRITER.create(J2JHelper.cast2ObjectList((List<?>) items),
pc.retrieve(items.iterator().next().getMetadataSet().getProfile(), user), user);
// Update the collection
cc.update(cc.retrieve(coll, user), Imeji.adminUser);
Expand Down Expand Up @@ -277,11 +277,11 @@ public Item create(Item item, File uploadedFile, String filename, User u, String
* @throws ImejiException
*/
public Item retrieve(URI imgUri, User user) throws ImejiException {
return (Item) reader.read(imgUri.toString(), user, new Item());
return (Item) READER.read(imgUri.toString(), user, new Item());
}

public Item retrieveLazy(URI imgUri, User user) throws ImejiException {
return (Item) reader.readLazy(imgUri.toString(), user, new Item());
return (Item) READER.readLazy(imgUri.toString(), user, new Item());
}

/**
Expand Down Expand Up @@ -316,7 +316,7 @@ public Item retrieveLazyForFile(String storageId, User user) throws ImejiExcepti
public Collection<Item> retrieveBatch(List<String> uris, int limit, int offset, User user)
throws ImejiException {
List<Item> items = uris2Items(uris, limit, offset);
reader.read(J2JHelper.cast2ObjectList(items), user);
READER.read(J2JHelper.cast2ObjectList(items), user);
return items;
}

Expand All @@ -333,7 +333,7 @@ public Collection<Item> retrieveBatch(List<String> uris, int limit, int offset,
public Collection<Item> retrieveBatchLazy(List<String> uris, int limit, int offset, User user)
throws ImejiException {
List<Item> items = uris2Items(uris, limit, offset);
reader.readLazy(J2JHelper.cast2ObjectList(items), user);
READER.readLazy(J2JHelper.cast2ObjectList(items), user);
return items;
}

Expand Down Expand Up @@ -418,7 +418,7 @@ public void updateBatch(Collection<Item> items, User user) throws ImejiException

cleanMetadata(items);
ProfileController pc = new ProfileController();
writer.update(imBeans,
WRITER.update(imBeans,
pc.retrieve(items.iterator().next().getMetadataSet().getProfile(), user), user, true);
}
}
Expand Down Expand Up @@ -527,7 +527,7 @@ public Item updateThumbnail(Item item, File f, User user) throws ImejiException
* @throws ImejiException
*/
public void delete(List<Item> items, User user) throws ImejiException {
writer.delete(new ArrayList<Object>(items), user);
WRITER.delete(new ArrayList<Object>(items), user);
for (Item item : items) {
removeFileFromStorage(item.getStorageId());
}
Expand Down
Expand Up @@ -21,8 +21,8 @@
import de.mpg.imeji.logic.jobs.CleanMetadataJob;
import de.mpg.imeji.logic.reader.ReaderFacade;
import de.mpg.imeji.logic.search.Search;
import de.mpg.imeji.logic.search.SearchIndexes;
import de.mpg.imeji.logic.search.Search.SearchObjectTypes;
import de.mpg.imeji.logic.search.SearchIndexes;
import de.mpg.imeji.logic.search.SearchQueryParser;
import de.mpg.imeji.logic.search.factory.SearchFactory;
import de.mpg.imeji.logic.search.factory.SearchFactory.SEARCH_IMPLEMENTATIONS;
Expand Down Expand Up @@ -54,8 +54,8 @@
* @version $Revision$ $LastChangedDate$
*/
public class ProfileController extends ImejiController {
private static final ReaderFacade reader = new ReaderFacade(Imeji.profileModel);
private static final WriterFacade writer = new WriterFacade(Imeji.profileModel);
private static final ReaderFacade READER = new ReaderFacade(Imeji.profileModel);
private static final WriterFacade WRITER = new WriterFacade(Imeji.profileModel);
private static final Logger LOGGER = Logger.getLogger(ProfileController.class);

/**
Expand All @@ -76,7 +76,7 @@ public ProfileController() {
public MetadataProfile create(MetadataProfile p, User user) throws ImejiException {
prepareCreate(p, user);
p.setStatus(Status.PENDING);
writer.create(WriterFacade.toList(p), null, user);
WRITER.create(WriterFacade.toList(p), null, user);
ShareBusinessController shareController = new ShareBusinessController();
shareController.shareToCreator(user, p.getId().toString());
return p;
Expand Down Expand Up @@ -108,7 +108,7 @@ public MetadataProfile retrieve(URI uri, User user) throws ImejiException {
if (uri == null) {
return null;
}
p = ((MetadataProfile) reader.read(uri.toString(), user, new MetadataProfile()));
p = ((MetadataProfile) READER.read(uri.toString(), user, new MetadataProfile()));
Collections.sort((List<Statement>) p.getStatements());
return p;
}
Expand Down Expand Up @@ -166,7 +166,7 @@ public MetadataProfile retrieveByItemId(URI itemId, User user) throws ImejiExcep
public void update(MetadataProfile mdp, User user) throws ImejiException {
isLoggedInUser(user);
prepareUpdate(mdp, user);
writer.update(WriterFacade.toList(mdp), null, user, true);
WRITER.update(WriterFacade.toList(mdp), null, user, true);
Imeji.executor.submit(new CleanMetadataJob(mdp));
}

Expand Down Expand Up @@ -209,7 +209,7 @@ && isReferencedByOtherResources(mdp.getId().toString(), collectionId)) {
} else if (mdp.getDefault()) {
throw new UnprocessableError("error_profile_is_default_cannot_be_deleted");
}
writer.delete(WriterFacade.toList(mdp), user);
WRITER.delete(WriterFacade.toList(mdp), user);
Imeji.executor.submit(new CleanMetadataJob(mdp));
}

Expand Down Expand Up @@ -319,26 +319,19 @@ public boolean isReferencedByAnyResources(String profileUri) {
return false;
}

/*
*
* /** Load {@link MetadataProfile} defined in a {@link List} of uris. Don't load the {@link Item}
/**
* Load {@link MetadataProfile} defined in a {@link List} of uris. Don't load the {@link Item}
* contained in the {@link MetadataProfile}
*
* @param uris
*
* @param uri
* @param limit
*
* @param offset
*
* @return
*
* @throws ImejiException
*/
public Collection<MetadataProfile> retrieveLazy(List<String> uris, int limit, int offset,
User user) throws ImejiException {

User user) {
List<MetadataProfile> cols = new ArrayList<MetadataProfile>();

List<String> retrieveUris;
if (limit < 0) {
retrieveUris = uris;
Expand All @@ -350,9 +343,8 @@ public Collection<MetadataProfile> retrieveLazy(List<String> uris, int limit, in
for (String s : retrieveUris) {
cols.add((MetadataProfile) J2JHelper.setId(new MetadataProfile(), URI.create(s)));
}

try {
reader.readLazy(J2JHelper.cast2ObjectList(cols), user);
READER.readLazy(J2JHelper.cast2ObjectList(cols), user);
return cols;
} catch (ImejiException e) {
LOGGER.error("Error loading metadataProfiles: " + e.getMessage(), e);
Expand All @@ -361,7 +353,7 @@ public Collection<MetadataProfile> retrieveLazy(List<String> uris, int limit, in
}

public MetadataProfile retrieveLazy(URI imgUri, User user) throws ImejiException {
return (MetadataProfile) reader.readLazy(imgUri.toString(), user, new MetadataProfile());
return (MetadataProfile) READER.readLazy(imgUri.toString(), user, new MetadataProfile());

}
}
Expand Up @@ -53,8 +53,8 @@
*/
public class SpaceController extends ImejiController {
private static final Logger LOGGER = LoggerFactory.getLogger(SpaceController.class);
private static final ReaderFacade reader = new ReaderFacade(Imeji.spaceModel);
private static final WriterFacade writer = new WriterFacade(Imeji.spaceModel);
private static final ReaderFacade READER = new ReaderFacade(Imeji.spaceModel);
private static final WriterFacade WRITER = new WriterFacade(Imeji.spaceModel);
public static final String SPACES_STORAGE_SUBDIRECTORY = "/spaces";

/**
Expand Down Expand Up @@ -97,7 +97,7 @@ public Space create(Space space, User user) throws ImejiException {
* AuthorizationPredefinedRoles.admin(space.getId() .toString(), null), user);
*/

writer.create(WriterFacade.toList(space), null, user);
WRITER.create(WriterFacade.toList(space), null, user);

// add collections if exist
Collection<String> spaceCollections = space.getSpaceCollections();
Expand Down Expand Up @@ -167,7 +167,7 @@ public Space update(Space space, Collection<String> newSpaceCollections, File fi
*/
public Space update(Space space, User user) throws ImejiException {
prepareUpdate(space, user);
writer.update(WriterFacade.toList(space), null, user, true);
WRITER.update(WriterFacade.toList(space), null, user, true);
return retrieve(space.getId(), user);
}

Expand Down Expand Up @@ -272,7 +272,7 @@ public void removeFile(Space space) throws IOException {
*/
public void updateLazy(Space space, User user) throws ImejiException {
prepareUpdate(space, user);
writer.updateLazy(WriterFacade.toList(space), null, user);
WRITER.updateLazy(WriterFacade.toList(space), null, user);
}

/**
Expand All @@ -284,7 +284,7 @@ public void updateLazy(Space space, User user) throws ImejiException {
* @throws ImejiException
*/
public Space retrieve(URI spaceId, User user) throws ImejiException {
Space space = (Space) reader.read(spaceId.toString(), user, new Space());
Space space = (Space) READER.read(spaceId.toString(), user, new Space());
space.setSpaceCollections(retrieveCollections(space));
return space;
}
Expand Down Expand Up @@ -461,7 +461,7 @@ private void setSpaceInCollections(Space space, Collection<String> collIds, User
* @throws ImejiException
*/
public Space retrieveLazy(URI uri, User user) throws ImejiException {
return (Space) reader.readLazy(uri.toString(), user, new Space());
return (Space) READER.readLazy(uri.toString(), user, new Space());
}

/**
Expand Down Expand Up @@ -500,7 +500,7 @@ public Space retrieveSpaceByLabel(String spaceId, User user) throws ImejiExcepti
public void delete(Space space, User user) throws ImejiException, IOException {
removeFile(space);
removeCollections(space, retrieveCollections(space, true), user);
writer.delete(WriterFacade.toList(space), user);
WRITER.delete(WriterFacade.toList(space), user);
}

public boolean isSpaceByLabel(String spaceId) {
Expand Down

0 comments on commit 44079cf

Please sign in to comment.