Tuesday, December 1, 2009

Dynamic deployment of Alfresco Custom Workflow

This feature is available from Alfreso 3.0 and above.

Alfresco 3 has given the facility of Dynamic Deployment for
1.New content/Workflow model.
2.Message Resource Bundle.
3.Alfresco Explorer configuration (Web-client-config.xml).
4.Workflow Process Definition.

Please download this pdf file for working example.

http://docs.google.com/fileview?id=0B2GTDzbcX3UsMWE2NTRmNGYtNDhhNC00NTIyLTllZjYtOTNmMmZlMjc2OWNl&hl=en

Friday, November 27, 2009

Alfresco CIFS on Windows XP

Below steps will enable to Configure Alfresco CIFS on Windows Platform

1. Create file-server-custom.xml in alfresco/extension package

<alfresco-config area="file-servers">

<!-- To override the default Alfresco filesystem use replace="true", to -->
<!-- add additional filesystems remove the replace="true" attribute -->

<config evaluator="string-compare" condition="Filesystems" replace="true">
<filesystems>

<filesystem name="Alfresco">
<store>workspace://SpacesStore</store>
<rootPath>/app:company_home</rootPath>
<disableChangeNotification/>
<!-- Add a URL file to each folder that links back to the web client -->
<urlFile>
<filename>__Alfresco.url</filename>
<webpath>http://${localname}A:8080/alfresco/</webpath>
</urlFile>

<!-- Mark locked files as offline -->
<offlineFiles/>

<!-- Desktop actions -->

<desktopActions>
<global>
<path>alfresco/desktop/Alfresco.exe</path>
<webpath>http://${localname}A:8080/alfresco/</webpath>
</global>
<action>
<class>org.alfresco.filesys.smb.server.repo.desk.CheckInOutDesktopAction</class>
<name>CheckInOut</name>
<filename>__CheckInOut.exe</filename>
</action>
<action>
<class>org.alfresco.filesys.smb.server.repo.desk.JavaScriptDesktopAction</class>
<name>JavaScriptURL</name>
<filename>__ShowDetails.exe</filename>
<script>alfresco/desktop/showDetails.js</script>
<attributes>anyFiles</attributes>
<preprocess>copyToTarget</preprocess>
</action>

</desktopActions>

<!--
<accessControl default="Write">
<user name="admin" access="Write"/>
<address subnet="90.1.0.0" mask="255.255.0.0" access="Write"/>
</accessControl>
-->
</filesystem>

<!-- AVM virtualization view of all stores/versions for WCM -->
<avmfilesystem name="AVM">
<virtualView/>
</avmfilesystem>

</filesystems>
</config>

</alfresco-config>


2. Enable Debug setting for CIFS server (so that you can see successful execution on CIFS @ tomcat\webapps\alfresco\WEB-INF\classes\log4j.properties)
log4j.logger.org.alfresco.smb.protocol=debug
log4j.logger.org.alfresco.smb.protocol.auth=debug
log4j.logger.org.alfresco.acegi=debug
3. Restart Tomcat and Map Drive with \\alfresco109A\Alfresco


Troubleshooting
If your are still unable to get CIFS server up...
Please be sure

1. Your custom-configuration is deployed on tomcat server (see in "tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension" or in jar if you are using jar for your application module).
2. Your computer name should be less than 15 character.


Please post a comment if you found this blog useful to you :)

Tuesday, August 18, 2009

WSSecurityEngine: Invalid timestamp The security semantics of message have expired

Each message sent by the client contains a time-stamp. The server refuses messages sent more than five minutes ago. This is to prevent replay attacks (where an attacker gets hold of a valid message and then sends it again later).

Handler definition:

<handler name="WSSecurity" type="java:org.apache.ws.axis.security.WSDoAllReceiver">
<parameter name="action" value="UsernameToken Timestamp"/>
</handler>


How Timestamp handling in WSS4J
WSS4J supports several time features and options. If you just use the action Timestamp without any further configuration WSS4J uses the following defaults :

•All timestaps use millisecond precision
•The default time difference between Created and Expires is set to 300 seconds (5 minutes).
•The handler performs strict timestamp handling, i.e. throws an exception if verification of the timestamp fails.
Use the following handler parameters to change these settings:
timeToLive to specify another time difference between Created and Expires. The value of this parameter is an integer that defines the time difference in seconds.
precisionInMilliseconds to switch off the millisecond time precision. Set the value to false or 0 to generate timestamps without milliseconds.
timestampStrict to switch off strict timestamp handling. Set the value to false or 0 to switch off strict handling. According to WSS specfications it is optional to report a fault if timestamp verification fails.

Check the system clock on your server and make sure it's set to the same time as the client machine.

If both client and server reside in US then we need to set timezone like

For Window Sever – (GMT – 05:00) Eastern Time (US & Canada)
Go to Start-->Control Panel-->Date and Time and change time zone

Changing time zone in Solaris 10 - x86
Create new file /etc/TIMEZONE
vi /etc/TIMEZONE

Change the value for TZ to the zone I want
E.g. TZ=US/Eastern

For full list, refer /usr/share/lib/zoneinfo

Run below command
#rtc –z US/Eastern
#rtc –c

Reboot you system to get date and time zone changed effect.

You can verify your ) Eastern Time (US & Canada) with
http://www.timeanddate.com/library/abbreviations/timezones/na/edt.html

Wednesday, July 1, 2009

How to return PDF file byte array from webservice

Below is the solution code snippet which shows how to pass and return pdf file byte[] as string from and to Webservice.

For the webservice as input parameter or as return parameter as String[] one needs to convert byte[] of PDF file buffer to String.

So it could be like


public String[] getDocument(String pdffileName) {
File file =null;
InputStream is = null;
String[] retParam = new String[2];
try {
file = new File(pdffileName);
is = new FileInputStream(file);

// Get the size of the file
long length = file.length();
// Create the byte array to hold the data
byte[] bytes = new byte[(int) length];

// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) {
offset += numRead;
}

// Ensure all the bytes have been read in
if (offset < bytes.length) {
throw new IOException("Could not completely read file "
+ file.getName());
}
String pdfByteArrayStr = new sun.misc.BASE64Encoder().encode(bytes);
retParam[0] = file.getName();
retParam[1] = pdfByteArrayStr;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
if (is !=null){
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

return retParam;
}



Now Read The Parameters From WebService

String []responseParam = this.locator.getDocumentService().getDocument(pdffileName);
requestParam could be file name or any other parameter

String fileName = responseParam[0];
byte [] formBuffer = new sun.misc.BASE64Decoder().decodeBuffer(responseParam[1]);

This formBuffer can be used to either pass to FileOututStream to store file on FileSystem or to ServletOutputStream to show in browser.