Powered By Blogger

Thursday, March 31, 2011

Alfresco installation in Weblogic server

1. Download the .ear file and put it in c:\Alfresco and execute below commands for extraction
mkdir alfresco
cd alfresco
jar xvf ../alfresco-enterprise-3.4.0.ear
move alfresco.war alfresco.war.tmp
move share.war share.war.tmp
mkdir alfresco.war
mkdir share.war
cd alfresco.war
jar xvf ../alfresco.war.tmp
cd ../share.war
jar xvf ../share.war.tmp

WebLogic administration

System administration of WebLogic Server includes a wide range of tasks: creating WebLogic Server domains; deploying applications; migrating domains from development environments to production environments; monitoring and managing the performance of the run-time system; and diagnosing and troubleshooting problems. (A WebLogic Server domain is a collection of WebLogic Server services designed for a specific purpose. For example, you might create one domain to provide an employee portal and another domain to provide business services to your customers.)

WebLogic Server provides several ways to start and stop server instances. The method that you choose depends on whether you prefer using a graphical or command-line interface, and on whether you are using the Node Manager to manage a server's life cycle.
You can start a server instance on any computer on which WebLogic Server has been installed. The server's configuration information always resides in the domain's config.xml file, which is located on the computer that hosts the Administration Server. The first server instance you start in a domain assumes the role of Administration Server. Additional server instances assume the role of Managed Server.

No matter how you start a server, the end result passes a set of configuration options to initialize a Java Virtual Machine (JVM). The server instance runs within the JVM, and the JVM can host only one server instance.

Tuesday, March 29, 2011

Liferay Tags

Liferay portal tags are JavaServer Pages Standard Tag Library (JSTL) tags. Using Liferay tags has the following two benefits.

You get a complicated feature with only one tag.
Liferay UI tags have been tested. They do not introduce bugs. This saves testing time.

They can be classified as below

Alloy (AUI) tags
Liferay portlet tags
Liferay liferay-portlet tags
Liferay security tags
Liferay theme tags
Liferay UI tags
Liferay utility tags


Liferay portlet tags

com.liferay.taglib.portlet.DefineObjectsTag class is responsible for its interpretation. The result is that the following objects, among others, are set in
the pageContext:
renderRequest
renderResponse
portletPreferences
In this way we can directly use these objects in our portlet JSP file coding


portlet:actionURL

We can use the actionURL tag to dynamically generate a URL in our JSP file and
use it, say, as an action URL for a form.




This tag is interpreted by the com.liferay.taglib.portlet.ActionURLTag class. It generates an action URL string with page layout ID, portlet ID, portlet mode, window state, and layout information. It will also include a parameter name of struts_action with a value of /journal/edit_article. This URL is set as value for an editArticleActionURL variable. Eventually this variable is used as the
action URL for a form as follows:


Monday, March 28, 2011

localization of Web Content in Liferay

Liferay has built-in support for localization of web contents in some of the out-of-box portlets such as Web Content portlet.
A user needs to create a new article with contents in the default language first and save it. The user can then edit the article, select a different language in the Language drop down, and then add the localized content by using the WYSIWYG online editor.

Status command of mysql

mysql> create database lportal character set utf8 collate utf8_bin;
mysql> use lportal;
mysql> status;


The status comman will display the below details.
mysql Ver 14.14 Distrib 5.1.44, for Win32 (ia32)
Connection id: 3
Current database: lportal
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.1.44-community MySQL Community Server (GPL)
Protocol version: 10
Connection: localhost via TCP/IP
Styling Pages
[ 100 ]
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 45 min 51 sec
Threads: 1 Questions: 12 Slow queries: 0 Opens: 15 Flush tables: 1 Open tables: 0 Queries per
second avg: 0.4
--------------
mysql>

Getting CMISObject from nodeRef of Alfresco

/**
*
*/
package com.packtpub.a3ws.samples.chemistry;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.ObjectId;
import org.apache.chemistry.opencmis.client.api.Repository;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;

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



private static Session getSession(String serverUrl, String username, String password) {
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map params = new HashMap();
params.put(SessionParameter.USER, username);
params.put(SessionParameter.PASSWORD, password);
params.put(SessionParameter.ATOMPUB_URL, serverUrl);
params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
List repos = sessionFactory.getRepositories(params);
if (repos.isEmpty()) {
throw new RuntimeException("Server has no repositories!");
}
return repos.get(0).createSession();
}









