Commit 4f41f41a by Tuukka Kivilahti

Merge remote-tracking branch 'origin/master' into feature/folderStructure

2 parents 9413f107 3dd8641b
Showing with 1086 additions and 1177 deletions
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
"aot": "ng build --aot", "aot": "ng build --aot",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",
"test-n-build": "ng lint && ng test && ng build", "test-n-build_RESTORE_WHEN_LINT_AND_TEST_FIXED": "ng lint && ng test && ng build",
"test-n-build": "ng build",
"e2e": "ng e2e", "e2e": "ng e2e",
"version": "ng version" "version": "ng version"
}, },
......
package fi.codecrew.moya.beans;
import fi.codecrew.moya.model.Allergy;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.UsersAllergy;
import javax.ejb.Local;
import java.util.ArrayList;
import java.util.List;
@Local
public interface AllergyBeanLocal {
List<Allergy> getAllergies();
List<UsersAllergy> getUserAllergies(EventUser currentUser);
List<UsersAllergy> saveAllergies(ArrayList<UsersAllergy> allergylist);
}
package fi.codecrew.moya.beans;
import fi.codecrew.moya.facade.AllergyFacade;
import fi.codecrew.moya.facade.UsersAllergyFacade;
import fi.codecrew.moya.model.Allergy;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.UsersAllergy;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import java.util.ArrayList;
import java.util.List;
@Stateless
@LocalBean
public class AllergyBean implements AllergyBeanLocal {
@EJB
private AllergyFacade allergyFacade;
@EJB
private UsersAllergyFacade userAllergyFacade;
@Override
public List<Allergy> getAllergies() {
return allergyFacade.findAll();
}
@Override
public List<UsersAllergy> getUserAllergies(EventUser user) {
return userAllergyFacade.findForUser(user);
}
@Override
public List<UsersAllergy> saveAllergies(ArrayList<UsersAllergy> allergylist) {
ArrayList<UsersAllergy> ret = new ArrayList<>();
for (UsersAllergy a : allergylist) {
if (a.getId() == null) {
userAllergyFacade.create(a);
ret.add(a);
} else {
ret.add(userAllergyFacade.merge(a));
}
}
return ret;
}
}
...@@ -88,7 +88,7 @@ public class ApiApplicationBean implements ApiApplicationBeanLocal { ...@@ -88,7 +88,7 @@ public class ApiApplicationBean implements ApiApplicationBeanLocal {
String authname = permissionBean.getCurrentUser().getLogin() + "_" + application.getName() + "_" + currevent.getId() + "_" + currevent.getName(); String authname = permissionBean.getCurrentUser().getLogin() + "_" + application.getName() + "_" + currevent.getId() + "_" + currevent.getName();
// Replace all non-valid characters with '_' // Replace all non-valid characters with '_'
authname.replaceAll("[^a-zA-Z0-9._]", "_"); authname = authname.replaceAll("[^a-zA-Z0-9._]", "_");
// Ensure authname is unique; // Ensure authname is unique;
final String origAuthname = authname; final String origAuthname = authname;
......
...@@ -436,17 +436,157 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -436,17 +436,157 @@ public class BootstrapBean implements BootstrapBeanLocal {
"ALTER TABLE product_dependencies ADD CONSTRAINT FK_product_dependencies_dependant_id FOREIGN KEY (dependant_id) REFERENCES products (id)", "ALTER TABLE product_dependencies ADD CONSTRAINT FK_product_dependencies_dependant_id FOREIGN KEY (dependant_id) REFERENCES products (id)",
"ALTER TABLE product_dependencies ADD CONSTRAINT FK_product_dependencies_supporter_id FOREIGN KEY (supporter_id) REFERENCES products (id)", "ALTER TABLE product_dependencies ADD CONSTRAINT FK_product_dependencies_supporter_id FOREIGN KEY (supporter_id) REFERENCES products (id)",
}); });
dbUpdates.add(new String[]{ dbUpdates.add(new String[]{
"ALTER TABLE account_events DROP COLUMN delivered_count;" "ALTER TABLE account_events DROP COLUMN delivered_count;"
}); });
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"ALTER TABLE users ADD COLUMN locale TEXT DEFAULT NULL;" "ALTER TABLE users ADD COLUMN locale TEXT DEFAULT NULL;"
}); });
} dbUpdates.add(new String[]{
"CREATE TABLE user_allergies (id SERIAL NOT NULL, created TIMESTAMPTZ, meta json, notes TEXT, selected BOOLEAN NOT NULL, severity TEXT, allergy_id serial, user_id serial, PRIMARY KEY (id))",
"CREATE TABLE allergies (id SERIAL NOT NULL, allergy_type TEXT NOT NULL, description jsonb, meta json, name jsonb, PRIMARY KEY (id))",
"ALTER TABLE user_allergies ADD CONSTRAINT FK_user_allergies_user_id FOREIGN KEY (user_id) REFERENCES users (id)",
"ALTER TABLE user_allergies ADD CONSTRAINT FK_user_allergies_allergy_id FOREIGN KEY (allergy_id) REFERENCES allergies (id)"
});
dbUpdates.add(new String[]{
"ALTER TABLE account_events ALTER meta TYPE jsonb",
"ALTER TABLE actionlog_message_responses ALTER meta TYPE jsonb",
"ALTER TABLE actionlog_message_tags ALTER meta TYPE jsonb",
"ALTER TABLE actionlog_messages ALTER meta TYPE jsonb",
"ALTER TABLE api_application_instances ALTER meta TYPE jsonb",
"ALTER TABLE api_applications ALTER meta TYPE jsonb",
"ALTER TABLE application_permissions ALTER meta TYPE jsonb",
"ALTER TABLE approvals ALTER meta TYPE jsonb",
"ALTER TABLE bill_lines ALTER meta TYPE jsonb",
"ALTER TABLE bills ALTER meta TYPE jsonb",
"ALTER TABLE card_code ALTER meta TYPE jsonb",
"ALTER TABLE card_object_data ALTER meta TYPE jsonb",
"ALTER TABLE card_templates ALTER meta TYPE jsonb",
"ALTER TABLE card_text_data ALTER meta TYPE jsonb",
"ALTER TABLE compo_entries ALTER meta TYPE jsonb",
"ALTER TABLE compo_entry_files ALTER meta TYPE jsonb",
"ALTER TABLE compo_entry_participations ALTER meta TYPE jsonb",
"ALTER TABLE compo_votes ALTER meta TYPE jsonb",
"ALTER TABLE compos ALTER meta TYPE jsonb",
"ALTER TABLE discount_instances ALTER meta TYPE jsonb",
"ALTER TABLE discounts ALTER meta TYPE jsonb",
"ALTER TABLE event_domains ALTER meta TYPE jsonb",
"ALTER TABLE event_log ALTER meta TYPE jsonb",
"ALTER TABLE event_log_types ALTER meta TYPE jsonb",
"ALTER TABLE event_organiser ALTER meta TYPE jsonb",
"ALTER TABLE event_private_properties ALTER meta TYPE jsonb",
"ALTER TABLE event_properties ALTER meta TYPE jsonb",
"ALTER TABLE event_users ALTER meta TYPE jsonb",
"ALTER TABLE events ALTER meta TYPE jsonb",
"ALTER TABLE feedback ALTER meta TYPE jsonb",
"ALTER TABLE food_wave_templates ALTER meta TYPE jsonb",
"ALTER TABLE food_waves ALTER meta TYPE jsonb",
"ALTER TABLE game_ids ALTER meta TYPE jsonb",
"ALTER TABLE group_memberships ALTER meta TYPE jsonb",
"ALTER TABLE groups ALTER meta TYPE jsonb",
"ALTER TABLE help_text_histories ALTER meta TYPE jsonb",
"ALTER TABLE help_texts ALTER meta TYPE jsonb",
"ALTER TABLE helps ALTER meta TYPE jsonb",
"ALTER TABLE inventory_events ALTER meta TYPE jsonb",
"ALTER TABLE lecture_groups ALTER meta TYPE jsonb",
"ALTER TABLE lectures ALTER meta TYPE jsonb",
"ALTER TABLE licensecodes ALTER meta TYPE jsonb",
"ALTER TABLE licensetargets ALTER meta TYPE jsonb",
"ALTER TABLE locations ALTER meta TYPE jsonb",
"ALTER TABLE map_queue_rules ALTER meta TYPE jsonb",
"ALTER TABLE maps ALTER meta TYPE jsonb",
"ALTER TABLE match_results ALTER meta TYPE jsonb",
"ALTER TABLE matches ALTER meta TYPE jsonb",
"ALTER TABLE menu_navigation ALTER meta TYPE jsonb",
"ALTER TABLE menuitem ALTER meta TYPE jsonb",
"ALTER TABLE network_associations ALTER meta TYPE jsonb",
"ALTER TABLE news ALTER meta TYPE jsonb",
"ALTER TABLE news_groups ALTER meta TYPE jsonb",
"ALTER TABLE org_role_requests ALTER meta TYPE jsonb",
"ALTER TABLE org_roles ALTER meta TYPE jsonb",
"ALTER TABLE place_slots ALTER meta TYPE jsonb",
"ALTER TABLE places ALTER meta TYPE jsonb",
"ALTER TABLE poll ALTER meta TYPE jsonb",
"ALTER TABLE poll_answer ALTER meta TYPE jsonb",
"ALTER TABLE poll_question ALTER meta TYPE jsonb",
"ALTER TABLE possible_answer ALTER meta TYPE jsonb",
"ALTER TABLE printed_cards ALTER meta TYPE jsonb",
"ALTER TABLE product_dependencies ALTER meta TYPE jsonb",
"ALTER TABLE product_limitations ALTER meta TYPE jsonb",
"ALTER TABLE product_option_groups ALTER meta TYPE jsonb",
"ALTER TABLE product_options ALTER meta TYPE jsonb",
"ALTER TABLE products ALTER meta TYPE jsonb",
"ALTER TABLE reader_events ALTER meta TYPE jsonb",
"ALTER TABLE readers ALTER meta TYPE jsonb",
"ALTER TABLE roles ALTER meta TYPE jsonb",
"ALTER TABLE sales_entity ALTER meta TYPE jsonb",
"ALTER TABLE salespoint ALTER meta TYPE jsonb",
"ALTER TABLE site_page_content ALTER meta TYPE jsonb",
"ALTER TABLE site_pages ALTER meta TYPE jsonb",
"ALTER TABLE tournament_games ALTER meta TYPE jsonb",
"ALTER TABLE tournament_participants ALTER meta TYPE jsonb",
"ALTER TABLE tournament_rules ALTER meta TYPE jsonb",
"ALTER TABLE tournament_team_members ALTER meta TYPE jsonb",
"ALTER TABLE tournaments ALTER meta TYPE jsonb",
"ALTER TABLE user_approvals ALTER meta TYPE jsonb",
"ALTER TABLE user_images ALTER meta TYPE jsonb",
"ALTER TABLE user_notes ALTER meta TYPE jsonb",
"ALTER TABLE users ALTER meta TYPE jsonb",
"ALTER TABLE vip_product_deliveries ALTER meta TYPE jsonb",
"ALTER TABLE vip_products ALTER meta TYPE jsonb",
"ALTER TABLE vips ALTER meta TYPE jsonb",
"ALTER TABLE user_allergies ALTER meta TYPE jsonb"
});
dbUpdates.add(new String[]{
"ALTER TABLE account_events ALTER delivered TYPE TIMESTAMPTZ",
"ALTER TABLE account_events ALTER event_time TYPE TIMESTAMPTZ",
"ALTER TABLE bills ALTER sent_time TYPE TIMESTAMPTZ",
"ALTER TABLE bills ALTER paid_date TYPE TIMESTAMPTZ",
"ALTER TABLE compo_entries ALTER entry_created TYPE TIMESTAMPTZ",
"ALTER TABLE compo_entry_files ALTER uploaded TYPE TIMESTAMPTZ",
"ALTER TABLE compo_entry_participations ALTER confirmed TYPE TIMESTAMPTZ",
"ALTER TABLE compo_votes ALTER vote_time TYPE TIMESTAMPTZ",
"ALTER TABLE compos ALTER compo_start TYPE TIMESTAMPTZ",
"ALTER TABLE compos ALTER submit_end TYPE TIMESTAMPTZ",
"ALTER TABLE compos ALTER submit_start TYPE TIMESTAMPTZ",
"ALTER TABLE compos ALTER vote_end TYPE TIMESTAMPTZ",
"ALTER TABLE compos ALTER vote_start TYPE TIMESTAMPTZ",
"ALTER TABLE compos ALTER compo_end TYPE TIMESTAMPTZ",
"ALTER TABLE discounts ALTER valid_from TYPE TIMESTAMPTZ",
"ALTER TABLE discounts ALTER valid_to TYPE TIMESTAMPTZ",
"ALTER TABLE event_log ALTER event_time TYPE TIMESTAMPTZ",
"ALTER TABLE event_private_properties ALTER date_value TYPE TIMESTAMPTZ",
"ALTER TABLE event_properties ALTER date_value TYPE TIMESTAMPTZ",
"ALTER TABLE event_users ALTER createtime TYPE TIMESTAMPTZ",
"ALTER TABLE events ALTER end_time TYPE TIMESTAMPTZ",
"ALTER TABLE events ALTER start_time TYPE TIMESTAMPTZ",
"ALTER TABLE events ALTER ticket_sales_begin TYPE TIMESTAMPTZ",
"ALTER TABLE feedback ALTER timestamp TYPE TIMESTAMPTZ",
"ALTER TABLE food_waves ALTER wave_time TYPE TIMESTAMPTZ",
"ALTER TABLE group_memberships ALTER invite_accepted TYPE TIMESTAMPTZ",
"ALTER TABLE group_memberships ALTER entered_event TYPE TIMESTAMPTZ",
"ALTER TABLE groups ALTER group_edited TYPE TIMESTAMPTZ",
"ALTER TABLE groups ALTER group_created TYPE TIMESTAMPTZ",
"ALTER TABLE news ALTER expire TYPE TIMESTAMPTZ",
"ALTER TABLE news ALTER publish TYPE TIMESTAMPTZ",
"ALTER TABLE old_actionlog_message_responses ALTER time TYPE TIMESTAMPTZ",
"ALTER TABLE old_actionlog_messages ALTER time TYPE TIMESTAMPTZ",
"ALTER TABLE places ALTER reserve_time TYPE TIMESTAMPTZ",
"ALTER TABLE poll ALTER closing_time TYPE TIMESTAMPTZ",
"ALTER TABLE poll ALTER opening_time TYPE TIMESTAMPTZ",
"ALTER TABLE printed_cards ALTER print_time TYPE TIMESTAMPTZ",
"ALTER TABLE reader_events ALTER event_time TYPE TIMESTAMPTZ",
"ALTER TABLE reader_events ALTER event_updated TYPE TIMESTAMPTZ",
"ALTER TABLE site_page_content ALTER expire TYPE TIMESTAMPTZ",
"ALTER TABLE site_page_content ALTER publish TYPE TIMESTAMPTZ",
"ALTER TABLE user_images ALTER uploaded TYPE TIMESTAMPTZ",
"ALTER TABLE users ALTER birthday TYPE TIMESTAMPTZ",
"ALTER TABLE users ALTER confirm_time TYPE TIMESTAMPTZ",
"ALTER TABLE users ALTER created TYPE TIMESTAMPTZ"
});
}
public BootstrapBean() { public BootstrapBean() {
} }
......
...@@ -127,6 +127,8 @@ public class MenuBean implements MenuBeanLocal { ...@@ -127,6 +127,8 @@ public class MenuBean implements MenuBeanLocal {
usermenu.addPage(menuitemfacade.findOrCreate("/auth/resetmailSent"), null).setVisible(false); usermenu.addPage(menuitemfacade.findOrCreate("/auth/resetmailSent"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/auth/passwordChanged"), null).setVisible(false); usermenu.addPage(menuitemfacade.findOrCreate("/auth/passwordChanged"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/auth/notauthorized"), null).setVisible(false); usermenu.addPage(menuitemfacade.findOrCreate("/auth/notauthorized"), null).setVisible(false);
usermenu.addPage(menuitemfacade.findOrCreate("/viewExpired"), null).setVisible(false);
MenuNavigation userEvent = usermenu.addPage(null, null); MenuNavigation userEvent = usermenu.addPage(null, null);
userEvent.setKey("topnavi.userevent"); userEvent.setKey("topnavi.userevent");
......
...@@ -47,8 +47,8 @@ public class PdfPrinter { ...@@ -47,8 +47,8 @@ public class PdfPrinter {
} }
private static final String fontname = CoreFont.HELVETICA; private static final CoreFont fontname = CoreFont.HELVETICA;
private static final String boldfontname = CoreFont.HELVETICA_BOLD; private static final CoreFont boldfontname = CoreFont.HELVETICA_BOLD;
private static final String EURO = " EUR"; private static final String EURO = " EUR";
// Legacy y-coordinater reverse constant // Legacy y-coordinater reverse constant
private static final double INVERT = 840; private static final double INVERT = 840;
......
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.facade;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.model.*;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Root;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@Stateless
@LocalBean
public class AllergyFacade extends IntegerPkGenericFacade<Allergy> {
public AllergyFacade() {
super(Allergy.class);
}
public List<Allergy> findAll() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Allergy> cq = cb.createQuery(Allergy.class);
Root<Allergy> root = cq.from(Allergy.class);
cq.orderBy(cb.desc(root.get(Allergy_.id)));
TypedQuery<Allergy> q = getEm().createQuery(cq);
return q.getResultList();
}
}
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.facade;
import fi.codecrew.moya.model.Allergy;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.UsersAllergy;
import fi.codecrew.moya.model.UsersAllergy_;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import java.util.List;
@Stateless
@LocalBean
public class UsersAllergyFacade extends IntegerPkGenericFacade<UsersAllergy> {
public UsersAllergyFacade() {
super(UsersAllergy.class);
}
public List<UsersAllergy> findForUser(EventUser user) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<UsersAllergy> cq = cb.createQuery(UsersAllergy.class);
Root<UsersAllergy> root = cq.from(UsersAllergy.class);
cq.where(cb.equal(root.get(UsersAllergy_.user), user.getUser()));
return getEm().createQuery(cq).getResultList();
}
}
...@@ -32,22 +32,11 @@ ...@@ -32,22 +32,11 @@
<version>1.2-SNAPSHOT</version> <version>1.2-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>fi.codecrew.moya</groupId> <groupId>fi.codecrew.moya</groupId>
<artifactId>moya-authmodule-client</artifactId> <artifactId>moya-authmodule-client</artifactId>
<version>1.2-SNAPSHOT</version> <version>1.2-SNAPSHOT</version>
</dependency> </dependency>
<!-- <dependency> <groupId>javax.ejb</groupId> <artifactId>javax.ejb-api</artifactId>
<version>3.2</version> <scope>test</scope> </dependency> -->
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-web</artifactId>
<version>4.1</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<parent> <parent>
<groupId>fi.codecrew.moya</groupId> <groupId>fi.codecrew.moya</groupId>
......
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin-version}</version>
<configuration>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
<executions> <executions>
<execution> <execution>
<id>generate-entity-metamodel</id> <id>generate-entity-metamodel</id>
...@@ -35,13 +39,6 @@ ...@@ -35,13 +39,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
...@@ -58,51 +55,12 @@ ...@@ -58,51 +55,12 @@
<version>1.2-SNAPSHOT</version> <version>1.2-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.ancoron.postgresql</groupId>
<artifactId>org.ancoron.postgresql.jpa</artifactId>
<version>9.1.901.jdbc4.1-rc9</version>
<exclusions>
<exclusion>
<artifactId>javax.persistence</artifactId>
<groupId>org.eclipse.persistence</groupId>
</exclusion>
<exclusion>
<artifactId>org.eclipse.persistence.osgi</artifactId>
<groupId>org.eclipse.persistence</groupId>
</exclusion>
<exclusion>
<artifactId>org.eclipse.persistence.core</artifactId>
<groupId>org.eclipse.persistence</groupId>
</exclusion>
<exclusion>
<artifactId>org.postgresql</artifactId>
<groupId>org.ancoron.postgresql</groupId>
</exclusion>
<exclusion>
<artifactId>org.postgresql.net</artifactId>
<groupId>org.ancoron.postgresql</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.postgresql</groupId> <groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
<version>9.3-1102-jdbc41</version> <version>42.2.2.jre7</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.ancoron.postgresql</groupId>
<artifactId>org.postgresql.net</artifactId>
<version>9.1.901.jdbc4.1-rc9</version>
<exclusions>
<exclusion>
<artifactId>org.postgresql</artifactId>
<groupId>org.ancoron.postgresql</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId> <groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId> <artifactId>org.eclipse.persistence.core</artifactId>
<version>2.5.2-RC1</version> <version>2.5.2-RC1</version>
......
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.database.eclipselink;
import java.util.Hashtable;
import org.ancoron.postgresql.jpa.eclipselink.ExtendedPostgreSQLPlatform;
import org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Smarter defaults. Use TEXT for string columns and understand JSON fields.
* Also inherit ExtendedPostgreSQLPlatform which understand the Inet types.
*
* @author jkj
*
*/
public class MoyaPostgreSQLPlatform extends ExtendedPostgreSQLPlatform {
private static final long serialVersionUID = 6351395815598077327L;
private static final Logger log = LoggerFactory.getLogger(MoyaPostgreSQLPlatform.class);
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected Hashtable buildFieldTypes() {
log.info("Customizing SQL Platform field types for Moya");
Hashtable map = super.buildFieldTypes();
map.put(String.class, new FieldTypeDefinition("TEXT", false));
map.put(java.sql.Timestamp.class, new FieldTypeDefinition("TIMESTAMPTZ", false));
map.put(javax.json.JsonObject.class, new FieldTypeDefinition("JSON", false));
return map;
}
}
package fi.codecrew.moya.model;
import javax.persistence.*;
@Table(name="allergies")
@Entity
public class Allergy extends GenericEntity {
public enum AllergyType {
FOOD, ANIMAL, DIET
}
@Column(nullable = false, name="allergy_type")
@Enumerated(EnumType.STRING)
private AllergyType allergyType;
@Convert(converter = LanguageAwareStringConverter.class )
@Column(nullable = false, columnDefinition = "jsonb", name="name")
private LanguageAwareString name = new LanguageAwareString();
@Convert(converter = LanguageAwareStringConverter.class )
@Column(nullable = false, columnDefinition = "jsonb", name="description")
private LanguageAwareString description = new LanguageAwareString() ;
public AllergyType getAllergyType() {
return allergyType;
}
public void setAllergyType(AllergyType allergyType) {
this.allergyType = allergyType;
}
public LanguageAwareString getName() {
return name;
}
public void setName(LanguageAwareString name) {
this.name = name;
}
public LanguageAwareString getDescription() {
return description;
}
public void setDescription(LanguageAwareString description) {
this.description = description;
}
}
package fi.codecrew.moya.model;
public enum AllergySeverity {
PREFERENCE, MILD, NORMAL, SEVERE, DEADLY
}
...@@ -21,6 +21,7 @@ package fi.codecrew.moya.model; ...@@ -21,6 +21,7 @@ package fi.codecrew.moya.model;
import javax.json.Json; import javax.json.Json;
import javax.json.JsonObject; import javax.json.JsonObject;
import javax.json.JsonObjectBuilder; import javax.json.JsonObjectBuilder;
import javax.json.JsonValue;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
...@@ -28,8 +29,11 @@ import javax.persistence.Transient; ...@@ -28,8 +29,11 @@ import javax.persistence.Transient;
import fi.codecrew.moya.utilities.jpa.EntityEquals; import fi.codecrew.moya.utilities.jpa.EntityEquals;
import fi.codecrew.moya.utilities.jpa.ModelInterface; import fi.codecrew.moya.utilities.jpa.ModelInterface;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
@MappedSuperclass @MappedSuperclass
@OptimisticLocking(type= OptimisticLockingType.ALL_COLUMNS)
public class GenericEntity extends EntityEquals implements ModelInterface, EntityMeta { public class GenericEntity extends EntityEquals implements ModelInterface, EntityMeta {
private static final long serialVersionUID = -9041737052951021560L; private static final long serialVersionUID = -9041737052951021560L;
...@@ -66,10 +70,28 @@ public class GenericEntity extends EntityEquals implements ModelInterface, Entit ...@@ -66,10 +70,28 @@ public class GenericEntity extends EntityEquals implements ModelInterface, Entit
@Transient @Transient
public String getMetaStringValue(String key) { public String getMetaStringValue(String key) {
try { try {
return getMeta().getString(key); JsonObject m = getMeta();
if(m != null && m.containsKey(key)) {
return getMeta().getString(key);
}
} catch (NullPointerException e) { } catch (NullPointerException e) {
// this is normal if key is not found etc. // this is normal if key is not found etc.
return ""; }
return "";
}
@Transient
public void deleteMetaKey(String key){
final JsonObject m = getMeta();
if(m != null){
JsonObjectBuilder metaBuilder = Json.createObjectBuilder();
getMeta()
.entrySet()
.stream()
.filter(e->!e.getKey().equals(key))
.forEach(e -> metaBuilder.add(e.getKey(), e.getValue()));
setMeta(metaBuilder.build());
} }
} }
...@@ -79,15 +101,10 @@ public class GenericEntity extends EntityEquals implements ModelInterface, Entit ...@@ -79,15 +101,10 @@ public class GenericEntity extends EntityEquals implements ModelInterface, Entit
JsonObjectBuilder metaBuilder = Json.createObjectBuilder(); JsonObjectBuilder metaBuilder = Json.createObjectBuilder();
if (getMeta() != null) { if (getMeta() != null) {
for (String valKey : getMeta().keySet()) { getMeta().entrySet().forEach(e -> metaBuilder.add(e.getKey(), e.getValue()));
if (!valKey.equals(key)) {
metaBuilder.add(valKey, getMeta().get(valKey));
}
}
} }
metaBuilder.add(key, value); metaBuilder.add(key, value);
setMeta(metaBuilder.build()); setMeta(metaBuilder.build());
} }
......
package fi.codecrew.moya.model;
import java.util.HashMap;
import java.util.Map;
public class LanguageAwareString {
private String defaultLanguage;
private Map<String, String> values = new HashMap<>();
public String getValue(String language) {
if (values.isEmpty()) {
return null;
}
String ret = values.get(language);
// Fallback to default Language
if (ret == null) {
ret = values.get(defaultLanguage);
// If everything else fails, get a random entry from the map.
if (ret == null) {
ret = values.get(0);
}
}
return ret;
}
public String getDefaultLanguage() {
return defaultLanguage;
}
public void setDefaultLanguage(String defaultLanguage) {
this.defaultLanguage = defaultLanguage;
}
public Map<String, String> getValues() {
return values;
}
public void getValues(Map<String, String> values) {
this.values = values;
}
}
package fi.codecrew.moya.model;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.postgresql.util.PGobject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.io.IOException;
import java.sql.SQLException;
@Converter(autoApply = false)
public class LanguageAwareStringConverter implements AttributeConverter<LanguageAwareString, PGobject> {
private static final Logger logger = LoggerFactory.getLogger(LanguageAwareStringConverter.class);
private static final ObjectMapper mapper = new ObjectMapper();
private void test() {
LanguageAwareString foo = new LanguageAwareString();
foo.setDefaultLanguage("FI");
foo.getValues().put("FI", "Suomeksi");
foo.getValues().put("EN", "Eng");
ObjectMapper mapper = new ObjectMapper();
ObjectWriter writer = mapper.writerFor(LanguageAwareString.class);
try {
logger.warn("Got json", writer.writeValueAsString(foo));
} catch (JsonProcessingException e) {
logger.warn("Error in jsontest", e);
}
}
@Override
public PGobject convertToDatabaseColumn(LanguageAwareString attribute) {
test();
if (attribute == null) {
return null;
}
PGobject pgObject = null;
try {
pgObject = new PGobject();
pgObject.setType("jsonb");
ObjectWriter writer = mapper.writerFor(LanguageAwareString.class);
pgObject.setValue(writer.writeValueAsString(attribute));
} catch (SQLException | JsonProcessingException e) {
logger.warn("Error converting LanguageAwareString to PGObject", e);
throw new RuntimeException(e);
}
return pgObject;
}
@Override
public LanguageAwareString convertToEntityAttribute(PGobject dbData) {
test();
if (dbData == null || dbData.getValue() == null || dbData.getValue().toLowerCase().equals("null")) {
return null;
}
if (!dbData.getType().equals("jsonb") && !dbData.getType().equals("json")) {
throw new RuntimeException("Invalid type for LanguageAwareString from database. Expected json, got " + dbData.getType());
}
LanguageAwareString ret = null;
ObjectReader reader = mapper.readerFor(LanguageAwareString.class);
try {
ret = reader.readValue(dbData.getValue());
} catch (IOException e) {
logger.warn("Error converting PGobject to LanguageAwareString ", e);
throw new RuntimeException(e);
}
return ret;
}
}
...@@ -58,6 +58,7 @@ public class User extends GenericEntity implements IUser { ...@@ -58,6 +58,7 @@ public class User extends GenericEntity implements IUser {
public static final String ANONYMOUS_LOGINNAME = "anonymous"; public static final String ANONYMOUS_LOGINNAME = "anonymous";
private static final long serialVersionUID = -1632200627103418206L; private static final long serialVersionUID = -1632200627103418206L;
private static final String SHIRT_SIZE_METAKEY = "shirtSize";
@Column(name = "created", nullable = false, updatable = false) @Column(name = "created", nullable = false, updatable = false)
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
...@@ -433,12 +434,16 @@ public class User extends GenericEntity implements IUser { ...@@ -433,12 +434,16 @@ public class User extends GenericEntity implements IUser {
@Transient @Transient
public String getShirtSize() { public String getShirtSize() {
return getMetaStringValue("shirtSize"); return getMetaStringValue(SHIRT_SIZE_METAKEY);
} }
@Transient @Transient
public void setShirtSize(String size) { public void setShirtSize(String size) {
setMetaStringValue("shirtSize", size); if(size == null || size.isEmpty()){
deleteMetaKey(SHIRT_SIZE_METAKEY);
}else {
setMetaStringValue(SHIRT_SIZE_METAKEY, size);
}
} }
public String getLocale() { public String getLocale() {
......
package fi.codecrew.moya.model;
import javax.persistence.*;
import java.util.Date;
@Table(name="user_allergies")
@Entity
public class UsersAllergy extends GenericEntity {
@Column(nullable=false, name = "selected")
private boolean selected = false;
@Enumerated(EnumType.STRING)
@Column(name="severity")
private AllergySeverity severity = AllergySeverity.NORMAL;
@ManyToOne
@JoinColumn(name="user_id", updatable = false, referencedColumnName = "id", nullable = false)
private User user;
@ManyToOne
@JoinColumn(name="allergy_id", updatable = false, referencedColumnName = "id", nullable = false)
private Allergy allergy;
@Column(name="created")
@Temporal(TemporalType.TIMESTAMP)
private Date created;
@Lob
@Column(name="notes")
private String notes;
public UsersAllergy() {
super();
}
public UsersAllergy(Allergy allergy, User user) {
this();
this.allergy = allergy;
this.user = user;
}
public AllergySeverity getSeverity() {
return severity;
}
public void setSeverity(AllergySeverity severity) {
this.severity = severity;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Allergy getAllergy() {
return allergy;
}
public void setAllergy(Allergy allergy) {
this.allergy = allergy;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
}
...@@ -42,7 +42,7 @@ public class JsonAttributeConverter implements AttributeConverter<JsonObject, PG ...@@ -42,7 +42,7 @@ public class JsonAttributeConverter implements AttributeConverter<JsonObject, PG
//log.info("Converting JsonObject to PGobject. Original JsonObject: {}", jsonObject); //log.info("Converting JsonObject to PGobject. Original JsonObject: {}", jsonObject);
PGobject pgObject = new PGobject(); PGobject pgObject = new PGobject();
pgObject.setType("json"); pgObject.setType("jsonb");
try { try {
if (jsonObject != null) { if (jsonObject != null) {
pgObject.setValue(jsonObject.toString()); pgObject.setValue(jsonObject.toString());
...@@ -69,7 +69,7 @@ public class JsonAttributeConverter implements AttributeConverter<JsonObject, PG ...@@ -69,7 +69,7 @@ public class JsonAttributeConverter implements AttributeConverter<JsonObject, PG
} }
// Correct type of object? // Correct type of object?
if (pgObject.getType().equals("json") == false) { if (!pgObject.getType().equals("jsonb") && !pgObject.getType().equals("json")) {
log.error("Expected to be converting JSON column, but got PGobject whose type is not json but {}", pgObject.getType()); log.error("Expected to be converting JSON column, but got PGobject whose type is not json but {}", pgObject.getType());
throw new RuntimeException("Expected JSON object from database"); throw new RuntimeException("Expected JSON object from database");
} }
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
<property name="eclipselink.cache.size.default" value="16384" /> <property name="eclipselink.cache.size.default" value="16384" />
<property name="eclipselink.logging.logger" value="ServerLogger" /> <property name="eclipselink.logging.logger" value="ServerLogger" />
<property name="eclipselink.jdbc.uppercase-columns" value="false" /> <property name="eclipselink.jdbc.uppercase-columns" value="false" />
<property name="eclipselink.target-database" <property name="eclipselink.target-database" value="PostgreSQL" />
value="fi.codecrew.moya.database.eclipselink.MoyaPostgreSQLPlatform" />
<property name="eclipselink.create-ddl-jdbc-file-name" value="moyaCreateDDL.sql" /> <property name="eclipselink.create-ddl-jdbc-file-name" value="moyaCreateDDL.sql" />
<property name="eclipselink.drop-ddl-jdbc-file-name" value="moyaDropDDL.sql" /> <property name="eclipselink.drop-ddl-jdbc-file-name" value="moyaDropDDL.sql" />
<property name="eclipselink.target-server" value="Glassfish" /> <property name="eclipselink.target-server" value="Glassfish" />
......
...@@ -50,9 +50,9 @@ ...@@ -50,9 +50,9 @@
<version>1.5.9</version> <version>1.5.9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>fi.iudex.pdfjet</groupId> <groupId>fi.iudex.com.pdfjet</groupId>
<artifactId>pdfjet</artifactId> <artifactId>pdfjet</artifactId>
<version>0.0.0-2013-08-19</version> <version>2017.04.09-1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.glxn</groupId> <groupId>net.glxn</groupId>
...@@ -122,13 +122,6 @@ ...@@ -122,13 +122,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version> <version>${slf4j.version}</version>
...@@ -144,40 +137,24 @@ ...@@ -144,40 +137,24 @@
<version>1.0.4</version> <version>1.0.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version> <version>${swaggerv3.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId> <artifactId>swagger-jaxrs2</artifactId>
<version>${swagger.version}</version> <version>${swaggerv3.version}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-servlet</artifactId> <artifactId>swagger-jaxrs2-servlet-initializer</artifactId>
<version>${swagger.version}</version> <version>${swaggerv3.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.glassfish.jersey.containers</groupId> <groupId>fish.payara.extras</groupId>
<artifactId>jersey-container-servlet</artifactId> <artifactId>payara-embedded-all</artifactId>
<version>2.17</version> <version>${payara.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- These are required for findbugs annotations--> <!-- These are required for findbugs annotations-->
......
...@@ -46,9 +46,9 @@ ...@@ -46,9 +46,9 @@
</build> </build>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version> <version>${swaggerv3.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
package fi.codecrew.moya.rest.pojo.appconfig.v1; package fi.codecrew.moya.rest.pojo.appconfig.v1;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
...@@ -11,7 +11,7 @@ import java.util.List; ...@@ -11,7 +11,7 @@ import java.util.List;
/** /**
* Created by tuukka on 28.3.2015. * Created by tuukka on 28.3.2015.
*/ */
@ApiModel
public class EventPojo { public class EventPojo {
private Integer lanEventId; private Integer lanEventId;
......
...@@ -18,14 +18,13 @@ ...@@ -18,14 +18,13 @@
*/ */
package fi.codecrew.moya.rest.pojo.map.v1; package fi.codecrew.moya.rest.pojo.map.v1;
import io.swagger.annotations.ApiModel;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement()
@ApiModel("Map")
public class MapRoot { public class MapRoot {
private List<MapPojo> maps; private List<MapPojo> maps;
......
...@@ -18,14 +18,15 @@ ...@@ -18,14 +18,15 @@
*/ */
package fi.codecrew.moya.rest.pojo.map.v1; package fi.codecrew.moya.rest.pojo.map.v1;
import io.swagger.annotations.ApiModel;
import java.util.Calendar; import java.util.Calendar;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@ApiModel @XmlRootElement
public class PlacePojo { public class PlacePojo {
private Integer id; private Integer id;
......
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
*/ */
package fi.codecrew.moya.rest.pojo.map.v1; package fi.codecrew.moya.rest.pojo.map.v1;
import io.swagger.annotations.ApiModel;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
@ApiModel
public class PlaceRoot { public class PlaceRoot {
public PlaceRoot() { public PlaceRoot() {
......
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
package fi.codecrew.moya.rest.pojo.network.v1; package fi.codecrew.moya.rest.pojo.network.v1;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ApiModel
public class NetworkAssociationInfoPojo { public class NetworkAssociationInfoPojo {
private String createTime; private String createTime;
private String modifyTime; private String modifyTime;
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
package fi.codecrew.moya.rest.pojo.network.v1; package fi.codecrew.moya.rest.pojo.network.v1;
import io.swagger.annotations.ApiModel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ApiModel
public class NetworkAssociationResponseRoot { public class NetworkAssociationResponseRoot {
private RESTCallResultPojo result; private RESTCallResultPojo result;
private List<NetworkAssociationActionPojo> additions; private List<NetworkAssociationActionPojo> additions;
......
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
*/ */
package fi.codecrew.moya.rest.pojo.network.v1; package fi.codecrew.moya.rest.pojo.network.v1;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ApiModel
public class RESTCallResultPojo { public class RESTCallResultPojo {
private Integer resultCode; private Integer resultCode;
private String resultMessage; private String resultMessage;
......
...@@ -24,10 +24,9 @@ import javax.xml.bind.annotation.XmlElement; ...@@ -24,10 +24,9 @@ import javax.xml.bind.annotation.XmlElement;
import fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo; import fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo;
import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo; import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo;
import io.swagger.annotations.ApiModel;
@ApiModel
public class ReaderEventRestPojo { public class ReaderEventRestPojo {
private EventUserRestPojo eventUser; private EventUserRestPojo eventUser;
......
...@@ -18,12 +18,9 @@ ...@@ -18,12 +18,9 @@
*/ */
package fi.codecrew.moya.rest.pojo.reader.v1; package fi.codecrew.moya.rest.pojo.reader.v1;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ApiModel
public class ReaderRestPojo { public class ReaderRestPojo {
private Integer readerId; private Integer readerId;
...@@ -46,7 +43,7 @@ public class ReaderRestPojo { ...@@ -46,7 +43,7 @@ public class ReaderRestPojo {
} }
@XmlElement(name = "description") @XmlElement(name = "description")
public String getdescription() { public String getDescription() {
return description; return description;
} }
...@@ -67,10 +64,6 @@ public class ReaderRestPojo { ...@@ -67,10 +64,6 @@ public class ReaderRestPojo {
this.readerId = readerId; this.readerId = readerId;
} }
public String getDescription() {
return description;
}
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
......
...@@ -21,13 +21,13 @@ package fi.codecrew.moya.rest.pojo.reader.v3; ...@@ -21,13 +21,13 @@ package fi.codecrew.moya.rest.pojo.reader.v3;
import fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo; import fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo;
import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo; import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardRestPojo;
import fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3; import fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import java.util.Date; import java.util.Date;
@ApiModel
public class ReaderEventRestPojoV3 { public class ReaderEventRestPojoV3 {
private EventUserRestPojo eventUser; private EventUserRestPojo eventUser;
......
...@@ -3,9 +3,9 @@ package fi.codecrew.moya.rest.pojo.userinfo.v1; ...@@ -3,9 +3,9 @@ package fi.codecrew.moya.rest.pojo.userinfo.v1;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import io.swagger.annotations.ApiModel;
@ApiModel
public class ApiApplicationInstancePojo implements Serializable { public class ApiApplicationInstancePojo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -18,14 +18,8 @@ ...@@ -18,14 +18,8 @@
*/ */
package fi.codecrew.moya.rest.pojo.userinfo.v1; package fi.codecrew.moya.rest.pojo.userinfo.v1;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ApiModel("EventUser")
@Api("Event user")
public class EventUserRestPojo { public class EventUserRestPojo {
private String nick = ""; private String nick = "";
...@@ -39,39 +33,39 @@ public class EventUserRestPojo { ...@@ -39,39 +33,39 @@ public class EventUserRestPojo {
} }
@XmlElement() @XmlElement()
@ApiModelProperty("Nickname")
public String getNick() { public String getNick() {
return nick; return nick;
} }
@XmlElement() @XmlElement()
@ApiModelProperty("Login name")
public String getLogin() public String getLogin()
{ {
return login; return login;
} }
@XmlElement() @XmlElement()
@ApiModelProperty("EventUser entity ID")
public Integer getEventuserId() public Integer getEventuserId()
{ {
return eventuserId; return eventuserId;
} }
@XmlElement() @XmlElement()
@ApiModelProperty("User entity ID")
public Integer getUserId() { public Integer getUserId() {
return userId; return userId;
} }
@XmlElement() @XmlElement()
@ApiModelProperty("First name")
public String getFirstname() { public String getFirstname() {
return firstname; return firstname;
} }
@XmlElement() @XmlElement()
@ApiModelProperty("Last name")
public String getLastname() { public String getLastname() {
return lastname; return lastname;
} }
......
...@@ -18,13 +18,12 @@ ...@@ -18,13 +18,12 @@
*/ */
package fi.codecrew.moya.rest.pojo.userinfo.v1; package fi.codecrew.moya.rest.pojo.userinfo.v1;
import io.swagger.annotations.ApiModel;
import java.util.Date; import java.util.Date;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ApiModel
public class PrintedCardRestPojo { public class PrintedCardRestPojo {
private Integer eventuserId; private Integer eventuserId;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
package fi.codecrew.moya.rest.pojo.userinfo.v1; package fi.codecrew.moya.rest.pojo.userinfo.v1;
import io.swagger.annotations.ApiModel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -26,7 +26,7 @@ import java.util.List; ...@@ -26,7 +26,7 @@ import java.util.List;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement() @XmlRootElement()
@ApiModel
public class SimpleEventuserRoot { public class SimpleEventuserRoot {
private List<EventUserRestPojo> eventusers; private List<EventUserRestPojo> eventusers;
......
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
*/ */
package fi.codecrew.moya.rest.pojo.userinfo.v1; package fi.codecrew.moya.rest.pojo.userinfo.v1;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ApiModel
public class UserPermissionRestPojo { public class UserPermissionRestPojo {
@XmlElement() @XmlElement()
private EventUserRestPojo user; private EventUserRestPojo user;
......
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
*/ */
package fi.codecrew.moya.rest.pojo.userinfo.v3; package fi.codecrew.moya.rest.pojo.userinfo.v3;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
@ApiModel
public class CardCodePojoV3 { public class CardCodePojoV3 {
private String readerType; private String readerType;
......
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
*/ */
package fi.codecrew.moya.rest.pojo.userinfo.v3; package fi.codecrew.moya.rest.pojo.userinfo.v3;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ApiModel
public class PrintedCardRestPojoV3 { public class PrintedCardRestPojoV3 {
private Integer eventuserId; private Integer eventuserId;
......
package fi.codecrew.moya.rest.pojo.util.v1; package fi.codecrew.moya.rest.pojo.util.v1;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
@ApiModel
public class ErrorRoot { public class ErrorRoot {
private String error; private String error;
......
package fi.codecrew.moya.rest.pojo.vip.v2; package fi.codecrew.moya.rest.pojo.vip.v2;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -9,7 +8,6 @@ import java.util.List; ...@@ -9,7 +8,6 @@ import java.util.List;
@XmlRootElement() @XmlRootElement()
@ApiModel(description = "vip")
public class VipRestPojo { public class VipRestPojo {
public Integer id; public Integer id;
......
...@@ -108,7 +108,7 @@ public abstract class AbstractView implements Serializable { ...@@ -108,7 +108,7 @@ public abstract class AbstractView implements Serializable {
viewidbuilder.toString()); viewidbuilder.toString());
// navihandler.navigateTo("/permissionDenied"); // navihandler.navigateTo("/permissionDenied");
fcont.getApplication().getNavigationHandler() fcont.getApplication().getNavigationHandler()
.handleNavigation(fcont, null, "/permissionDenied"); .handleNavigation(fcont, null, "/permissionDenied?faces-redirect=true");
} }
return ret; return ret;
......
...@@ -41,8 +41,9 @@ public class GitRepositoryState { ...@@ -41,8 +41,9 @@ public class GitRepositoryState {
private GitRepositoryState() { private GitRepositoryState() {
logger.info("Initializing git status"); logger.info("Initializing git status");
this.properties = new Properties(); this.properties = new Properties();
InputStream resource = null;
try { try {
InputStream resource = getClass().getResourceAsStream("/git.properties"); resource = getClass().getResourceAsStream("/git.properties");
if (resource == null) { if (resource == null) {
logger.warn("Resource not found!"); logger.warn("Resource not found!");
...@@ -53,6 +54,14 @@ public class GitRepositoryState { ...@@ -53,6 +54,14 @@ public class GitRepositoryState {
logger.info("Git keys:", this.properties.keys()); logger.info("Git keys:", this.properties.keys());
} catch (IOException e) { } catch (IOException e) {
logger.warn("Error initializing git proerties", e); logger.warn("Error initializing git proerties", e);
} finally {
if (resource != null) {
try {
resource.close();
} catch (IOException e) {
// Error clsoing resource in finally.. Eat the error.
}
}
} }
} }
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.1"> xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>MoyaWeb</display-name> <display-name>MoyaWeb</display-name>
<context-param> <context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
<composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" /> <composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" />
<composite:attribute name="camAlwaysOn" required="false" default="false" /> <composite:attribute name="camAlwaysOn" required="false" default="false" />
<composite:attribute name="showRoles" required="false" default="false" /> <composite:attribute name="showRoles" required="false" default="false" />
<composite:attribute name="commitvalue" required="false" default="Save" />
</composite:interface> </composite:interface>
<composite:implementation> <composite:implementation>
...@@ -130,19 +132,24 @@ ...@@ -130,19 +132,24 @@
<p:outputLabel value="#{i18n['user.shirtSize']}" for="shirtSize" rendered="#{userView.shirtEnabled}" /> <p:outputLabel value="#{i18n['user.shirtSize']}" for="shirtSize" rendered="#{userView.shirtEnabled}" />
<p:selectOneMenu style="width: 200px;" disabled="#{!cc.attrs.creating and !userView.canSave}" id="shirtSize" value="#{userView.selectedUser.user.shirtSize}" rendered="#{userView.shirtEnabled}"> <p:selectOneMenu style="width: 200px;" disabled="#{!cc.attrs.creating and !userView.canSave}" id="shirtSize" value="#{userView.selectedUser.user.shirtSize}" rendered="#{userView.shirtEnabled}">
<f:selectItem itemLabel="#{i18n['user.shirt.select']}" itemValue="" /> <f:selectItem itemLabel="#{i18n['user.shirt.select']}" itemValue="" />
<f:selectItem itemLabel="#{i18n['user.shirt.S']}" itemValue="S" /> <f:selectItem itemLabel="#{i18n['user.shirt.S']}" itemValue="S" />
<f:selectItem itemLabel="#{i18n['user.shirt.M']}" itemValue="M" /> <f:selectItem itemLabel="#{i18n['user.shirt.M']}" itemValue="M" />
<f:selectItem itemLabel="#{i18n['user.shirt.L']}" itemValue="L" /> <f:selectItem itemLabel="#{i18n['user.shirt.L']}" itemValue="L" />
<f:selectItem itemLabel="#{i18n['user.shirt.XL']}" itemValue="XL" /> <f:selectItem itemLabel="#{i18n['user.shirt.XL']}" itemValue="XL" />
<f:selectItem itemLabel="#{i18n['user.shirt.XXL']}" itemValue="XXL" /> <f:selectItem itemLabel="#{i18n['user.shirt.XXL']}" itemValue="XXL" />
<f:selectItem itemLabel="#{i18n['user.shirt.XXXL']}" itemValue="XXXL" /> <f:selectItem itemLabel="#{i18n['user.shirt.3XL']}" itemValue="3XL" />
<f:selectItem itemLabel="#{i18n['user.shirt.4XL']}" itemValue="4XL" />
<f:selectItem itemLabel="#{i18n['user.shirt.5XL']}" itemValue="5XL" />
<f:selectItem itemLabel="#{i18n['user.shirt.LadyXS']}" itemValue="Lady-XS" /> <f:selectItem itemLabel="#{i18n['user.shirt.LadyXS']}" itemValue="Lady-XS" />
<f:selectItem itemLabel="#{i18n['user.shirt.LadyS']}" itemValue="Lady-S" /> <f:selectItem itemLabel="#{i18n['user.shirt.LadyS']}" itemValue="Lady-S" />
<f:selectItem itemLabel="#{i18n['user.shirt.LadyM']}" itemValue="Lady-M" /> <f:selectItem itemLabel="#{i18n['user.shirt.LadyM']}" itemValue="Lady-M" />
<f:selectItem itemLabel="#{i18n['user.shirt.LadyL']}" itemValue="Lady-L" /> <f:selectItem itemLabel="#{i18n['user.shirt.LadyL']}" itemValue="Lady-L" />
<f:selectItem itemLabel="#{i18n['user.shirt.LadyXL']}" itemValue="Lady-XL" /> <f:selectItem itemLabel="#{i18n['user.shirt.LadyXL']}" itemValue="Lady-XL" />
<f:selectItem itemLabel="#{i18n['user.shirt.LadyXXL']}" itemValue="Lady-XXL" /> <f:selectItem itemLabel="#{i18n['user.shirt.LadyXXL']}" itemValue="Lady-XXL" />
<f:selectItem itemLabel="#{i18n['user.shirt.Lady3XL']}" itemValue="Lady-3XL" />
<f:selectItem itemLabel="#{i18n['user.shirt.Lady4XL']}" itemValue="Lady-4XL" />
<f:selectItem itemLabel="#{i18n['user.shirt.Lady5XL']}" itemValue="Lady-5XL" />
</p:selectOneMenu> </p:selectOneMenu>
<p:message for="shirtSize" rendered="#{userView.shirtEnabled}" /> <p:message for="shirtSize" rendered="#{userView.shirtEnabled}" />
...@@ -150,27 +157,27 @@ ...@@ -150,27 +157,27 @@
<p:commandButton rendered="#{cc.attrs.creating or userView.canSave}" id="commitbtn" action="#{cc.attrs.commitaction}" ajax="false" value="#{cc.attrs.commitvalue}" onerror="location.reload(true);" /> <p:commandButton rendered="#{cc.attrs.creating or userView.canSave}" id="commitbtn" action="#{cc.attrs.commitaction}" ajax="false" value="#{cc.attrs.commitvalue}" onerror="location.reload(true);" />
</p:fieldset> </p:fieldset>
</h:form> </h:form>
<ui:fragment rendered="#{not empty userView.meta}">
<h:outputScript target="head" library="script" name="jsonview.js" />
<h:outputScript target="head">
window.onload = function() {
jsonView('#usermetaview');
}
</h:outputScript>
<h:form id="usermetaform" enctype="multipart/form-data">
<p:fieldset legend="#{i18n['user.meta.box.title']}">
<p:panelGrid columns="1" cellpadding="1">
<div id="usermetaview">#{userView.meta}</div>
</p:panelGrid>
</p:fieldset>
</h:form>
</ui:fragment>
</p:panelGrid> <p:fieldset legend="#{i18n['user.meta.box.title']}" toggleable="true" collapsed="true" rendered="#{not empty userView.meta}">
<div id="usermetaview"><pre><h:outputText value="#{userView.prettyMeta}" /></pre></div>
</p:fieldset>
</p:panelGrid>
<p:fieldset toggleable="true" collapsed="true" legend="#{i18n['user.allergies']}">
<h:form id="userAllergies">
<p:dataTable value="#{userAllergyView.allergies}" var="allergy">
<p:column width="30"><p:selectBooleanCheckbox value="#{allergy.usersAllergy.selected}" /></p:column>
<p:column><h:outputText value="#{allergy.allergy.name.getValue(sessionStore.language)}"/></p:column>
</p:dataTable><br />
<p:inputTextarea value="#{userAllergyView.freetext}" cols="40" rows="5"/>
<br/>
<p:commandButton ajax="false" update="userAllergies" action="#{userAllergyView.saveAllergies}" value="#{i18n['allergies.save']}" />
</h:form>
</p:fieldset>
<h:form id="userSelectableRoles"> <h:form id="userSelectableRoles">
<p:fieldset legend="#{i18n['user.userSelectableRoles']}" rendered="#{userView.showUserSelectableRoles and cc.attrs.showRoles}"> <p:fieldset legend="#{i18n['user.userSelectableRoles']}" rendered="#{userView.showUserSelectableRoles and cc.attrs.showRoles}">
<p:panelGrid columns="2" styleClass="noBorders"> <p:panelGrid columns="2" styleClass="noBorders">
......
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<title>Swagger UI</title> <meta charset="UTF-8">
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/> <title>Swagger UI</title>
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/> <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/> <link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/> <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link href='css/screen.css' media='print' rel='stylesheet' type='text/css'/> <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<script type="text/javascript" src="lib/shred.bundle.js"></script> <style>
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script> html
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script> {
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script> box-sizing: border-box;
<script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script> overflow: -moz-scrollbars-vertical;
<script src='lib/handlebars-1.0.0.js' type='text/javascript'></script> overflow-y: scroll;
<script src='lib/underscore-min.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='lib/swagger.js' type='text/javascript'></script>
<script src='lib/swagger-client.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<!-- enabling this will enable oauth2 implicit scope support -->
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
<script type="text/javascript">
$(function () {
var url = window.location.protocol + '//' + window.location.host + '/MoyaWeb/rest/api-docs';
if (!url || url.length < 1) {
url = "http://localhost:8080/MoyaWeb/rest/api-docs";
} }
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded SwaggerUI");
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
sorter : "alpha"
});
function addApiKeyAuthorization() { *,
var key = $('#input_apiKey')[0].value; *:before,
log("key: " + key); *:after
if(key && key.trim() != "") { {
log("added key " + key); box-sizing: inherit;
window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query"));
}
} }
$('#input_apiKey').change(function() { body
addApiKeyAuthorization(); {
}); margin:0;
background: #fafafa;
}
</style>
</head>
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes... <body>
/* <div id="swagger-ui"></div>
var apiKey = "myApiKeyXXXX123456789";
$('#input_apiKey').val(apiKey);
addApiKeyAuthorization();
*/
window.swaggerUi.load(); <script src="./swagger-ui-bundle.js"> </script>
}); <script src="./swagger-ui-standalone-preset.js"> </script>
</script> <script>
</head> window.onload = function() {
<body class="swagger-section"> // Build a system
<div id='header'> const ui = SwaggerUIBundle({
<div class="swagger-ui-wrap"> url: "../rest/openapi.json",
<a id="logo" href="http://swagger.io">swagger</a> dom_id: '#swagger-ui',
<form id='api_selector'> deepLinking: true,
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div> presets: [
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div> SwaggerUIBundle.presets.apis,
<div class='input'><a id="explore" href="#">Explore</a></div> SwaggerUIStandalonePreset
</form> ],
</div> plugins: [
</div> SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div> window.ui = ui
<div id="swagger-ui-container" class="swagger-ui-wrap"></div> }
</body> </script>
</body>
</html> </html>
var hljs=new function(){function l(o){return o.replace(/&/gm,"&amp;").replace(/</gm,"&lt;").replace(/>/gm,"&gt;")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o<p.length;o++){if(e[p[o]]||p[o]=="no-highlight"){return p[o]}}}function c(q){var o=[];(function p(r,s){for(var t=r.firstChild;t;t=t.nextSibling){if(t.nodeType==3){s+=t.nodeValue.length}else{if(t.nodeName=="BR"){s+=1}else{if(t.nodeType==1){o.push({event:"start",offset:s,node:t});s=p(t,s);o.push({event:"stop",offset:s,node:t})}}}}return s})(q,0);return o}function j(x,v,w){var p=0;var y="";var r=[];function t(){if(x.length&&v.length){if(x[0].offset!=v[0].offset){return(x[0].offset<v[0].offset)?x:v}else{return v[0].event=="start"?x:v}}else{return x.length?x:v}}function s(A){function z(B){return" "+B.nodeName+'="'+l(B.value)+'"'}return"<"+A.nodeName+Array.prototype.map.call(A.attributes,z).join("")+">"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=("</"+o.nodeName.toLowerCase()+">")}while(o!=u.node);r.splice(q,1);while(q<r.length){y+=s(r[q]);q++}}}}return y+l(w.substr(p))}function f(q){function o(s,r){return RegExp(s,"m"+(q.cI?"i":"")+(r?"g":""))}function p(y,w){if(y.compiled){return}y.compiled=true;var s=[];if(y.k){var r={};function z(A,t){t.split(" ").forEach(function(B){var C=B.split("|");r[C[0]]=[A,C[1]?Number(C[1]):1];s.push(C[0])})}y.lR=o(y.l||hljs.IR,true);if(typeof y.k=="string"){z("keyword",y.k)}else{for(var x in y.k){if(!y.k.hasOwnProperty(x)){continue}z(x,y.k[x])}}y.k=r}if(w){if(y.bWK){y.b="\\b("+s.join("|")+")\\s"}y.bR=o(y.b?y.b:"\\B|\\b");if(!y.e&&!y.eW){y.e="\\B|\\b"}if(y.e){y.eR=o(y.e)}y.tE=y.e||"";if(y.eW&&w.tE){y.tE+=(y.e?"|":"")+w.tE}}if(y.i){y.iR=o(y.i)}if(y.r===undefined){y.r=1}if(!y.c){y.c=[]}for(var v=0;v<y.c.length;v++){if(y.c[v]=="self"){y.c[v]=y}p(y.c[v],y)}if(y.starts){p(y.starts,w)}var u=[];for(var v=0;v<y.c.length;v++){u.push(y.c[v].b)}if(y.tE){u.push(y.tE)}if(y.i){u.push(y.i)}y.t=u.length?o(u.join("|"),true):{exec:function(t){return null}}}p(q)}function d(D,E){function o(r,M){for(var L=0;L<M.c.length;L++){var K=M.c[L].bR.exec(r);if(K&&K.index==0){return M.c[L]}}}function s(K,r){if(K.e&&K.eR.test(r)){return K}if(K.eW){return s(K.parent,r)}}function t(r,K){return K.i&&K.iR.test(r)}function y(L,r){var K=F.cI?r[0].toLowerCase():r[0];return L.k.hasOwnProperty(K)&&L.k[K]}function G(){var K=l(w);if(!A.k){return K}var r="";var N=0;A.lR.lastIndex=0;var L=A.lR.exec(K);while(L){r+=K.substr(N,L.index-N);var M=y(A,L);if(M){v+=M[1];r+='<span class="'+M[0]+'">'+L[0]+"</span>"}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return'<span class="'+r.language+'">'+r.value+"</span>"}function J(){return A.sL!==undefined?z():G()}function I(L,r){var K=L.cN?'<span class="'+L.cN+'">':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function C(K,r){w+=K;if(r===undefined){x+=J();return 0}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB?0:r.length}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+="</span>"}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;return r.length||1}var F=e[D];f(F);var A=F;var w="";var B=0;var v=0;var x="";try{var u,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"<br>")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.xml=function(a){var c="[A-Za-z0-9\\._:-]+";var b={eW:true,c:[{cN:"attribute",b:c,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"<!DOCTYPE",e:">",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"<!--",e:"-->",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"<style(?=\\s|>|$)",e:">",k:{title:"style"},c:[b],starts:{e:"</style>",rE:true,sL:"css"}},{cN:"tag",b:"<script(?=\\s|>|$)",e:">",k:{title:"script"},c:[b],starts:{e:"<\/script>",rE:true,sL:"javascript"}},{b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"</?",e:"/?>",c:[{cN:"title",b:"[^ />]+"},b]}]}}(hljs);hljs.LANGUAGES.json=function(a){var e={literal:"true false null"};var d=[a.QSM,a.CNM];var c={cN:"value",e:",",eW:true,eE:true,c:d,k:e};var b={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:true,eE:true,c:[a.BE],i:"\\n",starts:c}],i:"\\S"};var f={b:"\\[",e:"\\]",c:[a.inherit(c,{cN:null})],i:"\\S"};d.splice(d.length,0,b,f);return{c:d,k:e,i:"\\S"}}(hljs);
\ No newline at end of file
/*
* jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
* http://benalman.com/projects/jquery-bbq-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M<N?O[P]||(R[M+1]&&isNaN(R[M+1])?{}:[]):J}}else{if($.isArray(H[P])){H[P].push(J)}else{if(H[P]!==i){H[P]=[H[P],J]}else{H[P]=J}}}}else{if(P){H[P]=F?i:""}}});return H};function z(H,F,G){if(F===i||typeof F==="boolean"){G=F;F=a[H?D:A]()}else{F=E(F)?F.replace(H?w:x,""):F}return l(F,G)}l[A]=B(z,0);l[D]=v=B(z,1);$[y]||($[y]=function(F){return $.extend(C,F)})({a:k,base:k,iframe:t,img:t,input:t,form:"action",link:k,script:t});j=$[y];function s(I,G,H,F){if(!E(H)&&typeof H!=="object"){F=H;H=G;G=i}return this.each(function(){var L=$(this),J=G||j()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,F))})}$.fn[A]=B(s,A);$.fn[D]=B(s,D);b.pushState=q=function(I,F){if(E(I)&&/^#/.test(I)&&F===i){F=2}var H=I!==i,G=c(p[g][k],H?I:{},H?F:2);p[g][k]=G+(/#/.test(G)?"":"#")};b.getState=u=function(F,G){return F===i||typeof F==="boolean"?v(F):v(G)[F]};b.removeState=function(F){var G={};if(F!==i){G=u();$.each($.isArray(F)?F:arguments,function(I,H){delete G[H]})}q(G,2)};e[d]=$.extend(e[d],{add:function(F){var H;function G(J){var I=J[D]=c();J.getState=function(K,L){return K===i||typeof K==="boolean"?l(I,K):l(I,L)[K]};H.apply(this,arguments)}if($.isFunction(F)){H=F;return G}else{H=F.handler;F.handler=G}}})})(jQuery,this);
/*
* jQuery hashchange event - v1.2 - 2/11/2010
* http://benalman.com/projects/jquery-hashchange-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
\ No newline at end of file
(function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery);
/*
jQuery Wiggle
Author: WonderGroup, Jordan Thomas
URL: http://labs.wondergroup.com/demos/mini-ui/index.html
License: MIT (http://en.wikipedia.org/wiki/MIT_License)
*/
jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('<div class="wiggle-wrap"></div>').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
\ No newline at end of file
// The purpose of the `Content` object is to abstract away the data conversions
// to and from raw content entities as strings. For example, you want to be able
// to pass in a Javascript object and have it be automatically converted into a
// JSON string if the `content-type` is set to a JSON-based media type.
// Conversely, you want to be able to transparently get back a Javascript object
// in the response if the `content-type` is a JSON-based media-type.
// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5).
// The `Content` constructor takes an options object, which *must* have either a
// `body` or `data` property and *may* have a `type` property indicating the
// media type. If there is no `type` attribute, a default will be inferred.
var Content = function(options) {
this.body = options.body;
this.data = options.data;
this.type = options.type;
};
Content.prototype = {
// Treat `toString()` as asking for the `content.body`. That is, the raw content entity.
//
// toString: function() { return this.body; }
//
// Commented out, but I've forgotten why. :/
};
// `Content` objects have the following attributes:
Object.defineProperties(Content.prototype,{
// - **type**. Typically accessed as `content.type`, reflects the `content-type`
// header associated with the request or response. If not passed as an options
// to the constructor or set explicitly, it will infer the type the `data`
// attribute, if possible, and, failing that, will default to `text/plain`.
type: {
get: function() {
if (this._type) {
return this._type;
} else {
if (this._data) {
switch(typeof this._data) {
case "string": return "text/plain";
case "object": return "application/json";
}
}
}
return "text/plain";
},
set: function(value) {
this._type = value;
return this;
},
enumerable: true
},
// - **data**. Typically accessed as `content.data`, reflects the content entity
// converted into Javascript data. This can be a string, if the `type` is, say,
// `text/plain`, but can also be a Javascript object. The conversion applied is
// based on the `processor` attribute. The `data` attribute can also be set
// directly, in which case the conversion will be done the other way, to infer
// the `body` attribute.
data: {
get: function() {
if (this._body) {
return this.processor.parser(this._body);
} else {
return this._data;
}
},
set: function(data) {
if (this._body&&data) Errors.setDataWithBody(this);
this._data = data;
return this;
},
enumerable: true
},
// - **body**. Typically accessed as `content.body`, reflects the content entity
// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the
// `data` attribute, the `body` attribute will be inferred and vice-versa. If
// you attempt to set both, an exception is raised.
body: {
get: function() {
if (this._data) {
return this.processor.stringify(this._data);
} else {
return this._body.toString();
}
},
set: function(body) {
if (this._data&&body) Errors.setBodyWithData(this);
this._body = body;
return this;
},
enumerable: true
},
// - **processor**. The functions that will be used to convert to/from `data` and
// `body` attributes. You can add processors. The two that are built-in are for
// `text/plain`, which is basically an identity transformation and
// `application/json` and other JSON-based media types (including custom media
// types with `+json`). You can add your own processors. See below.
processor: {
get: function() {
var processor = Content.processors[this.type];
if (processor) {
return processor;
} else {
// Return the first processor that matches any part of the
// content type. ex: application/vnd.foobar.baz+json will match json.
var main = this.type.split(";")[0];
var parts = main.split(/\+|\//);
for (var i=0, l=parts.length; i < l; i++) {
processor = Content.processors[parts[i]]
}
return processor || {parser:identity,stringify:toString};
}
},
enumerable: true
},
// - **length**. Typically accessed as `content.length`, returns the length in
// bytes of the raw content entity.
length: {
get: function() {
if (typeof Buffer !== 'undefined') {
return Buffer.byteLength(this.body);
}
return this.body.length;
}
}
});
Content.processors = {};
// The `registerProcessor` function allows you to add your own processors to
// convert content entities. Each processor consists of a Javascript object with
// two properties:
// - **parser**. The function used to parse a raw content entity and convert it
// into a Javascript data type.
// - **stringify**. The function used to convert a Javascript data type into a
// raw content entity.
Content.registerProcessor = function(types,processor) {
// You can pass an array of types that will trigger this processor, or just one.
// We determine the array via duck-typing here.
if (types.forEach) {
types.forEach(function(type) {
Content.processors[type] = processor;
});
} else {
// If you didn't pass an array, we just use what you pass in.
Content.processors[types] = processor;
}
};
// Register the identity processor, which is used for text-based media types.
var identity = function(x) { return x; }
, toString = function(x) { return x.toString(); }
Content.registerProcessor(
["text/html","text/plain","text"],
{ parser: identity, stringify: toString });
// Register the JSON processor, which is used for JSON-based media types.
Content.registerProcessor(
["application/json; charset=utf-8","application/json","json"],
{
parser: function(string) {
return JSON.parse(string);
},
stringify: function(data) {
return JSON.stringify(data); }});
var qs = require('querystring');
// Register the post processor, which is used for JSON-based media types.
Content.registerProcessor(
["application/x-www-form-urlencoded"],
{ parser : qs.parse, stringify : qs.stringify });
// Error functions are defined separately here in an attempt to make the code
// easier to read.
var Errors = {
setDataWithBody: function(object) {
throw new Error("Attempt to set data attribute of a content object " +
"when the body attributes was already set.");
},
setBodyWithData: function(object) {
throw new Error("Attempt to set body attribute of a content object " +
"when the data attributes was already set.");
}
}
module.exports = Content;
\ No newline at end of file
var appName;
var popupMask;
var popupDialog;
var clientId;
var realm;
function handleLogin() {
var scopes = [];
var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
if(auths) {
var key;
var defs = auths;
for(key in defs) {
var auth = defs[key];
if(auth.type === 'oauth2' && auth.scopes) {
var scope;
if(Array.isArray(auth.scopes)) {
// 1.2 support
var i;
for(i = 0; i < auth.scopes.length; i++) {
scopes.push(auth.scopes[i]);
}
}
else {
// 2.0 support
for(scope in auth.scopes) {
scopes.push({scope: scope, description: auth.scopes[scope]});
}
}
}
}
}
if(window.swaggerUi.api
&& window.swaggerUi.api.info) {
appName = window.swaggerUi.api.info.title;
}
popupDialog = $(
[
'<div class="api-popup-dialog">',
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
'<div class="api-popup-content">',
'<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.',
'<a href="#">Learn how to use</a>',
'</p>',
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
'<ul class="api-popup-scopes">',
'</ul>',
'<p class="error-msg"></p>',
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
'</div>',
'</div>'].join(''));
$(document.body).append(popupDialog);
popup = popupDialog.find('ul.api-popup-scopes').empty();
for (i = 0; i < scopes.length; i ++) {
scope = scopes[i];
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
if (scope.description) {
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
}
str += '</label></li>';
popup.append(str);
}
var $win = $(window),
dw = $win.width(),
dh = $win.height(),
st = $win.scrollTop(),
dlgWd = popupDialog.outerWidth(),
dlgHt = popupDialog.outerHeight(),
top = (dh -dlgHt)/2 + st,
left = (dw - dlgWd)/2;
popupDialog.css({
top: (top < 0? 0 : top) + 'px',
left: (left < 0? 0 : left) + 'px'
});
popupDialog.find('button.api-popup-cancel').click(function() {
popupMask.hide();
popupDialog.hide();
popupDialog.empty();
popupDialog = [];
});
popupDialog.find('button.api-popup-authbtn').click(function() {
popupMask.hide();
popupDialog.hide();
var authSchemes = window.swaggerUi.api.authSchemes;
var host = window.location;
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
var url = null;
for (var key in authSchemes) {
if (authSchemes.hasOwnProperty(key)) {
if(authSchemes[key].type === 'oauth2' && authSchemes[key].flow === 'implicit') {
var dets = authSchemes[key];
url = dets.authorizationUrl + '?response_type=token';
window.swaggerUi.tokenName = dets.tokenUrl || 'access_token';
}
else if(authSchemes[key].grantTypes) {
// 1.2 support
var o = authSchemes[key].grantTypes;
for(var t in o) {
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t];
var ep = dets.loginEndpoint.url;
url = dets.loginEndpoint.url + '?response_type=token';
window.swaggerUi.tokenName = dets.tokenName;
}
}
}
}
}
var scopes = []
var o = $('.api-popup-scopes').find('input:checked');
for(k =0; k < o.length; k++) {
scopes.push($(o[k]).attr('scope'));
}
window.enabledScopes=scopes;
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
url += '&realm=' + encodeURIComponent(realm);
url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopes);
window.open(url);
});
popupMask.show();
popupDialog.show();
return;
}
function handleLogout() {
for(key in window.authorizations.authz){
window.authorizations.remove(key)
}
window.enabledScopes = null;
$('.api-ic.ic-on').addClass('ic-off');
$('.api-ic.ic-on').removeClass('ic-on');
// set the info box
$('.api-ic.ic-warning').addClass('ic-error');
$('.api-ic.ic-warning').removeClass('ic-warning');
}
function initOAuth(opts) {
var o = (opts||{});
var errors = [];
appName = (o.appName||errors.push('missing appName'));
popupMask = (o.popupMask||$('#api-common-mask'));
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
clientId = (o.clientId||errors.push('missing client id'));
realm = (o.realm||errors.push('missing realm'));
if(errors.length > 0){
log('auth unable initialize oauth: ' + errors);
return;
}
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
$('.api-ic').click(function(s) {
if($(s.target).hasClass('ic-off'))
handleLogin();
else {
handleLogout();
}
false;
});
}
function onOAuthComplete(token) {
if(token) {
if(token.error) {
var checkbox = $('input[type=checkbox],.secured')
checkbox.each(function(pos){
checkbox[pos].checked = false;
});
alert(token.error);
}
else {
var b = token[window.swaggerUi.tokenName];
if(b){
// if all roles are satisfied
var o = null;
$.each($('.auth #api_information_panel'), function(k, v) {
var children = v;
if(children && children.childNodes) {
var requiredScopes = [];
$.each((children.childNodes), function (k1, v1){
var inner = v1.innerHTML;
if(inner)
requiredScopes.push(inner);
});
var diff = [];
for(var i=0; i < requiredScopes.length; i++) {
var s = requiredScopes[i];
if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
diff.push(s);
}
}
if(diff.length > 0){
o = v.parentNode;
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
// sorry, not all scopes are satisfied
$(o).find('.api-ic').addClass('ic-warning');
$(o).find('.api-ic').removeClass('ic-error');
}
else {
o = v.parentNode;
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
// all scopes are satisfied
$(o).find('.api-ic').addClass('ic-info');
$(o).find('.api-ic').removeClass('ic-warning');
$(o).find('.api-ic').removeClass('ic-error');
}
}
});
window.authorizations.add('oauth2', new ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
}
}
}
}
\ No newline at end of file
<script>
var qp = null;
if(window.location.hash) {
qp = location.hash.substring(1);
}
else {
qp = location.search.substring(1);
}
qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
function(key, value) {
return key===""?value:decodeURIComponent(value) }
):{}
window.opener.onOAuthComplete(qp);
window.close();
</script>
\ No newline at end of file
<!doctype html>
<html lang="en-US">
<body onload="run()">
</body>
</html>
<script>
'use strict';
function run () {
var oauth2 = window.opener.swaggerUIRedirectOauth2;
var sentState = oauth2.state;
var redirectUrl = oauth2.redirectUrl;
var isValid, qp, arr;
if (/code|token|error/.test(window.location.hash)) {
qp = window.location.hash.substring(1);
} else {
qp = location.search.substring(1);
}
arr = qp.split("&")
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
qp = qp ? JSON.parse('{' + arr.join() + '}',
function (key, value) {
return key === "" ? value : decodeURIComponent(value)
}
) : {}
isValid = qp.state === sentState
if ((
oauth2.auth.schema.get("flow") === "accessCode"||
oauth2.auth.schema.get("flow") === "authorizationCode"
) && !oauth2.auth.code) {
if (!isValid) {
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "warning",
message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
});
}
if (qp.code) {
delete oauth2.state;
oauth2.auth.code = qp.code;
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
} else {
let oauthErrorMsg
if (qp.error) {
oauthErrorMsg = "["+qp.error+"]: " +
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
(qp.error_uri ? "More info: "+qp.error_uri : "");
}
oauth2.errCb({
authId: oauth2.auth.name,
source: "auth",
level: "error",
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
});
}
} else {
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
}
window.close();
}
</script>
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
{"version":3,"sources":[],"names":[],"mappings":"","file":"swagger-ui.css","sourceRoot":""}
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
...@@ -40,25 +40,12 @@ ...@@ -40,25 +40,12 @@
<artifactId>all-themes</artifactId> <artifactId>all-themes</artifactId>
<version>${primefaces.themeversion}</version> <version>${primefaces.themeversion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>fi.codecrew.moya</groupId> <groupId>fi.codecrew.moya</groupId>
<artifactId>moya-restpojo</artifactId> <artifactId>moya-restpojo</artifactId>
<version>1.2.4</version> <version>1.2.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId> <groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId> <artifactId>rewrite-servlet</artifactId>
<version>${rewriteservlet.version}</version> <version>${rewriteservlet.version}</version>
......
...@@ -23,6 +23,7 @@ import java.util.Map; ...@@ -23,6 +23,7 @@ import java.util.Map;
import javax.ejb.AccessLocalException; import javax.ejb.AccessLocalException;
import javax.ejb.EJBAccessException; import javax.ejb.EJBAccessException;
import javax.enterprise.context.NonexistentConversationException;
import javax.faces.FacesException; import javax.faces.FacesException;
import javax.faces.application.NavigationHandler; import javax.faces.application.NavigationHandler;
import javax.faces.application.ViewExpiredException; import javax.faces.application.ViewExpiredException;
...@@ -50,43 +51,53 @@ public class BortalExceptionHandler extends ExceptionHandlerWrapper { ...@@ -50,43 +51,53 @@ public class BortalExceptionHandler extends ExceptionHandlerWrapper {
return wrapped; return wrapped;
} }
@Override @Override
public void handle() throws FacesException { public void handle() throws FacesException {
Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();
while (i.hasNext()) { while (i.hasNext()) {
ExceptionQueuedEvent event = i.next(); ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource(); ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException(); Throwable t = context.getException();
logger.debug("Found exception! handing it: {}", t.getClass().toString()); logger.debug("Found exception! handing it: {}", t.getClass().toString());
if (t instanceof ViewExpiredException) { if(checkException(i, t)){
logger.debug("ViewExpiredException details", t); return;
errorpage(i, t, "/viewExpired");
} }
Throwable cause = t.getCause(); Throwable cause = t.getCause();
for (int loop = 0; loop < 20 && cause != null; ++loop) { for (int loop = 0; loop < 20 && cause != null; ++loop) {
logger.debug("Cause not null, but {}: {}, checking" + cause.getClass(), cause.getMessage()); logger.debug("Cause not null, but {}: {}, checking " + cause.getClass(), cause.getMessage());
if (cause instanceof EJBAccessException || if(checkException(i, cause)){
cause instanceof AccessLocalException) { return;
logger.debug("Found Permission Denied cause: {}, {}", cause.getClass(), cause.getMessage());
// errorpage(i, t, "permissionDenied");
} }
cause = cause.getCause(); cause = cause.getCause();
} }
} }
// At this point, the queue will not contain any ViewExpiredEvents.
// Therefore, let the parent handle them.
getWrapped().handle(); getWrapped().handle();
} }
private void errorpage(Iterator<ExceptionQueuedEvent> i, Throwable t, String navigateTo) { private boolean checkException(Iterator<ExceptionQueuedEvent> i, Throwable t) {
if (t instanceof ViewExpiredException) {
logger.debug("ViewExpiredException details", t);
errorpage(i, t, "/viewExpired?faces-redirect=true");
} else if (t instanceof NonexistentConversationException) {
logger.debug("Server restart? Got nonexistent converstation", t);
errorpage(i, t, "/viewExpired?faces-redirect=true");
} else if (t instanceof EJBAccessException || t instanceof AccessLocalException) {
logger.debug("Found Permission Denied cause: {}, {}", t.getClass(), t.getMessage());
// We should handler permission checking elsewhere. Lets just pass the error through
//errorpage(i, t, "/permissionDenied?faces-redirect=true");
} else {
return false;
}
return true;
}
private void errorpage(Iterator<ExceptionQueuedEvent> iter, Throwable t, String navigateTo) {
logger.info("navigating to {} because root exception: {}", navigateTo, t.getClass()); logger.info("navigating to {} because root exception: {}", navigateTo, t.getClass());
ViewExpiredException vee = null; ViewExpiredException vee = null;
if (t instanceof ViewExpiredException) { if (t instanceof ViewExpiredException) {
...@@ -106,7 +117,9 @@ public class BortalExceptionHandler extends ExceptionHandlerWrapper { ...@@ -106,7 +117,9 @@ public class BortalExceptionHandler extends ExceptionHandlerWrapper {
nav.handleNavigation(fc, null, navigateTo); nav.handleNavigation(fc, null, navigateTo);
fc.renderResponse(); fc.renderResponse();
} finally { } finally {
i.remove(); if(iter != null) {
iter.remove();
}
} }
} }
} }
...@@ -45,6 +45,10 @@ public class SessionStore implements Serializable { ...@@ -45,6 +45,10 @@ public class SessionStore implements Serializable {
private static final Logger logger = LoggerFactory.getLogger(SessionStore.class); private static final Logger logger = LoggerFactory.getLogger(SessionStore.class);
public String getLanguage() {
return getLocale().getLanguage();
}
public Locale getLocale() { public Locale getLocale() {
Locale ret = locale; Locale ret = locale;
if (ret == null || ret.toString().equals("")) if (ret == null || ret.toString().equals(""))
......
...@@ -38,15 +38,13 @@ import fi.codecrew.moya.model.AccountEvent; ...@@ -38,15 +38,13 @@ import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.rest.highcharts.HcSeries; import fi.codecrew.moya.rest.highcharts.HcSeries;
import fi.codecrew.moya.rest.highcharts.HcSeriesRoot; import fi.codecrew.moya.rest.highcharts.HcSeriesRoot;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.annotations.ApiResponse;
@RequestScoped @RequestScoped
@Path("/acc") @Path("/acc")
//@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) //@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
//@Produces({ MediaType.APPLICATION_JSON }) //@Produces({ MediaType.APPLICATION_JSON })
@Api(value = "/acc", description = "Access account events")
public class AccountEventRestView { public class AccountEventRestView {
@EJB @EJB
...@@ -57,8 +55,7 @@ public class AccountEventRestView { ...@@ -57,8 +55,7 @@ public class AccountEventRestView {
@GET @GET
@Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" }) @Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" })
@Path("/boughtTimecount/{productId}") @Path("/boughtTimecount/{productId}")
@ApiOperation("Ask how many times a product has been bought") @Operation(description="Ask how many times a product has been bought")
@ApiResponse(code = 200, message = "What is this this returned?")
public ArrayList<HcSeriesRoot> boughtTimecount(@PathParam("productId") Integer productId) { public ArrayList<HcSeriesRoot> boughtTimecount(@PathParam("productId") Integer productId) {
Product product = productBean.findById(productId); Product product = productBean.findById(productId);
......
...@@ -35,13 +35,16 @@ import javax.ws.rs.core.Response; ...@@ -35,13 +35,16 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.Response.Status;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.EventMapBeanLocal; import fi.codecrew.moya.beans.EventMapBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal; import fi.codecrew.moya.beans.PlaceBeanLocal;
...@@ -61,7 +64,8 @@ import fi.codecrew.moya.rest.pojo.map.v1.PlaceRoot; ...@@ -61,7 +64,8 @@ import fi.codecrew.moya.rest.pojo.map.v1.PlaceRoot;
@Path("/placeadmin") @Path("/placeadmin")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
@Api(value = "/placeadmin", description = "Administer places") @OpenAPIDefinition( tags = {@Tag(name="Maps", description = "Maps"), @Tag(name="Places",description = "Places")},
info = @Info(title = "Administer places"))
public class MapAdminView { public class MapAdminView {
@EJB @EJB
...@@ -81,7 +85,7 @@ public class MapAdminView { ...@@ -81,7 +85,7 @@ public class MapAdminView {
@GET @GET
@Path("/background/{mapId}") @Path("/background/{mapId}")
@ApiResponse(code = 200, message = "Return backround map as JPEG") @Operation(description = "Return backround map as JPEG")
public Response getMapBg(@PathParam("mapId") Integer mapid) { public Response getMapBg(@PathParam("mapId") Integer mapid) {
try { try {
EventMap map = placebean.findMap(mapid); EventMap map = placebean.findMap(mapid);
...@@ -95,8 +99,7 @@ public class MapAdminView { ...@@ -95,8 +99,7 @@ public class MapAdminView {
@GET @GET
@Path("/maps") @Path("/maps")
@ApiOperation(value = "Get All maps", response = MapRoot.class) @Operation(description = "Get All maps", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = MapRoot.class))) })
@ApiResponse(code = 200, message = "Return all maps")
public MapRoot getAllMaps() { public MapRoot getAllMaps() {
try { try {
MapRoot ret = PojoUtils.parseMaps(eventbean.getCurrentEvent().getEventMaps()); MapRoot ret = PojoUtils.parseMaps(eventbean.getCurrentEvent().getEventMaps());
...@@ -110,7 +113,7 @@ public class MapAdminView { ...@@ -110,7 +113,7 @@ public class MapAdminView {
@GET @GET
@Path("/places/{mapId}") @Path("/places/{mapId}")
@ApiOperation(value = "Get places by mapId", response = PlaceRoot.class) @Operation(description = "Get places by mapId", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PlaceRoot.class))) })
public PlaceRoot getPlaces(@PathParam("mapId") Integer mapid) { public PlaceRoot getPlaces(@PathParam("mapId") Integer mapid) {
try { try {
EventMap map = placebean.findMap(mapid); EventMap map = placebean.findMap(mapid);
...@@ -125,7 +128,6 @@ public class MapAdminView { ...@@ -125,7 +128,6 @@ public class MapAdminView {
@DELETE @DELETE
@Path("/place/{id}") @Path("/place/{id}")
@ApiOperation("Delete a place")
public Response deletePlace(@PathParam("id") Integer id) { public Response deletePlace(@PathParam("id") Integer id) {
try { try {
Place place = eventmapbean.findPlace(id); Place place = eventmapbean.findPlace(id);
...@@ -142,8 +144,7 @@ public class MapAdminView { ...@@ -142,8 +144,7 @@ public class MapAdminView {
@GET @GET
@Path("/place/") @Path("/place/")
@ApiOperation(value = "Always returns 406 - Not acceptable") @Operation(description = "Always returns 406 - Not acceptable")
@ApiResponse(code = 406, message = "Nope. Not acceptable.")
public Response getPlaceError() { public Response getPlaceError() {
try { try {
ResponseBuilder ret = Response.ok(); ResponseBuilder ret = Response.ok();
...@@ -158,7 +159,7 @@ public class MapAdminView { ...@@ -158,7 +159,7 @@ public class MapAdminView {
@POST @POST
@Path("/place/") @Path("/place/")
@ApiOperation(value = "Create a place", response = PlacePojo.class) @Operation(description = "Create a place", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PlacePojo.class))) })
public Response createPlace(PlacePojo create) { public Response createPlace(PlacePojo create) {
try { try {
logger.info("Finding map with id {}", create.getMapId()); logger.info("Finding map with id {}", create.getMapId());
...@@ -183,7 +184,7 @@ public class MapAdminView { ...@@ -183,7 +184,7 @@ public class MapAdminView {
@PUT @PUT
@Path("/place/{id}") @Path("/place/{id}")
@ApiOperation(value = "Set a place", response = PlacePojo.class) @Operation(description = "Set a place", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PlacePojo.class))) })
public Response updatePlace(@PathParam("id") Integer id, PlacePojo update) { public Response updatePlace(@PathParam("id") Integer id, PlacePojo update) {
try { try {
if (update == null || id == null) { if (update == null || id == null) {
...@@ -207,7 +208,7 @@ public class MapAdminView { ...@@ -207,7 +208,7 @@ public class MapAdminView {
@PUT @PUT
@Path("/place/{placeId}/release") @Path("/place/{placeId}/release")
@ApiOperation("Release a class") @Operation(description = "release a class")
public Response releasePlace(@PathParam("placeId") Integer placeId) { public Response releasePlace(@PathParam("placeId") Integer placeId) {
try { try {
Place place = eventmapbean.findPlace(placeId); Place place = eventmapbean.findPlace(placeId);
...@@ -226,7 +227,7 @@ public class MapAdminView { ...@@ -226,7 +227,7 @@ public class MapAdminView {
@PUT @PUT
@Path("/place/{placeId}/reserve/{eventuserId}") @Path("/place/{placeId}/reserve/{eventuserId}")
@ApiOperation("Reserve a place") @Operation(description = "Reserve a place")
public Response reserve(@PathParam("placeId") Integer placeId, @PathParam("eventuserId") Integer eventuserId) { public Response reserve(@PathParam("placeId") Integer placeId, @PathParam("eventuserId") Integer eventuserId) {
try { try {
Place place = eventmapbean.findPlace(placeId); Place place = eventmapbean.findPlace(placeId);
......
...@@ -18,48 +18,52 @@ ...@@ -18,48 +18,52 @@
*/ */
package fi.codecrew.moya.rest; package fi.codecrew.moya.rest;
import javax.ws.rs.ApplicationPath; import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;
import io.swagger.v3.oas.integration.SwaggerConfiguration;
import io.swagger.jaxrs.listing.ApiListingResource; import io.swagger.v3.oas.models.OpenAPI;
import org.glassfish.jersey.filter.LoggingFilter; import io.swagger.v3.oas.models.servers.Server;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletConfig;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Context;
import java.util.Arrays;
import io.swagger.jaxrs.config.BeanConfig;
@ApplicationPath(RestApplicationEntrypoint.REST_PATH) @ApplicationPath(RestApplicationEntrypoint.REST_PATH)
public class RestApplicationEntrypoint extends ResourceConfig { public class RestApplicationEntrypoint extends ResourceConfig {
private static final Logger logger = LoggerFactory.getLogger(RestApplicationEntrypoint.class);
public static final String REST_PATH = "/rest"; public static final String REST_PATH = "/rest";
private static final String BASE_URL = "/MoyaWeb"; private static final String BASE_URL = "/MoyaWeb";
private static final String API_RESOURCE_PACKAGE = "fi.codecrew.moya.rest"; private static final String API_RESOURCE_PACKAGE = "fi.codecrew.moya.rest";
public RestApplicationEntrypoint() { public RestApplicationEntrypoint() {
super();
Server srv = new Server();
srv.setUrl("/MoyaWeb/");
// swagger OpenAPI oas = new OpenAPI();
BeanConfig beanConfig = new BeanConfig(); oas.setServers(Arrays.asList(srv));
beanConfig.setVersion("1.0.0");
beanConfig.setBasePath(BASE_URL + REST_PATH);
beanConfig.setResourcePackage(API_RESOURCE_PACKAGE);
beanConfig.setScan(true);
register(beanConfig);
//ReflectiveJaxrsScanner scanner = new ReflectiveJaxrsScanner(); SwaggerConfiguration swagCfg = new SwaggerConfiguration();
//scanner.setResourcePackage(API_RESOURCE_PACKAGE); swagCfg.setPrettyPrint(true);
//ScannerFactory.setScanner(scanner); swagCfg.setOpenAPI(oas);
//ClassReaders.setReader(new JerseyApiReader());
//ClassReaders.setReader(new DefaultJaxrsApiReader());
// register(ApiListingResource.class); OpenApiResource openApiResource = new OpenApiResource();
//register(JerseyApiDeclarationProvider.class); openApiResource.setOpenApiConfiguration(swagCfg);
//register(JerseyResourceListingProvider.class); register(openApiResource);
// mime multipart image uploads // mime multipart image uploads
register(MultiPartFeature.class); register(MultiPartFeature.class);
// packages to scan // packages to scan
packages("io.swagger.jaxrs.json", "fi.codecrew.moya.rest"); packages("fi.codecrew.moya.rest");
registerInstances(new LoggingFilter());
registerInstances(new LoggingFeature());
} }
} }
...@@ -44,13 +44,17 @@ import javax.ws.rs.core.Response.ResponseBuilder; ...@@ -44,13 +44,17 @@ import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.Response.Status;
import fi.codecrew.moya.model.*; import fi.codecrew.moya.model.*;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import fi.codecrew.moya.beans.CardTemplateBeanLocal; import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal; import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal; import fi.codecrew.moya.beans.PlaceBeanLocal;
...@@ -72,7 +76,9 @@ import fi.codecrew.moya.utilities.SearchResult; ...@@ -72,7 +76,9 @@ import fi.codecrew.moya.utilities.SearchResult;
@Path("/user") @Path("/user")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"}) @Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"})
@Api(value = "/user", description = "Administer users") @OpenAPIDefinition(
tags = @Tag(name = "Users", description="User management"),
info = @Info(title = "Administer users"))
public class UserRestView { public class UserRestView {
@EJB @EJB
...@@ -103,7 +109,7 @@ public class UserRestView { ...@@ -103,7 +109,7 @@ public class UserRestView {
@POST @POST
@Path("/giveplace/{placeId}") @Path("/giveplace/{placeId}")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@ApiOperation(value = "Set place status to give/ungive", response = UserReservationPlacePojo.class) @Operation(description = "Set place status to give/ungive", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = UserReservationPlacePojo.class))) })
public Response setPlacesGivenStatus( public Response setPlacesGivenStatus(
@PathParam("placeId") Integer id, @PathParam("placeId") Integer id,
@FormParam("action") String status) { @FormParam("action") String status) {
...@@ -145,7 +151,7 @@ public class UserRestView { ...@@ -145,7 +151,7 @@ public class UserRestView {
@GET @GET
@Path("/reservationswithcode/{code}") @Path("/reservationswithcode/{code}")
@ApiOperation(value = "Get places with code", response = UserReservationRoot.class) @Operation(description = "Get places with code", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = UserReservationRoot.class))) })
public Response getPlacesWithCode(@PathParam("code") String code) { public Response getPlacesWithCode(@PathParam("code") String code) {
try { try {
...@@ -177,7 +183,7 @@ public class UserRestView { ...@@ -177,7 +183,7 @@ public class UserRestView {
@GET @GET
@Path("/{userid}/reservations") @Path("/{userid}/reservations")
@ApiOperation(value = "Get user's reservations", response = UserReservationRoot.class) @Operation(description = "Get user's reservations", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = UserReservationRoot.class))) })
public Response usersPlaces(@PathParam("userid") Integer userid) { public Response usersPlaces(@PathParam("userid") Integer userid) {
EventUser eu = userbean.findByUserId(userid, false); EventUser eu = userbean.findByUserId(userid, false);
if (eu != null) { if (eu != null) {
...@@ -198,7 +204,7 @@ public class UserRestView { ...@@ -198,7 +204,7 @@ public class UserRestView {
@Path("/auth") @Path("/auth")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@ApiOperation(value = "Authenticate", response = EventUserRestPojo.class) @Operation(description = "Authenticate", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = EventUserRestPojo.class))) })
public Response auth( public Response auth(
@FormParam("username") String username, @FormParam("username") String username,
@FormParam("password") String password) { @FormParam("password") String password) {
...@@ -237,7 +243,7 @@ public class UserRestView { ...@@ -237,7 +243,7 @@ public class UserRestView {
@GET @GET
@Path("/eventusers") @Path("/eventusers")
@ApiOperation(value = "Get EventUsers", response = SimpleEventuserRoot.class) @Operation(description = "Get EventUsers", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SimpleEventuserRoot.class))) })
public SimpleEventuserRoot getEventUsers( public SimpleEventuserRoot getEventUsers(
@DefaultValue("0") @QueryParam("pagesize") Integer pagesize, @DefaultValue("0") @QueryParam("pagesize") Integer pagesize,
@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("0") @QueryParam("page") Integer page,
...@@ -258,9 +264,9 @@ public class UserRestView { ...@@ -258,9 +264,9 @@ public class UserRestView {
@GET @GET
@Path("/card/{eventuserId}") @Path("/card/{eventuserId}")
@ApiOperation(value = "Get PrintedCard for EventUser", response = PrintedCardRestPojo.class) @Operation(description = "Get PrintedCard for EventUser", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PrintedCardRestPojo.class))) })
public PrintedCardRestPojo getUsersCard( public PrintedCardRestPojo getUsersCard(
@ApiParam("EventUser entity ID") @PathParam("eventuserId") Integer eventuserid) { @Parameter(description = "EventUser entity ID") @PathParam("eventuserId") Integer eventuserid) {
EventUser user = userbean.findByEventUserId(eventuserid); EventUser user = userbean.findByEventUserId(eventuserid);
logger.warn("users card for user: {}", user); logger.warn("users card for user: {}", user);
PrintedCard card = cardbean.checkPrintedCard(user); PrintedCard card = cardbean.checkPrintedCard(user);
...@@ -274,9 +280,9 @@ public class UserRestView { ...@@ -274,9 +280,9 @@ public class UserRestView {
@GET @GET
@Path("/eventuser/{cardauthcode}") @Path("/eventuser/{cardauthcode}")
@ApiOperation(value = "Get EventUser by cardAuthCode", response = EventUserRestPojo.class) @Operation(description = "Get EventUser by cardAuthCode", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = EventUserRestPojo.class))) })
public EventUserRestPojo getEventUser( public EventUserRestPojo getEventUser(
@ApiParam("Card authentication code") @PathParam("cardauthcode") String code) { @Parameter(description ="Card authentication code") @PathParam("cardauthcode") String code) {
EventUser user = userbean.getUserByAuthcode(code); EventUser user = userbean.getUserByAuthcode(code);
if (user != null) if (user != null)
...@@ -288,9 +294,13 @@ public class UserRestView { ...@@ -288,9 +294,13 @@ public class UserRestView {
@GET @GET
@Path("/") @Path("/")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
@ApiOperation(value = "Find event user", response = EventUserRestPojo.class) @Operation(
public Response getEventUser(@QueryParam("email") @ApiParam("Email address") String email, description = "Find event user",
@QueryParam("login") @ApiParam("Username") String userName) { responses = {
@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = EventUserRestPojo.class)))
})
public Response getEventUser(@QueryParam("email") @Parameter(description = "Email address") String email,
@QueryParam("login") @Parameter(description = "Username") String userName) {
try { try {
if (permbean.hasPermission(UserPermission.VIEW_ALL) == false) { if (permbean.hasPermission(UserPermission.VIEW_ALL) == false) {
return Response.status(Status.FORBIDDEN).build(); return Response.status(Status.FORBIDDEN).build();
...@@ -327,10 +337,10 @@ public class UserRestView { ...@@ -327,10 +337,10 @@ public class UserRestView {
@POST @POST
@Path("/{userid}/check-password") @Path("/{userid}/check-password")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
@ApiOperation(value = "Check user password", response = EventUserRestPojo.class) @Operation(description = "Check user password", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = EventUserRestPojo.class))) })
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response checkPassword(@PathParam("userid") @ApiParam("User ID") Integer userId, public Response checkPassword(@PathParam("userid") @Parameter(description = "User ID") Integer userId,
@FormParam("password") @ApiParam("Password") String password) { @FormParam("password") @Parameter(description = "Password") String password) {
try { try {
if (permbean.hasPermission(UserPermission.VIEW_ALL) == false) { if (permbean.hasPermission(UserPermission.VIEW_ALL) == false) {
return Response.status(Status.FORBIDDEN).build(); return Response.status(Status.FORBIDDEN).build();
...@@ -358,10 +368,10 @@ public class UserRestView { ...@@ -358,10 +368,10 @@ public class UserRestView {
@POST @POST
@Path("/{userid}/reset-password") @Path("/{userid}/reset-password")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
@ApiOperation(value = "Reset user password", response = EventUserRestPojo.class) @Operation(description = "Reset user password", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = EventUserRestPojo.class))) })
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response resetPassword(@PathParam("userid") @ApiParam("User ID") Integer userId, public Response resetPassword(@PathParam("userid") @Parameter(description = "User ID") Integer userId,
@FormParam("password") @ApiParam("New password") String password) { @FormParam("password") @Parameter(description = "New password") String password) {
try { try {
if (permbean.hasPermission(UserPermission.MODIFY) == false || permbean.hasPermission(UserPermission.VIEW_ALL)) { if (permbean.hasPermission(UserPermission.MODIFY) == false || permbean.hasPermission(UserPermission.VIEW_ALL)) {
return Response.status(Status.FORBIDDEN).build(); return Response.status(Status.FORBIDDEN).build();
...@@ -386,10 +396,10 @@ public class UserRestView { ...@@ -386,10 +396,10 @@ public class UserRestView {
*/ */
@PUT @PUT
@Path("/{userid}/image") @Path("/{userid}/image")
@ApiOperation(value = "Upload image", response = EventUserRestPojo.class) @Operation(description = "Upload image", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = EventUserRestPojo.class))) })
@Consumes(MediaType.MULTIPART_FORM_DATA) @Consumes(MediaType.MULTIPART_FORM_DATA)
public Response updateUserImage(@Context HttpServletRequest request, public Response updateUserImage(@Context HttpServletRequest request,
@PathParam("userid") @ApiParam("User ID") Integer userId) throws IOException { @PathParam("userid") @Parameter(description = "User ID") Integer userId) throws IOException {
try { try {
if (permbean.hasPermission(UserPermission.MODIFY) == false || permbean.hasPermission(UserPermission.VIEW_ALL)) { if (permbean.hasPermission(UserPermission.MODIFY) == false || permbean.hasPermission(UserPermission.VIEW_ALL)) {
return Response.status(Status.FORBIDDEN).build(); return Response.status(Status.FORBIDDEN).build();
......
package fi.codecrew.moya.rest.apiapp.v1; package fi.codecrew.moya.rest.apiapp.v1;
import java.nio.charset.Charset; import fi.codecrew.moya.beans.ApiApplicationBeanLocal;
import java.security.Principal; import fi.codecrew.moya.model.ApiApplication;
import java.util.Base64; import fi.codecrew.moya.model.ApiApplicationInstance;
import fi.codecrew.moya.rest.pojo.userinfo.v1.ApiApplicationInstancePojo;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
...@@ -12,22 +17,15 @@ import javax.ws.rs.*; ...@@ -12,22 +17,15 @@ import javax.ws.rs.*;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.security.Principal;
import org.slf4j.Logger; import java.util.Base64;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.ApiApplicationBeanLocal;
import fi.codecrew.moya.model.ApiApplication;
import fi.codecrew.moya.model.ApiApplicationInstance;
import fi.codecrew.moya.rest.pojo.userinfo.v1.ApiApplicationInstancePojo;
import fi.codecrew.moya.rest.pojo.userinfo.v1.UserPwdPojo;
import io.swagger.annotations.Api;
@RequestScoped @RequestScoped
@Path("/apiapp/v1") @Path("/apiapp/v1")
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"}) @Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"})
@Api(value = "/apiapp/v1/", description = "Manage api application and keys") @OpenAPIDefinition(
info = @Info(title = "Manage api application and keys"))
public class ApiAppRestViewV1 { public class ApiAppRestViewV1 {
private static final Logger logger = LoggerFactory.getLogger(ApiAppRestViewV1.class); private static final Logger logger = LoggerFactory.getLogger(ApiAppRestViewV1.class);
......
package fi.codecrew.moya.rest.appconfig.v1; package fi.codecrew.moya.rest.appconfig.v1;
import java.security.Principal; import fi.codecrew.moya.beans.EventBeanLocal;
import java.util.Base64; import fi.codecrew.moya.beans.PermissionBeanLocal;
import java.util.Date; import fi.codecrew.moya.rest.PojoUtils;
import fi.codecrew.moya.rest.pojo.appconfig.v1.EventRoot;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*; import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.security.Principal;
import jdk.nashorn.internal.objects.annotations.Getter; import java.util.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.rest.PojoUtils;
import fi.codecrew.moya.rest.apiapp.v1.ApiAppRestViewV1;
import fi.codecrew.moya.rest.pojo.appconfig.v1.EventRoot;
import fi.codecrew.moya.rest.pojo.userinfo.v1.UserPwdPojo;
/** /**
* Created by tuukka on 28.3.2015. * Created by tuukka on 28.3.2015.
...@@ -36,7 +35,8 @@ import fi.codecrew.moya.rest.pojo.userinfo.v1.UserPwdPojo; ...@@ -36,7 +35,8 @@ import fi.codecrew.moya.rest.pojo.userinfo.v1.UserPwdPojo;
@Path("/appconfig/v1/eventinfo") @Path("/appconfig/v1/eventinfo")
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"}) @Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"})
@Api(value = "/appconfig/v1/eventinfo", description = "Event information for application") @OpenAPIDefinition(
info = @Info(title = "Event information for application"))
public class EventInfoV1 { public class EventInfoV1 {
private static final Logger logger = LoggerFactory.getLogger(EventInfoV1.class); private static final Logger logger = LoggerFactory.getLogger(EventInfoV1.class);
...@@ -90,8 +90,7 @@ public class EventInfoV1 { ...@@ -90,8 +90,7 @@ public class EventInfoV1 {
@GET @GET
@Path("/listevents/") @Path("/listevents/")
@ApiOperation(value = "Get all events for current user", response = EventRoot.class) @Operation(description = "Get all events for current user", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = EventRoot.class))) })
@ApiResponse(code = 200, message = "Return events for current user")
public Response getEventsForCurrentUser() { public Response getEventsForCurrentUser() {
if (permissionBean.getCurrentUser().isAnonymous()) { if (permissionBean.getCurrentUser().isAnonymous()) {
......
...@@ -32,19 +32,18 @@ import javax.ws.rs.Produces; ...@@ -32,19 +32,18 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.PathSegment; import javax.ws.rs.core.PathSegment;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.info.Info;
@RequestScoped @RequestScoped
@Path("/meta/v1/eventuser") @Path("/meta/v1/eventuser")
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" }) @Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" })
@Api(value="/meta/v1/eventuser", description = "Access EventUser meta data") @OpenAPIDefinition(info = @Info(description = "Access EventUser meta data"))
public class EventUserRestViewV1 extends AbstractRestViewV1 { public class EventUserRestViewV1 extends AbstractRestViewV1 {
@EJB @EJB
...@@ -52,10 +51,10 @@ public class EventUserRestViewV1 extends AbstractRestViewV1 { ...@@ -52,10 +51,10 @@ public class EventUserRestViewV1 extends AbstractRestViewV1 {
@GET @GET
@Path("/{id}/{path:.*}") @Path("/{id}/{path:.*}")
@ApiOperation(value = "Get metadata for EventUser by id") @Operation(description = "Get metadata for EventUser by id")
public String getMeta( public String getMeta(
@ApiParam("EventUser entity ID") @PathParam("id") Integer id, @Parameter(description = "EventUser entity ID") @PathParam("id") Integer id,
@ApiParam("Path in JSON metadata object") @PathParam("path") List<PathSegment> path) { @Parameter(description = "Path in JSON metadata object") @PathParam("path") List<PathSegment> path) {
EventUser eventUser = userBean.findByEventUserId(id); EventUser eventUser = userBean.findByEventUserId(id);
return getEntityMeta(eventUser, path); return getEntityMeta(eventUser, path);
...@@ -63,12 +62,11 @@ public class EventUserRestViewV1 extends AbstractRestViewV1 { ...@@ -63,12 +62,11 @@ public class EventUserRestViewV1 extends AbstractRestViewV1 {
@PUT @PUT
@Path("/{id}/{path:.*}") @Path("/{id}/{path:.*}")
@ApiOperation(value="Set EventUser metada path", notes ="foo") @Operation(description="Set EventUser metada path")
@ApiResponse(code = 200, message = "OK")
public void putMeta( public void putMeta(
@ApiParam("EventUser entity ID") @PathParam("id") Integer id, @Parameter(description = "EventUser entity ID") @PathParam("id") Integer id,
@ApiParam("Path in metadata JSON object") @PathParam("path") List<PathSegment> path, @Parameter(description = "Path in metadata JSON object") @PathParam("path") List<PathSegment> path,
@ApiParam("JSON to store") String jsonString) { @Parameter(description = "JSON to store") String jsonString) {
EventUser eventUser = userBean.findByEventUserId(id); EventUser eventUser = userBean.findByEventUserId(id);
setEntityMeta(eventUser, path, jsonString); setEntityMeta(eventUser, path, jsonString);
...@@ -77,7 +75,7 @@ public class EventUserRestViewV1 extends AbstractRestViewV1 { ...@@ -77,7 +75,7 @@ public class EventUserRestViewV1 extends AbstractRestViewV1 {
@POST @POST
@Path("/{id}/{path:.*}") @Path("/{id}/{path:.*}")
@ApiOperation("Set EventUser metadata path with POST") @Operation(description = "Set EventUser metadata path with POST")
public void postMeta( public void postMeta(
@PathParam("id") Integer id, @PathParam("id") Integer id,
@PathParam("path") List<PathSegment> path, String jsonString) { @PathParam("path") List<PathSegment> path, String jsonString) {
......
...@@ -32,19 +32,19 @@ import javax.ws.rs.Produces; ...@@ -32,19 +32,19 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.PathSegment; import javax.ws.rs.core.PathSegment;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import fi.codecrew.moya.beans.CardTemplateBeanLocal; import fi.codecrew.moya.beans.CardTemplateBeanLocal;
import fi.codecrew.moya.model.PrintedCard; import fi.codecrew.moya.model.PrintedCard;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.info.Info;
@RequestScoped @RequestScoped
@Path("/meta/v1/printedcard") @Path("/meta/v1/printedcard")
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" }) @Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" })
@Api(value = "/meta/v1/printedcard", description = "PrintedCard metadata access") @OpenAPIDefinition(
info = @Info(title = "PrintedCard metadata access"))
public class PrintedCardRestViewV1 extends AbstractRestViewV1 { public class PrintedCardRestViewV1 extends AbstractRestViewV1 {
@EJB @EJB
...@@ -52,10 +52,10 @@ public class PrintedCardRestViewV1 extends AbstractRestViewV1 { ...@@ -52,10 +52,10 @@ public class PrintedCardRestViewV1 extends AbstractRestViewV1 {
@GET @GET
@Path("/{id}/{path:.*}") @Path("/{id}/{path:.*}")
@ApiOperation("Return PrintedCard metadata") @Operation(description = "Return PrintedCard metadata")
public String getMeta( public String getMeta(
@ApiParam("PrintedCard entity ID") @PathParam("id") Integer id, @Parameter(description = "PrintedCard entity ID") @PathParam("id") Integer id,
@ApiParam(value="Path in metadata JSON object") @PathParam("path") List<PathSegment> path) { @Parameter(description = "Path in metadata JSON object") @PathParam("path") List<PathSegment> path) {
PrintedCard printedCard = cardTemplateBeanLocal.findCard(id); PrintedCard printedCard = cardTemplateBeanLocal.findCard(id);
return getEntityMeta(printedCard, path); return getEntityMeta(printedCard, path);
...@@ -63,12 +63,11 @@ public class PrintedCardRestViewV1 extends AbstractRestViewV1 { ...@@ -63,12 +63,11 @@ public class PrintedCardRestViewV1 extends AbstractRestViewV1 {
@PUT @PUT
@Path("/{id}/{path:.*}") @Path("/{id}/{path:.*}")
@ApiOperation("Set PrintedCard metadata path") @Operation(description = "Set PrintedCard metadata path")
@ApiResponse(code = 200, message = "OK")
public void putMeta( public void putMeta(
@ApiParam("PrintedCard entity ID") @PathParam("id") Integer id, @Parameter(description = "PrintedCard entity ID") @PathParam("id") Integer id,
@ApiParam("Path in metadata JSON object") @PathParam("path") List<PathSegment> path, @Parameter(description = "Path in metadata JSON object") @PathParam("path") List<PathSegment> path,
@ApiParam("JSON object to store in metadata") String jsonString) { @Parameter(description = "JSON object to store in metadata") String jsonString) {
PrintedCard printedCard = cardTemplateBeanLocal.findCard(id); PrintedCard printedCard = cardTemplateBeanLocal.findCard(id);
setEntityMeta(printedCard, path, jsonString); setEntityMeta(printedCard, path, jsonString);
...@@ -77,7 +76,7 @@ public class PrintedCardRestViewV1 extends AbstractRestViewV1 { ...@@ -77,7 +76,7 @@ public class PrintedCardRestViewV1 extends AbstractRestViewV1 {
@POST @POST
@Path("/{id}/{path:.*}") @Path("/{id}/{path:.*}")
@ApiOperation("Set PrintedCard metadata path. Please use PUT.") @Operation(description = "Set PrintedCard metadata path. Please use PUT.")
public void postMeta(@PathParam("id") Integer id, public void postMeta(@PathParam("id") Integer id,
@PathParam("path") List<PathSegment> path, String jsonString) { @PathParam("path") List<PathSegment> path, String jsonString) {
......
...@@ -32,15 +32,18 @@ import javax.ws.rs.core.PathSegment; ...@@ -32,15 +32,18 @@ import javax.ws.rs.core.PathSegment;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.model.User; import fi.codecrew.moya.model.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.annotations.ApiParam; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.info.Info;
@RequestScoped @RequestScoped
@Path("/meta/v1/user") @Path("/meta/v1/user")
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" }) @Produces({ MediaType.APPLICATION_JSON + "; charset=UTF-8" })
@Api(value = "/meta/v1/user", description = "Access User metadata") @OpenAPIDefinition(
info = @Info(title = "Access User metadata"))
public class UserRestViewV1 extends AbstractRestViewV1 { public class UserRestViewV1 extends AbstractRestViewV1 {
@EJB @EJB
...@@ -48,10 +51,10 @@ public class UserRestViewV1 extends AbstractRestViewV1 { ...@@ -48,10 +51,10 @@ public class UserRestViewV1 extends AbstractRestViewV1 {
@GET @GET
@Path("/{id}/{path:.*}") @Path("/{id}/{path:.*}")
@ApiOperation("Get metadata for user") @Operation(description="Get metadata for user")
public String getMeta( public String getMeta(
@ApiParam("User entity ID") @PathParam("id") Integer id, @Parameter(description = "User entity ID") @PathParam("id") Integer id,
@ApiParam("Path in metadata JSON object") @PathParam("path") List<PathSegment> path) { @Parameter(description = "Path in metadata JSON object") @PathParam("path") List<PathSegment> path) {
User user = userBean.getUser(id); User user = userBean.getUser(id);
return getEntityMeta(user, path); return getEntityMeta(user, path);
......
...@@ -4,11 +4,11 @@ import javax.xml.bind.annotation.XmlRootElement; ...@@ -4,11 +4,11 @@ import javax.xml.bind.annotation.XmlRootElement;
import fi.codecrew.moya.model.Place; import fi.codecrew.moya.model.Place;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModel;
@XmlRootElement() @XmlRootElement()
@ApiModel(description = "PlaceCode")
public class PlaceCodePojo { public class PlaceCodePojo {
public PlaceCodePojo() { public PlaceCodePojo() {
......
package fi.codecrew.moya.rest.v2; package fi.codecrew.moya.rest.v2;
import java.util.List; import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.rest.v2.pojo.ProductPojo;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
...@@ -9,15 +12,12 @@ import javax.ws.rs.Path; ...@@ -9,15 +12,12 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List;
import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.rest.v2.pojo.ProductPojo;
import io.swagger.annotations.Api;
@RequestScoped @RequestScoped
@Path("/v2/product") @Path("/v2/product")
@Api(value = "/v2/product", description = "Product operations") @OpenAPIDefinition(
info = @Info(title = "Product operations"))
public class ProductRestView { public class ProductRestView {
@EJB @EJB
......
...@@ -6,12 +6,15 @@ import fi.codecrew.moya.enums.apps.UserPermission; ...@@ -6,12 +6,15 @@ import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.model.*; import fi.codecrew.moya.model.*;
import fi.codecrew.moya.rest.PojoUtils; import fi.codecrew.moya.rest.PojoUtils;
import fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo; import fi.codecrew.moya.rest.pojo.userinfo.v1.EventUserRestPojo;
import fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3;
import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardUpdateCodePojo; import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardUpdateCodePojo;
import fi.codecrew.moya.rest.v2.pojo.UserPojo; import fi.codecrew.moya.rest.v2.pojo.UserPojo;
import io.swagger.annotations.Api; import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.annotations.ApiParam; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam; import org.glassfish.jersey.media.multipart.FormDataParam;
...@@ -31,7 +34,8 @@ import java.io.InputStream; ...@@ -31,7 +34,8 @@ import java.io.InputStream;
@RequestScoped @RequestScoped
@Path("/v2/user") @Path("/v2/user")
@Api(value = "/v2/user", description = "User operations") @OpenAPIDefinition(
info = @Info(title = "User operations"))
public class UserRestViewV2 { public class UserRestViewV2 {
private static final Logger logger = LoggerFactory.getLogger(UserRestViewV2.class); private static final Logger logger = LoggerFactory.getLogger(UserRestViewV2.class);
...@@ -54,9 +58,9 @@ public class UserRestViewV2 { ...@@ -54,9 +58,9 @@ public class UserRestViewV2 {
@GET @GET
@Path("/get") @Path("/get")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Find user", response = UserPojo.class) @Operation(description = "Find user", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = UserPojo.class))) })
public Response getEventUser(@QueryParam("email") @ApiParam("Email address") String email, public Response getEventUser(@QueryParam("email") @Parameter(description = "Email address") String email,
@QueryParam("login") @ApiParam("Username") String userName) { @QueryParam("login") @Parameter(description = "Username") String userName) {
try { try {
if (permissionBean.hasPermission(UserPermission.VIEW_ALL) == false) { if (permissionBean.hasPermission(UserPermission.VIEW_ALL) == false) {
return Response.status(Response.Status.FORBIDDEN).build(); return Response.status(Response.Status.FORBIDDEN).build();
...@@ -85,8 +89,8 @@ public class UserRestViewV2 { ...@@ -85,8 +89,8 @@ public class UserRestViewV2 {
@GET @GET
@Path("/{userid}") @Path("/{userid}")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get user", response = UserPojo.class) @Operation(description = "Get user", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = UserPojo.class))) })
public Response getEventUser(@PathParam("userid") @ApiParam("User ID") Integer userId) { public Response getEventUser(@PathParam("userid") @Parameter(description = "User ID") Integer userId) {
try { try {
if (permissionBean.hasPermission(UserPermission.VIEW_ALL) == false) { if (permissionBean.hasPermission(UserPermission.VIEW_ALL) == false) {
return Response.status(Response.Status.FORBIDDEN).build(); return Response.status(Response.Status.FORBIDDEN).build();
...@@ -111,7 +115,7 @@ public class UserRestViewV2 { ...@@ -111,7 +115,7 @@ public class UserRestViewV2 {
@GET @GET
@Path("/current") @Path("/current")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Fetch current user", response = EventUserRestPojo.class) @Operation(description = "Fetch current user", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = EventUserRestPojo.class))) })
public Response getCurrentUser() { public Response getCurrentUser() {
EventUser usr = permissionBean.getCurrentUser(); EventUser usr = permissionBean.getCurrentUser();
logger.info("Got current user {} ", usr); logger.info("Got current user {} ", usr);
...@@ -126,7 +130,7 @@ public class UserRestViewV2 { ...@@ -126,7 +130,7 @@ public class UserRestViewV2 {
@Path("/create") @Path("/create")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Create user", response = UserPojo.class) @Operation(description = "Create user", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = UserPojo.class))) })
public Response createUser(UserPojo userPojo) { public Response createUser(UserPojo userPojo) {
if (permissionBean.hasPermission(UserPermission.CREATE_NEW) == false) { if (permissionBean.hasPermission(UserPermission.CREATE_NEW) == false) {
return Response.status(Response.Status.FORBIDDEN).build(); return Response.status(Response.Status.FORBIDDEN).build();
...@@ -163,7 +167,7 @@ public class UserRestViewV2 { ...@@ -163,7 +167,7 @@ public class UserRestViewV2 {
@PUT @PUT
@ApiOperation(value = "Update code ") @Operation(description = "Update code ")
@Path("/{userid}/cardcode") @Path("/{userid}/cardcode")
public Response updateUserCard(PrintedCardUpdateCodePojo codepojo, @PathParam("userid") Integer userid) { public Response updateUserCard(PrintedCardUpdateCodePojo codepojo, @PathParam("userid") Integer userid) {
ReaderEvent event = readerbean.checkCode(codepojo.getReaderName(), codepojo.getCode()); ReaderEvent event = readerbean.checkCode(codepojo.getReaderName(), codepojo.getCode());
...@@ -195,10 +199,10 @@ public class UserRestViewV2 { ...@@ -195,10 +199,10 @@ public class UserRestViewV2 {
*/ */
@PUT @PUT
@Path("/{userid}/image") @Path("/{userid}/image")
@ApiOperation(value = "Upload image", response = EventUserRestPojo.class) @Operation(description = "Upload image", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = EventUserRestPojo.class))) })
@Consumes(MediaType.MULTIPART_FORM_DATA) @Consumes(MediaType.MULTIPART_FORM_DATA)
public Response updateUserImage(@Context HttpServletRequest request, public Response updateUserImage(@Context HttpServletRequest request,
@PathParam("userid") @ApiParam("User ID") Integer userId, @PathParam("userid") @Parameter(description = "User ID") Integer userId,
@FormDataParam("image") FormDataContentDisposition imageInfo, @FormDataParam("image") FormDataContentDisposition imageInfo,
@FormDataParam("image") InputStream imageStream, @FormDataParam("image") InputStream imageStream,
@FormDataParam("image") FormDataBodyPart body) { @FormDataParam("image") FormDataBodyPart body) {
...@@ -229,12 +233,12 @@ public class UserRestViewV2 { ...@@ -229,12 +233,12 @@ public class UserRestViewV2 {
*/ */
@GET @GET
@Path("/{userid}/image") @Path("/{userid}/image")
@ApiOperation(value = "Download user image") @Operation(description = "Download user image")
//@Consumes() //@Consumes()
//@Consumes(MediaType.APPLICATION_FORM_URLENCODED) //@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
//@Produces({MediaType.APPLICATION_JSON, "image/png", "image/jpeg"}) //@Produces({MediaType.APPLICATION_JSON, "image/png", "image/jpeg"})
//@Produces({MediaType.MULTIPART_FORM_DATA, "image/png", "image/jpeg"}) //@Produces({MediaType.MULTIPART_FORM_DATA, "image/png", "image/jpeg"})
public Response downloadUserImage(@PathParam("userid") @ApiParam("User ID") Integer userId) { public Response downloadUserImage(@PathParam("userid") @Parameter(description = "User ID") Integer userId) {
try { try {
User user = userBean.getUser(userId); User user = userBean.getUser(userId);
UserImage image = user.getCurrentImage(); UserImage image = user.getCurrentImage();
...@@ -263,9 +267,9 @@ public class UserRestViewV2 { ...@@ -263,9 +267,9 @@ public class UserRestViewV2 {
@Path("/{userid}/check-password") @Path("/{userid}/check-password")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@ApiOperation(value = "Check user password", response = UserPojo.class) @Operation(description = "Check user password", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = UserPojo.class))) })
public Response checkPassword(@PathParam("userid") @ApiParam("User ID") Integer userId, public Response checkPassword(@PathParam("userid") @Parameter(description = "User ID") Integer userId,
@FormParam("password") @ApiParam("Password") String password) { @FormParam("password") @Parameter(description = "Password") String password) {
try { try {
if (permissionBean.hasPermission(UserPermission.VIEW_ALL) == false) { if (permissionBean.hasPermission(UserPermission.VIEW_ALL) == false) {
return Response.status(Response.Status.FORBIDDEN).build(); return Response.status(Response.Status.FORBIDDEN).build();
......
...@@ -17,8 +17,6 @@ import javax.ws.rs.core.GenericEntity; ...@@ -17,8 +17,6 @@ import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import io.swagger.annotations.Api;
import fi.codecrew.moya.beans.PermissionBeanLocal; import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal; import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
...@@ -31,21 +29,15 @@ import fi.codecrew.moya.rest.pojo.vip.v2.VipRestPojo; ...@@ -31,21 +29,15 @@ import fi.codecrew.moya.rest.pojo.vip.v2.VipRestPojo;
import fi.codecrew.moya.rest.v2.pojo.VipPojoUtils; import fi.codecrew.moya.rest.v2.pojo.VipPojoUtils;
import fi.codecrew.moya.utilities.SearchQuery; import fi.codecrew.moya.utilities.SearchQuery;
import fi.codecrew.moya.utilities.SearchResult; import fi.codecrew.moya.utilities.SearchResult;
import io.swagger.annotations.Api; import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import javax.ejb.EJB; import io.swagger.v3.oas.annotations.tags.Tag;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@RequestScoped @RequestScoped
@Path("/v2/vip") @Path("/v2/vip")
@Api(value = "/v2/vip", description = "Vip list operations") @OpenAPIDefinition(
tags = @Tag(name="Viplist", description = "Viplist"),
info = @Info(title = "Vip list operations"))
@Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"}) @Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"})
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON})
public class VipRestView { public class VipRestView {
......
...@@ -6,12 +6,12 @@ import java.util.List; ...@@ -6,12 +6,12 @@ import java.util.List;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import io.swagger.annotations.ApiModel;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
@XmlRootElement() @XmlRootElement()
@ApiModel(description = "Product")
public class ProductPojo { public class ProductPojo {
public Integer id; public Integer id;
......
package fi.codecrew.moya.rest.v2.pojo; package fi.codecrew.moya.rest.v2.pojo;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date; import java.util.Date;
...@@ -10,7 +10,7 @@ import java.util.Date; ...@@ -10,7 +10,7 @@ import java.util.Date;
* Created by jkj on 2015-05-31. * Created by jkj on 2015-05-31.
*/ */
@XmlRootElement() @XmlRootElement()
@ApiModel(description = "User")
public class UserPojo { public class UserPojo {
public enum UserGender { public enum UserGender {
......
...@@ -2,10 +2,10 @@ package fi.codecrew.moya.rest.v3; ...@@ -2,10 +2,10 @@ package fi.codecrew.moya.rest.v3;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.rest.v3.pojo.LocalePojoV3; import fi.codecrew.moya.rest.v3.pojo.LocalePojoV3;
import io.swagger.annotations.Api; import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import javax.ejb.EJB; import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
...@@ -15,7 +15,8 @@ import javax.ws.rs.core.Response; ...@@ -15,7 +15,8 @@ import javax.ws.rs.core.Response;
@RequestScoped @RequestScoped
@Path("/v3/locale") @Path("/v3/locale")
@Api(value = "/v3/locale", description = "Locale operations") @OpenAPIDefinition(
info = @Info(title = "Locale operations"))
@Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"}) @Produces({MediaType.APPLICATION_JSON + "; charset=UTF-8"})
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON})
public class LocaleRestViewV3 { public class LocaleRestViewV3 {
......
...@@ -6,9 +6,12 @@ import fi.codecrew.moya.model.PrintedCard; ...@@ -6,9 +6,12 @@ import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.model.ReaderEvent; import fi.codecrew.moya.model.ReaderEvent;
import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardUpdateCodePojo; import fi.codecrew.moya.rest.pojo.userinfo.v1.PrintedCardUpdateCodePojo;
import fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3; import fi.codecrew.moya.rest.pojo.userinfo.v3.PrintedCardRestPojoV3;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.annotations.ApiParam; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -22,7 +25,6 @@ import javax.ws.rs.core.Response; ...@@ -22,7 +25,6 @@ import javax.ws.rs.core.Response;
@RequestScoped @RequestScoped
@Path("/v3/user") @Path("/v3/user")
@Api(value = "/v3/user", description = "User operations")
public class UserRestViewV3 { public class UserRestViewV3 {
private static final Logger logger = LoggerFactory.getLogger(UserRestViewV3.class); private static final Logger logger = LoggerFactory.getLogger(UserRestViewV3.class);
...@@ -38,11 +40,8 @@ public class UserRestViewV3 { ...@@ -38,11 +40,8 @@ public class UserRestViewV3 {
@EJB @EJB
private CardTemplateBeanLocal cardBean; private CardTemplateBeanLocal cardBean;
@PUT @PUT
@ApiOperation(value = "Update code ") @Operation(description = "Update code ")
@Path("/{userid}/cardcode") @Path("/{userid}/cardcode")
public Response updateUserCard(PrintedCardUpdateCodePojo codepojo, @PathParam("userid") Integer userid) { public Response updateUserCard(PrintedCardUpdateCodePojo codepojo, @PathParam("userid") Integer userid) {
ReaderEvent event = readerbean.checkCode(codepojo.getReaderName(), codepojo.getCode()); ReaderEvent event = readerbean.checkCode(codepojo.getReaderName(), codepojo.getCode());
...@@ -64,12 +63,10 @@ public class UserRestViewV3 { ...@@ -64,12 +63,10 @@ public class UserRestViewV3 {
return Response.status(status).entity(PojoFactoryV3.createReaderEventRestPojo(event)).build(); return Response.status(status).entity(PojoFactoryV3.createReaderEventRestPojo(event)).build();
} }
@GET @GET
@Path("/card/{eventuserId}") @Path("/card/{eventuserId}")
@ApiOperation(value = "Get PrintedCard for EventUser", response = PrintedCardRestPojoV3.class) @Operation(description = "Get PrintedCard for EventUser", responses = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PrintedCardRestPojoV3.class))) })
public PrintedCardRestPojoV3 getUsersCard(@ApiParam("EventUser entity ID") @PathParam("eventuserId") Integer eventuserid) { public PrintedCardRestPojoV3 getUsersCard(@Parameter(description = "EventUser entity ID") @PathParam("eventuserId") Integer eventuserid) {
EventUser user = userBean.findByEventUserId(eventuserid); EventUser user = userBean.findByEventUserId(eventuserid);
logger.warn("users card for user: {}", user); logger.warn("users card for user: {}", user);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!