From 22d59bd3bd1c6c00f3f354d92465fa71e46e196c Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Thu, 5 Oct 2017 15:16:34 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30543 --- .../Maestro/Resources/configuration-unc.json | 2 +- server/-configuration/log4j2.xml | 20 +- .../run-mediacube-server-bsh.launch | 2 +- .../run-mediacube-server-localhost.launch | 2 +- .../run-mediacube-server.launch | 2 +- server/-configuration/scheduledjobs.json | 2 +- server/-product/test1.product1 | 151 +++++++ .../commons/log4j2/appender/SmtpManager.java | 381 +++++++++--------- .../config/config.xml | 2 +- .../retrieve-traffic-missing-materials.xml | 3 - .../CheckTrafficMissingMaterialsStep.java | 17 +- .../jobengine/server/steps/TSMBackupStep.java | 15 +- .../server/steps/TSMRestoreStep.java | 4 +- .../META-INF/MANIFEST.MF | 2 +- .../user/jobengine/server/steps/JobStep.java | 5 +- 15 files changed, 387 insertions(+), 223 deletions(-) create mode 100644 server/-product/test1.product1 diff --git a/client/Maestro/Resources/configuration-unc.json b/client/Maestro/Resources/configuration-unc.json index 60442871..32c05da0 100644 --- a/client/Maestro/Resources/configuration-unc.json +++ b/client/Maestro/Resources/configuration-unc.json @@ -52,7 +52,7 @@ { "label": "Archiválandó", "processor": "UNCTargetProcessor", - "outputFormat": "%ID%-%SOURCENAME%", + "outputFormat": "%ID%", "tag": "Archiválásra kijelöl", "useMetadata": true, "remote": { diff --git a/server/-configuration/log4j2.xml b/server/-configuration/log4j2.xml index d83853a8..02af1498 100644 --- a/server/-configuration/log4j2.xml +++ b/server/-configuration/log4j2.xml @@ -9,25 +9,21 @@ - - - - + - - - - + - + - - + + + @@ -51,7 +47,7 @@ - + diff --git a/server/-configuration/run-mediacube-server-bsh.launch b/server/-configuration/run-mediacube-server-bsh.launch index 272a9a5c..84984baa 100644 --- a/server/-configuration/run-mediacube-server-bsh.launch +++ b/server/-configuration/run-mediacube-server-bsh.launch @@ -22,7 +22,7 @@ - + diff --git a/server/-configuration/run-mediacube-server-localhost.launch b/server/-configuration/run-mediacube-server-localhost.launch index 2659d4f8..1cbf6e74 100644 --- a/server/-configuration/run-mediacube-server-localhost.launch +++ b/server/-configuration/run-mediacube-server-localhost.launch @@ -22,7 +22,7 @@ - + diff --git a/server/-configuration/run-mediacube-server.launch b/server/-configuration/run-mediacube-server.launch index ac2b9795..f7c8b51d 100644 --- a/server/-configuration/run-mediacube-server.launch +++ b/server/-configuration/run-mediacube-server.launch @@ -22,7 +22,7 @@ - + diff --git a/server/-configuration/scheduledjobs.json b/server/-configuration/scheduledjobs.json index fa37b2a7..199f396d 100644 --- a/server/-configuration/scheduledjobs.json +++ b/server/-configuration/scheduledjobs.json @@ -17,7 +17,7 @@ "executeimmediate": true, "cronexpression": "0 0 0/1 1/1 * ? *", "parameters": [ - {"name": "dbUrl", "value": "jdbc:sqlserver://folkloredb.hu\\sql08:33860;databaseName=CLArchiveTF_0;", "type": "java.lang.String"}, + {"name": "dbUrl", "value": "jdbc:sqlserver://10.10.1.45\\sql16;databaseName=PA_Echo;", "type": "java.lang.String"}, {"name": "userName", "value": "MAM", "type": "java.lang.String"}, {"name": "password", "value": "Echotv.hu", "type": "java.lang.String"}, {"name": "lookupDays", "value": 7, "type": "java.lang.Integer"}, diff --git a/server/-product/test1.product1 b/server/-product/test1.product1 new file mode 100644 index 00000000..51f35774 --- /dev/null +++ b/server/-product/test1.product1 @@ -0,0 +1,151 @@ + + + + + + + + + + -consoleLog -console + + -Djavax.ws.rs.ext.RuntimeDelegate=org.jboss.resteasy.spi.ResteasyProviderFactory +-Dorg.eclipse.equinox.http.jetty.http.port=8080 +-Dorg.eclipse.epp.logging.aeri.skipReports=true +-Declipse.ignoreApp=true +-Dosgi.noShutdown=true +-Djobengine.jobsteps.root="${workspace_loc}/user.jobengine.executors/config" +-Djobengine.jobtemplates.root="${workspace_loc}/user.jobengine.executors/jobtemplates" +-Djobengine.db.url=jdbc:db2://10.10.1.28:50000/mc:retrieveMessagesFromServerOnGetMessage=true; +-Djobengine.db.user=db2admin +-Djobengine.db.password=password +-Djobengine.loglevel=INFO +-Dlog4j.configurationFile="${workspace_loc}/-configuration/log4j2.xml" +-Djobengine.jobsteps.alternate.root="${workspace_loc}/user.jobengine.executors/bin/user/jobengine/server/steps" +-Djetty.home="${workspace_loc:}/-configuration/jetty" +-Djetty.etc.config.urls=etc/user-jetty.xml,etc/user-jetty-ssl.xml,etc/user-jetty-ssl-context.xml,,etc/user-jetty-http.xml,etc/user-jetty-https.xml +-Djobengine.octopus.api.address=http://10.10.1.11/api/v1 +-Djobengine.octopus.api.user=mam +-Djobengine.octopus.api.password=napocska +-Djobengine.nosql.db.url=jdbc:db2://10.10.1.28:50000/mc:retrieveMessagesFromServerOnGetMessage=true; +-Djobengine.nosql.db.user=db2admin +-Djobengine.nosql.db.password=password +-Djobengine.nosql.db.schema=test +-Djobengine.selenio.address=http://10.10.1.71:44000/TranscodeMgrWS?wsdl +-Djobengine.selenio.projectfilepath=\\10.10.1.71\Data\Blueprints\MP4_H264_AAC_v4.zenium +-Djobengine.jobscheduling.config="${workspace_loc}/-configuration/scheduledjobs.json" +-Dnexio.host=10.10.1.555 + + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java b/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java index a6bcba1c..1bafe875 100644 --- a/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java +++ b/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java @@ -21,6 +21,8 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Date; import java.util.Properties; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import javax.activation.DataSource; import javax.mail.Authenticator; @@ -58,45 +60,103 @@ import org.apache.logging.log4j.util.Strings; * Manager for sending SMTP events. */ public class SmtpManager extends AbstractManager { - private static final SMTPManagerFactory FACTORY = new SMTPManagerFactory(); + /** + * Factory data. + */ + private static class FactoryData { + private final String to; + private final String cc; + private final String bcc; + private final String from; + private final String replyto; + private final Serializer subject; + private final String protocol; + private final String host; + private final int port; + private final String username; + private final String password; + private final boolean isDebug; + private final int numElements; - private final Session session; + public FactoryData(final String to, final String cc, final String bcc, final String from, final String replyTo, final Serializer subjectSerializer, + final String protocol, final String host, final int port, final String username, final String password, final boolean isDebug, + final int numElements) { + this.to = to; + this.cc = cc; + this.bcc = bcc; + this.from = from; + this.replyto = replyTo; + this.subject = subjectSerializer; + this.protocol = protocol; + this.host = host; + this.port = port; + this.username = username; + this.password = password; + this.isDebug = isDebug; + this.numElements = numElements; + } + } - private final CyclicBuffer buffer; + /** + * Factory to create the SMTP Manager. + */ + private static class SMTPManagerFactory implements ManagerFactory { - private volatile MimeMessage message; + private Authenticator buildAuthenticator(final String username, final String password) { + if (null != password && null != username) { + return new Authenticator() { + private final PasswordAuthentication passwordAuthentication = new PasswordAuthentication(username, password); - private final FactoryData data; + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return passwordAuthentication; + } + }; + } + return null; + } - private static MimeMessage createMimeMessage(final FactoryData data, final Session session, - final LogEvent appendEvent) throws MessagingException { - return new MimeMessageBuilder(session).setFrom(data.from).setReplyTo(data.replyto) - .setRecipients(Message.RecipientType.TO, data.to).setRecipients(Message.RecipientType.CC, data.cc) - .setRecipients(Message.RecipientType.BCC, data.bcc).setSubject(data.subject.toSerializable(appendEvent)) - .build(); - } + @Override + public SmtpManager createManager(final String name, final FactoryData data) { + final String prefix = "mail." + data.protocol; - protected SmtpManager(final String name, final Session session, final MimeMessage message, final FactoryData data) { - super(null, name); - this.session = session; - this.message = message; - this.data = data; - this.buffer = new CyclicBuffer<>(LogEvent.class, data.numElements); - } + final Properties properties = PropertiesUtil.getSystemProperties(); + properties.put("mail.transport.protocol", data.protocol); + if (properties.getProperty("mail.host") == null) { + // Prevent an UnknownHostException in Java 7 + properties.put("mail.host", NetUtils.getLocalHostname()); + } - public void add(LogEvent event) { - if (event instanceof Log4jLogEvent && event.getMessage() instanceof ReusableMessage) { - ((Log4jLogEvent) event).makeMessageImmutable(); - } else if (event instanceof MutableLogEvent) { - event = ((MutableLogEvent) event).createMemento(); + if (null != data.host) { + properties.put(prefix + ".host", data.host); + } + if (data.port > 0) { + properties.put(prefix + ".port", String.valueOf(data.port)); + } + + final Authenticator authenticator = buildAuthenticator(data.username, data.password); + if (null != authenticator) { + properties.put(prefix + ".auth", "true"); + } + + final Session session = Session.getInstance(properties, authenticator); + session.setProtocolForAddress("rfc822", data.protocol); + session.setDebug(data.isDebug); + return new SmtpManager(name, session, null, data); } - buffer.add(event); } - public static SmtpManager getSmtpManager(final Configuration config, final String to, final String cc, - final String bcc, final String from, final String replyTo, final String subject, String protocol, - final String host, final int port, final String username, final String password, final boolean isDebug, - final String filterName, final int numElements) { + private static final SMTPManagerFactory FACTORY = new SMTPManagerFactory(); + + private static MimeMessage createMimeMessage(final FactoryData data, final Session session, final LogEvent appendEvent) throws MessagingException { + return new MimeMessageBuilder(session).setFrom(data.from).setReplyTo(data.replyto).setRecipients(Message.RecipientType.TO, data.to) + .setRecipients(Message.RecipientType.CC, data.cc).setRecipients(Message.RecipientType.BCC, data.bcc) + .setSubject(data.subject.toSerializable(appendEvent)).build(); + } + + public static SmtpManager getSmtpManager(final Configuration config, final String to, final String cc, final String bcc, final String from, + final String replyTo, final String subject, String protocol, final String host, final int port, final String username, final String password, + final boolean isDebug, final String filterName, final int numElements) { if (Strings.isEmpty(protocol)) { protocol = "smtp"; } @@ -138,98 +198,72 @@ public class SmtpManager extends AbstractManager { sb.append(filterName); final String name = "SMTP:" + NameUtil.md5(sb.toString()); - final Serializer subjectSerializer = PatternLayout.newSerializerBuilder().setConfiguration(config) - .setPattern(subject).build(); + final Serializer subjectSerializer = PatternLayout.newSerializerBuilder().setConfiguration(config).setPattern(subject).build(); - return getManager(name, FACTORY, new FactoryData(to, cc, bcc, from, replyTo, subjectSerializer, protocol, host, - port, username, password, isDebug, numElements)); + return getManager(name, FACTORY, + new FactoryData(to, cc, bcc, from, replyTo, subjectSerializer, protocol, host, port, username, password, isDebug, numElements)); } - /** - * Send the contents of the cyclic buffer as an e-mail message. - * @param layout The layout for formatting the events. - * @param appendEvent The event that triggered the send. - */ - public void sendEvents(final Layout layout, final LogEvent appendEvent) { - if (message == null) { - connect(appendEvent); - } - try { - final LogEvent[] priorEvents = buffer.removeAll(); - // LOG4J-310: log appendEvent even if priorEvents is empty - - final byte[] rawBytes = formatContentToBytes(priorEvents, appendEvent, layout); + private final Session session; - final String contentType = layout.getContentType(); - final String encoding = getEncoding(rawBytes, contentType); - final byte[] encodedBytes = encodeContentToBytes(rawBytes, encoding); + private final CyclicBuffer buffer; - final InternetHeaders headers = getHeaders(contentType, encoding); - final MimeMultipart mp = getMimeMultipart(encodedBytes, headers); + private volatile MimeMessage message; - sendMultipartMessage(message, mp); - } catch (final MessagingException | IOException | RuntimeException e) { - logError("Caught exception while sending e-mail notification.", e); - throw new LoggingException("Error occurred while sending email", e); - } - } + private final FactoryData data; - protected byte[] formatContentToBytes(final LogEvent[] priorEvents, final LogEvent appendEvent, - final Layout layout) throws IOException { - final ByteArrayOutputStream raw = new ByteArrayOutputStream(); - writeContent(priorEvents, appendEvent, layout, raw); - return raw.toByteArray(); - } + private final ExecutorService executor = Executors.newFixedThreadPool(5); - private void writeContent(final LogEvent[] priorEvents, final LogEvent appendEvent, final Layout layout, - final ByteArrayOutputStream out) throws IOException { - writeHeader(layout, out); - writeBuffer(priorEvents, appendEvent, layout, out); - writeFooter(layout, out); + protected SmtpManager(final String name, final Session session, final MimeMessage message, final FactoryData data) { + super(null, name); + this.session = session; + this.message = message; + this.data = data; + this.buffer = new CyclicBuffer<>(LogEvent.class, data.numElements); } - protected void writeHeader(final Layout layout, final OutputStream out) throws IOException { - final byte[] header = layout.getHeader(); - if (header != null) { - out.write(header); + public void add(LogEvent event) { + if (event instanceof Log4jLogEvent && event.getMessage() instanceof ReusableMessage) { + ((Log4jLogEvent) event).makeMessageImmutable(); + } else if (event instanceof MutableLogEvent) { + event = ((MutableLogEvent) event).createMemento(); } + buffer.add(event); } - protected void writeBuffer(final LogEvent[] priorEvents, final LogEvent appendEvent, final Layout layout, - final OutputStream out) throws IOException { - // for (final LogEvent priorEvent : priorEvents) { - // final byte[] bytes = layout.toByteArray(priorEvent); - // out.write(bytes); - // } - - final byte[] bytes = layout.toByteArray(appendEvent); - out.write(bytes); - } - - protected void writeFooter(final Layout layout, final OutputStream out) throws IOException { - final byte[] footer = layout.getFooter(); - if (footer != null) { - out.write(footer); + private synchronized void connect(final LogEvent appendEvent) { + if (message != null) { + return; + } + try { + message = createMimeMessage(data, session, appendEvent); + } catch (final MessagingException e) { + logError("Could not set SmtpAppender message options", e); + message = null; } } - protected String getEncoding(final byte[] rawBytes, final String contentType) { - final DataSource dataSource = new ByteArrayDataSource(rawBytes, contentType); - return MimeUtility.getEncoding(dataSource); + protected void encodeContent(final byte[] bytes, final String encoding, final ByteArrayOutputStream out) throws MessagingException, IOException { + try (final OutputStream encoder = MimeUtility.encode(out, encoding)) { + encoder.write(bytes); + } } - protected byte[] encodeContentToBytes(final byte[] rawBytes, final String encoding) - throws MessagingException, IOException { + protected byte[] encodeContentToBytes(final byte[] rawBytes, final String encoding) throws MessagingException, IOException { final ByteArrayOutputStream encoded = new ByteArrayOutputStream(); encodeContent(rawBytes, encoding, encoded); return encoded.toByteArray(); } - protected void encodeContent(final byte[] bytes, final String encoding, final ByteArrayOutputStream out) - throws MessagingException, IOException { - try (final OutputStream encoder = MimeUtility.encode(out, encoding)) { - encoder.write(bytes); - } + protected byte[] formatContentToBytes(final LogEvent[] priorEvents, final LogEvent appendEvent, final Layout layout) throws IOException { + final ByteArrayOutputStream raw = new ByteArrayOutputStream(); + writeContent(priorEvents, appendEvent, layout, raw); + return raw.toByteArray(); + } + + protected String getEncoding(final byte[] rawBytes, final String contentType) { + final DataSource dataSource = new ByteArrayDataSource(rawBytes, contentType); + return MimeUtility.getEncoding(dataSource); } protected InternetHeaders getHeaders(final String contentType, final String encoding) { @@ -239,14 +273,51 @@ public class SmtpManager extends AbstractManager { return headers; } - protected MimeMultipart getMimeMultipart(final byte[] encodedBytes, final InternetHeaders headers) - throws MessagingException { + protected MimeMultipart getMimeMultipart(final byte[] encodedBytes, final InternetHeaders headers) throws MessagingException { final MimeMultipart mp = new MimeMultipart(); final MimeBodyPart part = new MimeBodyPart(headers, encodedBytes); mp.addBodyPart(part); return mp; } + /** + * Send the contents of the cyclic buffer as an e-mail message. + * + * @param layout + * The layout for formatting the events. + * @param appendEvent + * The event that triggered the send. + */ + public void sendEvents(final Layout layout, final LogEvent appendEvent) { + if (message == null) { + connect(appendEvent); + } + try { + final LogEvent[] priorEvents = buffer.removeAll(); + // LOG4J-310: log appendEvent even if priorEvents is empty + + final byte[] rawBytes = formatContentToBytes(priorEvents, appendEvent, layout); + + final String contentType = layout.getContentType(); + final String encoding = getEncoding(rawBytes, contentType); + final byte[] encodedBytes = encodeContentToBytes(rawBytes, encoding); + + final InternetHeaders headers = getHeaders(contentType, encoding); + final MimeMultipart mp = getMimeMultipart(encodedBytes, headers); + + executor.submit(() -> { + try { + sendMultipartMessage(message, mp); + } catch (MessagingException e) { + System.out.println(e.getMessage()); + } + }); + } catch (final MessagingException | IOException | RuntimeException e) { + logError("Caught exception while sending e-mail notification.", e); + throw new LoggingException("Error occurred while sending email", e); + } + } + protected void sendMultipartMessage(final MimeMessage msg, final MimeMultipart mp) throws MessagingException { synchronized (msg) { msg.setContent(mp); @@ -255,102 +326,34 @@ public class SmtpManager extends AbstractManager { } } - /** - * Factory data. - */ - private static class FactoryData { - private final String to; - private final String cc; - private final String bcc; - private final String from; - private final String replyto; - private final Serializer subject; - private final String protocol; - private final String host; - private final int port; - private final String username; - private final String password; - private final boolean isDebug; - private final int numElements; + protected void writeBuffer(final LogEvent[] priorEvents, final LogEvent appendEvent, final Layout layout, final OutputStream out) throws IOException { + // for (final LogEvent priorEvent : priorEvents) { + // final byte[] bytes = layout.toByteArray(priorEvent); + // out.write(bytes); + // } - public FactoryData(final String to, final String cc, final String bcc, final String from, final String replyTo, - final Serializer subjectSerializer, final String protocol, final String host, final int port, - final String username, final String password, final boolean isDebug, final int numElements) { - this.to = to; - this.cc = cc; - this.bcc = bcc; - this.from = from; - this.replyto = replyTo; - this.subject = subjectSerializer; - this.protocol = protocol; - this.host = host; - this.port = port; - this.username = username; - this.password = password; - this.isDebug = isDebug; - this.numElements = numElements; - } + final byte[] bytes = layout.toByteArray(appendEvent); + out.write(bytes); } - private synchronized void connect(final LogEvent appendEvent) { - if (message != null) { - return; - } - try { - message = createMimeMessage(data, session, appendEvent); - } catch (final MessagingException e) { - logError("Could not set SmtpAppender message options", e); - message = null; - } + private void writeContent(final LogEvent[] priorEvents, final LogEvent appendEvent, final Layout layout, final ByteArrayOutputStream out) + throws IOException { + writeHeader(layout, out); + writeBuffer(priorEvents, appendEvent, layout, out); + writeFooter(layout, out); } - /** - * Factory to create the SMTP Manager. - */ - private static class SMTPManagerFactory implements ManagerFactory { - - @Override - public SmtpManager createManager(final String name, final FactoryData data) { - final String prefix = "mail." + data.protocol; - - final Properties properties = PropertiesUtil.getSystemProperties(); - properties.put("mail.transport.protocol", data.protocol); - if (properties.getProperty("mail.host") == null) { - // Prevent an UnknownHostException in Java 7 - properties.put("mail.host", NetUtils.getLocalHostname()); - } - - if (null != data.host) { - properties.put(prefix + ".host", data.host); - } - if (data.port > 0) { - properties.put(prefix + ".port", String.valueOf(data.port)); - } - - final Authenticator authenticator = buildAuthenticator(data.username, data.password); - if (null != authenticator) { - properties.put(prefix + ".auth", "true"); - } - - final Session session = Session.getInstance(properties, authenticator); - session.setProtocolForAddress("rfc822", data.protocol); - session.setDebug(data.isDebug); - return new SmtpManager(name, session, null, data); + protected void writeFooter(final Layout layout, final OutputStream out) throws IOException { + final byte[] footer = layout.getFooter(); + if (footer != null) { + out.write(footer); } + } - private Authenticator buildAuthenticator(final String username, final String password) { - if (null != password && null != username) { - return new Authenticator() { - private final PasswordAuthentication passwordAuthentication = new PasswordAuthentication(username, - password); - - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return passwordAuthentication; - } - }; - } - return null; + protected void writeHeader(final Layout layout, final OutputStream out) throws IOException { + final byte[] header = layout.getHeader(); + if (header != null) { + out.write(header); } } } diff --git a/server/user.jobengine.executors/config/config.xml b/server/user.jobengine.executors/config/config.xml index d856098f..066dc7a4 100644 --- a/server/user.jobengine.executors/config/config.xml +++ b/server/user.jobengine.executors/config/config.xml @@ -3,7 +3,7 @@ - + diff --git a/server/user.jobengine.executors/jobtemplates/retrieve-traffic-missing-materials.xml b/server/user.jobengine.executors/jobtemplates/retrieve-traffic-missing-materials.xml index 693013ae..2e5682b9 100644 --- a/server/user.jobengine.executors/jobtemplates/retrieve-traffic-missing-materials.xml +++ b/server/user.jobengine.executors/jobtemplates/retrieve-traffic-missing-materials.xml @@ -21,9 +21,6 @@ - - - diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CheckTrafficMissingMaterialsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CheckTrafficMissingMaterialsStep.java index 274a5e16..a5b9dc1b 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/CheckTrafficMissingMaterialsStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CheckTrafficMissingMaterialsStep.java @@ -23,7 +23,7 @@ public class CheckTRAFFICMissingMaterialsStep extends JobStep { private static final String OUTPUT_PATH = "outputPath"; private static final String MEDIA_CUBE_MEDIA = "mediaCubeMedia"; private static final String SQLSERVER_JDBC_SQL_SERVER_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; - private static final String SQL = "{call clIFsp_EC_MAM(1001, 40, Null, Null, ?)}"; + private static final String SQL = "{call dbo.clIFsp_EC_MAM(1001, 32, Null, Null, ?)}"; private static final String JOBTEMPLATE = "retrieve-material.xml"; @StepEntry @@ -35,12 +35,13 @@ public class CheckTRAFFICMissingMaterialsStep extends JobStep { try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { String trafficId = rs.getString(5); - if (StringUtils.isNotBlank(trafficId)) { - try { - processTrafficId(trafficId, outputPath, jobEngine); - } catch (Exception e) { - logger.error(getMarker(), "Hiba lépett fel az {} anyag visszatöltéskor. A rendszer hibaüzenete: {}", trafficId, e.getMessage()); - } + if (StringUtils.isBlank(trafficId)) + continue; + + try { + processTrafficId(trafficId, outputPath, jobEngine); + } catch (Exception e) { + logger.error(getMarker(), "Hiba lépett fel az {} anyag visszatöltéskor. A rendszer hibaüzenete: {}", trafficId, e.getMessage()); } } @@ -74,7 +75,7 @@ public class CheckTRAFFICMissingMaterialsStep extends JobStep { return; } - if (medias.size() > 0) { + if (medias.size() > 1) { logger.error(getMarker(), "Az {} anyagból egynél több található az archívumban.", trafficId); return; } diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMBackupStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMBackupStep.java index 393d6e11..1e1b33b2 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMBackupStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMBackupStep.java @@ -55,7 +55,8 @@ public class TSMBackupStep extends JobStep { String sourceFileName = inputFilePath.toFile().getName(); RemoteFile remoteFile = sourceUri.transferFrom(targetStoreUri, sourceFileName, sourceFileName); - saveMetadata(mediaCubeMedia, sourceFileName); + String name = getHouseId(archiveItem); + saveMetadata(mediaCubeMedia, sourceFileName, name); logger.info(getMarker(), "A {} állomány archiválása sikeres.", archiveItem.getMediaFile().toFile().getName()); } catch (Exception e) { @@ -67,11 +68,21 @@ public class TSMBackupStep extends JobStep { return null; } - private void saveMetadata(Media mediaCubeMedia, String sourceFileName) { + private String getHouseId(ArchiveItem archiveItem) { + String name = archiveItem.getMediaFile().toFile().getName(); + int pos = name.lastIndexOf("."); + if (pos > 0) { + name = name.substring(0, pos); + } + return name; + } + + private void saveMetadata(Media mediaCubeMedia, String sourceFileName, String houseId) { MediaFile mediaFile = manager.createMediaFile(sourceFileName, fileType, targetStore, mediaCubeMedia); mediaFile.add(); mediaCubeMedia.setPersister(manager); mediaCubeMedia.setArchived(new Timestamp(new Date().getTime())); + mediaCubeMedia.setHouseId(houseId); mediaCubeMedia.modify(); } diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMRestoreStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMRestoreStep.java index 1a745b5c..cbe2fd76 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMRestoreStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMRestoreStep.java @@ -27,7 +27,7 @@ public class TSMRestoreStep extends JobStep { } @StepEntry - public Object[] execute(Media media, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { + public Object[] execute(Media media, String outputPath, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { RemoteFile result = null; final IJobRuntime runtime = jobRuntime; IItemManager manager = jobEngine.getItemManager(); @@ -57,6 +57,8 @@ public class TSMRestoreStep extends JobStep { StoreUri sourceUri = new StoreUri(); sourceUri.setProtocol(RemoteStoreProtocol.TSM); + + //TODO outputPath alapon! StoreUri target = systemStore.getTargetStoreUri(RemoteStoreProtocol.LOCAL); logger.info("Target is: " + target.getUri()); sourceUri.addProgressListener(new IProgressEventListener() { diff --git a/server/user.jobengine.osgi.server/META-INF/MANIFEST.MF b/server/user.jobengine.osgi.server/META-INF/MANIFEST.MF index abcec96b..51e7912d 100644 --- a/server/user.jobengine.osgi.server/META-INF/MANIFEST.MF +++ b/server/user.jobengine.osgi.server/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Server Bundle-SymbolicName: user.jobengine.osgi.server;singleton:=true Bundle-Version: 1.0.0 -Service-Component: OSGI-INF/*.xml +Service-Component: OSGI-INF/component.xml, OSGI-INF/ConsoleCommandProvider.xml Import-Package: javax.servlet;version="3.1.0", javax.servlet.http;version="3.1.0", org.apache.logging.log4j.core;version="2.8.2", diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/JobStep.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/JobStep.java index 10098123..15b8aa18 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/JobStep.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/JobStep.java @@ -41,7 +41,10 @@ public class JobStep implements IJobStep { } protected Marker getMarker() { - return MarkerManager.getMarker(getRuntimeName()); + Marker parentMarker = MarkerManager.getMarker("MEDIACUBE"); + Marker result = MarkerManager.getMarker(getRuntimeName()); + result.setParents(parentMarker); + return result; } protected String getRuntimeName() { -- 2.54.0