/**
* @param args
*/



public static void main(String[] args) {
String serverUrl = "http://localhost:8080/alfresco/service/cmis";
String username = "admin";
String password = "admin";
Session session = getSession(serverUrl, username, password);
Folder root = session.getRootFolder();

System.out.println("The root folder is :::"+ root.getId());

//Create the folder(Wiki, inside Wiki images) under CompanyHome

Folder wikiImagesFolder = (Folder) session.getObjectByPath("/Wiki/images");

System.out.println("Illustrating how to construct the CMISObject from the noderef");
System.out.println("The folder ref of the image created is::"+ wikiImagesFolder.getId());
ObjectId parentId = session.createObjectId(wikiImagesFolder.getId());
Folder wikiImagesFolder1 = (Folder) session.getObject(parentId);

System.out.println("Reconstructed the CMisobject from the nodeRef:::"+ wikiImagesFolder1.getId());





}

}

Alfresco CMIS support for Custom types

As of noe CMIS 1.0 spec does not support the custom content types used in alfresco.

refer to the below link
http://forums.alfresco.com/en/viewtopic.php?f=45&t=37645

Re: Defining custom metadata types through CMIS.

Postby fmui » 08 Mar 2011, 11:16
Hi,

There are two answers:

1) Creating new custom types through CMIS is not possible at this time because it is not part of the CMIS 1.0 standard.
This going to change with CMIS 1.1. The next revision of the standard will define type creation, modification and deletion.
The CMIS 1.1 specification will hopefully be completed in late summer and Alfresco will have an implementation shortly aft that.

2) You can set up a dynamic model through CMIS: http://wiki.alfresco.com/wiki/Dynamic_Models
Create the model document with type "cm:dictionaryModel" and set the property "cm:modelActive" to true.
This, of course, is Alfresco specific and will not work with other repositories.

- Florian

Wednesday, March 23, 2011

Loading of files in Liferay

Initially the servlet init method will get called,
Refer to MainServlet used by Main Servlet.
It is going to read the files from the classpath.
It will load the themes and layouts related files from both the core and the ext environment.

The following methods will be called
initThemes()
readPluginPackage();
initPortlets(pluginPackage);
initLayoutTemplates(pluginPackage, portlets);
initThemes(pluginPackage, portlets);
initSocialEquityLogScheduler();

Sunday, March 20, 2011

SCJP Naming convention and First Java Program

/**
*
*/
package com.patil.chapter1;

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

private static int $1;
private static Integer integr2;
private static double dou1ble;
private static Double $dou1$ble2;
private static float floatValue;
private static Float floatValue$;
private static boolean boolean1;
private static Boolean _boolean$;

public static void main(String[] args) {


System.out.println("static method can access only static variable or the static method");
System.out.println("Naming Convention and default value is:::"+ $1);
System.out.println("default value of double is:::"+ dou1ble);
System.out.println("default value of Integer is:::"+ integr2);
System.out.println("default value of double is:::"+ dou1ble);
System.out.println("default value of Double is:::"+ $dou1$ble2);
System.out.println("default value of float is:::"+ floatValue);
System.out.println("default value of Float is:::"+ floatValue$);
System.out.println("default value of boolean is:::"+ boolean1);
System.out.println("default value of Boolean is:::"+ _boolean$);




}

static{
System.out.println("Starting with the static block");
System.out.println("variable can be started with the number or characters,only $ is allowed as the special character");
$1 = 100;
}

NamingConvention(){
System.out.println("Inside the Constructor");
System.out.println("Constructor is not called since we have not instantiated");
}

public void nonstaticMethod(){
System.out.println("Inside nonstaticMethod");
}

public void $methodWithNumber1AndSpecial$Character(){
System.out.println("Inside nonstaticMethod");
System.out.println("Method can start only with the special character $, other characters are not allowed");
System.out.println("Method cannot start with the Number,but inbetween it can have the number");
}

public void _methodWithUnderScore1AndSpecial$Character(){
System.out.println("Method Name can be started with the underscore, and even the character can start with the underscore");

}

}

Sunday, March 13, 2011

WebServices of Alfresco

End point to access the Authority WebService

http://localhost:8080/alfresco/wsdl/authoring-service.wsdl

