Powered By Blogger

Tuesday, February 28, 2012

Monday, February 27, 2012

Eclipse's Memory Analyzer

Eclipse's Memory Analyzer

You can find more details in the below link
http://www.eclipse.org/mat/about/screenshots.php

Friday, February 24, 2012

XmlAdapter


1. http://blog.bdoughan.com/2010/07/xmladapter-jaxbs-secret-weapon.html

2. JMX
Exposing the beans and controlling them through the Jconsole

Alfresco projects

http://forge.alfresco.com/gf/project/

AbstractLifecycleBean

AbstractLifecycleBean

It has to be implemnted if we want to do something on the start up of the
container and shitdown of container. It is usually done for initializing
surf objects

it provides below call back methods
onBootstrap
onShutdown

Tuesday, February 21, 2012

Good post on Alfresco Installation

http://www.howtoforge.com/how-to-install-alfresco-community-3.3-on-ubuntu-server-10.04-lucid-lynx
http://shane.jaducana.net/2010/installing-alfresco-3-2r2-on-ubuntu-9-10-karmic-koala/
http://wiki.alfresco.com/wiki/JVM_Tuning
http://wiki.alfresco.com/wiki/Best_Practices

Monday, February 20, 2012

Mysql Workbench

Mysql workbench is the best tool for managing the mysql related configurations and connections.
It requires .net support for while installing

Wednesday, February 15, 2012

Mysql InnoDB

http://www.chriscalender.com/?tag=show-engine-innodb-status
http://dev.mysql.com/doc/refman/5.0/en/innodb-monitors.html
http://www.mysqlperformanceblog.com/2006/07/17/show-innodb-status-walk-through/

It speaks about how to configure the system
http://datastrangler.com/uploads/cnf/my.cnf_4GB

Tuesday, February 14, 2012

Friday, February 10, 2012

Alfresco server startup

set JAVA_OPTS=-Xms512m -Xmx1024m -Xss1024k -XX:MaxPermSize=256m

Set the JAVA_OPTS in the startup.bat of alfresco , so that we can start alfresco in the cosnsole instead of service.


rem
rem $Id: startup.bat 908749 2010-02-10 23:26:42Z markt $
rem ---------------------------------------------------------------------------
set JAVA_OPTS=-Xms512m -Xmx1024m -Xss1024k -XX:MaxPermSize=256m
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"

Thursday, February 9, 2012

Linux Tutors useful links

http://www.ee.surrey.ac.uk/Teaching/Unix/
http://linuxcommand.org/learning_the_shell.php

http://www.cyberciti.biz/faq/linux-unix-set-java_home-path-variable/
http://www.cyberciti.biz/faq/set-environment-variable-linux/

Session time out in tomcat

http://www.smartsoftwarebits.com/qaa/46-misc/82-how-to-set-session-timeout-for-tomcat

1.<session-config>
2.<session-timeout>30session-timeout>
3.session-config>

The above entry has to be done in web.xml. Time out is been mentioned in minutes.
http://www.chemaxon.com/jchem/doc/admin/tomcat.html

Tuesday, February 7, 2012

CURL Response codes

http://beerpla.net/2010/06/10/how-to-display-just-the-http-response-code-in-cli-curl/

Monday, February 6, 2012

Calling the WebScript from command line and Java class

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;

/**
*
*/

/**
* @author basanagowda.patil
*
*/
public class Test2 {

/**
* Main class of entry point
*
* @param args
*/
public static void main(final String[] args) {
System.out.println("Lucene Backup is been triggered");
final String url = "http://ecmdev.patil.com/alfresco/wcservice/patils/tags/all";
final HttpClient client = new HttpClient();
final GetMethod httpGet = new GetMethod(url);

try {

httpGet.addRequestHeader("CTUSER", "HFPBB101");
client.executeMethod(httpGet);
final String response = (httpGet.getResponseBodyAsString());
System.out.println(response);


System.out.println("StatusText:::"+ httpGet.getStatusText());
httpGet.releaseConnection();

} catch (final Exception e) {
e.printStackTrace();
}

}
}




