From 3e6da71d36a4a8e1f452cf8fa6acb289193a3b00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Fri, 24 Apr 2020 14:39:26 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C31798 --- .../run-mediacube-server-mv.launch | 2 +- server/-configuration/scheduledjobs.json | 5 +- .../jobtemplates/cancelable.xml | 6 + .../server/steps/CancelableStep.java} | 4 +- .../user/jobengine/server/steps/FakeStep.java | 12 +- .../server/steps/TranscodeFFAStranStep.java | 15 +- .../server/steps/TranscodeSELENIOStep.java | 28 +- .../jobengine/server/steps/TranscodeStep.java | 4 +- .../src/user/commons/StoreUri.java | 10 + .../META-INF/MANIFEST.MF | 1 + .../scripts/007_add_alternate_store.sql | 39 ++ .../src/user/jobengine/db/IItemManager.java | 2 + .../src/user/jobengine/db/ItemManager.java | 51 +++ .../src/user/jobengine/db/SearchOptions.java | 8 +- .../user/jobengine/search/MediaFinder.java | 32 +- .../WEB-INF/web.xml | 2 - .../js/searchitems.js | 10 +- .../pages/icons.zul | 408 ++++++++++++++++++ .../pages/joblist.zul | 50 +-- .../pages/jobselector.zul | 2 +- .../user.jobengine.osgi.server/pages/menu.zul | 14 +- .../pages/searchitems.zul | 1 - .../pages/searchitems/details.zul | 8 +- .../pages/searchitems/filters.zul | 126 +++--- .../src/user/jobengine/server/IJobEngine.java | 8 +- .../src/user/jobengine/server/JobEngine.java | 25 +- .../server/scheduler/ScheduledJob.java | 12 + .../jobengine/zk/model/CachedListModel.java | 62 ++- .../user/jobengine/zk/model/JobListModel.java | 47 +- .../jobengine/zk/model/JobSelectorModel.java | 2 +- .../user/jobengine/zk/model/SearchModel.java | 115 ++++- .../user/jobengine/server/IT/SupportTest.java | 39 +- .../WEB-INF/web.xml | 9 + .../osgi/mediacube/MediaFileServlet.java | 4 +- 34 files changed, 927 insertions(+), 236 deletions(-) create mode 100644 server/user.jobengine.executors/jobtemplates/cancelable.xml rename server/user.jobengine.executors/{obsolate/obsolate/AFakeStep.java => src/user/jobengine/server/steps/CancelableStep.java} (80%) create mode 100644 server/user.jobengine.osgi.db/migrations/scripts/007_add_alternate_store.sql create mode 100644 server/user.jobengine.osgi.server/pages/icons.zul diff --git a/server/-configuration/run-mediacube-server-mv.launch b/server/-configuration/run-mediacube-server-mv.launch index 648b19a4..43a0b0c9 100644 --- a/server/-configuration/run-mediacube-server-mv.launch +++ b/server/-configuration/run-mediacube-server-mv.launch @@ -19,7 +19,7 @@ - + diff --git a/server/-configuration/scheduledjobs.json b/server/-configuration/scheduledjobs.json index 44221188..fa356491 100644 --- a/server/-configuration/scheduledjobs.json +++ b/server/-configuration/scheduledjobs.json @@ -1,4 +1,7 @@ {"joblist":[ + { + "template": "cancelable.xml" + }, { "name" : "Proxy pótlása", "template": "create-lowres-ondemand.xml", @@ -259,7 +262,7 @@ "executeimmediate": false, "name" : "Teszt folyamat", "template": "fake.xml", - "cronexpression": "0 46-50/1 * * * ?", + "cronexpression": "0/20 * * * * ?", "parameters": [ {"name": "itemID", "value": 1, "type": "java.lang.Long"} ] }, { diff --git a/server/user.jobengine.executors/jobtemplates/cancelable.xml b/server/user.jobengine.executors/jobtemplates/cancelable.xml new file mode 100644 index 00000000..899a3c10 --- /dev/null +++ b/server/user.jobengine.executors/jobtemplates/cancelable.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/server/user.jobengine.executors/obsolate/obsolate/AFakeStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CancelableStep.java similarity index 80% rename from server/user.jobengine.executors/obsolate/obsolate/AFakeStep.java rename to server/user.jobengine.executors/src/user/jobengine/server/steps/CancelableStep.java index 71a9256e..3b5f9ec1 100644 --- a/server/user.jobengine.executors/obsolate/obsolate/AFakeStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CancelableStep.java @@ -1,10 +1,10 @@ -package obsolate; +package user.jobengine.server.steps; import user.jobengine.server.IJobRuntime; import user.jobengine.server.steps.JobStep; import user.jobengine.server.steps.StepEntry; -public class AFakeStep extends JobStep { +public class CancelableStep extends JobStep { int count = 10; @StepEntry diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java index 775a94ce..97ade7df 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java @@ -1,9 +1,5 @@ package user.jobengine.server.steps; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -23,8 +19,8 @@ public class FakeStep extends JobStep { public Object[] execute(long itemID, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { Object[] result = { itemID + 1 }; - Files.copy(Paths.get("/etc/security/limits.conf"), Paths.get("/etc/security/limits.conf.bak")); - Files.write(Paths.get("/etc/security/limits.conf"), new byte[0], StandardOpenOption.TRUNCATE_EXISTING); + // Files.copy(Paths.get("/etc/security/limits.conf"), Paths.get("/etc/security/limits.conf.bak")); + // Files.write(Paths.get("/etc/security/limits.conf"), new byte[0], StandardOpenOption.TRUNCATE_EXISTING); //test(); @@ -40,7 +36,9 @@ public class FakeStep extends JobStep { if (!canContinue()) break; jobRuntime.incrementProgress((i + 1) * count); - Thread.sleep(100); + for (int j = 0; j < 100; j++) { + Thread.sleep(1000); + } //jobEngine.sendMessage(new CancelRequest(jobRuntime.getId())); logger.info("Progress {}", jobRuntime.getProgress()); diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeFFAStranStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeFFAStranStep.java index bcb2ac90..6c172d78 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeFFAStranStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeFFAStranStep.java @@ -15,6 +15,8 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import user.commons.FFAStransAPI; import user.commons.IFFAStransAPI; +import user.commons.StoreUri; +import user.commons.remotestore.RemoteStoreProtocol; import user.jobengine.db.FileType; import user.jobengine.db.IItemManager; import user.jobengine.db.Media; @@ -36,12 +38,11 @@ public class TranscodeFFAStranStep extends JobStep { @StepEntry public Object[] execute(ArchiveItem archiveItem, Media mediaCubeMedia, String transcoderAddress, String transcoderTemplateName, - String globalHiresSourcePath, String localLowresTargetPath, String webPath, boolean deleteSource, IJobEngine jobEngine, IJobRuntime jobRuntime) - throws Exception { + String globalHiresSourcePath, String localLowresTargetPath, boolean deleteSource, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { this.marker = jobRuntime.getMarker(); this.manager = jobEngine.getItemManager(); - this.store = check(manager.getSystemStore(true), "lowres Store"); + this.store = check(manager.getCurrentLowresStore(), "lowres Store"); this.fileType = check(manager.getFileType(LOWRES_FILETYPE), "lowres FileType"); this.mediaCubeMedia = check(mediaCubeMedia, "mediaCubeMedia"); check(archiveItem, "archiveItem"); @@ -49,12 +50,18 @@ public class TranscodeFFAStranStep extends JobStep { check(transcoderTemplateName, "transcoderTemplateName"); check(globalHiresSourcePath, "globalHiresSourcePath"); check(localLowresTargetPath, "localLowresTargetPath"); - check(webPath, "webPath"); File sourceMediaFile = new File(archiveItem.getMediaFile()); logger.info("Transcoding {}", archiveItem.getMediaFile()); String sourceFileName = sourceMediaFile.getName(); String details = String.format("%s (%d bytes)", sourceFileName, sourceMediaFile.length()); + + StoreUri storeUri = store.getTargetStoreUri(RemoteStoreProtocol.LOCAL); + if (storeUri == null) + throw new Exception("Can not detect proxy folder."); + + String webPath = storeUri.toString(true); + Path targetPath = null; try { String targetFileName = FilenameUtils.removeExtension(sourceFileName) + MP4EXT; diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java index d4bf472d..7b5407c3 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java @@ -1,8 +1,6 @@ package user.jobengine.server.steps; import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; @@ -20,6 +18,8 @@ import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.message.Message; import org.apache.logging.log4j.message.ParameterizedMessage; +import user.commons.StoreUri; +import user.commons.remotestore.RemoteStoreProtocol; import user.commons.selenio.wsclient.AudioSource; import user.commons.selenio.wsclient.Clip; import user.commons.selenio.wsclient.ClipList; @@ -54,8 +54,8 @@ public class TranscodeSELENIOStep extends JobStep { private Store store; private FileType fileType; private String transcoderTargetPath; - private String webPath; private Marker marker; + private StoreUri storeUri; private TranscodeRequest buildTranscodeRequest(String projectFilePath, String sourceFilePath) throws java.lang.Exception { Clip clip = new Clip(); @@ -90,13 +90,13 @@ public class TranscodeSELENIOStep extends JobStep { } @StepEntry - public Object[] execute(String globalSourcePath, ArchiveItem archiveItem, Media mediaCubeMedia, String transcoderTargetPath, String webPath, - IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { + public Object[] execute(String globalSourcePath, ArchiveItem archiveItem, Media mediaCubeMedia, String transcoderTargetPath, IJobEngine jobEngine, + IJobRuntime jobRuntime) throws Exception { marker = jobRuntime.getMarker(); String sourceFileName = null; try { - setAndCheck(globalSourcePath, transcoderTargetPath, webPath, jobEngine); + setAndCheck(globalSourcePath, transcoderTargetPath, jobEngine); File sourceMediaFile = new File(archiveItem.getMediaFile()); sourceFileName = sourceMediaFile.getName(); @@ -170,8 +170,9 @@ public class TranscodeSELENIOStep extends JobStep { } } + String webPath = null; try { - + webPath = storeUri.toString(true); outFile = outFile.substring(outFile.lastIndexOf("\\") + 1); if (outFile.indexOf(".") > 2) { Path subdir = Paths.get(outFile.substring(0, 1), outFile.substring(1, 2), outFile.substring(2, 3)); @@ -184,7 +185,7 @@ public class TranscodeSELENIOStep extends JobStep { manager.createMediaFile(outFile, fileType, store, mediaCubeMedia).add(); Files.move(Paths.get(transcoderTargetPath, outFile), Paths.get(webPath, outFile), StandardCopyOption.REPLACE_EXISTING); } - } catch (IOException e) { + } catch (Exception e) { logger.catching(e); logger.error(marker, "Az '{}' állomány mozgatása a '{}' mappába nem sikerült.", outFile, webPath); } @@ -203,7 +204,7 @@ public class TranscodeSELENIOStep extends JobStep { } } - private void setAndCheck(String globalSourcePath, String transcoderTargetPath, String webPath, IJobEngine jobEngine) throws MalformedURLException { + private void setAndCheck(String globalSourcePath, String transcoderTargetPath, IJobEngine jobEngine) throws Exception { address = System.getProperty("jobengine.selenio.address"); if (StringUtils.isBlank(address)) throw new NullPointerException("System is not configured properly, 'jobengine.selenio.address' startup parameter missing."); @@ -219,10 +220,14 @@ public class TranscodeSELENIOStep extends JobStep { throw new NullPointerException("System is not configured properly, 'globalInputFolder' parameter missing."); manager = jobEngine.getItemManager(); - store = manager.getSystemStore(true); + store = manager.getCurrentLowresStore(); if (store == null) throw new NullPointerException("System is not configured properly, low-res system store definition missing."); + storeUri = store.getTargetStoreUri(RemoteStoreProtocol.LOCAL); + if (storeUri == null) + throw new Exception("Can not detect proxy folder."); + fileType = manager.getFileType(LOWRES_FILETYPE); if (fileType == null) throw new NullPointerException("System is not configured properly, low-res file type definition missing."); @@ -231,9 +236,6 @@ public class TranscodeSELENIOStep extends JobStep { throw new NullPointerException("System is not configured properly, 'transcoderTargetPath' parameter missing."); this.transcoderTargetPath = transcoderTargetPath; - if (StringUtils.isBlank(webPath)) - throw new NullPointerException("System is not configured properly, 'webPath' parameter missing."); - this.webPath = webPath; } } diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeStep.java index 34e3f0f6..5a68f813 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeStep.java @@ -16,14 +16,14 @@ public class TranscodeStep extends JobStep { switch (version) { case 0: { TranscodeSELENIOStep selenioStep = new TranscodeSELENIOStep(); - selenioStep.execute(globalSourcePath, archiveItem, mediaCubeMedia, transcoderTargetPath, webPath, jobEngine, jobRuntime); + selenioStep.execute(globalSourcePath, archiveItem, mediaCubeMedia, transcoderTargetPath, jobEngine, jobRuntime); break; } case 1: { TranscodeFFAStranStep ffaStransStep = new TranscodeFFAStranStep(); String transcoderAddress = System.getProperty("jobengine.transcoder.address"); String transcoderTemplateName = System.getProperty("jobengine.transcoder.template"); - ffaStransStep.execute(archiveItem, mediaCubeMedia, transcoderAddress, transcoderTemplateName, globalSourcePath, transcoderTargetPath, webPath, false, + ffaStransStep.execute(archiveItem, mediaCubeMedia, transcoderAddress, transcoderTemplateName, globalSourcePath, transcoderTargetPath, false, jobEngine, jobRuntime); break; } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java b/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java index 76eb5705..5c3f94d5 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java @@ -46,6 +46,8 @@ public class StoreUri extends EntityBase implements Serializable { private int percent; private IDirectoryLister lister; private boolean showDirectories; + //1-magas, n-alacsony + private int priority; public StoreUri() { super(); @@ -216,6 +218,10 @@ public class StoreUri extends EntityBase implements Serializable { return portNumber; } + public int getPriority() { + return priority; + } + public RemoteStoreProtocol getProtocol() { return protocol; } @@ -309,6 +315,10 @@ public class StoreUri extends EntityBase implements Serializable { this.portNumber = portNumber; } + public void setPriority(int priority) { + this.priority = priority; + } + public void setProtocol(RemoteStoreProtocol protocol) { this.protocol = protocol; } diff --git a/server/user.jobengine.osgi.db/META-INF/MANIFEST.MF b/server/user.jobengine.osgi.db/META-INF/MANIFEST.MF index 5ceaaa3f..dae95dba 100644 --- a/server/user.jobengine.osgi.db/META-INF/MANIFEST.MF +++ b/server/user.jobengine.osgi.db/META-INF/MANIFEST.MF @@ -16,6 +16,7 @@ Bundle-ActivationPolicy: lazy Import-Package: com.fasterxml.jackson.annotation;version="2.4.5", javax.ws.rs.client, javax.ws.rs.core, + org.apache.commons.io;version="2.2.0", org.apache.logging.log4j;version="2.8.2" Export-Package: user.jobengine.db, user.jobengine.search diff --git a/server/user.jobengine.osgi.db/migrations/scripts/007_add_alternate_store.sql b/server/user.jobengine.osgi.db/migrations/scripts/007_add_alternate_store.sql new file mode 100644 index 00000000..ed0e1edd --- /dev/null +++ b/server/user.jobengine.osgi.db/migrations/scripts/007_add_alternate_store.sql @@ -0,0 +1,39 @@ +-- +-- Copyright 2010-2016 the original author or authors. +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + +-- // Insert alternate lowres store +-- Migration SQL that makes the change goes here. + +INSERT INTO STORE (NAME, ISSYSTEM, ISLOWRES) VALUES ('Alternate Low-res', 'N', 'N') +@ + +INSERT INTO STOREURI (STOREID, PROTOCOL, URI, ISSTREAM, ISSOURCE, ISTARGET) + VALUES +((SELECT ID FROM STORE WHERE NAME='Alternate Low-res'), 'HTTP', '/services/proxy/', 'Y', 'Y', 'N') +@ + +INSERT INTO STOREURI (STOREID, PROTOCOL, URI, ISSTREAM, ISSOURCE, ISTARGET) + VALUES +((SELECT ID FROM STORE WHERE NAME='Alternate Low-res'), 'LOCAL', '/mediacube/data/lowres/www/video/ITF3', 'N', 'Y', 'Y') +@ + +-- //@UNDO +-- SQL to undo the change goes here. +DELETE FROM STOREURI WHERE ID=(SELECT ID FROM STORE WHERE NAME='Alternate Low-res') +@ + +DELETE FROM STORE WHERE NAME='Alternate Low-res' +@ diff --git a/server/user.jobengine.osgi.db/src/user/jobengine/db/IItemManager.java b/server/user.jobengine.osgi.db/src/user/jobengine/db/IItemManager.java index 82804beb..99a60ef2 100644 --- a/server/user.jobengine.osgi.db/src/user/jobengine/db/IItemManager.java +++ b/server/user.jobengine.osgi.db/src/user/jobengine/db/IItemManager.java @@ -145,6 +145,8 @@ public interface IItemManager extends IEntityPersister { Break getBreak(long id); + Store getCurrentLowresStore() throws Exception; + DefaultContext getDbContext(); /** diff --git a/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemManager.java b/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemManager.java index 46061720..419efda7 100644 --- a/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemManager.java +++ b/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemManager.java @@ -15,7 +15,9 @@ import java.util.Date; import java.util.Hashtable; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; +import org.apache.commons.io.FileSystemUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,6 +28,7 @@ import user.commons.BaseType; import user.commons.CalendarUtils; import user.commons.IEntityBase; import user.commons.Job; +import user.commons.ListUtils; import user.commons.StoreUri; import user.commons.pool.ConnectionPoolProperties; import user.commons.pool.ContextPool; @@ -575,6 +578,34 @@ public class ItemManager extends MemoryCache implements IItemManager { return (Break) get(Break.class, id); } + @Override + public Store getCurrentLowresStore() throws Exception { + Store result = null; + Store sysLowres = getSystemStore(true); + StoreUri lowresUri = selectLowresUri(sysLowres); + if (lowresUri == null) { + //az elsodlegesen tul keves a hely + StoreDAO dao = (StoreDAO) getBaseDAO(Store.class); + List stores = ListUtils.cast(dao.getAll()); + for (Store store : stores) { + //kompatibilitas miatt ez maradt + if (store.isLowres() || store.isSystem()) + continue; + lowresUri = selectLowresUri(store); + if (lowresUri != null) { + result = store; + break; + } + } + } else + result = sysLowres; + + //nincs mas + if (result == null) + result = sysLowres; + return result; + } + @Override public DefaultContext getDbContext() { DefaultContext context = null; @@ -1097,6 +1128,26 @@ public class ItemManager extends MemoryCache implements IItemManager { return result; } + //min 5 GB szabad hely eseten ad vissza LOCAL uri-t + public StoreUri selectLowresUri(Store store) throws Exception { + StoreUri result = null; + List uris = store.getStoreUris(); + if (uris != null && uris.size() > 1) { + uris = uris.stream().filter(u -> u.getProtocol() == RemoteStoreProtocol.LOCAL && u.isTarget()).sorted((u1, u2) -> { + return Integer.compare(u1.getPriority(), u2.getPriority()); + }).collect(Collectors.toList()); + + for (StoreUri uri : uris) { + //min 5GB + if (FileSystemUtils.freeSpaceKb(uri.toString(true)) > 5000000) { + result = uri; + break; + } + } + } + return result; + } + @Override public void signal(long id, SignalType signalType, StaticTables staticTable) { if (signalServer != null) { diff --git a/server/user.jobengine.osgi.db/src/user/jobengine/db/SearchOptions.java b/server/user.jobengine.osgi.db/src/user/jobengine/db/SearchOptions.java index ab582b5b..a2041947 100644 --- a/server/user.jobengine.osgi.db/src/user/jobengine/db/SearchOptions.java +++ b/server/user.jobengine.osgi.db/src/user/jobengine/db/SearchOptions.java @@ -10,15 +10,17 @@ public class SearchOptions { final private Date searchTo; final private String orderBy; final private boolean orderAscending; + final private boolean missingProxy; private long mediaId; private int fromResult; private int toResult; - public SearchOptions(String text, List filters, Date searchFrom, Date searchTo, String orderBy, boolean orderAscending) { + public SearchOptions(String text, List filters, Date searchFrom, Date searchTo, boolean missingProxy, String orderBy, boolean orderAscending) { this.text = text; this.filters = filters; this.searchFrom = searchFrom; this.searchTo = searchTo; + this.missingProxy = missingProxy; this.orderBy = orderBy; this.orderAscending = orderAscending; } @@ -71,4 +73,8 @@ public class SearchOptions { this.toResult = toResult; } + public boolean isMissingProxy() { + return missingProxy; + } + } diff --git a/server/user.jobengine.osgi.db/src/user/jobengine/search/MediaFinder.java b/server/user.jobengine.osgi.db/src/user/jobengine/search/MediaFinder.java index 9e3e2570..61909434 100644 --- a/server/user.jobengine.osgi.db/src/user/jobengine/search/MediaFinder.java +++ b/server/user.jobengine.osgi.db/src/user/jobengine/search/MediaFinder.java @@ -6,7 +6,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.List; import org.apache.logging.log4j.LogManager; @@ -23,14 +22,13 @@ import user.jobengine.db.SearchOptions; public class MediaFinder implements IMediaFinder { private static final Logger logger = LogManager.getLogger(); private ItemManager manager = null; - private SimpleDateFormat df = new SimpleDateFormat("YYYY-mm-dd"); + private SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); public MediaFinder(ItemManager manager) { this.manager = manager; } - private PreparedStatement createStatement(Connection connection, String criteria, List typeIDs, Date searchFrom, Date searchTo, String orderBy, - boolean orderAscending) throws SQLException { + private PreparedStatement createStatement(Connection connection, String criteria, List typeIDs, SearchOptions options) throws SQLException { StringBuilder typeCriteria = getTypeCriterias(typeIDs); String criteriasPattern = getCriteriasRegexPattern(criteria); @@ -60,26 +58,30 @@ public class MediaFinder implements IMediaFinder { if (criteria != null && criteria.trim().length() > 0) sql.append(" AND CONTAINS(md.description, ?) >= 1"); - if (searchFrom != null) { - sql.append(String.format(" AND m.archived > '%s'", df.format(searchFrom))); + if (options.getSearchFrom() != null) { + sql.append(String.format(" AND m.archived > '%s'", df.format(options.getSearchFrom()))); } - if (searchTo != null) { - sql.append(String.format(" AND m.archived < '%s'", df.format(searchTo))); + if (options.getSearchTo() != null) { + sql.append(String.format(" AND m.archived < '%s'", df.format(options.getSearchTo()))); } - sql.append(" ORDER BY "); + if (options.isMissingProxy()) + sql.append(" AND vw_mf.mediafilecount=1"); - if (orderBy == null) { + sql.append(" ORDER BY "); + if (options.getOrderBy() == null) { sql.append("itemtitle desc, mediaitemtypeid"); } else { - sql.append(orderBy); - sql.append(orderAscending ? " ASC" : " DESC"); + sql.append(options.getOrderBy()); + sql.append(options.isOrderAscending() ? " ASC" : " DESC"); } String query = sql.toString(); logger.info(query); PreparedStatement st = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); - st.setString(1, criteria); + + if (criteria != null && criteria.trim().length() > 0) + st.setString(1, criteria); return st; } @@ -89,7 +91,7 @@ public class MediaFinder implements IMediaFinder { for (String c : specials) { result = result.replace(c, "\\" + c); } - if (!(result.startsWith("\"") && result.endsWith("\""))) + if (!(result.startsWith("\"") && result.endsWith("\"")) && result.length() != 0) result += "*"; return result; } @@ -149,7 +151,7 @@ public class MediaFinder implements IMediaFinder { Connection connection = context.getConnection(); try { String text = formatSearchValue(options.getText()); - st = createStatement(connection, text, typeIDs, options.getSearchFrom(), options.getSearchTo(), options.getOrderBy(), options.isOrderAscending()); + st = createStatement(connection, text, typeIDs, options); rs = st.executeQuery(); rs.last(); result.setItemCount(rs.getRow()); diff --git a/server/user.jobengine.osgi.server/WEB-INF/web.xml b/server/user.jobengine.osgi.server/WEB-INF/web.xml index cc052fb4..a5f81153 100644 --- a/server/user.jobengine.osgi.server/WEB-INF/web.xml +++ b/server/user.jobengine.osgi.server/WEB-INF/web.xml @@ -70,7 +70,6 @@ index.zhtml - diff --git a/server/user.jobengine.osgi.server/js/searchitems.js b/server/user.jobengine.osgi.server/js/searchitems.js index 2ccd6dd0..e8b14946 100644 --- a/server/user.jobengine.osgi.server/js/searchitems.js +++ b/server/user.jobengine.osgi.server/js/searchitems.js @@ -22,6 +22,11 @@ function setSource(src) { setSource(null); +//player.src({ +// type : 'application/x-mpegURL', +// src : '/services/proxy/media1/index.m3u8' +//}); + function pushTcIn() { var current = player.currentTime(); console.log("pushTcIn", current); @@ -42,7 +47,7 @@ function pushTcOut() { }); } -/* Címke kezelés */ +/* Címke kezelés var input = document.querySelector('textarea[name=tags2]'), tagify = new Tagify( input, { @@ -68,3 +73,6 @@ function onTag(e) { toServer : true }); } +*/ +function addTags(tags, current) { +} \ No newline at end of file diff --git a/server/user.jobengine.osgi.server/pages/icons.zul b/server/user.jobengine.osgi.server/pages/icons.zul new file mode 100644 index 00000000..0f634195 --- /dev/null +++ b/server/user.jobengine.osgi.server/pages/icons.zul @@ -0,0 +1,408 @@ + + + +