The bean which has the declaration of the beans are in the location
D:\Alfresco3.3.4\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\web-services-application-context


All these services are implemented in JAX-RPC protocol(Validate this once)

package org.alfresco.repo.webservice.administration;

public interface AdministrationServiceSoapPort extends java.rmi.Remote {

/**
* Gets the details of the requested users.
*/
public org.alfresco.repo.webservice.administration.UserQueryResults queryUsers(org.alfresco.repo.webservice.administration.UserFilter filter) throws java.rmi.RemoteException, org.alfresco.repo.webservice.administration.AdministrationFault;

/**
* Fetch the next bathc of users from an existing user query.
*/
public org.alfresco.repo.webservice.administration.UserQueryResults fetchMoreUsers(java.lang.String querySession) throws java.rmi.RemoteException, org.alfresco.repo.webservice.administration.AdministrationFault;

/**
* Get the details of a specified user.
*/
public org.alfresco.repo.webservice.administration.UserDetails getUser(java.lang.String userName) throws java.rmi.RemoteException, org.alfresco.repo.webservice.administration.AdministrationFault;

/**
* Create new users with the details provided.
*/
public org.alfresco.repo.webservice.administration.UserDetails[] createUsers(org.alfresco.repo.webservice.administration.NewUserDetails[] newUsers) throws java.rmi.RemoteException, org.alfresco.repo.webservice.administration.AdministrationFault;

/**
* Updates the details of the specified users.
*/
public org.alfresco.repo.webservice.administration.UserDetails[] updateUsers(org.alfresco.repo.webservice.administration.UserDetails[] users) throws java.rmi.RemoteException, org.alfresco.repo.webservice.administration.AdministrationFault;

/**
* Changes the password of the specified user.
*/
public void changePassword(java.lang.String userName, java.lang.String oldPassword, java.lang.String newPassword) throws java.rmi.RemoteException, org.alfresco.repo.webservice.administration.AdministrationFault;

/**
* Delete the specified users.
*/
public void deleteUsers(java.lang.String[] userNames) throws java.rmi.RemoteException, org.alfresco.repo.webservice.administration.AdministrationFault;
}


A pattern called "WSDL First" is generally considered the best approach for developing interoperable web services. We have defined the schemas for all the types we'll use in the web services and are in the process of defining the WSDL for each of the services.

Once the WSDL is defined we use Axis's WSDL2Java tool to generate the classes required to support the service. We then write a class implementing the generated interface for the service and add setters for all the services that need to be injected by Spring. This class is then referenced in web-services-application-context.xml so that it can be referenced by server-config.wsdd using the Axis/Spring integration.


One of the class implementation is given below
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see .
*/
package org.alfresco.repo.webservice.administration;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.webservice.AbstractWebService;
import org.alfresco.repo.webservice.Utils;
import org.alfresco.repo.webservice.action.ActionFault;
import org.alfresco.repo.webservice.repository.RepositoryFault;
import org.alfresco.repo.webservice.types.NamedValue;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.apache.axis.MessageContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* @author Roy Wetherall
*/
public class AdministrationWebService extends AbstractWebService implements
AdministrationServiceSoapPort
{
/** Log */
private static Log logger = LogFactory.getLog(AdministrationWebService.class);

/** The person service */
private PersonService personService = null;

/**
* Indicates whether the user administration methods should manage the authentication
* details, or just the person details.
*
* Set this to true if an 3rd party authentication implementation has been pluged into
* the repository that manages authentication details.
*/
private boolean manageAuthenticationDetails = true;

/** The authentication service */
private MutableAuthenticationService authenticationService = null;

private AuthorityService authorityService;

/** The transaction service */
private TransactionService transactionService = null;

/** A set of ignored properties */
private static Set ignoredProperties = new HashSet(3);

/**
* Constructor
*/
public AdministrationWebService()
{
// Set properties to ignore
AdministrationWebService.ignoredProperties.add(ContentModel.PROP_STORE_PROTOCOL);
AdministrationWebService.ignoredProperties.add(ContentModel.PROP_STORE_IDENTIFIER);
AdministrationWebService.ignoredProperties.add(ContentModel.PROP_NODE_UUID);
}

/**
* Set the flag that indicates whether this service should manage user authentication details as
* well as person details.
*
* @param manageAuthenticationDetails true if authentication details are managed, false otherwise
*/
public void setManageAuthenticationDetails(boolean manageAuthenticationDetails)
{
this.manageAuthenticationDetails = manageAuthenticationDetails;
}

/**
* Set the transaction service
*
* @param transactionService the transaction service
*/
public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
}