You can call the webscripts from the CURL .

1. By passing the header

curl --header "CTUSER:HFPBB01" http://ecmdev.patil.com/alfresco/wcservice/patil/tags/all

2. By passing username and password

curl -uhfpbb101:8999 http://ecmdev.patil.com/alfresco/s/cmis

The first one is the preferred approach. Now we can write the webscript which triggers lucene backup and call that webscript as mentioned above.


There are other ways of backing the lucene indexes trigger

1. JMX

2.Command line

Refer to the link http://wiki.alfresco.com/wiki/Backup_and_Restore#

3. To get the http code

curl -sL -w "%{http_code} %{url_effective}\\n" --header "CTUSER:55551" "http://halfd01.patil.com:8080/alfresco/wcservice/patils/tags/all" -o /dev/null

Control-M Tool to Schedule backups - command execution tool

This tool can be used with commands written in bash shell script, perl, python or java.
http://www.scheduler-usage.com/document/Documentation/CTMS/V6.3.01/57941.pdf

http://www.scribd.com/aneezanis/d/22694387-ControlM-Concepts-Guide

Thursday, February 2, 2012

Maven important tutorial

http://blog.3kbo.com/2009/02/20/maven-commands/

Creating Maven Projects

  • mvn archetype:create -DgroupId=com._3kbo -DartifactId=application (create a project for building a jar file )
  • mvn archetype:create -DgroupId=com._3kbo -DartifactId=webapplication -DarchetypeArtifactId=maven-archetype-webapp (create a web app project for building a war file)
  • mvn archetype:generate (Select the number of the desired archetype.)

Building, Testing, Packaging and Installing to the Repository

  • mvn clean (cleans the project, i.e. delete the target directory)
  • mvn compile (compiles the source code)
  • mvn test (if required compiles the source code, then runs the unit tests)
  • mvn package (compiles, tests then packages the jar or war file)
  • mvn clean install (cleans the project, compiles, tests, packages and installs the jar or war file)
  • mvn install (compiles, tests, packages and installs the jar or war file)
  • mvn -o install (compiles, tests, packages and installs the jar or war file in offline mode)
  • mvn -Dmaven.test.skip package (package without running the tests)
  • mvn -Dmaven.test.skip clean install (clean and install without running tests)
  • mvn -o test (test offline)

Unit Tests

  • mvn test –Dtest=AspectTest (run a specific test)
  • mvn test -Dtest=*ModelTest (run a subset of tests using regular expression. E.g. test all ModelTest classes)

Excluding log4j.properties from jar file

Move log4j.properties from src/main/resources to src/test/resources.
That way it gets picked up by the testResources for testing but excluded from the jar file.

Manually Install a file to the Repository

mvn install:install-file -DgroupId=com._3kbo -DartifactId=model -Dversion=1.0.0 -Dpackaging=jar -Dfile=new_file.jar

Set Java Build Version




org.apache.maven.plugins
maven-compiler-plugin

1.5
1.5



Documentation

The mvn site command builds a useful dependency tree at target/site/dependencies.html.

  • mvn site (generate documentation in the target/site directory)
  • mvn javadoc:javadoc (generate javadoc in target/site/apidocs directory )
  • mvn help:active-profiles (lists the profiles currently active)
  • mvn help:effective-pom (displays the effective POM for the current build)
  • mvn help:effective-settings (displays the calculated settings for the project, given any profile enhancement and the inheritance of the global settings into the user-level settings.)
  • mvn help:describe (describes the attributes of a plugin)

For large projects mvn site can run out of memory. Use MAVEN_OPTS in the mvn or mvn.bat script to allocate additional memory, e.g:

MAVEN_OPTS=”-Xmx512m -Xms256m -XX:MaxPermSize=128m”

Repositories

