Thursday, August 28, 2014

Liferay SQL

SELECT * FROM "LRAY"."LAYOUT" WHERE FRIENDLYURL = '/bla'
SELECT * FROM "LRAY"."JOURNALARTICLE" where TITLE = 'bla'

Find dups:

SELECT FRIENDLYURL, count(*)
FROM "LRAY"."LAYOUT"
GROUP BY
FRIENDLYURL
having
count(*) > 1


Find bad article

SELECT * FROM "LRAY"."JOURNALARTICLE" where URLTITLE IS NULL;



Count

select count(*) cnt
from user_constraints
where table_name='JOURNALARTICLE'
and constraint_type='U';




Let's say:

17:30:33,297 ERROR [JDBCExceptionReporter:234] ORA-00001: unique constraint (LRAY.IX_E2815081) violated

17:30:33,298 ERROR [JDBCExceptionReporter:234] ORA-00001: unique constraint (LRAY.IX_E2815081) violated

17:30:33,299 ERROR [PortletImporter:669] com.liferay.portal.kernel.lar.PortletDataException: com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
com.liferay.portal.kernel.lar.PortletDataException: com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at com.liferay.portal.kernel.lar.BasePortletDataHandler.importData(BasePortletDataHandler.java:78)
at com.liferay.portal.lar.PortletImporter.importPortletData(PortletImporter.java:665)
at com.liferay.portal.lar.PortletImporter.importPortletData(PortletImporter.java:546)
at com.liferay.portal.lar.LayoutImporter.importLayouts(LayoutImporter.java:417)
at com.liferay.portal.service.impl.LayoutLocalServiceImpl.importLayouts(LayoutLocalServiceImpl.java:685)
at com.liferay.portal.service.impl.LayoutLocalServiceImpl.importLayouts(LayoutLocalServiceImpl.java:709)
at com.liferay.portal.service.impl.LayoutLocalServiceImpl.importLayouts(LayoutLocalServiceImpl.java:672)
at sun.reflect.GeneratedMethodAccessor4493.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:86)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy34.importLayouts(Unknown Source)



select table_name from all_indexes where index_name='IX_E2815081';

shows DLFILEVERSION


Monday, August 25, 2014

SSL notes

1. Log into the web server to be updated.





4. cd conf/extra directory



Example: SSLCertificateFile "/u01/app/appadmin/product/servers/pactiprd/ssl/rsact01.crt"



Example: SSLCertificateKeyFile "/u01/app/appadmin/product/servers/pactiprd/ssl/rsact01.key"

8. Copy the server crt and key file to the location defined within the httpd-ssl.conf file.



step 2: Download the cert from the server.
openssl s_client -connect 10.4.10.1:7336 | tee cert

Step 5: Verify whether the cert got added to the keystore and check its information.
keytool -list -v -keystore keystore



Step x: If you want to print the cert
keytool -printcert -file file.cer

You can use openssl to test certificate store if running in a container such as java.

openssl s_client -connect bla:PORT -state -debug
If it errors out this will verify that there is a problem with the keystore.
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class MulticastNode {

InetAddress group = null;
MulticastSocket s = null;

public static void main(String[] args) {

if (args.length > 0) {

System.out.println("Sending message: " + args[0]);

MulticastNode node = new MulticastNode();

node.send(args[0]);

node.receive();


} else {

System.out.println("Need an argument string to send.");
System.exit(1);

}

}

public MulticastNode() {

try {

group = InetAddress.getByName("228.0.0.4");
s = new MulticastSocket(45564);
s.joinGroup(group);

} catch (Exception e) {

e.printStackTrace();

}

}

public void send (String msg) {

try {

DatagramPacket hi = new DatagramPacket(
msg.getBytes(), msg.length(),group,45564);
s.send(hi);

} catch (Exception e) {

e.printStackTrace();

}
}

public void receive() {

byte[] buf;

while (true) {


try {

buf = new byte[1000];
DatagramPacket recv = new DatagramPacket(buf, buf.length);
s.receive(recv);
System.out.println("Received: " + new String(buf));

} catch (Exception e) {

e.printStackTrace();

}

}

}

}



to test.
Copy to a test directory on each machine you want to test.
Then run "$JAVA_HOME/bin/java MulticastNode NodeOne" on the first node.
On the second node ""$JAVA_HOME/bin/java MulticastNode NodeTwo"
You will first see:
>java MulticastNode NodeOne
Sending message: NodeOne
Received: NodeOne
on the first node, then when starting on second:

This is from pages 374-378 of "Tomcat the definitive guide" from O'Reilly.