/**
* Set the person service
*
* @param personService sets the person service
*/
public void setPersonService(PersonService personService)
{
this.personService = personService;
}

/**
* Set the authentication service
*
* @param authenticationService the authentication service
*/
public void setAuthenticationService(MutableAuthenticationService authenticationService)
{
this.authenticationService = authenticationService;
}

/**
* Set the authority service used to determine admin rights.
*
* @param authorityService the service implementation
*/
public void setAuthorityService(AuthorityService authorityService)
{
this.authorityService = authorityService;
}

/**
* @see org.alfresco.repo.webservice.administration.AdministrationServiceSoapPort#queryUsers(org.alfresco.repo.webservice.administration.UserFilter)
*/
public UserQueryResults queryUsers(final UserFilter filter)
throws RemoteException, AdministrationFault
{
try
{
RetryingTransactionCallback callback = new RetryingTransactionCallback()
{
public UserQueryResults execute() throws Exception
{
return queryUsersImpl(filter);
}
};
return transactionService.getRetryingTransactionHelper().doInTransaction(callback);
}
catch (Throwable exception)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", exception);
}

throw new ActionFault(0, exception.getMessage());
}
}

/**
* Query users, batch by set size
*
* @param filter used to filter results
* @return user query results, optionally batched
*/
private UserQueryResults queryUsersImpl(UserFilter filter)
{
MessageContext msgContext = MessageContext.getCurrentContext();

// Create the query
UserQuery query = new UserQuery(filter);

// Create a user query session
UserQuerySession userQuerySession = new UserQuerySession(Long.MAX_VALUE, Utils.getBatchSize(msgContext), query);

// Get the next batch of results
UserQueryResults userQueryResults = userQuerySession.getNextResults(serviceRegistry);

String querySessionId = userQuerySession.getId();
// add the session to the cache if there are more results to come
boolean haveMoreResults = userQuerySession.haveMoreResults();
if (haveMoreResults)
{
querySessionCache.put(querySessionId, userQuerySession);
}

// Construct the return value
// TODO: http://issues.alfresco.com/browse/AR-1689
// This looks odd, but I've chosen to be specific about when the ID is set on the return
// results and when it isn't.
UserQueryResults result = new UserQueryResults(
haveMoreResults ? querySessionId : null,
userQueryResults.getUserDetails());

// Done
return result;
}

/**
* @see org.alfresco.repo.webservice.administration.AdministrationServiceSoapPort#fetchMoreUsers(java.lang.String)
*/
public UserQueryResults fetchMoreUsers(final String querySession)
throws RemoteException, AdministrationFault
{
try
{
RetryingTransactionCallback callback = new RetryingTransactionCallback()
{
public UserQueryResults execute() throws Exception
{
return fetchMoreUsersImpl(querySession);
}
};
return transactionService.getRetryingTransactionHelper().doInTransaction(callback);
}
catch (Throwable exception)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", exception);
}

throw new ActionFault(0, exception.getMessage());
}
}

/**
*
* @param querySessionId
* @return
*/
private UserQueryResults fetchMoreUsersImpl(String querySessionId) throws RepositoryFault
{
UserQuerySession session = null;
try
{
session = (UserQuerySession) querySessionCache.get(querySessionId);
}
catch (ClassCastException e)
{
if (logger.isDebugEnabled())
{
logger.debug("Query session was not generated by the AdministrationWebService: " + querySessionId);
}
throw new RepositoryFault(
4,
"querySession with id '" + querySessionId + "' is invalid");
}

UserQueryResults queryResult = null;
if (session != null)
{
queryResult = session.getNextResults(serviceRegistry);
if (!session.haveMoreResults())
{
this.querySessionCache.remove(querySessionId);
}
else
{
// Update the cache instance so that it can trigger replication as required
querySessionCache.put(querySessionId, session);
}
}

return queryResult;
}

