├── .gitignore ├── .reuse └── dep5 ├── .settings ├── org.eclipse.core.resources.prefs └── org.eclipse.m2e.core.prefs ├── CONTRIBUTING.md ├── CONTRIBUTING_USING_GENAI.md ├── DEPLOYING.md ├── LICENSE ├── LICENSES └── Apache-2.0.txt ├── README.md ├── cf ├── app-cf │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ ├── org.eclipse.jdt.apt.core.prefs │ │ ├── org.eclipse.jdt.core.prefs │ │ ├── org.eclipse.m2e.core.prefs │ │ ├── org.eclipse.wst.common.component │ │ ├── org.eclipse.wst.common.project.facet.core.xml │ │ └── org.eclipse.wst.validation.prefs │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── sap │ │ └── primetime │ │ ├── adapters │ │ ├── CFCMISProvider.java │ │ ├── CFDataSourceProvider.java │ │ ├── CFFeatureFlagsProvider.java │ │ ├── CFTenantProvider.java │ │ └── CFUserDetailsProvider.java │ │ ├── startup │ │ ├── CFGuiceInitializer.java │ │ ├── CFLiquibaseRunner.java │ │ └── CFModule.java │ │ └── util │ │ └── VcapServicesReader.java ├── approuter-html5repo │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ └── org.eclipse.m2e.core.prefs │ ├── package.json │ ├── pom.xml │ └── xs-app.json ├── approuter-proxy-only │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ └── org.eclipse.m2e.core.prefs │ ├── package.json │ ├── pom.xml │ └── xs-app.json ├── approuter-static-content │ ├── .gitignore │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ └── org.eclipse.m2e.core.prefs │ ├── package.json │ ├── pom.xml │ └── xs-app.json ├── html5-cf │ ├── .gitignore │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ └── org.eclipse.m2e.core.prefs │ ├── manifest.json │ ├── package.json │ ├── pom.xml │ └── xs-app.json ├── manifest.yml ├── web-cf │ ├── .settings │ │ ├── .jsdtscope │ │ ├── org.eclipse.core.resources.prefs │ │ ├── org.eclipse.jdt.apt.core.prefs │ │ ├── org.eclipse.jdt.core.prefs │ │ ├── org.eclipse.m2e.core.prefs │ │ ├── org.eclipse.wst.common.component │ │ ├── org.eclipse.wst.common.project.facet.core.prefs.xml │ │ ├── org.eclipse.wst.common.project.facet.core.xml │ │ ├── org.eclipse.wst.jsdt.ui.superType.container │ │ ├── org.eclipse.wst.jsdt.ui.superType.name │ │ └── org.eclipse.wst.validation.prefs │ ├── pom.xml │ └── src │ │ └── main │ │ └── webapp │ │ └── WEB-INF │ │ └── web.xml └── xs-security.json ├── common ├── app │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ ├── org.eclipse.jdt.apt.core.prefs │ │ ├── org.eclipse.jdt.core.prefs │ │ ├── org.eclipse.jpt.core.prefs │ │ ├── org.eclipse.m2e.core.prefs │ │ ├── org.eclipse.wst.common.component │ │ ├── org.eclipse.wst.common.project.facet.core.prefs.xml │ │ ├── org.eclipse.wst.common.project.facet.core.xml │ │ └── org.eclipse.wst.validation.prefs │ ├── diagrams │ │ └── app.xml │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── sap │ │ │ │ └── primetime │ │ │ │ ├── adapters │ │ │ │ ├── CMISProvider.java │ │ │ │ ├── DataSourceProvider.java │ │ │ │ ├── DocumentAdapter.java │ │ │ │ ├── PersistenceAdapter.java │ │ │ │ ├── TenantProvider.java │ │ │ │ └── UserDetailsProvider.java │ │ │ │ ├── api │ │ │ │ ├── BasicService.java │ │ │ │ ├── DBService.java │ │ │ │ ├── DebugServlet.java │ │ │ │ ├── FileService.java │ │ │ │ ├── OwnerAPISupport.java │ │ │ │ ├── PageService.java │ │ │ │ ├── PlaylistService.java │ │ │ │ ├── ScreenService.java │ │ │ │ ├── ServiceRegistry.java │ │ │ │ ├── SystemService.java │ │ │ │ ├── UserService.java │ │ │ │ └── util │ │ │ │ │ ├── GsonMessageBodyHandler.java │ │ │ │ │ └── JsonIgnore.java │ │ │ │ ├── dao │ │ │ │ ├── BasicDAO.java │ │ │ │ ├── ConfigDAO.java │ │ │ │ ├── EventHistoryDAO.java │ │ │ │ ├── FileDAO.java │ │ │ │ ├── OwnerDAO.java │ │ │ │ ├── PageDAO.java │ │ │ │ ├── PageReferenceDAO.java │ │ │ │ ├── PlaylistDAO.java │ │ │ │ ├── ScreenDAO.java │ │ │ │ ├── UserDAO.java │ │ │ │ ├── dto │ │ │ │ │ ├── ApplianceError.java │ │ │ │ │ ├── ApplianceInfo.java │ │ │ │ │ ├── FileReferences.java │ │ │ │ │ ├── PageReferences.java │ │ │ │ │ ├── PlaylistReferences.java │ │ │ │ │ └── SystemInfo.java │ │ │ │ └── entities │ │ │ │ │ ├── BasicEntity.java │ │ │ │ │ ├── Config.java │ │ │ │ │ ├── ConfigPK.java │ │ │ │ │ ├── EventHistory.java │ │ │ │ │ ├── File.java │ │ │ │ │ ├── Owner.java │ │ │ │ │ ├── OwnerSupport.java │ │ │ │ │ ├── Page.java │ │ │ │ │ ├── PageReference.java │ │ │ │ │ ├── Playlist.java │ │ │ │ │ ├── Screen.java │ │ │ │ │ ├── TenantAwareEntity.java │ │ │ │ │ └── User.java │ │ │ │ ├── jobs │ │ │ │ └── DBCleanUpJob.java │ │ │ │ ├── startup │ │ │ │ ├── AppInitializer.java │ │ │ │ └── JobsInitializer.java │ │ │ │ └── util │ │ │ │ ├── Consts.java │ │ │ │ ├── HTTPRange.java │ │ │ │ ├── SecurityUtil.java │ │ │ │ ├── TemplateHelper.java │ │ │ │ ├── TemplateParam.java │ │ │ │ ├── UploadHandler.java │ │ │ │ ├── UserUtil.java │ │ │ │ └── configuration │ │ │ │ ├── ConfigAdapter.java │ │ │ │ ├── ConfigDBAdapter.java │ │ │ │ ├── ConfigSection.java │ │ │ │ ├── ConfigSectionParam.java │ │ │ │ ├── ConfigUtil.java │ │ │ │ └── FeatureFlagsProvider.java │ │ └── resources │ │ │ ├── META-INF │ │ │ ├── MANIFEST.MF │ │ │ └── persistence.xml │ │ │ ├── app.properties │ │ │ ├── appliance.properties │ │ │ ├── db │ │ │ ├── db.changelog-20181104-Dashboard-Rename.xml │ │ │ ├── db.changelog-20181113-Cleanup.xml │ │ │ ├── db.changelog-20181117-Template-Removal.xml │ │ │ └── db.changelog.xml │ │ │ ├── missing_screenshot.png │ │ │ ├── swagger.properties │ │ │ └── templateSchema.json │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── sap │ │ │ └── primetime │ │ │ ├── api │ │ │ ├── DBServiceTest.java │ │ │ ├── FileServiceTest.java │ │ │ ├── PageServiceTest.java │ │ │ ├── PlaylistServiceTest.java │ │ │ ├── ScreenServiceTest.java │ │ │ ├── SystemServiceTest.java │ │ │ └── UserServiceTest.java │ │ │ ├── testutil │ │ │ ├── HttpServletRequestMock.java │ │ │ ├── PrimeTimeTest.java │ │ │ ├── PrincipalMock.java │ │ │ ├── ServletContextMock.java │ │ │ ├── TestCMISProvider.java │ │ │ ├── TestDataSourceProvider.java │ │ │ ├── TestFeatureFlagsProvider.java │ │ │ ├── TestModule.java │ │ │ ├── TestTenantProvider.java │ │ │ ├── TestUserDetailsProvider.java │ │ │ └── UploadHelper.java │ │ │ └── util │ │ │ ├── TemplateHelperTest.java │ │ │ └── configuration │ │ │ └── ConfigUtilTest.java │ │ └── resources │ │ ├── 500x300.jpg │ │ ├── 600x400.png │ │ ├── small.mp4 │ │ ├── test-3pages.docx │ │ ├── test-3pages.pdf │ │ ├── test-4pages.docx │ │ ├── test-4pages.pdf │ │ ├── test.pptx │ │ ├── testtemplate.zip │ │ ├── testtemplate2.zip │ │ ├── testtemplate3.zip │ │ └── textfile.txt └── web │ ├── .settings │ ├── .jsdtscope │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.prefs.xml │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.wst.jsdt.ui.superType.container │ ├── org.eclipse.wst.jsdt.ui.superType.name │ └── org.eclipse.wst.validation.prefs │ ├── package.json │ ├── pom.xml │ ├── src │ └── main │ │ └── webapp │ │ ├── error_404.html │ │ ├── error_unspecific.html │ │ ├── favicon.png │ │ ├── index.html │ │ ├── showHTML.html │ │ ├── showImage.html │ │ ├── showMediaShare.html │ │ ├── showMovie.html │ │ ├── showPDF │ │ ├── Component.js │ │ ├── controller │ │ │ └── ShowPDF.controller.js │ │ ├── css │ │ │ └── style.css │ │ ├── i18n │ │ │ └── i18n.properties │ │ ├── index.html │ │ ├── manifest.json │ │ └── view │ │ │ └── ShowPDF.view.xml │ │ ├── showText.html │ │ ├── showURLGrid.html │ │ ├── showYouTube.html │ │ ├── test.pdf │ │ └── ui │ │ ├── 3rdparty │ │ ├── QRCode.js │ │ ├── nysoft │ │ │ ├── .library │ │ │ ├── control │ │ │ │ └── PDF.js │ │ │ ├── library.js │ │ │ └── thirdparty │ │ │ │ ├── pdf.js │ │ │ │ └── pdf.worker.js │ │ └── qr │ │ │ └── qrcode.js │ │ ├── Component.js │ │ ├── controller │ │ ├── AdminHome.controller.js │ │ ├── Companion.controller.js │ │ ├── FileDetails.controller.js │ │ ├── PageDetails.controller.js │ │ ├── PlaylistDetails.controller.js │ │ ├── PublicPageCatalog.controller.js │ │ ├── RemoteControl.controller.js │ │ ├── RotateContent.controller.js │ │ ├── ScreenDetails.controller.js │ │ ├── SelfTest.controller.js │ │ └── UserDetails.controller.js │ │ ├── css │ │ └── main.css │ │ ├── img │ │ ├── image_preview.png │ │ ├── logo.png │ │ ├── missing_screenshot.png │ │ ├── onboarding.jpg │ │ ├── pages.jpg │ │ ├── playlist.jpg │ │ ├── teaser.mp4 │ │ └── white.png │ │ ├── manifest.json │ │ ├── model │ │ ├── DateTime.js │ │ └── FileSize.js │ │ ├── util.js │ │ └── view │ │ ├── About.fragment.xml │ │ ├── AdminHome.view.xml │ │ ├── App.view.xml │ │ ├── Companion.view.xml │ │ ├── FileCatalog.fragment.xml │ │ ├── FileDetails.view.xml │ │ ├── FileDetailsDisplay.fragment.xml │ │ ├── FileDetailsEdit.fragment.xml │ │ ├── FileDialog.fragment.xml │ │ ├── FileUsageDialog.fragment.xml │ │ ├── OwnersDialog.fragment.xml │ │ ├── PageActions.fragment.xml │ │ ├── PageCatalog.fragment.xml │ │ ├── PageDetails.view.xml │ │ ├── PageDetailsDisplay.fragment.xml │ │ ├── PageDetailsEdit.fragment.xml │ │ ├── PageDialog.fragment.xml │ │ ├── PageUsageDialog.fragment.xml │ │ ├── PlaylistCatalog.fragment.xml │ │ ├── PlaylistDetails.view.xml │ │ ├── PlaylistDetailsDisplay.fragment.xml │ │ ├── PlaylistDetailsEdit.fragment.xml │ │ ├── PlaylistDialog.fragment.xml │ │ ├── PlaylistUsageDialog.fragment.xml │ │ ├── PublicPageCatalog.view.xml │ │ ├── RemoteControl.view.xml │ │ ├── RotateContent.view.xml │ │ ├── ScreenClaimDialog.fragment.xml │ │ ├── ScreenDetails.view.xml │ │ ├── ScreenDetailsDisplay.fragment.xml │ │ ├── ScreenDetailsEdit.fragment.xml │ │ ├── ScreenDialog.fragment.xml │ │ ├── SelfTest.view.xml │ │ ├── UserDetails.fragment.xml │ │ └── UserDetails.view.xml │ ├── ui-assembly.xml │ └── ui5.yaml ├── neo ├── app-neo │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ ├── org.eclipse.jdt.apt.core.prefs │ │ ├── org.eclipse.jdt.core.prefs │ │ ├── org.eclipse.m2e.core.prefs │ │ ├── org.eclipse.wst.common.component │ │ ├── org.eclipse.wst.common.project.facet.core.xml │ │ └── org.eclipse.wst.validation.prefs │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── sap │ │ └── primetime │ │ ├── adapters │ │ ├── NeoCMISProvider.java │ │ ├── NeoDataSourceProvider.java │ │ ├── NeoFeatureFlagsProvider.java │ │ ├── NeoTenantProvider.java │ │ └── NeoUserDetailsProvider.java │ │ └── startup │ │ ├── AuthFilter.java │ │ ├── BASICAuthFilter.java │ │ ├── CERTAuthFilter.java │ │ ├── NeoGuiceInitializer.java │ │ ├── NeoModule.java │ │ └── SAMLAuthFilter.java ├── html5-neo │ ├── .settings │ │ ├── org.eclipse.core.resources.prefs │ │ └── org.eclipse.m2e.core.prefs │ ├── neo-app.json │ └── pom.xml └── web-neo │ ├── .settings │ ├── .jsdtscope │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.apt.core.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ ├── org.eclipse.wst.common.project.facet.core.prefs.xml │ ├── org.eclipse.wst.common.project.facet.core.xml │ ├── org.eclipse.wst.jsdt.ui.superType.container │ ├── org.eclipse.wst.jsdt.ui.superType.name │ └── org.eclipse.wst.validation.prefs │ ├── pom.xml │ └── src │ └── main │ └── webapp │ └── WEB-INF │ └── web.xml ├── pom.xml └── resources ├── SampleTemplate ├── SampleTemplate.zip ├── background.jpg ├── index.html ├── party.gif ├── screenshot.png ├── style.css └── template.json ├── image_preview.pdn ├── missing_screenshot.pdn └── teaser.wlmp /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .project 3 | package-lock.json 4 | *.cache 5 | *.log 6 | *.droplet 7 | app.*.properties 8 | target/ 9 | bin/ 10 | temp/ 11 | node/ 12 | node_modules/ 13 | dist/ 14 | neo/deploy*.properties 15 | cf/vars*.yml -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: cloud-primetime 3 | Upstream-Contact: Robert Wetzold 4 | Source: https://github.com/SAP/cloud-primetime 5 | 6 | Files: * 7 | Copyright: 2019-2021 SAP SE or an SAP affiliate company and cloud-primetime contributors 8 | License: Apache-2.0 -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /CONTRIBUTING_USING_GENAI.md: -------------------------------------------------------------------------------- 1 | # Guideline for AI-generated code contributions to SAP Open Source Software Projects 2 | 3 | As artificial intelligence evolves, AI-generated code is becoming valuable for many software projects, including open-source initiatives. While we recognize the potential benefits of incorporating AI-generated content into our open-source projects there are certain requirements that need to be reflected and adhered to when making contributions. 4 | 5 | When using AI-generated code contributions in OSS Projects, their usage needs to align with Open-Source Software values and legal requirements. We have established these essential guidelines to help contributors navigate the complexities of using AI tools while maintaining compliance with open-source licenses and the broader [Open-Source Definition](https://opensource.org/osd). 6 | 7 | AI-generated code or content can be contributed to SAP Open Source Software projects if the following conditions are met: 8 | 9 | 1. **Compliance with AI Tool Terms and Conditions**: Contributors must ensure that the AI tool's terms and conditions do not impose any restrictions on the tool's output that conflict with the project's open-source license or intellectual property policies. This includes ensuring that the AI-generated content adheres to the [Open-Source Definition](https://opensource.org/osd). 10 | 2. **Filtering Similar Suggestions**: Contributors must use features provided by AI tools to suppress responses that are similar to third-party materials or flag similarities. We only accept contributions from AI tools with such filtering options. If the AI tool flags any similarities, contributors must review and ensure compliance with the licensing terms of such materials before including them in the project. 11 | 3. **Management of Third-Party Materials**: If the AI tool's output includes pre-existing copyrighted materials, including open-source code authored or owned by third parties, contributors must verify that they have the necessary permissions from the original owners. This typically involves ensuring that there is an open-source license or public domain declaration that is compatible with the project's licensing policies. Contributors must also provide appropriate notice and attribution for these third-party materials, along with relevant information about the applicable license terms. 12 | 4. **Employer Policies Compliance**: If AI-generated content is contributed in the context of employment, contributors must also adhere to their employer’s policies. This ensures that all contributions are made with proper authorization and respect for relevant corporate guidelines. 13 | -------------------------------------------------------------------------------- /cf/app-cf/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding/=UTF-8 4 | -------------------------------------------------------------------------------- /cf/app-cf/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /cf/app-cf/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 9 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 10 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 11 | org.eclipse.jdt.core.compiler.release=disabled 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /cf/app-cf/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /cf/app-cf/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /cf/app-cf/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /cf/app-cf/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /cf/app-cf/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | app-cf 5 | jar 6 | 7 | 8 | com.sap.primetime 9 | parent 10 | 0.0.1 11 | ../.. 12 | 13 | 14 | 15 | 16 | com.sap.primetime 17 | app 18 | 0.0.1 19 | 20 | 21 | org.apache.chemistry.opencmis 22 | chemistry-opencmis-client-impl 23 | ${cmis.version} 24 | provided 25 | 26 | 27 | org.apache.tomcat 28 | tomcat-dbcp 29 | 8.0.24 30 | provided 31 | 32 | 33 | com.sap.cloud.security.xsuaa 34 | api 35 | 1.5.0 36 | provided 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /cf/app-cf/src/main/java/com/sap/primetime/adapters/CFCMISProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.adapters; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.apache.chemistry.opencmis.client.api.Session; 7 | import org.apache.chemistry.opencmis.client.api.SessionFactory; 8 | import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl; 9 | import org.apache.chemistry.opencmis.commons.SessionParameter; 10 | import org.apache.chemistry.opencmis.commons.enums.BindingType; 11 | 12 | import com.sap.primetime.util.VcapServicesReader; 13 | 14 | public class CFCMISProvider implements CMISProvider { 15 | // FIXME: get from environment, currently not available 16 | private static final String UNIQUE_NAME = "6a3a26a000563f61d76a3ea5"; 17 | 18 | @Override 19 | public Session getCmisSession() { 20 | SessionFactory factory = SessionFactoryImpl.newInstance(); 21 | Map parameters = new HashMap<>(); 22 | 23 | VcapServicesReader vcap = new VcapServicesReader(); 24 | 25 | parameters.put(SessionParameter.USER, vcap.get("primetime-ecm", "user")); 26 | parameters.put(SessionParameter.PASSWORD, vcap.get("primetime-ecm", "password")); 27 | parameters.put(SessionParameter.BROWSER_URL, vcap.get("primetime-ecm", "uri")); 28 | parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value()); 29 | parameters.put(SessionParameter.REPOSITORY_ID, UNIQUE_NAME); 30 | 31 | return factory.createSession(parameters); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /cf/app-cf/src/main/java/com/sap/primetime/adapters/CFDataSourceProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.adapters; 2 | 3 | import java.util.Properties; 4 | 5 | import javax.inject.Singleton; 6 | import javax.naming.InitialContext; 7 | import javax.naming.NamingException; 8 | import javax.sql.DataSource; 9 | 10 | import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; 11 | 12 | import com.sap.primetime.adapters.DataSourceProvider; 13 | import com.sap.primetime.util.VcapServicesReader; 14 | 15 | @Singleton 16 | public class CFDataSourceProvider implements DataSourceProvider { 17 | @Override 18 | public DataSource getDatasource() throws NamingException { 19 | InitialContext ctx = new InitialContext(); 20 | DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/DefaultDB"); 21 | 22 | if (!(ds instanceof BasicDataSource)) { 23 | throw new IllegalArgumentException( 24 | "The data source is not an instance of type " + BasicDataSource.class.getName()); 25 | } 26 | BasicDataSource bds = (BasicDataSource) ds; 27 | bds.setDriverClassName("org.postgresql.Driver"); 28 | 29 | VcapServicesReader vcap = new VcapServicesReader(); 30 | 31 | bds.setUrl("jdbc:postgresql://" + vcap.get("primetime-postgres", "hostname") + ":" 32 | + vcap.get("primetime-postgres", "port") + "/" + vcap.get("primetime-postgres", "dbname")); 33 | bds.setUsername(vcap.get("primetime-postgres", "username")); 34 | bds.setPassword(vcap.get("primetime-postgres", "password")); 35 | 36 | return bds; 37 | } 38 | 39 | @Override 40 | public Properties getProperties() { 41 | return new Properties(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /cf/app-cf/src/main/java/com/sap/primetime/adapters/CFFeatureFlagsProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.adapters; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.net.URL; 5 | import java.util.Base64; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import com.sap.primetime.util.Consts; 11 | import com.sap.primetime.util.VcapServicesReader; 12 | import com.sap.primetime.util.configuration.FeatureFlagsProvider; 13 | 14 | public class CFFeatureFlagsProvider implements FeatureFlagsProvider { 15 | private static final Logger logger = LoggerFactory.getLogger(CFFeatureFlagsProvider.class); 16 | 17 | @Override 18 | public Boolean getBooleanProperty(String group, String key) { 19 | HttpURLConnection urlConnection = null; 20 | 21 | try { 22 | VcapServicesReader vcap = new VcapServicesReader(); 23 | 24 | String value = vcap.get("primetime-featureflags", "uri"); 25 | URL url = new URL(value + "/api/v1/evaluate/" + key); 26 | 27 | String auth = Base64.getEncoder().encodeToString(new String(vcap.get("primetime-featureflags", "username") 28 | + ":" + vcap.get("primetime-featureflags", "password")).getBytes()); 29 | urlConnection = (HttpURLConnection) url.openConnection(); 30 | urlConnection.setRequestProperty("Authorization", "Basic " + auth); 31 | urlConnection.setConnectTimeout(Consts.BackendTimeout); 32 | int code = urlConnection.getResponseCode(); 33 | 34 | if (code == 200) { 35 | return true; 36 | } else if (code == 204) { 37 | return false; 38 | } else { 39 | return null; 40 | } 41 | } catch (Exception e) { 42 | logger.warn("Error connecting to feature flags service. Marking feature " + group + "." + key 43 | + " as unavailable.", e); 44 | return null; 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /cf/app-cf/src/main/java/com/sap/primetime/adapters/CFTenantProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.adapters; 2 | 3 | import javax.inject.Singleton; 4 | 5 | @Singleton 6 | public class CFTenantProvider implements TenantProvider { 7 | 8 | @Override 9 | public String getTenantId() { 10 | // TODO: retrieve tenant from JWT token 11 | return null; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /cf/app-cf/src/main/java/com/sap/primetime/adapters/CFUserDetailsProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.adapters; 2 | 3 | import javax.inject.Singleton; 4 | import javax.servlet.ServletRequest; 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import com.sap.primetime.dao.entities.User; 11 | import com.sap.xsa.security.container.XSUserInfo; 12 | import com.sap.xsa.security.container.XSUserInfoException; 13 | 14 | @Singleton 15 | public class CFUserDetailsProvider implements UserDetailsProvider { 16 | private static final Logger logger = LoggerFactory.getLogger(CFUserDetailsProvider.class); 17 | 18 | @Override 19 | public User getUserDetails(ServletRequest request) { 20 | HttpServletRequest httpRequest = (HttpServletRequest) request; 21 | XSUserInfo userInfo = (XSUserInfo) httpRequest.getUserPrincipal(); 22 | 23 | User user = new User(); 24 | try { 25 | user.setUserId(userInfo.getLogonName()); 26 | user.setEmail(userInfo.getEmail()); 27 | user.setFirstName(userInfo.getGivenName().trim()); 28 | user.setLastName(userInfo.getFamilyName().trim()); 29 | } catch (XSUserInfoException e) { 30 | logger.error("Could not get user information.", e); 31 | } 32 | 33 | return user; 34 | } 35 | 36 | @Override 37 | public boolean isAdmin(ServletRequest request) { 38 | return isUserInRole(request, "admin"); 39 | } 40 | 41 | @Override 42 | public boolean isDBAdmin(ServletRequest request) { 43 | return isUserInRole(request, "dbadmin"); 44 | } 45 | 46 | private boolean isUserInRole(ServletRequest request, String role) { 47 | try { 48 | HttpServletRequest httpRequest = (HttpServletRequest) request; 49 | XSUserInfo userInfo = (XSUserInfo) httpRequest.getUserPrincipal(); 50 | return userInfo.checkLocalScope(role); 51 | } catch (XSUserInfoException e) { 52 | logger.error("Could not get user information.", e); 53 | return false; 54 | } 55 | 56 | } 57 | 58 | @Override 59 | public boolean logOut(HttpServletRequest request) { 60 | // TODO: implement 61 | return false; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /cf/app-cf/src/main/java/com/sap/primetime/startup/CFGuiceInitializer.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.startup; 2 | 3 | import javax.servlet.ServletContextEvent; 4 | import javax.servlet.ServletContextListener; 5 | 6 | import com.google.inject.Guice; 7 | import com.google.inject.Injector; 8 | import com.google.inject.Stage; 9 | import com.sap.primetime.util.Consts; 10 | 11 | public class CFGuiceInitializer implements ServletContextListener { 12 | 13 | @Override 14 | public void contextInitialized(final ServletContextEvent sce) { 15 | Injector injector = Guice.createInjector(Stage.PRODUCTION, new CFModule()); 16 | sce.getServletContext().setAttribute(Injector.class.getName(), injector); 17 | Consts.injector = injector; 18 | } 19 | 20 | @Override 21 | public void contextDestroyed(ServletContextEvent arg0) { 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /cf/app-cf/src/main/java/com/sap/primetime/startup/CFLiquibaseRunner.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.startup; 2 | 3 | import java.sql.SQLException; 4 | 5 | import javax.servlet.ServletContextEvent; 6 | import javax.servlet.ServletContextListener; 7 | 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import com.sap.primetime.adapters.PersistenceAdapter; 12 | 13 | import liquibase.Contexts; 14 | import liquibase.LabelExpression; 15 | import liquibase.Liquibase; 16 | import liquibase.database.Database; 17 | import liquibase.database.DatabaseFactory; 18 | import liquibase.database.jvm.JdbcConnection; 19 | import liquibase.exception.DatabaseException; 20 | import liquibase.exception.LiquibaseException; 21 | import liquibase.resource.ClassLoaderResourceAccessor; 22 | 23 | public class CFLiquibaseRunner implements ServletContextListener { 24 | private static final Logger logger = LoggerFactory.getLogger(CFLiquibaseRunner.class); 25 | 26 | @Override 27 | public void contextInitialized(final ServletContextEvent sce) { 28 | try { 29 | Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation( 30 | new JdbcConnection(PersistenceAdapter.getDataSource().getConnection())); 31 | Liquibase liquibase = new liquibase.Liquibase("db/db.changelog.xml", new ClassLoaderResourceAccessor(), 32 | database); 33 | 34 | liquibase.update(new Contexts(), new LabelExpression()); 35 | } catch (DatabaseException | SQLException e) { 36 | logger.error("Could not initialize datasource.", e); 37 | } catch (LiquibaseException e) { 38 | logger.error("Could not perform Liquibase update.", e); 39 | } 40 | } 41 | 42 | @Override 43 | public void contextDestroyed(ServletContextEvent arg0) { 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /cf/app-cf/src/main/java/com/sap/primetime/startup/CFModule.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.startup; 2 | 3 | import com.google.inject.AbstractModule; 4 | import com.sap.primetime.adapters.CFCMISProvider; 5 | import com.sap.primetime.adapters.CFDataSourceProvider; 6 | import com.sap.primetime.adapters.CFFeatureFlagsProvider; 7 | import com.sap.primetime.adapters.CFTenantProvider; 8 | import com.sap.primetime.adapters.CFUserDetailsProvider; 9 | import com.sap.primetime.adapters.CMISProvider; 10 | import com.sap.primetime.adapters.DataSourceProvider; 11 | import com.sap.primetime.adapters.TenantProvider; 12 | import com.sap.primetime.adapters.UserDetailsProvider; 13 | import com.sap.primetime.util.configuration.FeatureFlagsProvider; 14 | 15 | public class CFModule extends AbstractModule { 16 | 17 | @Override 18 | protected void configure() { 19 | bind(UserDetailsProvider.class).to(CFUserDetailsProvider.class); 20 | bind(DataSourceProvider.class).to(CFDataSourceProvider.class); 21 | bind(CMISProvider.class).to(CFCMISProvider.class); 22 | bind(TenantProvider.class).to(CFTenantProvider.class); 23 | bind(FeatureFlagsProvider.class).to(CFFeatureFlagsProvider.class); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cf/app-cf/src/main/java/com/sap/primetime/util/VcapServicesReader.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map.Entry; 5 | 6 | import org.apache.commons.lang3.StringUtils; 7 | 8 | import com.google.gson.JsonArray; 9 | import com.google.gson.JsonElement; 10 | import com.google.gson.JsonObject; 11 | import com.google.gson.JsonParser; 12 | 13 | public class VcapServicesReader { 14 | private HashMap credentialsCache; 15 | 16 | public boolean containsService(String serviceName) { 17 | loadServiceDocument(); 18 | return credentialsCache.containsKey(serviceName); 19 | } 20 | 21 | public String get(String serviceName, String paramName) { 22 | loadServiceDocument(); 23 | 24 | JsonObject credentials = credentialsCache.get(serviceName); 25 | if (credentials == null) { 26 | throw new IllegalArgumentException("Failed to get credentials for service " + serviceName); 27 | } 28 | 29 | return credentials.get(paramName).getAsString(); 30 | } 31 | 32 | private void loadServiceDocument() { 33 | synchronized (this) { 34 | if (credentialsCache == null) { 35 | credentialsCache = new HashMap<>(); 36 | 37 | String servicesDocument = System.getenv("VCAP_SERVICES"); 38 | if (StringUtils.isBlank(servicesDocument)) { 39 | throw new IllegalArgumentException("VCAP_SERVICES environment variable not found."); 40 | } 41 | 42 | JsonObject allServices = new JsonParser().parse(servicesDocument).getAsJsonObject(); 43 | for (Entry entry : allServices.entrySet()) { 44 | if (entry.getValue().isJsonArray()) { 45 | JsonArray services = entry.getValue().getAsJsonArray(); 46 | 47 | for (int i = 0; i < services.size(); i++) { 48 | JsonElement singleService = services.get(i); 49 | JsonObject singleServiceObject = singleService.getAsJsonObject(); 50 | String serviceName = singleServiceObject.get("name").getAsString(); 51 | JsonObject credentials = singleServiceObject.get("credentials").getAsJsonObject(); 52 | credentialsCache.put(serviceName, credentials); 53 | } 54 | } 55 | } 56 | } 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /cf/approuter-html5repo/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /cf/approuter-html5repo/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /cf/approuter-html5repo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "approuter-html5repo", 3 | "version": "0.0.1", 4 | "dependencies": { 5 | "@sap/approuter": "2.6.1", 6 | "npm": "^6.0.0" 7 | }, 8 | "scripts": { 9 | "start": "node node_modules/@sap/approuter/approuter.js" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cf/approuter-html5repo/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | approuter-html5repo 5 | pom 6 | 7 | 8 | com.sap.primetime 9 | parent 10 | 0.0.1 11 | ../.. 12 | 13 | 14 | 15 | 16 | 17 | com.github.eirslett 18 | frontend-maven-plugin 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /cf/approuter-html5repo/xs-app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "source": "^/", 5 | "target": "/", 6 | "service": "html5-apps-rt", 7 | "authenticationType": "xsuaa", 8 | "csrfProtection": false 9 | } 10 | ] 11 | } -------------------------------------------------------------------------------- /cf/approuter-proxy-only/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /cf/approuter-proxy-only/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /cf/approuter-proxy-only/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "approuter-proxy-only", 3 | "version": "0.0.1", 4 | "dependencies": { 5 | "@sap/approuter": "2.6.1", 6 | "npm": "^6.0.1" 7 | }, 8 | "scripts": { 9 | "start": "node node_modules/@sap/approuter/approuter.js" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cf/approuter-proxy-only/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | approuter-proxy-only 5 | pom 6 | 7 | 8 | com.sap.primetime 9 | parent 10 | 0.0.1 11 | ../.. 12 | 13 | 14 | 15 | 16 | 17 | com.github.eirslett 18 | frontend-maven-plugin 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /cf/approuter-proxy-only/xs-app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "source": "^/", 5 | "target": "/", 6 | "destination": "app", 7 | "csrfProtection": false 8 | } 9 | ] 10 | } -------------------------------------------------------------------------------- /cf/approuter-static-content/.gitignore: -------------------------------------------------------------------------------- 1 | resources/ 2 | -------------------------------------------------------------------------------- /cf/approuter-static-content/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /cf/approuter-static-content/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /cf/approuter-static-content/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "approuter-static-content", 3 | "version": "0.0.1", 4 | "dependencies": { 5 | "@sap/approuter": "2.6.1", 6 | "npm": "^6.0.0" 7 | }, 8 | "scripts": { 9 | "start": "node node_modules/@sap/approuter/approuter.js" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /cf/approuter-static-content/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | approuter-static-content 5 | pom 6 | 7 | 8 | com.sap.primetime 9 | parent 10 | 0.0.1 11 | ../.. 12 | 13 | 14 | 15 | 16 | 17 | com.github.eirslett 18 | frontend-maven-plugin 19 | 20 | 21 | org.apache.maven.plugins 22 | maven-antrun-plugin 23 | 24 | 25 | clean 26 | clean 27 | 28 | 29 | 30 | 31 | 32 | 33 | run 34 | 35 | 36 | 37 | package 38 | package 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | run 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /cf/approuter-static-content/xs-app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "source": "^/s/api/", 5 | "target": "/s/api/", 6 | "destination": "app", 7 | "csrfProtection": false 8 | }, 9 | { 10 | "source": "^/", 11 | "localDir": "resources" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /cf/html5-cf/.gitignore: -------------------------------------------------------------------------------- 1 | resources/ 2 | -------------------------------------------------------------------------------- /cf/html5-cf/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /cf/html5-cf/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /cf/html5-cf/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "_version": "1.7.0", 3 | "sap.app": { 4 | "id": "primetime", 5 | "type": "application", 6 | "applicationVersion": { 7 | "version": "0.0.1" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /cf/html5-cf/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "PrimeTimeHTML5Deployer", 3 | "engines": { 4 | "node": ">=6.0.0" 5 | }, 6 | "dependencies": { 7 | "@sap/html5-app-deployer": "2.0.1" 8 | }, 9 | "scripts": { 10 | "start": "node node_modules/@sap/html5-app-deployer/index.js" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cf/html5-cf/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | html5-cf 5 | pom 6 | 7 | 8 | com.sap.primetime 9 | parent 10 | 0.0.1 11 | ../.. 12 | 13 | 14 | 15 | 16 | 17 | com.github.eirslett 18 | frontend-maven-plugin 19 | 20 | 21 | org.apache.maven.plugins 22 | maven-antrun-plugin 23 | 24 | 25 | clean 26 | clean 27 | 28 | 29 | 30 | 31 | 32 | 33 | run 34 | 35 | 36 | 37 | package 38 | package 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | run 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /cf/html5-cf/xs-app.json: -------------------------------------------------------------------------------- 1 | { 2 | "routes": [ 3 | { 4 | "source": "^/b/api", 5 | "destination": "primetime-server", 6 | "authenticationType": "xsuaa" 7 | }, 8 | { 9 | "source": "^/", 10 | "target": "app", 11 | "service": "html5-apps-repo-rt", 12 | "authenticationType": "xsuaa" 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /cf/manifest.yml: -------------------------------------------------------------------------------- 1 | applications: 2 | - name: ((appName)) 3 | path: web-cf/target/web-cf.war 4 | buildpacks: 5 | - sap_java_buildpack 6 | instances: 1 7 | memory: 1792M 8 | env: 9 | JAVA_OPTS: -XX:InitialCodeCacheSize=64m -XX:ReservedCodeCacheSize=64m 10 | SAP_JWT_TRUST_ACL: '[{"clientid" : "*", "identityzone" : "*"}]' 11 | services: 12 | - primetime-uaa 13 | - primetime-postgres 14 | - name: ((appName))HTML5Deployer 15 | path: html5-cf 16 | buildpacks: 17 | - nodejs_buildpack 18 | no-route: true 19 | memory: 128M 20 | services: 21 | - primetime-html5-host 22 | - name: ((appName))ar 23 | path: approuter-proxy-only 24 | buildpacks: 25 | - nodejs_buildpack 26 | memory: 128M 27 | env: 28 | destinations: | 29 | [ 30 | {"name":"app", 31 | "url":"https://((appName)).((host))", 32 | "forwardAuthToken": true} 33 | ] 34 | services: 35 | - primetime-uaa 36 | - name: ((appName))ar2 37 | path: approuter-static-content 38 | buildpacks: 39 | - nodejs_buildpack 40 | memory: 256M 41 | env: 42 | destinations: | 43 | [ 44 | {"name":"app", 45 | "url":"https://((appName)).((host))", 46 | "forwardAuthToken": true} 47 | ] 48 | services: 49 | - primetime-uaa 50 | - name: ((appName))ar3 51 | path: approuter-html5repo 52 | buildpacks: 53 | - nodejs_buildpack 54 | memory: 256M 55 | services: 56 | - primetime-html5-rt 57 | - primetime-uaa -------------------------------------------------------------------------------- /cf/web-cf/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /cf/web-cf/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/resources=UTF-8 3 | encoding/=UTF-8 4 | -------------------------------------------------------------------------------- /cf/web-cf/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /cf/web-cf/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 9 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 10 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 11 | org.eclipse.jdt.core.compiler.release=disabled 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /cf/web-cf/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /cf/web-cf/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | uses 8 | 9 | 10 | uses 11 | 12 | 13 | consumes 14 | 15 | 16 | consumes 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /cf/web-cf/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /cf/web-cf/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /cf/web-cf/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /cf/web-cf/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /cf/web-cf/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /cf/web-cf/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | web-cf 5 | war 6 | 7 | 8 | com.sap.primetime 9 | parent 10 | 0.0.1 11 | ../.. 12 | 13 | 14 | 15 | 16 | com.sap.primetime 17 | app-cf 18 | 0.0.1 19 | 20 | 21 | com.sap.primetime 22 | web 23 | 0.0.1 24 | war 25 | 26 | 27 | org.apache.chemistry.opencmis 28 | chemistry-opencmis-client-api 29 | ${cmis.version} 30 | runtime 31 | 32 | 33 | org.apache.chemistry.opencmis 34 | chemistry-opencmis-commons-api 35 | ${cmis.version} 36 | runtime 37 | 38 | 39 | org.apache.chemistry.opencmis 40 | chemistry-opencmis-client-impl 41 | ${cmis.version} 42 | runtime 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.apache.maven.plugins 52 | maven-war-plugin 53 | 54 | ${project.artifactId} 55 | 56 | / 57 | ${project.version} 58 | 59 | 60 | ../../common/app/src/main/resources/META-INF/MANIFEST.MF 61 | 62 | 63 | 64 | com.sap.primetime 65 | web 66 | 67 | 68 | false 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /cf/xs-security.json: -------------------------------------------------------------------------------- 1 | { 2 | "xsappname": "primetime", 3 | "tenant-mode": "dedicated", 4 | "scopes": [ 5 | { 6 | "name": "$XSAPPNAME.admin", 7 | "description": "admin" 8 | }, 9 | { 10 | "name": "$XSAPPNAME.dbadmin", 11 | "description": "dbadmin" 12 | } 13 | ], 14 | "role-templates": [ 15 | { 16 | "name": "admin", 17 | "description": "Admin in PrimeTime", 18 | "scope-references": [ 19 | "$XSAPPNAME.admin" 20 | ] 21 | }, 22 | { 23 | "name": "dbadmin", 24 | "description": "Database admin in PrimeTime", 25 | "scope-references": [ 26 | "$XSAPPNAME.dbadmin" 27 | ] 28 | }, 29 | { 30 | "name": "user", 31 | "description": "Normal user in PrimeTime", 32 | "scope-references": [ 33 | "uaa.user" 34 | ] 35 | } 36 | ] 37 | } -------------------------------------------------------------------------------- /common/app/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding//src/test/resources=UTF-8 6 | encoding/=UTF-8 7 | -------------------------------------------------------------------------------- /common/app/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /common/app/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 9 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 10 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 11 | org.eclipse.jdt.core.compiler.release=disabled 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /common/app/.settings/org.eclipse.jpt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jpt.core.platform=eclipselink2_4 3 | org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=true 4 | -------------------------------------------------------------------------------- /common/app/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /common/app/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /common/app/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /common/app/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /common/app/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | disabled=06target 2 | eclipse.preferences.version=1 3 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/adapters/CMISProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.adapters; 2 | 3 | import org.apache.chemistry.opencmis.client.api.Session; 4 | 5 | public interface CMISProvider { 6 | public Session getCmisSession(); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/adapters/DataSourceProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.adapters; 2 | 3 | import java.util.Properties; 4 | 5 | import javax.naming.NamingException; 6 | import javax.sql.DataSource; 7 | 8 | public interface DataSourceProvider { 9 | public DataSource getDatasource() throws NamingException; 10 | 11 | public Properties getProperties(); 12 | } 13 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/adapters/TenantProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.adapters; 2 | 3 | public interface TenantProvider { 4 | public String getTenantId(); 5 | } 6 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/adapters/UserDetailsProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.adapters; 2 | 3 | import javax.servlet.ServletRequest; 4 | import javax.servlet.http.HttpServletRequest; 5 | 6 | import com.sap.primetime.dao.entities.User; 7 | 8 | public interface UserDetailsProvider { 9 | public User getUserDetails(ServletRequest request); 10 | 11 | public boolean isAdmin(ServletRequest request); 12 | 13 | public boolean isDBAdmin(ServletRequest request); 14 | 15 | public boolean logOut(HttpServletRequest request); 16 | } 17 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/api/DBService.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.api; 2 | 3 | import java.util.List; 4 | 5 | import javax.ws.rs.GET; 6 | import javax.ws.rs.Path; 7 | import javax.ws.rs.Produces; 8 | import javax.ws.rs.core.MediaType; 9 | 10 | import com.sap.primetime.dao.FileDAO; 11 | import com.sap.primetime.dao.OwnerDAO; 12 | import com.sap.primetime.dao.PageDAO; 13 | import com.sap.primetime.dao.PageReferenceDAO; 14 | import com.sap.primetime.dao.PlaylistDAO; 15 | import com.sap.primetime.dao.ScreenDAO; 16 | import com.sap.primetime.dao.UserDAO; 17 | import com.sap.primetime.dao.entities.File; 18 | import com.sap.primetime.dao.entities.Owner; 19 | import com.sap.primetime.dao.entities.Page; 20 | import com.sap.primetime.dao.entities.PageReference; 21 | import com.sap.primetime.dao.entities.Playlist; 22 | import com.sap.primetime.dao.entities.Screen; 23 | import com.sap.primetime.dao.entities.User; 24 | 25 | import io.swagger.annotations.Api; 26 | 27 | @Api(value = "Database") 28 | @Path("/dbservice") 29 | public class DBService extends BasicService { 30 | @GET 31 | @Path("/users") 32 | @Produces(MediaType.APPLICATION_JSON) 33 | public List getUsers() { 34 | if (!isDBAdmin()) { 35 | throwUnauthorized(); 36 | } 37 | 38 | return new UserDAO().getAllDesc("dateModified", false); 39 | } 40 | 41 | @GET 42 | @Path("/pages") 43 | @Produces(MediaType.APPLICATION_JSON) 44 | public List getPages() { 45 | if (!isDBAdmin()) { 46 | throwUnauthorized(); 47 | } 48 | 49 | return new PageDAO().getAll("name"); 50 | } 51 | 52 | @GET 53 | @Path("/files") 54 | @Produces(MediaType.APPLICATION_JSON) 55 | public List getFiles() { 56 | if (!isDBAdmin()) { 57 | throwUnauthorized(); 58 | } 59 | 60 | return new FileDAO().getAll("name"); 61 | } 62 | 63 | @GET 64 | @Path("/playlists") 65 | @Produces(MediaType.APPLICATION_JSON) 66 | public List getPlaylists() { 67 | if (!isDBAdmin()) { 68 | throwUnauthorized(); 69 | } 70 | 71 | return new PlaylistDAO().getAll("name"); 72 | } 73 | 74 | @GET 75 | @Path("/screens") 76 | @Produces(MediaType.APPLICATION_JSON) 77 | public List getScreens() { 78 | if (!isDBAdmin()) { 79 | throwUnauthorized(); 80 | } 81 | 82 | return new ScreenDAO().getAll("name"); 83 | } 84 | 85 | @GET 86 | @Path("/owners") 87 | @Produces(MediaType.APPLICATION_JSON) 88 | public List getOwners() { 89 | if (!isDBAdmin()) { 90 | throwUnauthorized(); 91 | } 92 | 93 | return new OwnerDAO().getAll(); 94 | } 95 | 96 | @GET 97 | @Path("/pagereferences") 98 | @Produces(MediaType.APPLICATION_JSON) 99 | public List getPageReferences() { 100 | if (!isDBAdmin()) { 101 | throwUnauthorized(); 102 | } 103 | 104 | return new PageReferenceDAO().getAll(); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/api/DebugServlet.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.api; 2 | 3 | import java.io.IOException; 4 | import java.util.Enumeration; 5 | 6 | import javax.servlet.ServletException; 7 | import javax.servlet.annotation.WebServlet; 8 | import javax.servlet.http.HttpServlet; 9 | import javax.servlet.http.HttpServletRequest; 10 | import javax.servlet.http.HttpServletResponse; 11 | 12 | @WebServlet("/debug") 13 | public class DebugServlet extends HttpServlet { 14 | private static final long serialVersionUID = 1375980381655546658L; 15 | 16 | @Override 17 | protected void doGet(final HttpServletRequest request, final HttpServletResponse response) 18 | throws ServletException, IOException { 19 | response.setContentType("text/plain"); 20 | 21 | Enumeration headerNames = request.getHeaderNames(); 22 | while (headerNames.hasMoreElements()) { 23 | String key = headerNames.nextElement(); 24 | String value = request.getHeader(key); 25 | 26 | response.getOutputStream().println(key + ": " + value); 27 | } 28 | 29 | response.getOutputStream().println("principal: " + request.getUserPrincipal()); 30 | } 31 | } -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/api/OwnerAPISupport.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.api; 2 | 3 | import com.sap.primetime.dao.entities.Owner; 4 | 5 | public interface OwnerAPISupport { 6 | 7 | T addOwners(long id, Owner[] ownerData); 8 | 9 | @SuppressWarnings("unused") 10 | default T updateOwner(long id, long ownerId, Owner owner) { 11 | return null; 12 | } 13 | 14 | T deleteOwner(long id, long ownerId); 15 | 16 | } -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/api/ServiceRegistry.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.api; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import javax.ws.rs.core.Application; 7 | 8 | import org.apache.cxf.jaxrs.swagger.Swagger2Feature; 9 | 10 | import com.sap.primetime.api.util.GsonMessageBodyHandler; 11 | 12 | 13 | public class ServiceRegistry extends Application { 14 | private Set singletons = new HashSet<>(); 15 | 16 | public ServiceRegistry() { 17 | singletons.add(new GsonMessageBodyHandler<>()); 18 | 19 | singletons.add(new PlaylistService()); 20 | singletons.add(new DBService()); 21 | singletons.add(new FileService()); 22 | singletons.add(new PageService()); 23 | singletons.add(new ScreenService()); 24 | singletons.add(new SystemService()); 25 | singletons.add(new UserService()); 26 | 27 | // Swagger API Documentation 28 | // More Swagger settings in swagger.properties 29 | Swagger2Feature feature = new Swagger2Feature(); 30 | feature.setPrettyPrint(true); 31 | feature.setBasePath("/s/api"); 32 | singletons.add(feature); 33 | } 34 | 35 | @Override 36 | public Set getSingletons() { 37 | return singletons; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/api/UserService.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.api; 2 | 3 | import javax.ws.rs.DELETE; 4 | import javax.ws.rs.GET; 5 | import javax.ws.rs.POST; 6 | import javax.ws.rs.Path; 7 | import javax.ws.rs.PathParam; 8 | import javax.ws.rs.Produces; 9 | import javax.ws.rs.core.MediaType; 10 | import javax.ws.rs.core.Response; 11 | 12 | import com.sap.primetime.dao.OwnerDAO; 13 | import com.sap.primetime.dao.UserDAO; 14 | import com.sap.primetime.dao.entities.User; 15 | 16 | import io.swagger.annotations.Api; 17 | 18 | @Api(value = "Users") 19 | @Path("userservice") 20 | public class UserService extends BasicService { 21 | @GET 22 | @Path("/user") 23 | @Produces(MediaType.APPLICATION_JSON) 24 | public User getCurrentUser() { 25 | return userUtil.getLoggedInDBUser(request); 26 | } 27 | 28 | @GET 29 | @Path("/users/{userId}") 30 | @Produces(MediaType.APPLICATION_JSON) 31 | public User getUser(@PathParam("userId") long userId) { 32 | return getExistingUser(userId); 33 | } 34 | 35 | @DELETE 36 | @Path("/users/{userId}") 37 | public Response deleteUser(@PathParam("userId") long userId) { 38 | if (!isDBAdmin()) { 39 | throwUnauthorized(); 40 | } 41 | User existingUser = getExistingUser(userId); 42 | 43 | // remove references 44 | new OwnerDAO().deleteByField("user.id", existingUser.getId()); 45 | 46 | return (new UserDAO().deleteByField("userId", existingUser.getUserId())) ? RESPONSE_OK : RESPONSE_BAD; 47 | } 48 | 49 | @POST 50 | @Path("/users/{userId}/impersonate") 51 | public Response impersonateUser(@PathParam("userId") long userId) { 52 | if (!isAdmin()) { 53 | throwUnauthorized(); 54 | } 55 | User existingUser = getExistingUser(userId); 56 | 57 | userUtil.impersonateUser(request, existingUser.getUserId()); 58 | 59 | return RESPONSE_OK; 60 | } 61 | 62 | @POST 63 | @Path("/stopimpersonation") 64 | public Response stopImpersonation() { 65 | if (!isAdmin()) { 66 | throwUnauthorized(); 67 | } 68 | 69 | userUtil.stopImpersonation(request); 70 | 71 | return RESPONSE_OK; 72 | } 73 | 74 | @POST 75 | @Path("/logout") 76 | public Response logoutCurrentUser() { 77 | request.getSession().invalidate(); 78 | userUtil.logOut(request); 79 | 80 | return RESPONSE_OK; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/api/util/JsonIgnore.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.api.util; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Indicates that a field should not be rendered in JSON 10 | */ 11 | @Target(ElementType.FIELD) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface JsonIgnore { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/ConfigDAO.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.TypedQuery; 7 | 8 | import com.sap.primetime.adapters.PersistenceAdapter; 9 | import com.sap.primetime.dao.entities.Config; 10 | 11 | public class ConfigDAO extends BasicDAO { 12 | public static List getByGroup(String group) { 13 | EntityManager em = PersistenceAdapter.getEntityManager(); 14 | 15 | TypedQuery query = em.createNamedQuery(Config.QUERY_BYGROUP, Config.class); 16 | query.setParameter("group", group); 17 | List configs = query.getResultList(); 18 | 19 | return configs; 20 | } 21 | 22 | public static boolean deleteConfig(String group, String key) { 23 | EntityManager em = PersistenceAdapter.getEntityManager(); 24 | boolean closeTransaction = PersistenceAdapter.beginTransactionOnDemand(em); 25 | 26 | int deleteCount = em.createNamedQuery(Config.QUERY_DELETE).setParameter("group", group).setParameter("key", key) 27 | .executeUpdate(); 28 | 29 | PersistenceAdapter.commitTransactionOnDemand(em, closeTransaction); 30 | 31 | return deleteCount > 0; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/EventHistoryDAO.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao; 2 | 3 | import com.sap.primetime.dao.entities.EventHistory; 4 | 5 | public class EventHistoryDAO extends BasicDAO { 6 | } 7 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/FileDAO.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.EntityManager; 6 | 7 | import com.sap.primetime.adapters.PersistenceAdapter; 8 | import com.sap.primetime.dao.entities.File; 9 | import com.sap.primetime.dao.entities.User; 10 | 11 | public class FileDAO extends BasicDAO { 12 | public static List getFilesForUser(User user) { 13 | EntityManager em = PersistenceAdapter.getEntityManager(); 14 | 15 | return em.createNamedQuery(File.QUERY_BYUSER, File.class).setParameter("user", user).getResultList(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/OwnerDAO.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao; 2 | 3 | import com.sap.primetime.dao.entities.Owner; 4 | 5 | public class OwnerDAO extends BasicDAO { 6 | } 7 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/PageDAO.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.persistence.EntityManager; 7 | import javax.persistence.TypedQuery; 8 | 9 | import com.sap.primetime.adapters.PersistenceAdapter; 10 | import com.sap.primetime.dao.entities.File; 11 | import com.sap.primetime.dao.entities.Page; 12 | import com.sap.primetime.dao.entities.User; 13 | 14 | public class PageDAO extends BasicDAO { 15 | public static List getPagesForUser(User user) { 16 | EntityManager em = PersistenceAdapter.getEntityManager(); 17 | 18 | return em.createNamedQuery(Page.QUERY_BYUSER, Page.class).setParameter("user", user).getResultList(); 19 | } 20 | 21 | public static List getAdvertisedPages(int maxResults) { 22 | EntityManager em = PersistenceAdapter.getEntityManager(); 23 | 24 | TypedQuery query = em.createNamedQuery(Page.QUERY_ADVERTISED, Page.class); 25 | if (maxResults > 0) { 26 | query.setMaxResults(maxResults); 27 | } 28 | 29 | return query.getResultList(); 30 | } 31 | 32 | public static List getNextPagesWithoutAutoScreenshot(int maxResults) { 33 | EntityManager em = PersistenceAdapter.getEntityManager(); 34 | 35 | return em.createNamedQuery(Page.QUERY_WITHOUTSCREENSHOT, Page.class).setMaxResults(maxResults).getResultList(); 36 | } 37 | 38 | public static List getNextPageForAutoScreenshot(int maxResults) { 39 | EntityManager em = PersistenceAdapter.getEntityManager(); 40 | 41 | return em.createNamedQuery(Page.QUERY_AUTOSCREENSHOT, Page.class).setMaxResults(maxResults).getResultList(); 42 | } 43 | 44 | public static List getPagesByFileOrWithTemplate(File file) { 45 | EntityManager em = PersistenceAdapter.getEntityManager(); 46 | 47 | return em.createNamedQuery(Page.QUERY_BYFILEORWITHTEMPLATE, Page.class).setParameter("file", file) 48 | .getResultList(); 49 | } 50 | 51 | public static List getPageCatalog(User user) { 52 | List result = new ArrayList<>(); 53 | EntityManager em = PersistenceAdapter.getEntityManager(); 54 | 55 | List pages = em.createNamedQuery(Page.QUERY_CATALOG, Page.class).setParameter("user", user) 56 | .getResultList(); 57 | 58 | // determine distinct set manually since HANA does not support distinct selects 59 | // with LOBs 60 | long lastId = 0; 61 | for (Page page : pages) { 62 | if (page.getId() != lastId) { 63 | result.add(page); 64 | } 65 | lastId = page.getId(); 66 | } 67 | return result; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/PageReferenceDAO.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao; 2 | 3 | import javax.persistence.EntityManager; 4 | import javax.persistence.Query; 5 | 6 | import com.sap.primetime.adapters.PersistenceAdapter; 7 | import com.sap.primetime.dao.entities.Page; 8 | import com.sap.primetime.dao.entities.PageReference; 9 | 10 | public class PageReferenceDAO extends BasicDAO { 11 | public int deleteByPage(Page page) { 12 | EntityManager em = PersistenceAdapter.getEntityManager(); 13 | boolean closeTransaction = PersistenceAdapter.beginTransactionOnDemand(em); 14 | 15 | Query query = em.createNamedQuery(PageReference.QUERY_DELETEBYPAGE).setParameter("page", page); 16 | int count = query.executeUpdate(); 17 | 18 | PersistenceAdapter.commitTransactionOnDemand(em, closeTransaction); 19 | 20 | return count; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/UserDAO.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao; 2 | 3 | import javax.persistence.EntityManager; 4 | import javax.persistence.NoResultException; 5 | import javax.persistence.NonUniqueResultException; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import com.sap.primetime.adapters.PersistenceAdapter; 11 | import com.sap.primetime.dao.entities.User; 12 | 13 | public class UserDAO extends BasicDAO { 14 | private static final Logger logger = LoggerFactory.getLogger(UserDAO.class); 15 | 16 | public static User getUserByUserId(String userId) { 17 | EntityManager em = PersistenceAdapter.getEntityManager(); 18 | 19 | return getUserByUserId(userId, em); 20 | } 21 | 22 | public static User getUserByUserId(String userId, EntityManager em) { 23 | try { 24 | return (User) em.createNamedQuery(User.QUERY_BYUSERID).setParameter("userId", userId).getSingleResult(); 25 | } catch (NoResultException e) { 26 | return null; 27 | } catch (NonUniqueResultException e) { 28 | logger.error("User appears multiple times. This could mean severe database corruption. Fix immediately.", e); 29 | throw e; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/dto/ApplianceError.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.dto; 2 | 3 | import java.util.Date; 4 | 5 | public class ApplianceError { 6 | private String stacktrace; 7 | private Date timestamp; 8 | private String exception; 9 | private String reason; 10 | private String version; 11 | 12 | public ApplianceError() { 13 | } 14 | 15 | public ApplianceError(String stacktrace, Date timestamp, String exception, String reason, String version) { 16 | this.stacktrace = stacktrace; 17 | this.timestamp = timestamp; 18 | this.exception = exception; 19 | this.reason = reason; 20 | this.version = version; 21 | } 22 | 23 | public String getStacktrace() { 24 | return stacktrace; 25 | } 26 | 27 | public void setStacktrace(String stacktrace) { 28 | this.stacktrace = stacktrace; 29 | } 30 | 31 | public Date getTimestamp() { 32 | return timestamp; 33 | } 34 | 35 | public void setTimestamp(Date timestamp) { 36 | this.timestamp = timestamp; 37 | } 38 | 39 | public String getException() { 40 | return exception; 41 | } 42 | 43 | public void setException(String exception) { 44 | this.exception = exception; 45 | } 46 | 47 | public String getReason() { 48 | return reason; 49 | } 50 | 51 | public void setReason(String reason) { 52 | this.reason = reason; 53 | } 54 | 55 | public String getVersion() { 56 | return version; 57 | } 58 | 59 | public void setVersion(String version) { 60 | this.version = version; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/dto/ApplianceInfo.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.dto; 2 | 3 | import java.util.Date; 4 | 5 | public class ApplianceInfo { 6 | private ApplianceError dump; 7 | private Date timestamp; 8 | private String version; 9 | 10 | public ApplianceInfo() { 11 | } 12 | 13 | public ApplianceInfo(ApplianceError dump, Date timestamp, String version) { 14 | this.dump = dump; 15 | this.timestamp = timestamp; 16 | this.version = version; 17 | } 18 | 19 | public ApplianceError getDump() { 20 | return dump; 21 | } 22 | 23 | public void setDump(ApplianceError dump) { 24 | this.dump = dump; 25 | } 26 | 27 | public Date getTimestamp() { 28 | return timestamp; 29 | } 30 | 31 | public void setTimestamp(Date timestamp) { 32 | this.timestamp = timestamp; 33 | } 34 | 35 | public String getVersion() { 36 | return version; 37 | } 38 | 39 | public void setVersion(String version) { 40 | this.version = version; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/dto/FileReferences.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.dto; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.sap.primetime.dao.entities.Page; 7 | 8 | public class FileReferences { 9 | private List userPages = new ArrayList<>(); 10 | private long foreignPages; 11 | 12 | public List getUserPages() { 13 | return userPages; 14 | } 15 | 16 | public void setUserPages(List userPages) { 17 | this.userPages = userPages; 18 | } 19 | 20 | public void addUserPage(Page page) { 21 | this.userPages.add(page); 22 | } 23 | 24 | public long getForeignPages() { 25 | return foreignPages; 26 | } 27 | 28 | public void setForeignPages(long foreignPages) { 29 | this.foreignPages = foreignPages; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/dto/PageReferences.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.dto; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.sap.primetime.dao.entities.Playlist; 7 | 8 | public class PageReferences { 9 | private List userPlaylists = new ArrayList<>(); 10 | private long foreignPlaylists; 11 | 12 | public List getUserPlaylists() { 13 | return userPlaylists; 14 | } 15 | 16 | public void setUserPlaylists(List userPlaylists) { 17 | this.userPlaylists = userPlaylists; 18 | } 19 | 20 | public void addUserPlaylist(Playlist playlist) { 21 | this.userPlaylists.add(playlist); 22 | } 23 | 24 | public long getForeignPlaylists() { 25 | return foreignPlaylists; 26 | } 27 | 28 | public void setForeignPlaylists(long foreignPlaylists) { 29 | this.foreignPlaylists = foreignPlaylists; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/dto/PlaylistReferences.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.dto; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.sap.primetime.dao.entities.Playlist; 7 | import com.sap.primetime.dao.entities.Screen; 8 | 9 | public class PlaylistReferences { 10 | private List userScreens = new ArrayList<>(); 11 | private long foreignScreens; 12 | private List userPlaylists = new ArrayList<>(); 13 | private long foreignPlaylists; 14 | 15 | public List getUserScreens() { 16 | return userScreens; 17 | } 18 | 19 | public void setUserScreens(List userScreens) { 20 | this.userScreens = userScreens; 21 | } 22 | 23 | public void addUserScreen(Screen screen) { 24 | this.userScreens.add(screen); 25 | } 26 | 27 | public long getForeignScreens() { 28 | return foreignScreens; 29 | } 30 | 31 | public void setForeignScreens(long foreignScreens) { 32 | this.foreignScreens = foreignScreens; 33 | } 34 | 35 | public List getUserPlaylists() { 36 | return userPlaylists; 37 | } 38 | 39 | public void setUserPlaylists(List userPlaylists) { 40 | this.userPlaylists = userPlaylists; 41 | } 42 | 43 | public void addUserPlaylist(Playlist playlist) { 44 | this.userPlaylists.add(playlist); 45 | } 46 | 47 | public long getForeignPlaylists() { 48 | return foreignPlaylists; 49 | } 50 | 51 | public void setForeignPlaylists(long foreignPlaylists) { 52 | this.foreignPlaylists = foreignPlaylists; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/entities/BasicEntity.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.entities; 2 | 3 | import java.util.Date; 4 | 5 | import javax.persistence.MappedSuperclass; 6 | import javax.persistence.PrePersist; 7 | import javax.persistence.PreUpdate; 8 | import javax.persistence.Temporal; 9 | import javax.persistence.TemporalType; 10 | 11 | import org.joda.time.DateTime; 12 | 13 | /** 14 | * Commonly needed attributes of all entities. 15 | * 16 | */ 17 | @MappedSuperclass 18 | public abstract class BasicEntity { 19 | @Temporal(TemporalType.TIMESTAMP) 20 | private Date dateCreated; 21 | @Temporal(TemporalType.TIMESTAMP) 22 | private Date dateModified; 23 | 24 | public Date getDateCreated() { 25 | return dateCreated; 26 | } 27 | 28 | public void setDateCreated(Date dateCreated) { 29 | this.dateCreated = dateCreated; 30 | } 31 | 32 | public void setDateCreated(DateTime dateCreated) { 33 | this.dateCreated = dateCreated.toDate(); 34 | } 35 | 36 | public Date getDateModified() { 37 | return dateModified; 38 | } 39 | 40 | public void setDateModified(Date dateModified) { 41 | this.dateModified = dateModified; 42 | } 43 | 44 | @PreUpdate 45 | @PrePersist 46 | public void updateTimeStamps() { 47 | if (dateCreated == null) { 48 | dateCreated = new Date(); 49 | } 50 | setDateModified(new Date()); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/entities/Config.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.entities; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.Id; 6 | import javax.persistence.IdClass; 7 | import javax.persistence.NamedQueries; 8 | import javax.persistence.NamedQuery; 9 | import javax.persistence.Table; 10 | 11 | @Table(name = "Configurations") 12 | @NamedQueries({ 13 | @NamedQuery(name = Config.QUERY_BYGROUP, query = "SELECT c FROM Config c WHERE c.paramGroup = :group order by c.paramGroup"), 14 | @NamedQuery(name = Config.QUERY_DELETE, query = "DELETE FROM Config c WHERE c.paramGroup = :group and c.paramKey = :key") }) 15 | @IdClass(ConfigPK.class) 16 | @Entity 17 | public class Config extends TenantAwareEntity { 18 | public static final String QUERY_BYGROUP = "getConfigByGroup"; 19 | public static final String QUERY_DELETE = "deleteConfigById"; 20 | 21 | @Id 22 | private String paramGroup; 23 | @Id 24 | private String paramKey; 25 | @Column(length = 4000) 26 | private String paramValue; 27 | 28 | public Config() { 29 | } 30 | 31 | public Config(String group, String key, String value) { 32 | this.paramGroup = group; 33 | this.paramKey = key; 34 | this.paramValue = value; 35 | } 36 | 37 | public String getParamGroup() { 38 | return paramGroup; 39 | } 40 | 41 | public void setParamGroup(String paramGroup) { 42 | this.paramGroup = paramGroup; 43 | } 44 | 45 | public String getParamKey() { 46 | return paramKey; 47 | } 48 | 49 | public void setParamKey(String paramKey) { 50 | this.paramKey = paramKey; 51 | } 52 | 53 | public String getParamValue() { 54 | return paramValue; 55 | } 56 | 57 | public void setParamValue(String paramValue) { 58 | this.paramValue = paramValue; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return "Config [paramGroup=" + paramGroup + ", paramKey=" + paramKey + ", paramValue=" + paramValue + "]"; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/entities/ConfigPK.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.entities; 2 | 3 | import java.io.Serializable; 4 | 5 | public class ConfigPK implements Serializable { 6 | private static final long serialVersionUID = 5730873049224049200L; 7 | private String paramGroup; 8 | private String paramKey; 9 | 10 | public ConfigPK() { 11 | } 12 | 13 | public String getParamGroup() { 14 | return paramGroup; 15 | } 16 | 17 | public void setParamGroup(String paramGroup) { 18 | this.paramGroup = paramGroup; 19 | } 20 | 21 | public String getParamKey() { 22 | return paramKey; 23 | } 24 | 25 | public void setParamKey(String paramKey) { 26 | this.paramKey = paramKey; 27 | } 28 | 29 | @Override 30 | public int hashCode() { 31 | final int prime = 31; 32 | int result = 1; 33 | result = prime * result + ((paramGroup == null) ? 0 : paramGroup.hashCode()); 34 | result = prime * result + ((paramKey == null) ? 0 : paramKey.hashCode()); 35 | return result; 36 | } 37 | 38 | @Override 39 | public boolean equals(Object obj) { 40 | if (this == obj) { 41 | return true; 42 | } 43 | if (obj == null) { 44 | return false; 45 | } 46 | if (getClass() != obj.getClass()) { 47 | return false; 48 | } 49 | ConfigPK other = (ConfigPK) obj; 50 | if (paramGroup == null) { 51 | if (other.paramGroup != null) { 52 | return false; 53 | } 54 | } else if (!paramGroup.equals(other.paramGroup)) { 55 | return false; 56 | } 57 | if (paramKey == null) { 58 | if (other.paramKey != null) { 59 | return false; 60 | } 61 | } else if (!paramKey.equals(other.paramKey)) { 62 | return false; 63 | } 64 | return true; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/entities/EventHistory.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.entities; 2 | 3 | import java.util.Date; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.Table; 10 | import javax.persistence.Temporal; 11 | import javax.persistence.TemporalType; 12 | 13 | import org.eclipse.persistence.annotations.Index; 14 | 15 | @Table(name = "EventHistory") 16 | @Entity 17 | public class EventHistory extends TenantAwareEntity { 18 | public enum EventType { 19 | ScreenAlive 20 | } 21 | 22 | @Id 23 | @GeneratedValue(strategy = GenerationType.TABLE) 24 | private long id; 25 | @Index 26 | private long entityId; 27 | private EventType eventType = EventType.ScreenAlive; 28 | @Temporal(TemporalType.TIMESTAMP) 29 | private Date eventDate; 30 | 31 | public EventHistory() { 32 | } 33 | 34 | public EventHistory(long entityId, Date eventDate) { 35 | this.entityId = entityId; 36 | this.eventDate = eventDate; 37 | } 38 | 39 | public long getId() { 40 | return id; 41 | } 42 | 43 | public long getEntityId() { 44 | return entityId; 45 | } 46 | 47 | public void setEntityId(long entityId) { 48 | this.entityId = entityId; 49 | } 50 | 51 | public EventType getEventType() { 52 | return eventType; 53 | } 54 | 55 | public void setEventType(EventType eventType) { 56 | this.eventType = eventType; 57 | } 58 | 59 | public Date getEventDate() { 60 | return eventDate; 61 | } 62 | 63 | public void setEventDate(Date eventDate) { 64 | this.eventDate = eventDate; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/entities/Owner.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.entities; 2 | 3 | import javax.persistence.CascadeType; 4 | import javax.persistence.Column; 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.JoinColumn; 10 | import javax.persistence.ManyToOne; 11 | import javax.persistence.PostLoad; 12 | import javax.persistence.Table; 13 | 14 | @Table(name = "Owners") 15 | @Entity 16 | public class Owner extends TenantAwareEntity { 17 | public enum Role { 18 | ADMINISTRATOR, CONTENT_MANAGER 19 | } 20 | 21 | @Id 22 | @GeneratedValue(strategy = GenerationType.TABLE) 23 | private long id; 24 | @ManyToOne(cascade = CascadeType.DETACH) 25 | @JoinColumn(name = "USER_ID") 26 | private User user; 27 | @Column(name = "\"ROLE\"") 28 | private Role role = Role.ADMINISTRATOR; 29 | private boolean contact = true; 30 | 31 | public Owner() { 32 | } 33 | 34 | public Owner(User user) { 35 | this.setUser(user); 36 | } 37 | 38 | public Owner(User user, Role role) { 39 | this.setUser(user); 40 | this.setRole(role); 41 | } 42 | 43 | public long getId() { 44 | return id; 45 | } 46 | 47 | public User getUser() { 48 | return user; 49 | } 50 | 51 | public void setUser(User user) { 52 | this.user = user; 53 | } 54 | 55 | public Role getRole() { 56 | return role; 57 | } 58 | 59 | public void setRole(Role role) { 60 | this.role = role; 61 | } 62 | 63 | public boolean isContact() { 64 | return contact; 65 | } 66 | 67 | public void setContact(boolean contact) { 68 | this.contact = contact; 69 | } 70 | 71 | @PostLoad 72 | private void updateDynamicValues() { 73 | // FIXME: why is this needed, user should have executed this already 74 | user.updateDynamicValues(); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/entities/OwnerSupport.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.entities; 2 | 3 | import java.util.List; 4 | 5 | public interface OwnerSupport { 6 | public List getOwners(); 7 | 8 | public void setOwners(List owners); 9 | 10 | public void addOwner(Owner owner); 11 | 12 | } -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/dao/entities/TenantAwareEntity.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.dao.entities; 2 | 3 | import javax.persistence.MappedSuperclass; 4 | 5 | import org.eclipse.persistence.annotations.Multitenant; 6 | import org.eclipse.persistence.annotations.TenantDiscriminatorColumn; 7 | 8 | /** 9 | * Tenant enabling for tables which depend on tenants. 10 | * 11 | */ 12 | @MappedSuperclass 13 | @Multitenant 14 | @TenantDiscriminatorColumn(contextProperty = "eclipselink.tenant-id", length = 50) 15 | public abstract class TenantAwareEntity extends BasicEntity { 16 | } -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/jobs/DBCleanUpJob.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.jobs; 2 | 3 | import java.text.MessageFormat; 4 | import java.util.List; 5 | 6 | import org.joda.time.DateTime; 7 | import org.quartz.DisallowConcurrentExecution; 8 | import org.quartz.Job; 9 | import org.quartz.JobExecutionContext; 10 | import org.quartz.JobExecutionException; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | import com.sap.primetime.dao.EventHistoryDAO; 15 | import com.sap.primetime.dao.ScreenDAO; 16 | import com.sap.primetime.dao.entities.Screen; 17 | 18 | @DisallowConcurrentExecution 19 | public class DBCleanUpJob implements Job { 20 | private static final Logger logger = LoggerFactory.getLogger(DBCleanUpJob.class); 21 | 22 | @Override 23 | public void execute(JobExecutionContext context) throws JobExecutionException { 24 | deleteOutdatedEvents(); 25 | deleteOutdatedOnboardings(); 26 | } 27 | 28 | private void deleteOutdatedEvents() { 29 | DateTime threshold = DateTime.now().minusDays(7); 30 | int deletedCount = new EventHistoryDAO().deleteAllBefore(threshold); 31 | if (deletedCount > 0) { 32 | logger.info(MessageFormat.format("Deleted {0} outdated events from before {1}.", deletedCount, threshold)); 33 | } 34 | } 35 | 36 | private void deleteOutdatedOnboardings() { 37 | DateTime threshold = DateTime.now().minusDays(3); 38 | 39 | List screens = new ScreenDAO().getAll(); 40 | 41 | int deletedCount = 0; 42 | for (Screen screen : screens) { 43 | if (screen.getOwners().isEmpty() && threshold.isAfter(screen.getDateCreated().getTime())) { 44 | new ScreenDAO().deleteById(screen.getId()); 45 | deletedCount += 1; 46 | } 47 | } 48 | 49 | if (deletedCount > 0) { 50 | logger.info(MessageFormat.format("Deleted {0} outdated onboarding requests from before {1}.", deletedCount, 51 | threshold)); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/startup/JobsInitializer.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.startup; 2 | 3 | import static org.quartz.CronScheduleBuilder.cronSchedule; 4 | import static org.quartz.JobBuilder.newJob; 5 | import static org.quartz.TriggerBuilder.newTrigger; 6 | 7 | import org.quartz.CronTrigger; 8 | import org.quartz.JobDetail; 9 | import org.quartz.ObjectAlreadyExistsException; 10 | import org.quartz.Scheduler; 11 | import org.quartz.SchedulerException; 12 | import org.quartz.SchedulerFactory; 13 | import org.quartz.Trigger; 14 | import org.quartz.impl.StdSchedulerFactory; 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | 18 | import com.sap.primetime.jobs.DBCleanUpJob; 19 | import com.sap.primetime.util.Consts; 20 | import com.sap.primetime.util.configuration.ConfigUtil; 21 | 22 | public class JobsInitializer { 23 | private static Logger logger = LoggerFactory.getLogger(JobsInitializer.class); 24 | private static Scheduler scheduler; 25 | 26 | public static void shutDown() { 27 | if (scheduler != null) { 28 | try { 29 | scheduler.shutdown(); 30 | } catch (SchedulerException e) { 31 | logger.error("Job scheduler could not be shut down.", e); 32 | } 33 | } 34 | } 35 | 36 | public static Scheduler getScheduler() { 37 | return scheduler; 38 | } 39 | 40 | /** 41 | * Schedules all background jobs 42 | * 43 | * Important: Group names must be equal to the job name currently for manually 44 | * triggering jobs via REST 45 | */ 46 | public static void initScheduler() { 47 | try { 48 | // shutdown existing scheduler 49 | if (scheduler != null) { 50 | logger.info("Shutting down Quartz..."); 51 | scheduler.shutdown(true); 52 | logger.info("Shutdown complete."); 53 | } 54 | 55 | SchedulerFactory sf = new StdSchedulerFactory(); 56 | scheduler = sf.getScheduler(); 57 | scheduler.start(); 58 | 59 | JobDetail jobDetail = newJob(DBCleanUpJob.class).withIdentity("DBCleanUp", "DBCleanUp").build(); 60 | String jobSchedule = ConfigUtil.getProperty(Consts.APP, Consts.PROP_CRON_DBCLEANUP); 61 | CronTrigger cronTrigger = newTrigger().withIdentity("cronTrigger", "DBCleanUp") 62 | .withSchedule(cronSchedule(jobSchedule)).build(); 63 | scheduleJob(jobDetail, cronTrigger); 64 | } catch (SchedulerException e) { 65 | logger.error("Job scheduler could not be started.", e); 66 | } 67 | } 68 | 69 | private static void scheduleJob(JobDetail jobDetail, Trigger trigger) throws SchedulerException { 70 | try { 71 | scheduler.scheduleJob(jobDetail, trigger); 72 | } catch (ObjectAlreadyExistsException e) { 73 | scheduler.rescheduleJob(trigger.getKey(), trigger); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/Consts.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util; 2 | 3 | import org.joda.time.format.DateTimeFormat; 4 | import org.joda.time.format.DateTimeFormatter; 5 | 6 | import com.google.inject.Injector; 7 | 8 | public class Consts { 9 | public static final String VERSION = "1.7.1"; 10 | public static final int xDim = 350; 11 | public static final int yDim = 197; 12 | public static final int BUFFER_SIZE = 16 * 1024; 13 | public static final int BackendTimeout = 3000; 14 | 15 | public static final String DATEFORMAT = "yyyy-MM-dd'T'HH:mm:ss Z"; 16 | public static final DateTimeFormatter formatter = DateTimeFormat.forPattern(Consts.DATEFORMAT); 17 | 18 | public static final String APP = "app"; 19 | public static final String PROP_ADMINISTRATORS = "administrators"; 20 | public static final String PROP_USERIDPATTERN = "userIdPattern"; 21 | public static final String PROP_CRON_DBCLEANUP = "cronDBCleanUp"; 22 | public static final String PROP_APPURL = "appUrl"; 23 | public static final String PROP_AVATARURL = "avatarUrl"; 24 | public static final String PROP_PROFILEURL = "profileUrl"; 25 | public static final String PROP_BUILDTIME = "buildTimestamp"; 26 | public static final String PROP_FILESUPPORT = "fileSupport"; 27 | public static final String PROP_LOGOUTURL = "logoutUrl"; 28 | public static final String PROP_GETTINGSTARTEDURL = "gettingStartedUrl"; 29 | public static final String PROP_DEVELOPMENTURL = "developmentUrl"; 30 | public static final String PROP_NEWSURL = "newsUrl"; 31 | public static final String PROP_ANALYTICSTOKEN = "analyticsToken"; 32 | public static final String PROP_RECOMMENDEDAPPLETVAPPVERSION = "recommendedAppleTVAppVersion"; 33 | public static final String PROP_INFOCONDITION = "infoCondition"; 34 | public static final String PROP_INFOTEXT = "infoText"; 35 | public static final String PROP_INFOLINK = "infoLink"; 36 | 37 | public static final String APPLIANCE = "appliance"; 38 | public static final String PROP_CONFIGREFRESHINTERVAL = "configRefreshInterval"; 39 | public static final String PROP_RELOADINTERVAL = "reloadInterval"; 40 | public static final String PROP_SCREENSHOTINTERVAL = "screenshotInterval"; 41 | public static final String PROP_TECHNICALUSER = "technicalUser"; 42 | 43 | // only needed for testing, actually not a good practice to store injector 44 | // globally 45 | public static Injector injector; 46 | } 47 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/HTTPRange.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util; 2 | 3 | public class HTTPRange { 4 | private long start; 5 | private long end; 6 | private long total; 7 | 8 | public HTTPRange(long start, long end, long total) { 9 | this.start = start; 10 | this.end = end; 11 | this.total = total; 12 | } 13 | 14 | public long getLength() { 15 | return getEnd() - getStart() + 1; 16 | } 17 | 18 | public long getStart() { 19 | return start; 20 | } 21 | 22 | public long getEnd() { 23 | return end; 24 | } 25 | 26 | public long getTotal() { 27 | return total; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/SecurityUtil.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util; 2 | 3 | import org.jsoup.Jsoup; 4 | 5 | public class SecurityUtil { 6 | public static String textOnly(String html) { 7 | if (html == null) { 8 | return null; 9 | } 10 | String text = Jsoup.parse(html.replaceAll("\n", "br2n")).text(); 11 | text = text.replaceAll("br2n", "\n"); 12 | 13 | return text; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/TemplateHelper.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import com.google.gson.Gson; 6 | import com.google.gson.JsonElement; 7 | import com.google.gson.JsonObject; 8 | import com.google.gson.JsonParser; 9 | import com.sap.primetime.dao.entities.File; 10 | 11 | public class TemplateHelper { 12 | private TemplateParam[] params; 13 | 14 | public TemplateHelper(String params) { 15 | if (params != null) { 16 | Gson gson = new Gson(); 17 | this.params = gson.fromJson(params, TemplateParam[].class); 18 | } 19 | } 20 | 21 | public String replace(String text, String values) { 22 | if (params == null) { 23 | return text; 24 | } 25 | JsonObject obj = parseValues(values); 26 | 27 | for (TemplateParam p : params) { 28 | String value = "-missing value-"; 29 | if (obj != null && obj.has(p.getKey())) { 30 | value = obj.get(p.getKey()).getAsString(); 31 | if ("file".equalsIgnoreCase(p.getType())) { 32 | value = "/s/api/fileservice/files/" + value + "/content"; 33 | } 34 | } else if ("file".equalsIgnoreCase(p.getType())) { 35 | value = "/ui/img/image_preview.png"; 36 | } 37 | text = StringUtils.replace(text, "{{" + p.getKey() + "}}", value); 38 | } 39 | 40 | return text; 41 | } 42 | 43 | public boolean containsFile(File file, String values) { 44 | JsonObject obj = parseValues(values); 45 | if (obj == null) { 46 | return false; 47 | } 48 | 49 | for (TemplateParam p : params) { 50 | if ("file".equalsIgnoreCase(p.getType()) && obj.has(p.getKey()) 51 | && obj.get(p.getKey()).getAsLong() == file.getId()) { 52 | return true; 53 | } 54 | } 55 | 56 | return false; 57 | } 58 | 59 | private JsonObject parseValues(String values) { 60 | JsonObject obj = null; 61 | if (StringUtils.isNotEmpty(values)) { 62 | JsonParser parser = new JsonParser(); 63 | JsonElement element = parser.parse(values); 64 | obj = element.getAsJsonObject(); 65 | } 66 | return obj; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/TemplateParam.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util; 2 | 3 | public class TemplateParam { 4 | private String key; 5 | private String name; 6 | private String type; 7 | 8 | public String getKey() { 9 | return key; 10 | } 11 | 12 | public void setKey(String key) { 13 | this.key = key; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public String getType() { 25 | return type; 26 | } 27 | 28 | public void setType(String type) { 29 | this.type = type; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/UploadHandler.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util; 2 | 3 | import java.util.Iterator; 4 | import java.util.List; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | 8 | import org.apache.commons.fileupload.FileItem; 9 | import org.apache.commons.fileupload.FileItemFactory; 10 | import org.apache.commons.fileupload.FileUploadException; 11 | import org.apache.commons.fileupload.disk.DiskFileItemFactory; 12 | import org.apache.commons.fileupload.servlet.ServletFileUpload; 13 | 14 | public class UploadHandler { 15 | public static FileItem getUploadedDocument(HttpServletRequest request) throws FileUploadException { 16 | FileItemFactory factory = new DiskFileItemFactory(); 17 | ServletFileUpload upload = new ServletFileUpload(factory); 18 | List items = upload.parseRequest(request); 19 | Iterator iterator = items.iterator(); 20 | FileItem document = iterator.next(); 21 | 22 | return document; 23 | } 24 | } -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/configuration/ConfigAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util.configuration; 2 | 3 | import java.util.Properties; 4 | 5 | public interface ConfigAdapter { 6 | public Properties getByGroup(String group); 7 | 8 | public void save(String group, String key, String value); 9 | 10 | public boolean remove(String group, String key); 11 | } -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/configuration/ConfigDBAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util.configuration; 2 | 3 | import java.util.List; 4 | import java.util.Properties; 5 | 6 | import org.apache.commons.lang3.StringUtils; 7 | 8 | import com.sap.primetime.dao.ConfigDAO; 9 | import com.sap.primetime.dao.entities.Config; 10 | 11 | public class ConfigDBAdapter implements ConfigAdapter { 12 | @Override 13 | public Properties getByGroup(String group) { 14 | Properties groupProperties = new Properties(); 15 | 16 | List configs = ConfigDAO.getByGroup(group); 17 | for (Config config : configs) { 18 | if (StringUtils.isNotBlank(config.getParamKey())) { 19 | groupProperties.put(config.getParamKey(), config.getParamValue() == null ? "" : config.getParamValue()); 20 | } 21 | } 22 | 23 | return groupProperties; 24 | } 25 | 26 | @Override 27 | public void save(String group, String key, String value) { 28 | Config config = new Config(group, key, value); 29 | ConfigDAO.save(config); 30 | } 31 | 32 | @Override 33 | public boolean remove(String group, String key) { 34 | return ConfigDAO.deleteConfig(group, key); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/configuration/ConfigSection.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util.configuration; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class ConfigSection { 7 | private String key; 8 | private String name; 9 | private List parameters = new ArrayList<>(); 10 | 11 | public ConfigSection() { 12 | } 13 | 14 | public ConfigSection(String key, String name) { 15 | this.key = key; 16 | this.name = name; 17 | } 18 | 19 | public String getKey() { 20 | return key; 21 | } 22 | 23 | public void setKey(String key) { 24 | this.key = key; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | public List getParameters() { 36 | return parameters; 37 | } 38 | 39 | public void setParameters(List parameters) { 40 | this.parameters = parameters; 41 | } 42 | 43 | public void addParameter(ConfigSectionParam param) { 44 | parameters.add(param); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "ConfigSection [key=" + key + ", name=" + name + ", parameters=" + parameters + "]"; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/configuration/ConfigSectionParam.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util.configuration; 2 | 3 | import com.sap.primetime.util.configuration.ConfigUtil.Source; 4 | 5 | public class ConfigSectionParam { 6 | public enum Type { 7 | TEXT, PASSWORD, CHECKBOX, TEXTAREA 8 | } 9 | 10 | private String name; 11 | private String key; 12 | private String currentValue; 13 | private String resetValue; 14 | private Type type = Type.TEXT; 15 | private Source source; 16 | private Source resetSource; 17 | 18 | public ConfigSectionParam() { 19 | } 20 | 21 | public ConfigSectionParam(String key, String name) { 22 | this.key = key; 23 | this.name = name; 24 | } 25 | 26 | public ConfigSectionParam(String key, String name, Type type) { 27 | this(key, name); 28 | 29 | this.type = type; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public String getKey() { 41 | return key; 42 | } 43 | 44 | public void setKey(String key) { 45 | this.key = key; 46 | } 47 | 48 | public String getCurrentValue() { 49 | return currentValue; 50 | } 51 | 52 | public void setCurrentValue(String currentValue) { 53 | this.currentValue = currentValue; 54 | } 55 | 56 | public String getResetValue() { 57 | return resetValue; 58 | } 59 | 60 | public void setResetValue(String resetValue) { 61 | this.resetValue = resetValue; 62 | } 63 | 64 | public Type getType() { 65 | return type; 66 | } 67 | 68 | public void setType(Type type) { 69 | this.type = type; 70 | } 71 | 72 | public Source getSource() { 73 | return source; 74 | } 75 | 76 | public void setSource(Source source) { 77 | this.source = source; 78 | } 79 | 80 | public Source getResetSource() { 81 | return resetSource; 82 | } 83 | 84 | public void setResetSource(Source resetSource) { 85 | this.resetSource = resetSource; 86 | } 87 | 88 | @Override 89 | public String toString() { 90 | return "ConfigSectionParam [name=" + name + ", key=" + key + ", currentValue=" + currentValue + ", type=" + type 91 | + "]"; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /common/app/src/main/java/com/sap/primetime/util/configuration/FeatureFlagsProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util.configuration; 2 | 3 | public interface FeatureFlagsProvider { 4 | public Boolean getBooleanProperty(String group, String key); 5 | } 6 | -------------------------------------------------------------------------------- /common/app/src/main/resources/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Web-ContextPath: / 3 | Webapp-Context: / 4 | -------------------------------------------------------------------------------- /common/app/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | org.eclipse.persistence.jpa.PersistenceProvider 7 | 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 16 | 18 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /common/app/src/main/resources/app.properties: -------------------------------------------------------------------------------- 1 | avatarUrl=https://avatars.services.sap.com/images/%firstName%.%lastName%_small.png 2 | cronDBCleanUp=0 0 1 * * ? 3 | buildTimestamp=${maven.build.timestamp} 4 | userIdPattern=[dDiIcCsStTpP][0-9]* 5 | logoutUrl=https://cloudplatform.sap.com 6 | fileSupport=false 7 | recommendedAppleTVAppVersion=1.1.6 -------------------------------------------------------------------------------- /common/app/src/main/resources/appliance.properties: -------------------------------------------------------------------------------- 1 | configRefreshInterval=900 2 | reloadInterval=28800 3 | screenshotInterval=15 4 | -------------------------------------------------------------------------------- /common/app/src/main/resources/db/db.changelog-20181104-Dashboard-Rename.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /common/app/src/main/resources/db/db.changelog-20181113-Cleanup.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /common/app/src/main/resources/db/db.changelog-20181117-Template-Removal.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /common/app/src/main/resources/db/db.changelog.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /common/app/src/main/resources/missing_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/main/resources/missing_screenshot.png -------------------------------------------------------------------------------- /common/app/src/main/resources/swagger.properties: -------------------------------------------------------------------------------- 1 | title = PrimeTime API 2 | description = API for automation and alternative UI implementations 3 | version = 1.6.0+ 4 | contact = Robert Wetzold -------------------------------------------------------------------------------- /common/app/src/main/resources/templateSchema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://primetime.sap.com/template.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "title": "PrimeTime Template", 5 | "required": [ 6 | "name", 7 | "description", 8 | "version", 9 | "screenshot" 10 | ], 11 | "type": "object", 12 | "properties": { 13 | "name": { 14 | "type": "string", 15 | "description": "Template name.", 16 | "$ref": "#/definitions/nonEmptyString" 17 | }, 18 | "description": { 19 | "type": "string", 20 | "description": "Description of the template." 21 | }, 22 | "version": { 23 | "type": "string", 24 | "description": "Version of the template, e.g. 1.0.", 25 | "$ref": "#/definitions/nonEmptyString" 26 | }, 27 | "screenshot": { 28 | "type": "string", 29 | "description": "Name of an image file inside the archive acting as a cover image for the template, e.g. cover.png.", 30 | "$ref": "#/definitions/nonEmptyString" 31 | }, 32 | "parameters": { 33 | "type": "array", 34 | "description": "Parameters that the user can supply.", 35 | "items": { 36 | "$ref": "#/definitions/parameter" 37 | } 38 | } 39 | }, 40 | "definitions": { 41 | "nonEmptyString": { 42 | "type": "string", 43 | "minLength": 1 44 | }, 45 | "parameter": { 46 | "type": "object", 47 | "required": [ 48 | "type", 49 | "key", 50 | "name" 51 | ], 52 | "properties": { 53 | "type": { 54 | "type": "string", 55 | "description": "Type of the parameter.", 56 | "enum": [ 57 | "text", 58 | "file" 59 | ] 60 | }, 61 | "key": { 62 | "type": "string", 63 | "description": "Technical key for the parameter.", 64 | "$ref": "#/definitions/nonEmptyString" 65 | }, 66 | "name": { 67 | "type": "string", 68 | "description": "Name of the parameter shown in the UI.", 69 | "$ref": "#/definitions/nonEmptyString" 70 | } 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /common/app/src/test/java/com/sap/primetime/testutil/PrincipalMock.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.testutil; 2 | 3 | import java.security.Principal; 4 | 5 | import com.sap.primetime.dao.entities.User; 6 | 7 | public class PrincipalMock implements Principal { 8 | private User user; 9 | 10 | public PrincipalMock(User user) { 11 | this.user = user; 12 | } 13 | 14 | @Override 15 | public String getName() { 16 | return user.getUserId(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /common/app/src/test/java/com/sap/primetime/testutil/TestCMISProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.testutil; 2 | 3 | import org.apache.chemistry.opencmis.client.api.Session; 4 | 5 | import com.sap.primetime.adapters.CMISProvider; 6 | 7 | public class TestCMISProvider implements CMISProvider { 8 | 9 | @Override 10 | public Session getCmisSession() { 11 | // TODO: instantiate InMemory or FileSystem binding 12 | return null; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /common/app/src/test/java/com/sap/primetime/testutil/TestDataSourceProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.testutil; 2 | 3 | import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION; 4 | import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_DRIVER; 5 | import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_PASSWORD; 6 | import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_URL; 7 | import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_USER; 8 | import static org.eclipse.persistence.config.PersistenceUnitProperties.LOGGING_LEVEL; 9 | import static org.eclipse.persistence.config.PersistenceUnitProperties.TARGET_SERVER; 10 | import static org.eclipse.persistence.config.PersistenceUnitProperties.TRANSACTION_TYPE; 11 | 12 | import java.util.Properties; 13 | 14 | import javax.inject.Singleton; 15 | import javax.naming.NamingException; 16 | import javax.persistence.spi.PersistenceUnitTransactionType; 17 | import javax.sql.DataSource; 18 | 19 | import org.eclipse.persistence.config.TargetServer; 20 | import org.eclipse.persistence.logging.SessionLog; 21 | 22 | import com.sap.primetime.adapters.DataSourceProvider; 23 | 24 | @Singleton 25 | public class TestDataSourceProvider implements DataSourceProvider { 26 | private static final String DB_PASSWORD = ""; 27 | private static final String DB_USER = ""; 28 | private static final String DB_DRIVER = "org.apache.derby.jdbc.ClientDriver"; 29 | private static final String DB_CONN = "jdbc:derby:memory:PrimeTimeDB"; 30 | private static final String DB_DDL = "drop-and-create-tables"; 31 | 32 | @Override 33 | public DataSource getDatasource() throws NamingException { 34 | return null; 35 | } 36 | 37 | @Override 38 | public Properties getProperties() { 39 | Properties props = getJPAProperties(); 40 | props.put(JDBC_URL, props.get(JDBC_URL) + ";create=true"); 41 | 42 | return props; 43 | } 44 | 45 | private static Properties getJPAProperties() { 46 | Properties properties = new Properties(); 47 | properties.put(TRANSACTION_TYPE, PersistenceUnitTransactionType.RESOURCE_LOCAL.name()); 48 | properties.put(JDBC_DRIVER, DB_DRIVER); 49 | properties.put(JDBC_URL, DB_CONN); 50 | properties.put(JDBC_USER, DB_USER); 51 | properties.put(JDBC_PASSWORD, DB_PASSWORD); 52 | properties.put(LOGGING_LEVEL, SessionLog.INFO_LABEL); 53 | properties.put(TARGET_SERVER, TargetServer.None); 54 | properties.put(DDL_GENERATION, DB_DDL); 55 | 56 | return properties; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /common/app/src/test/java/com/sap/primetime/testutil/TestFeatureFlagsProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.testutil; 2 | 3 | import com.sap.primetime.util.configuration.FeatureFlagsProvider; 4 | 5 | public class TestFeatureFlagsProvider implements FeatureFlagsProvider { 6 | @Override 7 | public Boolean getBooleanProperty(String group, String key) { 8 | return null; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /common/app/src/test/java/com/sap/primetime/testutil/TestModule.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.testutil; 2 | 3 | import com.google.inject.AbstractModule; 4 | import com.sap.primetime.adapters.CMISProvider; 5 | import com.sap.primetime.adapters.DataSourceProvider; 6 | import com.sap.primetime.adapters.TenantProvider; 7 | import com.sap.primetime.adapters.UserDetailsProvider; 8 | import com.sap.primetime.util.configuration.FeatureFlagsProvider; 9 | 10 | public class TestModule extends AbstractModule { 11 | 12 | @Override 13 | protected void configure() { 14 | bind(UserDetailsProvider.class).to(TestUserDetailsProvider.class); 15 | bind(DataSourceProvider.class).to(TestDataSourceProvider.class); 16 | bind(CMISProvider.class).to(TestCMISProvider.class); 17 | bind(TenantProvider.class).to(TestTenantProvider.class); 18 | bind(FeatureFlagsProvider.class).to(TestFeatureFlagsProvider.class); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /common/app/src/test/java/com/sap/primetime/testutil/TestTenantProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.testutil; 2 | 3 | import javax.inject.Singleton; 4 | 5 | import com.sap.primetime.adapters.TenantProvider; 6 | 7 | @Singleton 8 | public class TestTenantProvider implements TenantProvider { 9 | 10 | @Override 11 | public String getTenantId() { 12 | return "dev_defaultId"; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /common/app/src/test/java/com/sap/primetime/testutil/TestUserDetailsProvider.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.testutil; 2 | 3 | import java.security.Principal; 4 | 5 | import javax.inject.Singleton; 6 | import javax.servlet.ServletRequest; 7 | import javax.servlet.http.HttpServletRequest; 8 | 9 | import com.sap.primetime.adapters.UserDetailsProvider; 10 | import com.sap.primetime.dao.entities.User; 11 | 12 | @Singleton 13 | public class TestUserDetailsProvider implements UserDetailsProvider { 14 | @Override 15 | public User getUserDetails(ServletRequest request) { 16 | Principal principal = ((HttpServletRequest) request).getUserPrincipal(); 17 | return new User(principal.getName()); 18 | } 19 | 20 | @Override 21 | public boolean isAdmin(ServletRequest request) { 22 | return ((HttpServletRequest) request).isUserInRole("admin"); 23 | } 24 | 25 | @Override 26 | public boolean isDBAdmin(ServletRequest request) { 27 | return ((HttpServletRequest) request).isUserInRole("dbadmin"); 28 | } 29 | 30 | @Override 31 | public boolean logOut(HttpServletRequest request) { 32 | return true; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /common/app/src/test/java/com/sap/primetime/testutil/UploadHelper.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.testutil; 2 | 3 | import static org.mockito.Mockito.when; 4 | 5 | import java.io.ByteArrayInputStream; 6 | import java.io.ByteArrayOutputStream; 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | 10 | import javax.servlet.ReadListener; 11 | import javax.servlet.ServletInputStream; 12 | 13 | import org.apache.commons.io.IOUtils; 14 | import org.apache.http.HttpEntity; 15 | import org.apache.http.entity.ContentType; 16 | import org.apache.http.entity.mime.MultipartEntityBuilder; 17 | 18 | public class UploadHelper { 19 | 20 | public static void simulateFileUpload(HttpServletRequestMock requestMock, String fileName, String mimeType) 21 | throws IOException { 22 | 23 | MultipartEntityBuilder builder = MultipartEntityBuilder.create(); 24 | builder = builder.addBinaryBody(fileName, IOUtils.resourceToByteArray("/" + fileName), 25 | ContentType.create(mimeType), fileName); 26 | HttpEntity entity = builder.build(); 27 | 28 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 29 | entity.writeTo(bos); 30 | ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); 31 | 32 | when(requestMock.getMethod()).thenReturn("POST"); 33 | when(requestMock.getContentType()).thenReturn(entity.getContentType().getValue()); 34 | when(requestMock.getContentLength()).thenReturn((int) entity.getContentLength()); 35 | when(requestMock.getInputStream()).thenReturn(new MockServletInputStream(bis)); 36 | } 37 | 38 | public static class MockServletInputStream extends ServletInputStream { 39 | private final InputStream delegate; 40 | 41 | public MockServletInputStream(InputStream delegate) { 42 | this.delegate = delegate; 43 | } 44 | 45 | @Override 46 | public int read() throws IOException { 47 | return delegate.read(); 48 | } 49 | 50 | @Override 51 | public boolean isFinished() { 52 | return true; 53 | } 54 | 55 | @Override 56 | public boolean isReady() { 57 | return true; 58 | } 59 | 60 | @Override 61 | public void setReadListener(ReadListener listener) { 62 | } 63 | 64 | } 65 | } -------------------------------------------------------------------------------- /common/app/src/test/java/com/sap/primetime/util/configuration/ConfigUtilTest.java: -------------------------------------------------------------------------------- 1 | package com.sap.primetime.util.configuration; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNull; 5 | 6 | import java.util.Arrays; 7 | import java.util.List; 8 | 9 | import org.apache.commons.lang3.RandomStringUtils; 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | 13 | import com.sap.primetime.dao.ConfigDAO; 14 | import com.sap.primetime.dao.entities.Config; 15 | import com.sap.primetime.testutil.PrimeTimeTest; 16 | import com.sap.primetime.util.configuration.ConfigUtil.Source; 17 | 18 | public class ConfigUtilTest extends PrimeTimeTest { 19 | @Before 20 | public void setup() throws Exception { 21 | prepareTest(); 22 | } 23 | 24 | @Test 25 | public void testFallbacks() throws Exception { 26 | List oldFallbacks = ConfigUtil.getFallbackChain(); 27 | 28 | ConfigUtil.setFallbacks(Arrays.asList(ConfigUtil.Source.FILE)); 29 | 30 | assertEquals(1, ConfigUtil.getFallbackChain().size()); 31 | assertEquals(ConfigUtil.Source.FILE, ConfigUtil.getFallbackChain().get(0)); 32 | 33 | // put a value into the database 34 | String randGroup = RandomStringUtils.randomAlphabetic(10); 35 | assertNull(ConfigUtil.getProperty(randGroup, "prop1")); 36 | 37 | ConfigDAO.saveNew(new Config(randGroup, "prop1", "value1")); 38 | assertNull(ConfigUtil.getProperty(randGroup, "prop1")); 39 | 40 | // add database fallback, value must be available now 41 | ConfigUtil.setFallbacks(Arrays.asList(ConfigUtil.Source.FILE, ConfigUtil.Source.DB)); 42 | assertEquals("value1", ConfigUtil.getProperty(randGroup, "prop1")); 43 | 44 | ConfigUtil.setFallbacks(oldFallbacks); 45 | } 46 | 47 | @Test 48 | public void testRefreshConfig() throws Exception { 49 | String randGroup = RandomStringUtils.randomAlphabetic(10); 50 | Config config = new Config(randGroup, "prop1", "value1"); 51 | ConfigDAO.saveNew(config); 52 | assertEquals("value1", ConfigUtil.getProperty(randGroup, "prop1")); 53 | 54 | // update value 55 | config.setParamValue("value2"); 56 | config = ConfigDAO.save(config); 57 | 58 | assertEquals("value1", ConfigUtil.getProperty(randGroup, "prop1")); 59 | 60 | ConfigUtil.reload(); 61 | assertEquals("value2", ConfigUtil.getProperty(randGroup, "prop1")); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /common/app/src/test/resources/500x300.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/500x300.jpg -------------------------------------------------------------------------------- /common/app/src/test/resources/600x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/600x400.png -------------------------------------------------------------------------------- /common/app/src/test/resources/small.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/small.mp4 -------------------------------------------------------------------------------- /common/app/src/test/resources/test-3pages.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/test-3pages.docx -------------------------------------------------------------------------------- /common/app/src/test/resources/test-3pages.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/test-3pages.pdf -------------------------------------------------------------------------------- /common/app/src/test/resources/test-4pages.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/test-4pages.docx -------------------------------------------------------------------------------- /common/app/src/test/resources/test-4pages.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/test-4pages.pdf -------------------------------------------------------------------------------- /common/app/src/test/resources/test.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/test.pptx -------------------------------------------------------------------------------- /common/app/src/test/resources/testtemplate.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/testtemplate.zip -------------------------------------------------------------------------------- /common/app/src/test/resources/testtemplate2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/testtemplate2.zip -------------------------------------------------------------------------------- /common/app/src/test/resources/testtemplate3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/app/src/test/resources/testtemplate3.zip -------------------------------------------------------------------------------- /common/app/src/test/resources/textfile.txt: -------------------------------------------------------------------------------- 1 | Text file -------------------------------------------------------------------------------- /common/web/.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /common/web/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /common/web/.settings/org.eclipse.jdt.apt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.apt.aptEnabled=false 3 | -------------------------------------------------------------------------------- /common/web/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 9 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 10 | org.eclipse.jdt.core.compiler.processAnnotations=disabled 11 | org.eclipse.jdt.core.compiler.release=disabled 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | -------------------------------------------------------------------------------- /common/web/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /common/web/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | uses 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /common/web/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /common/web/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /common/web/.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /common/web/.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /common/web/.settings/org.eclipse.wst.validation.prefs: -------------------------------------------------------------------------------- 1 | DELEGATES_PREFERENCE=delegateValidatorList 2 | USER_BUILD_PREFERENCE=enabledBuildValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; 3 | USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyValidator; 4 | USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.800.v201904082137 5 | disabled=06target 6 | eclipse.preferences.version=1 7 | override=true 8 | suspend=false 9 | vals/org.eclipse.wst.json.core.json/global=TF03 10 | vf.version=3 11 | -------------------------------------------------------------------------------- /common/web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "primetime", 3 | "version": "0.0.1", 4 | "private": true, 5 | "devDependencies": { 6 | "@ui5/cli": "^0.2.8" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/error_404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

