Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/bin
/target
target
.idea/
*.iml
/alf_data_dev/
alf_data_dev/
132 changes: 132 additions & 0 deletions alfresco-repo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.fmaul.alfresco</groupId>
<artifactId>alfresco-default-user-avatars</artifactId>
<version>1.2.0</version>
<name>alfresco-default-user-avatars Repository AMP project</name>
<packaging>amp</packaging>
<description>Default Users Avatar Generator</description>

<parent>
<groupId>org.alfresco.maven</groupId>
<artifactId>alfresco-sdk-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<!--
| SDK properties have sensible defaults in the SDK parent,
| but you can override the properties below to use another version.
| For more available properties see the alfresco-sdk-parent POM.
-->
<properties>
<!--
| Defines the groupId for the Alfresco Artifacts to work against. As of 4.2 the only allowed value is: org.alfresco
| NOTE: See http://docs.alfresco.com/4.2/concepts/dev-extensions-maven-sdk-tutorials-alfresco-enterprise.html for details
-->
<!-- <alfresco.groupId>org.alfresco</alfresco.groupId> -->
<!-- Defines the Alfresco version to work against.
Community versions are typically identified by major.minor.character (4.2.a) while Enterprise versions are identified by major.minor.digit (4.2.0) -->
<alfresco.version>5.0.b</alfresco.version>
<app.log.root.level>WARN</app.log.root.level>
<alfresco.data.location>alf_data_dev</alfresco.data.location>
<!-- This controls which properties will be picked in src/test/properties for embedded run -->
<env>local</env>
<!-- Defines the target WAR artifactId to run this amp, only used with the -Pamp-to-war profile
| Defaults to a vanilla repository AMP, but could point to your foundation / aggregator WAR
. | Allowed values for Community: alfresco | share
| Allowed values for Enterprise: alfresco-enterprise | share-enterprise
<alfresco.client.war>${alfresco.repo.artifactId}</alfresco.client.war> -->
<!-- Context path to run alfresco on -->
<alfresco.client.contextPath>/alfresco</alfresco.client.contextPath>
<!-- Defines the target WAR groupId to run this amp, only used with the -Pamp-to-war switch
. | Could be org.alfresco or your corporate groupId -->
<!-- <alfresco.client.war.groupId>${alfresco.groupId}</alfresco.client.war.groupId> -->

<!-- Defines the target WAR version to run this amp, only used with the -Pamp-to-war switch -->
<!-- <alfresco.client.war.version>${alfresco.version}</alfresco.client.war.version>-->
</properties>