/**
* @see org.alfresco.repo.webservice.administration.AdministrationServiceSoapPort#getUser(java.lang.String)
*/
public UserDetails getUser(final String userName) throws RemoteException, AdministrationFault
{
try
{
RetryingTransactionCallback callback = new RetryingTransactionCallback()
{
public UserDetails execute() throws Exception
{
return getUserImpl(userName);
}
};
return transactionService.getRetryingTransactionHelper().doInTransaction(callback);
}
catch (Throwable exception)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", exception);
}

throw new ActionFault(0, exception.getMessage());
}
}

/**
* Get the user details
*
* @param userName the user name
* @return the user details object
* @throws RemoteException
* @throws AdministrationFault
*/
private UserDetails getUserImpl(String userName)
{
NodeService nodeService = serviceRegistry.getNodeService();
UserDetails userDetails = null;

if (this.personService.personExists(userName) == true)
{
NodeRef nodeRef = this.personService.getPerson(userName);
userDetails = createUserDetails(nodeService, userName, nodeRef);
}
else
{
// Throw an exception to indicate that the user does not exist
throw new AlfrescoRuntimeException(MessageFormat.format("The user with name {0} does not exist.", new Object[]{userName}));
}

return userDetails;
}

/**
* Given a valid person node reference will create a user details object
*
* @param nodeRef the node reference
* @return the user details object populated with the appropriate property values
*/
/* package */ static UserDetails createUserDetails(NodeService nodeService, String userName, NodeRef nodeRef)
{
// Create the user details object
UserDetails userDetails = new UserDetails();

// Set the user name
userDetails.setUserName(userName);

// Set the various property values
Map properties = nodeService.getProperties(nodeRef);
List namedValues = new ArrayList(properties.size());
for (Map.Entry entry : properties.entrySet())
{
if (AdministrationWebService.ignoredProperties.contains(entry.getKey()) == false)
{
String value = null;
try
{
value = DefaultTypeConverter.INSTANCE.convert(String.class, entry.getValue());
}
catch (Throwable exception)
{
value = entry.getValue().toString();
}
NamedValue namedValue = new NamedValue();
namedValue.setName(entry.getKey().toString());
namedValue.setIsMultiValue(false);
namedValue.setValue(value);
namedValues.add(namedValue);
}
}
userDetails.setProperties((NamedValue[])namedValues.toArray(new NamedValue[namedValues.size()]));

return userDetails;
}

/**
* @see org.alfresco.repo.webservice.administration.AdministrationServiceSoapPort#createUsers(org.alfresco.repo.webservice.administration.NewUserDetails[])
*/
public UserDetails[] createUsers(final NewUserDetails[] newUsers) throws RemoteException, AdministrationFault
{
try
{
RetryingTransactionCallback callback = new RetryingTransactionCallback()
{
public UserDetails[] execute() throws Exception
{
return createUsersImpl(newUsers);
}
};
return transactionService.getRetryingTransactionHelper().doInTransaction(callback);
}
catch (Throwable exception)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", exception);
}

throw new ActionFault(0, exception.getMessage());
}
}

/**
* Create the new users
*
* @param newUsers the new users detail
* @return the details of the created users
* @throws RemoteException
* @throws AdministrationFault
*/
private UserDetails[] createUsersImpl(NewUserDetails[] newUsers)
{
NodeService nodeService = serviceRegistry.getNodeService();
UserDetails[] userDetails = new UserDetails[newUsers.length];

int index = 0;
for (NewUserDetails newUser : newUsers)
{
if (this.manageAuthenticationDetails == true)
{
// Create a new authentication
this.authenticationService.createAuthentication(newUser.getUserName(), newUser.getPassword().toCharArray());
}

// Create a new person
Map properties = new HashMap(7);
properties.put(ContentModel.PROP_USERNAME, newUser.getUserName());
for (NamedValue namedValue : newUser.getProperties())
{
properties.put(QName.createQName(namedValue.getName()), namedValue.getValue());
}
NodeRef personNodeRef = this.personService.createPerson(properties);

// Add the details to the result
userDetails[index] = createUserDetails(nodeService, newUser.getUserName(), personNodeRef);
index++;
}

return userDetails;
}