404 - Page not found

4 | 5 | 6 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/error_unspecific.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Internal server error

4 | 5 | 6 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/web/src/main/webapp/favicon.png -------------------------------------------------------------------------------- /common/web/src/main/webapp/showHTML.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | PrimeTime - HTML 4 | 5 | 6 | 7 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showImage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | PrimeTime - Image 4 | 5 | 6 | 7 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showMediaShare.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | PrimeTime - Media Share 4 | 8 | 9 | 10 | 53 | 54 | 64 | 65 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showMovie.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | PrimeTime - Movie 4 | 5 | 6 | 7 | 36 | 37 | 38 | 48 | 49 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showPDF/Component.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ 2 | "sap/ui/core/UIComponent", 3 | "sap/ui/model/json/JSONModel" 4 | ], function(UIComponent, JSONModel) { 5 | "use strict"; 6 | return UIComponent.extend("sap.hdb.showPDF.Component", { 7 | metadata: { 8 | manifest: "json" 9 | }, 10 | init: function() { 11 | UIComponent.prototype.init.apply(this, arguments); 12 | } 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showPDF/controller/ShowPDF.controller.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ 2 | "sap/ui/core/mvc/Controller", 3 | "sap/base/util/UriParameters", 4 | "de/nysoft/control/PDF" 5 | ], function(Controller, UriParameters, PDF) { 6 | "use strict"; 7 | 8 | return Controller.extend("sap.hdb.showPDF.controller.ShowPDF", { 9 | onInit: function() { 10 | var content = this.determinePDFToShow(); 11 | 12 | var oPDF = new PDF("pdf", { 13 | src: content 14 | }); 15 | oPDF.attachPagesLoaded(this.showCorrectPage.bind(this)); 16 | 17 | this.getView().byId("pdfPage").addContent(oPDF); 18 | }, 19 | 20 | determinePDFToShow: function() { 21 | var content = ""; 22 | var sContent = new UriParameters(window.location.href).get("content"); 23 | if (sContent) { 24 | content = sContent; 25 | } 26 | 27 | return content; 28 | }, 29 | 30 | determinePageToShow: function() { 31 | var pageNumber = 1; 32 | 33 | var pageParam = new UriParameters(window.location.href).get("page"); 34 | if (pageParam) { 35 | pageNumber = parseInt(pageParam, 10); 36 | } 37 | 38 | return pageNumber; 39 | }, 40 | 41 | showPageIfPossible: function(oPDF, pageNumber) { 42 | if (pageNumber > 0 && pageNumber <= oPDF.getNumPages()) { 43 | oPDF.setPage(pageNumber); 44 | } 45 | }, 46 | 47 | showCorrectPage: function() { 48 | var pageNumber = this.determinePageToShow(); 49 | var oPDF = sap.ui.getCore().byId("pdf"); 50 | this.showPageIfPossible(oPDF, pageNumber); 51 | } 52 | }); 53 | }); 54 | 55 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showPDF/css/style.css: -------------------------------------------------------------------------------- 1 | #pdf { 2 | text-align: center; 3 | } 4 | 5 | #pdf canvas { 6 | -webkit-box-shadow: 0px 0px 7px 1px rgba(0, 0, 0, 0.6); 7 | -moz-box-shadow: 0px 0px 7px 1px rgba(0, 0, 0, 0.6); 8 | box-shadow: 0px 0px 7px 1px rgba(0, 0, 0, 0.6); 9 | } -------------------------------------------------------------------------------- /common/web/src/main/webapp/showPDF/i18n/i18n.properties: -------------------------------------------------------------------------------- 1 | appTitle=SAP HANA Core Components Show PDF Content 2 | appDescription=Showing generic PDF content 3 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showPDF/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | PDF Viewer 7 | 18 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showPDF/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "_version": "1.1.0", 3 | "sap.app": { 4 | "id": "sap.hdb.showPDF", 5 | "type": "application", 6 | "i18n": "i18n/i18n.properties", 7 | "title": "{{appTitle}}", 8 | "description": "{{appDescription}}", 9 | "applicationVersion": { 10 | "version": "0.1.0" 11 | }, 12 | "ach": "" 13 | }, 14 | "sap.ui": { 15 | "_version": "1.1.0", 16 | "technology": "UI5", 17 | "deviceTypes": { 18 | "desktop": true, 19 | "tablet": true, 20 | "phone": true 21 | }, 22 | "supportedThemes": [ 23 | "sap_bluecrystal" 24 | ] 25 | }, 26 | "sap.ui5": { 27 | "_version": "1.1.0", 28 | "rootView": "sap.hdb.showPDF.view.ShowPDF", 29 | "dependencies": { 30 | "minUI5Version": "1.30", 31 | "libs": { 32 | "sap.m": { 33 | 34 | }, 35 | "sap.ui.unified": { 36 | 37 | } 38 | } 39 | }, 40 | "config": { 41 | 42 | }, 43 | "models": { 44 | "i18n": { 45 | "type": "sap.ui.model.resource.ResourceModel", 46 | "settings": { 47 | "bundleName": "sap.hdb.launchPad.i18n.i18n" 48 | } 49 | } 50 | }, 51 | "resources": { 52 | "css": [ 53 | { 54 | "uri": "css/style.css" 55 | } 56 | ] 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showPDF/view/ShowPDF.view.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showText.html: -------------------------------------------------------------------------------- 1 | 2 | PrimeTime - Text 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showURLGrid.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | PrimeTime - URL Grid 4 | 5 | 6 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/showYouTube.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | PrimeTime - YouTube 4 | 5 | 6 | 7 |
8 | 9 | 65 | 66 | 67 | 76 | 77 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/test.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/web/src/main/webapp/test.pdf -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/3rdparty/nysoft/.library: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | de.nysoft 5 | Manuel Richarz 6 | Library for SAPUI5 and OpenUI5 7 | * (c) Copyright 2015-2015 Manuel Richarz. 8 | * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. 9 | 1.0.0 10 | 11 | Library for SAPUI5 and OpenUI5 12 | 13 | 14 | 15 | sap.ui.core 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/3rdparty/nysoft/library.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Library for SAPUI5 and OpenUI5 3 | * (c) Copyright 2015-2015 Manuel Richarz. 4 | * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. 5 | */ 6 | 7 | /** 8 | * Initialization Code and shared classes of library de.nysoft. 9 | */ 10 | sap.ui.define(['jquery.sap.global', 'sap/ui/core/library', 'sap/m/library'], // library dependency 11 | function(jQuery) { 12 | "use strict"; 13 | 14 | 15 | /** 16 | * Library for SAPUI5 and OpenUI5 17 | * 18 | * @namespace 19 | * @name de.nysoft 20 | * @author Manuel Richarz 21 | * @version 1.0.0 22 | * @public 23 | */ 24 | 25 | // delegate further initialization of this library to the Core 26 | sap.ui.getCore().initLibrary({ 27 | name : "de.nysoft", 28 | version: "1.0.0", 29 | dependencies : ["sap.ui.core", "sap.m"], 30 | types: [ 31 | 32 | ], 33 | interfaces: [ 34 | 35 | ], 36 | controls: [ 37 | "de.nysoft.control.PDF" 38 | ], 39 | elements: [ 40 | 41 | ] 42 | }); 43 | 44 | return de.nysoft; 45 | 46 | }, /* bExport= */ false); 47 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/controller/Companion.controller.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ 2 | "jquery.sap.global", 3 | "sap/m/MessageBox", 4 | "sap/ui/core/mvc/Controller", 5 | "sap/ui/model/json/JSONModel", 6 | "sap/base/util/UriParameters", 7 | "sap/primetime/ui/util" 8 | ], function (jQuery, MessageBox, Controller, JSONModel, UriParameters, util) { 9 | "use strict"; 10 | 11 | return Controller.extend("sap.primetime.ui.controller.Companion", jQuery.extend({}, util, { 12 | onInit: function () { 13 | this.screen = new UriParameters(window.location.href).get("screen"); 14 | 15 | this.screenModel = new JSONModel(); 16 | this.getView().setModel(this.screenModel, "screen"); 17 | 18 | this.getOwnerComponent().getRouter().getRoute("Companion").attachMatched(this.onRouteMatched.bind(this)); 19 | }, 20 | 21 | loadData: function() { 22 | this.screenModel.loadData("/s/api/screenservice/screens/" + this.screen); 23 | }, 24 | 25 | openPlaylist: function() { 26 | window.open(this.getHostPart() + "/?playlist=" + this.screenModel.getProperty("/playlist/id")); 27 | }, 28 | 29 | navScreen: function() { 30 | this.getOwnerComponent().getRouter().navTo("ScreenDetails", {"id":this.screenModel.getProperty("/id")}); 31 | }, 32 | 33 | navRemote: function() { 34 | this.getOwnerComponent().getRouter().navTo("RemoteControl"); 35 | }, 36 | 37 | onRouteMatched: function(oEvent) { 38 | this.loadData(); 39 | } 40 | })); 41 | }); -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/controller/PublicPageCatalog.controller.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ 2 | "jquery.sap.global", 3 | "sap/m/MessageBox", 4 | "sap/ui/core/mvc/Controller", 5 | "sap/ui/model/json/JSONModel", 6 | "sap/primetime/ui/util" 7 | ], function (jQuery, MessageBox, Controller, JSONModel, util) { 8 | "use strict"; 9 | 10 | return Controller.extend("sap.primetime.ui.controller.PublicPageCatalog", jQuery.extend({}, util, { 11 | onInit: function () { 12 | this.adPagesModel = new JSONModel(); 13 | 14 | this.adPagesModel.setSizeLimit(Number.MAX_VALUE); 15 | 16 | this.getView().setModel(this.adPagesModel, "adpages"); 17 | this.getOwnerComponent().getRouter().getRoute("PublicPageCatalog").attachMatched(this.onRouteMatched.bind(this)); 18 | }, 19 | 20 | loadData: function() { 21 | this.adPagesModel.loadData("/s/api/pageservice/advertisedpages"); 22 | }, 23 | 24 | onSelectAdPage: function(oEvent) { 25 | var id = oEvent.getSource().getBindingContext("adpages").getObject().id; 26 | this.getOwnerComponent().getRouter().navTo("PageDetails", {"id":id}); 27 | }, 28 | 29 | onRouteMatched: function(oEvent) { 30 | this.loadData(); 31 | } 32 | })); 33 | }); -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/controller/SelfTest.controller.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ 2 | "jquery.sap.global", 3 | "sap/m/MessageBox", 4 | "sap/ui/core/mvc/Controller", 5 | "sap/ui/model/json/JSONModel", 6 | "sap/ui/model/Filter", 7 | "sap/m/MessageToast", 8 | "sap/primetime/ui/util" 9 | ], function (jQuery, MessageBox, Controller, JSONModel, Filter, MessageToast, util) { 10 | "use strict"; 11 | 12 | return Controller.extend("sap.primetime.ui.controller.SelfTest", jQuery.extend({}, util, { 13 | onInit: function () { 14 | this.infoModel = new JSONModel(); 15 | this.getView().setModel(this.infoModel, "info"); 16 | this.getOwnerComponent().getRouter().getRoute("SelfTest").attachMatched(this.onRouteMatched.bind(this)); 17 | }, 18 | 19 | loadData : function() { 20 | this.infoModel.setProperty("/mobile", sap.ui.Device.browser.mobile); 21 | this.infoModel.setProperty("/browserName", sap.ui.Device.browser.name); 22 | this.infoModel.setProperty("/browserVersion", sap.ui.Device.browser.version); 23 | 24 | this.infoModel.setProperty("/touchSupported", sap.ui.Device.support.touch); 25 | this.infoModel.setProperty("/fullscreen", sap.ui.Device.browser.fullscreen); 26 | this.infoModel.setProperty("/orientation", sap.ui.Device.orientation.landscape); 27 | 28 | this.infoModel.setProperty("/osName", sap.ui.Device.os.name); 29 | this.infoModel.setProperty("/osVersion", sap.ui.Device.os.version); 30 | 31 | this.infoModel.setProperty("/isCombi", sap.ui.Device.system.combi); 32 | this.infoModel.setProperty("/isDesktop", sap.ui.Device.system.desktop); 33 | this.infoModel.setProperty("/isPhone", sap.ui.Device.system.phone); 34 | this.infoModel.setProperty("/isTablet", sap.ui.Device.system.tablet); 35 | }, 36 | 37 | onRouteMatched: function(oEvent) { 38 | this.loadData(); 39 | } 40 | })); 41 | }); -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/img/image_preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/web/src/main/webapp/ui/img/image_preview.png -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/web/src/main/webapp/ui/img/logo.png -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/img/missing_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/web/src/main/webapp/ui/img/missing_screenshot.png -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/img/onboarding.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/web/src/main/webapp/ui/img/onboarding.jpg -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/img/pages.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/web/src/main/webapp/ui/img/pages.jpg -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/img/playlist.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/web/src/main/webapp/ui/img/playlist.jpg -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/img/teaser.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/web/src/main/webapp/ui/img/teaser.mp4 -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/img/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP/cloud-primetime/b671cd424960d8f3caee25c78e77239630ec1f8d/common/web/src/main/webapp/ui/img/white.png -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "sap.app": { 3 | "id": "sap.primetime", 4 | "type": "application" 5 | }, 6 | "sap.ui5": { 7 | "dependencies": { 8 | "libs": { 9 | "sap.ui.core": {}, 10 | "sap.m": {}, 11 | "sap.f": {} 12 | } 13 | }, 14 | "rootView": { 15 | "viewName": "sap.primetime.view.App", 16 | "type": "XML", 17 | "async": true, 18 | "id": "app" 19 | }, 20 | "models": { 21 | "i18n": { 22 | "type": "sap.ui.model.resource.ResourceModel", 23 | "settings": { 24 | "bundleName": "sap.ui.demo.todo.i18n.i18n" 25 | } 26 | }, 27 | "": { 28 | "type": "sap.ui.model.json.JSONModel", 29 | "uri": "model/todoitems.json" 30 | } 31 | }, 32 | "resources": { 33 | "css": [ 34 | { 35 | "uri": "css/styles.css" 36 | } 37 | ] 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/model/DateTime.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ "sap/ui/model/type/DateTime" ], function(UI5DateTime) { 2 | "use strict"; 3 | 4 | return UI5DateTime.extend("sap.primetime.model.DateTime", { 5 | constructor : function() { 6 | return UI5DateTime.call(this, { 7 | relative : true, 8 | relativeScale : 'auto', 9 | source : { 10 | pattern : 'yyyy-MM-ddTHH:mm:ss Z' 11 | } 12 | }); 13 | } 14 | }); 15 | }); -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/model/FileSize.js: -------------------------------------------------------------------------------- 1 | sap.ui.define([ "sap/ui/model/type/FileSize" ], function(UI5FileSize) { 2 | "use strict"; 3 | 4 | return UI5FileSize.extend("sap.primetime.model.FileSize", { 5 | constructor : function() { 6 | return UI5FileSize.call(this, { 7 | maxFractionDigits : 2 8 | }); 9 | } 10 | }); 11 | }); -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/view/About.fragment.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 7 | 8 | 9 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/view/App.view.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /common/web/src/main/webapp/ui/view/Companion.view.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 9 | 10 |