<!-- Here we realize the connection with the Alfresco selected platform
(e.g.version and edition) -->
<dependencyManagement>
<dependencies>
<!-- This will import the dependencyManagement for all artifacts in the selected Alfresco version/edition
(see http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies)
NOTE: You still need to define dependencies in your POM, but you can omit version as it's enforced by this dependencyManagement. NOTE: It defaults
to the latest version this SDK pom has been tested with, but alfresco version can/should be overridden in your project's pom -->
<dependency>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco-platform-distribution</artifactId>
<version>${alfresco.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- Following dependencies are needed for compiling Java code in src/main/java;
<scope>provided</scope> is inherited for each of the following;
for more info, please refer to alfresco-platform-distribution POM -->
<dependencies>
<dependency>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco-repository</artifactId>
<version>${alfresco.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Copied PostgreSQL dialect files to generate H2 dialect files on-the-fly -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>get-postgres-dialect</id>
<phase>generate-test-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco-repository</artifactId>
<version>${alfresco.version}</version>
</artifactItem>
</artifactItems>
<includes>alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/*,alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/*</includes>
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>config-h2-dialect</id>
<phase>generate-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<move verbose="true"
file="${project.build.testOutputDirectory}/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect"
tofile="${project.build.testOutputDirectory}/alfresco/dbscripts/create/org.hibernate.dialect.H2Dialect" />
<move verbose="true"
file="${project.build.testOutputDirectory}/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect"
tofile="${project.build.testOutputDirectory}/alfresco/ibatis/org.hibernate.dialect.H2Dialect" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
9 changes: 9 additions & 0 deletions alfresco-repo/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Downloads the spring-loaded lib if not existing and runs repository AMP
springloadedfile=~/.m2/repository/org/springframework/springloaded/1.2.5.RELEASE/springloaded-1.2.5.RELEASE.jar

if [ ! -f $springloadedfile ]; then
mvn validate -Psetup
fi

MAVEN_OPTS="-javaagent:$springloadedfile -noverify -Xms256m -Xmx2G -XX:PermSize=300m" mvn integration-test -Pamp-to-war
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<bean id="de.fmaul.avatarService" class="de.fmaul.alfresco.avatars.AvatarServiceImpl">
<property name="nodeService" ref="NodeService"/>
<property name="contentService" ref="ContentService"/>
<property name="transactionService" ref="transactionService"/>
<property name="avatarGenerator" ref="de.fmaul.avatarGenerator"/>
</bean>

Expand All @@ -54,7 +55,7 @@
<value>${version.schema}</value>
</property>
<property name="targetSchema">
<value>9999</value>
<value>99999</value>
</property>
<property name="avatarService" ref="de.fmaul.avatarService" />
</bean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.id=${project.artifactId}
#module.aliases=myModule-123, my-module
module.title=${project.name}
module.description=${project.description}
module.version=${noSnapshotVersion}
module.version=${project.version}

# The following optional properties can be used to prevent the module from being added
# to inappropriate versions of the WAR file.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package de.fmaul.alfresco.avatars;

import java.io.Serializable;
import java.util.Map;

import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.security.authentication.AuthenticationUtil;

public class AvatarServiceImpl implements AvatarService {

Log log = LogFactory.getLog(AvatarServiceImpl.class);

private NodeService nodeService;
private ContentService contentService;
private TransactionService transactionService;
private AvatarGenerator avatarGenerator;

@Override
public NodeRef createDefaultUserAvatar(final NodeRef person) {

if (avatarGenerator.avatarCanBeGenerated(person)) {

RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
txnHelper.setForceWritable(true);
boolean requiresNew = false;
if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_READ_WRITE)
{
//We can be in a read-only transaction, so force a new transaction
requiresNew = true;
}

return txnHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
{

@Override
public NodeRef execute() throws Throwable
{
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
String userName = (String) nodeService.getProperty(person, ContentModel.PROP_USERNAME);

String name = DEFAULT_AVATAR_NAME_PREFIX + userName + ".png";
QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name));

ChildAssociationRef avatarNodeAssoc = nodeService.createNode(person, ContentModel.ASSOC_PREFERENCE_IMAGE, assocQName,
ContentModel.TYPE_CONTENT);

NodeRef avatarNode = avatarNodeAssoc.getChildRef();
nodeService.setProperty(avatarNode, ContentModel.PROP_NAME, name);

ContentWriter writer = contentService.getWriter(avatarNode, ContentModel.PROP_CONTENT, true);
writer.guessMimetype(name);

avatarGenerator.createAvatar(person, writer.getContentOutputStream());

nodeService.createAssociation(person, avatarNode, ContentModel.ASSOC_AVATAR);

return avatarNode;
}
}, AuthenticationUtil.getSystemUserName());
}

}, false, requiresNew);


}
return null;
}

@Override
public boolean avatarUpdateNeeded(Map<QName, Serializable> before, Map<QName, Serializable> after) {
return avatarGenerator.avatarUpdateNeeded(before, after);
}

public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}

public void setContentService(ContentService contentService) {
this.contentService = contentService;
}

public void setAvatarGenerator(AvatarGenerator avatarGenerator) {
this.avatarGenerator = avatarGenerator;
}

public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

# Sample custom content and index data location
# This will create alf_data Relative to appserver run folder
# In this default file we take the property from the POM (for compatbility with local jetty and jboss deployments) but it can also be edited here.
# In this default file we take the property from the POM (for compatibility with local tomcat and jboss deployments) but it can also be edited here.
dir.root=${alfresco.data.location}
# Allowed values are: NONE, AUTO, FULL
index.recovery.mode=NONE
# As we run embedded, we set Lucene
index.subsystem.name=lucene
index.subsystem.name=buildonly

#dir.keystore=.
#keystore.password=storepassword
Expand All @@ -46,14 +46,9 @@ db.pool.max=100

# File servers related properties
# For local builds we disable CIFS and FTP. Edit the following property to reenable them
smb.server.enabled=false
smb.server.name=CFS_SHARE_LOCAL
smb.server.domain=mycompany.com
smb.server.bindto=127.0.0.1
smb.tcpip.port=1445
netbios.session.port=1139
netbios.name.port=1137
netbios.datagram.port=1138
ftp.server.enables=false
cifs.enabled=false

ftp.enabled=false
ftp.port=1121
ftp.authenticator=alfresco
ftp.authenticator=alfresco

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans>
<!-- This disables javascript compilation so that webscripts can be hot reloaded -->
<bean id="javaScriptProcessor" class="org.alfresco.repo.jscript.RhinoScriptProcessor" init-method="register">
<property name="name">
<value>javascript</value>
</property>
<property name="extension">
<value>js</value>
</property>
<!-- compile javascript and cache compiled scripts -->
<property name="compile">
<value>false</value>
</property>
<!-- allow sharing of sealed scopes for performance -->
<!-- disable to give each script it's own new scope which can be extended -->
<property name="shareSealedScopes">
<value>true</value>
</property>
<property name="scriptService">
<ref bean="scriptService"/>
</property>
<!-- Creates ScriptNodes which require the ServiceRegistry -->
<property name="serviceRegistry">
<ref bean="ServiceRegistry"/>
</property>
<property name="storeUrl">
<value>${spaces.store}</value>
</property>
<property name="storePath">
<value>${spaces.company_home.childname}</value>
</property>
</bean>


</beans>
Loading