/**
* @see org.alfresco.repo.webservice.administration.AdministrationServiceSoapPort#updateUsers(org.alfresco.repo.webservice.administration.UserDetails[])
*/
public UserDetails[] updateUsers(final UserDetails[] users) throws RemoteException, AdministrationFault
{
try
{
RetryingTransactionCallback callback = new RetryingTransactionCallback()
{
public UserDetails[] execute() throws Exception
{
return updateUsersImpl(users);
}
};
return transactionService.getRetryingTransactionHelper().doInTransaction(callback);
}
catch (Throwable exception)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", exception);
}

throw new ActionFault(0, exception.getMessage());
}
}

/**
* Update the users details
*
* @param users the user details to update
* @return the updated user details
*/
private UserDetails[] updateUsersImpl(UserDetails[] users)
{
NodeService nodeService = serviceRegistry.getNodeService();
UserDetails[] userDetails = new UserDetails[users.length];

int index = 0;
for (UserDetails user : users)
{
// Build the property map
Map properties = new HashMap(7);
properties.put(ContentModel.PROP_USERNAME, user.getUserName());
for (NamedValue namedValue : user.getProperties())
{
properties.put(QName.createQName(namedValue.getName()), namedValue.getValue());
}

// Update the properties of the person
this.personService.setPersonProperties(user.getUserName(), properties);

// Add the details to the result
NodeRef nodeRef = this.personService.getPerson(user.getUserName());
userDetails[index] = createUserDetails(nodeService, user.getUserName(), nodeRef);
index++;
}

return userDetails;
}

/**
* @see org.alfresco.repo.webservice.administration.AdministrationServiceSoapPort#changePassword(java.lang.String, java.lang.String, java.lang.String)
*/
public void changePassword(final String userName, final String oldPassword, final String newPassword) throws RemoteException, AdministrationFault
{
try
{
RetryingTransactionCallback callback = new RetryingTransactionCallback()
{
public Object execute() throws Exception
{
changePasswordImpl(userName, oldPassword, newPassword);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(callback);
}
catch (Throwable exception)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", exception);
}

throw new ActionFault(0, exception.getMessage());
}
}

/**
* Change the current password of the user
*
* @param userName the user name
* @param oldPassword the old (current) password
* @param newPassword the new password
*/
private void changePasswordImpl(String userName, String oldPassword, String newPassword)
{
if (this.manageAuthenticationDetails == true)
{
// Update the authentication details
if (this.authorityService.hasAdminAuthority() == true)
{
this.authenticationService.setAuthentication(userName, newPassword.toCharArray());
}
else
{
this.authenticationService.updateAuthentication(userName, oldPassword.toCharArray(), newPassword.toCharArray());
}
}
else
{
throw new RuntimeException("Web service has been configured so that user authenticaiton details are not managed.");
}
}

/**
* @see org.alfresco.repo.webservice.administration.AdministrationServiceSoapPort#deleteUsers(java.lang.String[])
*/
public void deleteUsers(final String[] userNames) throws RemoteException,
AdministrationFault
{
try
{
RetryingTransactionCallback callback = new RetryingTransactionCallback()
{
public Object execute() throws Exception
{
deleteUsersImpl(userNames);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(callback);
}
catch (Throwable exception)
{
if (logger.isDebugEnabled())
{
logger.error("Unexpected error occurred", exception);
}

throw new ActionFault(0, exception.getMessage());
}
}

/**
* Delete users
*
* @param userNames the names of the users to delete
*/
private void deleteUsersImpl(String[] userNames)
{
for (String userName : userNames)
{
this.personService.deletePerson(userName);
}
}
}

Integration with CXF



CXFServlet
org.apache.cxf.transport.servlet.CXFServlet
6



The above servlet config is responsible for CXF WebServices integration in alfresco.

The beans are loaded from the configuration as below



contextConfigLocation
/WEB-INF/web-application-context.xml
Spring config file location




org.springframework.web.context.ContextLoaderListener

Configuring Log4j in alfresco

Below command is responsible for loading the log4j configuration.


org.springframework.web.util.Log4jConfigListener


The above line has to be declared in the web.xml file

# Set root logger level to error
log4j.rootLogger=error, Console, File
//2 appenders been defined
1. Console
2. FIle

###### Console appender definition #######

# All outputs currently set to be a ConsoleAppender.
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout

# use log4j NDC to replace %x with tenant domain / username
log4j.appender.Console.layout.ConversionPattern=%d{ABSOLUTE} %x %-5p [%c{3}] %m%n
#log4j.appender.Console.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c] %m%n