Jena http://jena.hpl.hp.com/repo
Jersey http://download.java.net/maven/2/
Maven Central http://www.ibiblio.org/maven2


Wednesday, February 1, 2012

Sharepoint flow in Alfresco 3.4.5


${vti.share.siteInBrowser}

${vti.share.siteSettings}

${vti.share.siteGroupMembership}

${vti.share.userInformation}

${vti.share.documentLibrary}

${vti.share.documentDetails}

${vti.share.calendar}



The above bean declaration is using properties defined in the vti.properties which are speciic to site.


vti.share.siteSettings=/page/site/.../customise-site

vti.share.siteGroupMembership=/page/site/.../site-members

vti.share.userInformation=/page/user/.../profile

vti.share.documentLibrary=/page/site/.../documentlibrary

vti.share.documentDetails=/page/site/.../document-details

vti.share.calendar=/page/site/.../calendar



In the run time these values will be used by MS office.


  • alfresco-vti-3.4.5.jar is using the code required for the sharepoint communication.


AlfrescoDwsServiceHandler has the implementation to replace the node id urls



String uuid = req.getParameter("nodeId");


String uri = req.getRequestURI();

String redirectTo;


if (uuid != null)

{

// open site in browser

final NodeRef siteNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, uuid.toLowerCase());

redirectTo = pagesMap.get("siteInBrowser");

redirectTo = redirectTo.replace("...", siteNodeRef.getId());

}





  • Communication happens with MS office docs using WebService response.




here it is pointing to sites.








It talks about what info is required for integration in the class DwsServiceHandler


/**

* Returns information about a document workspace site and the lists it contains

*

* @param document the site-based URL of a document in a document library in the document workspace site

* @param id an optional document globally unique identifier (GUID)

* @param minimal determines whether the output includes information about the schemas, lists, documents, links, and tasks lists of a document workspace site

* @return DwsMetadata information about a document workspace site and the lists it contains ({@link DwsMetadata})

*/

public DwsMetadata getDWSMetaData(String documentURL, String id, boolean minimal) throws Exception;



If we have to support sharepoint protocol then we should have details about tasks,links and document list but in the normal doc we will not have this information.




The server will be done using the bean







The logs are as below


05:50:18,573 DEBUG [vti.web.VtiFilter] Checking request for VTI

05:50:18,573 DEBUG [vti.web.VtiFilter] Check authentication

05:50:18,591 DEBUG [module.vti.handler] Resolved file info for 'templatechange/_vti_bin/_vti_aut/author.dll' is null

05:50:18,596 DEBUG [module.vti.handler] Resolved file info for 'templatechange/_vti_bin/_vti_aut' is null

05:50:18,600 DEBUG [module.vti.handler] Resolved file info for 'templatechange/_vti_bin' is null

05:50:18,607 DEBUG [module.vti.handler] Resolved file info for 'templatechange' is FileInfo[name=templatechange, isFolder=true, nodeRef=workspace://SpacesStore/cb5eb9d0-81ad-43d3-8ef7-c059b1b88704]

05:50:18,617 DEBUG [alfresco.v3.AlfrescoMethodHandler] WebUrl: /alfresco/templatechange, fileUrl: '_vti_bin/_vti_aut/author.dll'

05:50:18,634 DEBUG [vti.web.VtiFilter] User was authenticated successfully

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Process request

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Find appropriate action by specific rules

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Specific rule not found

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Find appropriate action by pattern for uri='/templatechange/_vti_bin/_vti_aut/author.dll'

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Action found for request

05:50:18,635 DEBUG [vti.web.VtiRequestDispatcher] Execute target action

05:50:18,636 DEBUG [web.actions.VtiBinAction] Executing vtiMethod: org.alfresco.module.vti.web.fp.CheckoutDocumentMethod@3941f799

05:50:18,636 DEBUG [web.fp.CheckoutDocumentMethod] Start method execution. Method name: checkout document

05:50:18,636 DEBUG [handler.alfresco.AbstractAlfrescoMethodHandler] Checkout document: documentLibrary/test.doc. Site name: templatechange

05:50:18,647 DEBUG [module.vti.handler] Resolved file info for 'templatechange/documentLibrary/test.doc' is FileInfo[name=test.doc, isFolder=false, nodeRef=workspace://SpacesStore/ee54a9a8-837a-43f1-b02e-276d2603861a]

05:50:18,704 DEBUG [handler.alfresco.AbstractAlfrescoMethodHandler] Short-term checkout.

05:50:18,870 DEBUG [module.vti.handler] Convert FileInfo[name=test.doc, isFolder=false, nodeRef=workspace://SpacesStore/ee54a9a8-837a-43f1-b02e-276d2603861a] to url path 'templatechange/documentLibrary/test.doc'

05:50:18,871 DEBUG [web.fp.CheckoutDocumentMethod] End of method execution. Method name: checkout document




The flow will be



Filter → Handler →Request Dispatcher → Action(VtiBinAction) → Method




Authentication itself is been checked using the siteservice in the Group AlfrescoUserGroupServiceHandler.


/**

* @see org.alfresco.module.vti.handler.UserGroupServiceHandler#isUserMember(java.lang.String, java.lang.String)

*/

public boolean isUserMember(String dwsUrl, String username)

{

// Normalize the user ID taking into account case sensitivity settings

String normalized = personService.getUserIdentifier(username);

if (normalized == null)

{

return false;

}

boolean isMember = siteService.isMember(dwsUrl, normalized);

if (!isMember && authorityService.isAdminAuthority(username))

{

// Admin is allowed to do things even on sites they're not

// a member of. So, pretend they are a member so they're allowed

isMember = true;

}

return isMember;

}




In the DefaultAuthenticationHandler class it checks whether user belongs to site or not


authenticateRequest() → which inturn checks for whether user belongs to site or not. All the requests will be going through the filter and filter calls authentication code. There it fails since the user is not belonging to any of the site.



Conclusion :

All the requests will be passing through the filter which checks whether user belongs to any of the site or not. If the user is not member of the site then user will be stopped from accssing the document.


VtiFilter checks with authenticationhandler.


user = authenticationHandler.authenticateRequest(this.context, httpRequest, httpResponse, getAlfrescoContext());




public SessionUser authenticateRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response,

String alfrescoContext) throws IOException, ServletException

{

if (delegate.authenticateRequest(context, request, response))

{

HttpSession session = request.getSession(false);

if (session == null)

{

return null;

}

SessionUser user = (SessionUser) session.getAttribute(USER_SESSION_ATTRIBUTE);

if (user == null)

{

return null;

}

if(isSiteMember(request, alfrescoContext, user.getUserName()))

{

return user;

}

delegate.restartLoginChallenge(context, request, response);

}

return null;

}


It checks of the user belongs to site. If not it gives back null.





Next topic



/**

* @see org.alfresco.module.vti.handler.MeetingServiceHandler#createWorkspace(String, String, int, TimeZoneInformation, SessionUser)

*/

public String createWorkspace(String title, String templateName, int lcid, TimeZoneInformation timeZoneInformation, SessionUser user) throws Exception

{

title = removeIllegalCharacters(title);


if (title.equals("_"))

{

throw new RuntimeException(getMessage("vti.meeting.error.workspace_name"));

}


SiteInfo siteInfo = null;

String newTitle = null;

int i = 0;

do

{

newTitle = title + (i == 0 ? "" : "_" + i);

siteInfo = siteService.getSite(newTitle);

i++;

} while (siteInfo != null);


shareUtils.createSite(user, MEETING_WORKSPACE_NAME, newTitle, newTitle, "", true);


return newTitle;

}



Creation of the workspace leads to the creation of the site internally.





AlfrescoDwsServiceHandler and AlfrescoCheckOutCheckInServiceHandler these 2 handlers are most important and to be analysed to enable the online edit.